# HG changeset patch # User grandjoncl # Date 1354529020 -3600 # Node ID f0948f50816be925555b82b377d17c6273dacc97 # Parent c558d677ee527dffe8c65ae29d796b8bf3fcbed1 modification of initsitedomain command and migration to work when the web_url doesn't start with 'http://' diff -r c558d677ee52 -r f0948f50816b src/ldt/ldt/ldt_utils/migrations/0025_chg_site_domain.py --- a/src/ldt/ldt/ldt_utils/migrations/0025_chg_site_domain.py Mon Dec 03 10:43:13 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/migrations/0025_chg_site_domain.py Mon Dec 03 11:03:40 2012 +0100 @@ -11,8 +11,11 @@ Sites = orm['sites.Site'] site = Sites.objects.get(id=settings.SITE_ID) web_url = settings.WEB_URL - domain_area = web_url.split("//",1) - domain = domain_area[1] + if (web_url.startswith("http://")): + domain_area = web_url.split("//",1) + domain = domain_area[1] + else : + domain=web_url if site.domain!=domain: site.domain = domain site.save() diff -r c558d677ee52 -r f0948f50816b src/ldt/ldt/management/commands/initsitedomain.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/management/commands/initsitedomain.py Mon Dec 03 11:03:40 2012 +0100 @@ -0,0 +1,24 @@ +from django.core.management.base import BaseCommand +from ldt.ldt_utils.models import Content, Project +from ldt.ldt_utils.contentindexer import ContentIndexer, ProjectIndexer +from django.conf import settings +from django.db import models +from django.contrib.sites.models import Site + +class Command(BaseCommand): + help = 'set the site domain to the right value according to the django settings' + + def handle(self, *args, **options): + site = Site.objects.get(id=settings.SITE_ID) + web_url = settings.WEB_URL + if (web_url.startswith("http://")): + domain_area = web_url.split("//",1) + domain = domain_area[1] + else: + domain=web_url + if site.domain!=domain: + site.domain = domain + site.save() + if site.name!=domain: + site.name=domain + site.save() \ No newline at end of file