Esempio n. 1
0
    def handle(self, *args, **options):
        """Command entry point."""
        load_core_settings()
        load_admin_settings()
        load_limits_settings()

        if not User.objects.filter(is_superuser=True).count():
            admin = User(username="******", is_superuser=True)
            admin.set_password("password")
            admin.save()
            ObjectAccess.objects.create(user=admin,
                                        content_object=admin,
                                        is_owner=True)

        param_name = "core.SECRET_KEY"
        qset = lib_models.Parameter.objects.filter(name=param_name)
        if not qset.exists():
            lib_models.Parameter.objects.create(name=param_name,
                                                value=random_key())

        for service_name in ['relay', 'smtp']:
            relay_models.Service.objects.get_or_create(name=service_name)

        exts_pool.load_all()

        superadmin = User.objects.filter(is_superuser=True).first()
        groups = PERMISSIONS.keys() + [
            role[0] for role in events.raiseQueryEvent("GetExtraRoles",
                                                       superadmin, None)
        ]
        for groupname in groups:
            group, created = Group.objects.get_or_create(name=groupname)
            permissions = (
                PERMISSIONS.get(groupname, []) +
                events.raiseQueryEvent("GetExtraRolePermissions", groupname))
            if not permissions:
                continue
            add_permissions_to_group(group, permissions)

        for extname in exts_pool.extensions.keys():
            extension = exts_pool.get_extension(extname)
            extension.load_initial_data()
            events.raiseEvent("InitialDataLoaded", extname)
Esempio n. 2
0
    def handle(self, *args, **options):
        """Command entry point."""
        load_core_settings()
        load_admin_settings()
        load_limits_settings()

        if not User.objects.filter(is_superuser=True).count():
            admin = User(username="******", is_superuser=True)
            admin.set_password("password")
            admin.save()
            ObjectAccess.objects.create(
                user=admin, content_object=admin, is_owner=True)

        param_name = "core.SECRET_KEY"
        qset = lib_models.Parameter.objects.filter(name=param_name)
        if not qset.exists():
            lib_models.Parameter.objects.create(
                name=param_name, value=random_key())

        for service_name in ['relay', 'smtp']:
            relay_models.Service.objects.get_or_create(name=service_name)

        exts_pool.load_all()

        superadmin = User.objects.filter(is_superuser=True).first()
        groups = PERMISSIONS.keys() + [
            role[0] for role
            in events.raiseQueryEvent("GetExtraRoles", superadmin, None)
        ]
        for groupname in groups:
            group, created = Group.objects.get_or_create(name=groupname)
            permissions = (
                PERMISSIONS.get(groupname, []) +
                events.raiseQueryEvent("GetExtraRolePermissions", groupname)
            )
            if not permissions:
                continue
            add_permissions_to_group(group, permissions)

        for extname in exts_pool.extensions.keys():
            extension = exts_pool.get_extension(extname)
            extension.load_initial_data()
            events.raiseEvent("InitialDataLoaded", extname)
Esempio n. 3
0
from django.conf import settings
from django.conf.urls import patterns, include, url

from modoboa.admin.app_settings import load_admin_settings
from modoboa.core import load_core_settings
from modoboa.core.extensions import exts_pool
from modoboa.lib import parameters, events
from modoboa.limits.app_settings import load_limits_settings
from modoboa.relaydomains.app_settings import load_relaydomains_settings


load_core_settings()
load_admin_settings()
load_limits_settings()
load_relaydomains_settings()

urlpatterns = patterns(
    '',
    url(r'^$', 'modoboa.lib.web_utils.topredirection', name="topredirection"),
    (r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
     {'packages': ('modoboa', ), }),
    ('', include('modoboa.core.urls', namespace="core")),
    ('', include('modoboa.admin.urls', namespace="admin")),
    ('', include('modoboa.relaydomains.urls', namespace="relaydomains")),
)

urlpatterns += patterns(
    '',
    *exts_pool.load_all()
)