mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Reset TOWER_URL_BASE to the hostname used for the request when setting is deleted.
This commit is contained in:
parent
03bb260963
commit
f007046e2b
@ -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 _
|
||||
@ -118,6 +119,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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user