modification of initsitedomain command and migration to work when the web_url doesn't start with 'http://'
--- 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()
--- /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