X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/21b3e0e515fb780dd7768e521c20a40882d0bcc6..16c91c1902f065c6d9b12a5c89c04d6aef620291:/models/nodes.py?ds=sidebyside diff --git a/models/nodes.py b/models/nodes.py index 0ece55f..de10ed1 100644 --- a/models/nodes.py +++ b/models/nodes.py @@ -119,6 +119,14 @@ class MultiView(View): kwargs['extra_context'] = extra_context return view(request, *args, **kwargs) + def reverse(self, view_name, args=None, kwargs=None, node=None): + """Shortcut method to handle the common pattern of getting the absolute url for a multiview's + subpaths.""" + subpath = reverse(view_name, urlconf=self, args=args or [], kwargs=kwargs or {}) + if node is not None: + return '/%s/%s/' % (node.get_absolute_url().strip('/'), subpath.strip('/')) + return subpath + class Meta: abstract = True