Skip to content

Commit

Permalink
Fix/update site script (#98)
Browse files Browse the repository at this point in the history
* Update site name and domain on script

Signed-off-by: Matheus Fernandes <[email protected]>

* Add missed function cal

Signed-off-by: Matheus Fernandes <[email protected]>
  • Loading branch information
msfernandes committed Nov 28, 2017
1 parent 41e2301 commit ac58f3b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions wikilegis/create_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ def create_superuser():
sys.exit(1)


def update_sites():
from django.contrib.sites.models import Site
import re
site = Site.objects.get_current()
site_domain = os.environ.get('SITE_DOMAIN', None)
site_name = os.environ.get('SITE_NAME', None)

if None not in [site_domain, site_name]:
print('Updating site infos...')
site_domain = re.sub('^(http|https)://', '', site_domain)

site.domain, site.name = site_domain, site_name
site.save()
print('Done!')
else:
print('Missing SITE_DOMAIN or SITE_NAME environment variable.')
sys.exit(2)


if __name__ == '__main__':
django.setup()
create_superuser()
update_sites()

0 comments on commit ac58f3b

Please sign in to comment.