Merge pull request #4093 from cchurch/tower-url-base-reset

Reset TOWER_URL_BASE to the hostname used for the request
This commit is contained in:
Chris Church
2016-11-22 14:51:09 -05:00
committed by GitHub

View File

@@ -6,6 +6,7 @@ import collections
import sys
# Django
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import Http404
from django.utils.translation import ugettext_lazy as _
@@ -119,6 +120,13 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView):
for setting in self.get_queryset().exclude(key='LICENSE'):
setting.delete()
# When TOWER_URL_BASE is deleted from the API, reset it to the hostname
# used to make the request as a default.
if hasattr(instance, 'TOWER_URL_BASE'):
url = '{}://{}'.format(self.request.scheme, self.request.get_host())
if settings.TOWER_URL_BASE != url:
settings.TOWER_URL_BASE = url
# Create view functions for all of the class-based views to simplify inclusion
# in URL patterns and reverse URL lookups, converting CamelCase names to