Fixed absolute URLs (now for real)

This commit is contained in:
Raphael Michel
2015-06-21 21:15:12 +02:00
parent 058d33765c
commit fa94d17d74
3 changed files with 15 additions and 3 deletions
+1 -3
View File
@@ -4,6 +4,4 @@ from django.core.urlresolvers import reverse
def build_absolute_uri(urlname, args=None, kwargs=None):
# Pass prefix='' as a possible SCRIPT_PREFIX (if pretix runs in a subdirectory)
# is included in SITE_URL _and_ is added by reverse.
return urljoin(settings.SITE_URL, reverse(urlname, args=args, kwargs=kwargs, prefix=''))
return urljoin(settings.SITE_URL, reverse(urlname, args=args, kwargs=kwargs))
View File
+14
View File
@@ -0,0 +1,14 @@
from django.conf import settings
from pretix.helpers.urls import build_absolute_uri
from django.core import urlresolvers
def test_site_url_domain():
settings.SITE_URL = 'https://example.com'
assert build_absolute_uri('control:auth.login') == 'https://example.com/control/login'
def test_site_url_subpath():
settings.SITE_URL = 'https://example.com/presale'
urlresolvers.set_script_prefix('/presale/')
assert build_absolute_uri('control:auth.login') == 'https://example.com/presale/control/login'