| author | grandjoncl |
| Fri, 30 Nov 2012 10:24:12 +0100 | |
| changeset 999 | ec918337fe41 |
| child 1005 | d9ec04dce82a |
| permissions | -rw-r--r-- |
|
999
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
1 |
from django.core.management.base import BaseCommand |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
2 |
from ldt.ldt_utils.models import Content, Project |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
3 |
from ldt.ldt_utils.contentindexer import ContentIndexer, ProjectIndexer |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
4 |
from django.conf import settings |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
5 |
from django.db import models |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
6 |
from django.contrib.sites.models import Site |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
7 |
|
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
8 |
class Command(BaseCommand): |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
9 |
help = 'set the site domain to the right value according to the django settings' |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
10 |
|
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
11 |
def handle(self, *args, **options): |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
12 |
site = Site.objects.get(id=settings.SITE_ID) |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
13 |
web_url = settings.WEB_URL |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
14 |
domain_area = web_url.split("//",1) |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
15 |
domain = domain_area[1] |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
16 |
if site.domain!=domain: |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
17 |
site.domain = domain |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
18 |
site.save() |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
19 |
if site.name!=domain: |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
20 |
site.name=domain |
|
ec918337fe41
new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table
grandjoncl
parents:
diff
changeset
|
21 |
site.save() |