-class NodeNavigationOverride(Entity):
- parent = models.ForeignKey(Node, related_name="child_navigation_overrides", blank=True, null=True)
- child = models.ForeignKey(Node, related_name="navigation_overrides")
-
- title = models.CharField(max_length=100, blank=True)
- url = models.CharField(max_length=200, validators=[RedirectValidator()], blank=True)
- order = models.PositiveSmallIntegerField(blank=True, null=True)
- child_navigation = JSONField()
- hide = models.BooleanField()
-
- def get_navigation(self, node, depth, current_depth):
- if self.child_navigation:
- depth = current_depth
- default = node.view.get_navigation(depth, current_depth)
- if self.url:
- default['url'] = self.url
- if self.title:
- default['title'] = self.title
- if self.order:
- default['order'] = self.order
- if isinstance(self.child_navigation, list):
- if 'children' in default:
- default['children'] += self.child_navigation
- else:
- default['children'] = self.child_navigation
- return default
-
- class Meta:
- ordering = ['order']
- unique_together = ('parent', 'child',)
- app_label = 'philo'
-
-