- # Should this be enforced? Not enforcing it would allow creation of "headers" in the navbar.
- if not self.target_node and not self.url_or_subpath:
- raise ValidationError("Either a target node or a url must be defined.")
-
- if self.reversing_parameters and (not self.url_or_subpath or not self.target_node):
- raise ValidationError("Reversing parameters require a view name and a target node.")
-
- try:
- self.get_target_url()
- except NoReverseMatch, e:
- raise ValidationError(e.message)
-
- def get_target_url(self):
- node = self.target_node
- if node is not None and node.accepts_subpath and self.url_or_subpath:
- if self.reversing_parameters is not None:
- view_name = self.url_or_subpath
- params = self.reversing_parameters
- args = isinstance(params, list) and params or None
- kwargs = isinstance(params, dict) and params or None
- return node.view.reverse(view_name, args=args, kwargs=kwargs, node=node)
- else:
- subpath = self.url_or_subpath
- while subpath and subpath[0] == '/':
- subpath = subpath[1:]
- return '%s%s' % (node.get_absolute_url(), subpath)
- elif node is not None:
- return node.get_absolute_url()
- else:
- return self.url_or_subpath
- target_url = property(get_target_url)
+ super(NavigationItem, self).clean()
+ if bool(self.parent) == bool(self.navigation):
+ raise ValidationError("Exactly one of `parent` and `navigation` must be defined.")