Use django's site framework.

see #551
This commit is contained in:
Antoine Nguyen
2014-12-05 14:14:48 +01:00
parent 5e80f76c0d
commit b355f24ba4
3 changed files with 44 additions and 5 deletions
+7 -1
View File
@@ -62,7 +62,13 @@ versions. To activate it, you need to:
#. Define the ``MODOBOA_API_URL`` variable::
MODOBOA_API_URL = 'http://api.modoboa.org/1/'
MODOBOA_API_URL = 'http://api.modoboa.org/1/'
#. Run the following commands to define the hostname of your
instance::
$ cd <modoboa_instance_dir>
$ python manage.py set_default_site <hostname>
1.1.7: manual learning for SpamAssassin
=======================================
+11 -4
View File
@@ -1,13 +1,16 @@
# coding: utf-8
import sys
import getpass
import os
import shutil
import getpass
import sys
import subprocess
import dj_database_url
from django.core import management
from django.template import Context, Template
import dj_database_url
from modoboa.lib.sysutils import exec_cmd
from modoboa.core.commands import Command
@@ -183,7 +186,7 @@ class DeployCommand(Command):
allowed_host = parsed_args.domain[0]
else:
allowed_host = raw_input(
'Under which domain do you want to deploy modoboa? '
'What will be the hostname used to access Modoboa? '
)
bower_components_dir = os.path.realpath(
@@ -233,3 +236,7 @@ class DeployCommand(Command):
self._exec_django_command(
"manage_extensions", parsed_args.name, *parsed_args.extensions
)
self._exec_django_command(
"set_default_site", parsed_args.name, allowed_host
)
@@ -0,0 +1,26 @@
# coding: utf-8
"""
A simple managemenent command to update the default site.
See `https://docs.djangoproject.com/en/dev/ref/contrib/sites/`_.
"""
from django.core.management.base import BaseCommand, CommandError
from django.contrib.sites.models import Site
class Command(BaseCommand):
"""Management command to set the default site."""
help = 'Set default site (see django.contrib.sites)'
def handle(self, *args, **options):
"""Command entry point."""
if not args:
raise CommandError("You must provide a hostname")
site = Site.objects.get(pk=1)
site.domain = args[0]
site.name = args[0]
site.save()