From f8392db16c84d82d01f8c0cdad27c0b9e750e15c Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 31 Jul 2016 13:06:20 +0200 Subject: [PATCH] Added a mainreverse equivalent to eventreverse --- src/pretix/multidomain/urlreverse.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/pretix/multidomain/urlreverse.py b/src/pretix/multidomain/urlreverse.py index 92aa5f931..b27b95660 100644 --- a/src/pretix/multidomain/urlreverse.py +++ b/src/pretix/multidomain/urlreverse.py @@ -18,6 +18,27 @@ def get_domain(organizer): return domain +def mainreverse(name, kwargs=None): + """ + Works similar to ``django.core.urlresolvers.reverse`` but uses the maindomain URLconf even + if on a subpath. + + Non-keyword arguments are not supported as we want do discourage using them for better + readability. + + :param name: The name of the URL route + :type name: str + :param kwargs: A dictionary of additional keyword arguments that should be used. You do not + need to provide the organizer or event slug here, it will be added automatically as + needed. + :returns: An absolute URL (including scheme and host) as a string + """ + from pretix.multidomain import maindomain_urlconf + + kwargs = kwargs or {} + return reverse(name, kwargs=kwargs, urlconf=maindomain_urlconf) + + def eventreverse(obj, name, kwargs=None): """ Works similar to ``django.core.urlresolvers.reverse`` but takes into account that some