-class NodeNavigationOverride(Entity):
- parent = models.ForeignKey(Node, related_name="navigation_override_child_set")
- child = models.OneToOneField(Node, related_name="navigation_override")
- url = models.CharField(max_length=200, validators=[RedirectValidator()], blank=True)
- title = models.CharField(max_length=100, blank=True)
- order = models.PositiveSmallIntegerField(blank=True, null=True)
- child_navigation = JSONField()
-
- def get_navigation(self, node, depth, current_depth):
- if self.child_navigation:
- depth = current_depth
- default = node.get_navigation(depth, current_depth)
- if self.url:
- default['url'] = self.url
- if self.title:
- default['title'] = self.title
- if self.child_navigation:
- if 'children' in default:
- default['children'] += self.child_navigation
- else:
- default['children'] = self.child_navigation
-
- class Meta:
- ordering = ['order']
-
-