Esempio n. 1
0
    def handle(self, *args, **options):
        """Command entry point."""
        load_core_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)

        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()

        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)

        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
    def handle(self, *args, **options):
        """Command entry point."""
        if not models.User.objects.filter(is_superuser=True).count():
            admin = models.User(
                username=options["admin_username"], is_superuser=True)
            admin.set_password("password")
            admin.save()
            models.ObjectAccess.objects.create(
                user=admin, content_object=admin, is_owner=True)

        lc = models.LocalConfig.objects.first()
        secret_key = lc.parameters.get_value("secret_key")
        if not secret_key:
            lc.parameters.set_value("secret_key", random_key())
            lc.save()

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

        exts_pool.load_all()

        superadmin = models.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)

        if options["extra_fixtures"]:
            from modoboa.admin import factories
            factories.populate_database()
Esempio n. 4
0
    def handle(self, *args, **options):
        """Command entry point."""
        if not models.User.objects.filter(is_superuser=True).count():
            admin = models.User(username=options["admin_username"],
                                is_superuser=True)
            admin.set_password("password")
            admin.save()
            models.ObjectAccess.objects.create(user=admin,
                                               content_object=admin,
                                               is_owner=True)

        lc = models.LocalConfig.objects.first()
        secret_key = lc.parameters.get_value("secret_key")
        if not secret_key:
            lc.parameters.set_value("secret_key", random_key())
            lc.save()

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

        exts_pool.load_all()

        superadmin = models.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)

        if options["extra_fixtures"]:
            from modoboa.admin import factories
            factories.populate_database()
Esempio n. 5
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. 6
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. 7
0
"""General event callbacks."""

from django.utils.translation import ugettext as _

from modoboa.core import PERMISSIONS as CORE_PERMS
from modoboa.extensions.admin.modo_extension import PERMISSIONS as ADMIN_PERMS
from modoboa.extensions.limits.forms import ResourcePoolForm
from modoboa.extensions.limits.models import LimitTemplates
from modoboa.lib import events


PERMISSIONS = {
    "Resellers": (
        CORE_PERMS.get("DomainAdmins") +
        ADMIN_PERMS.get("DomainAdmins") +
        [["admin", "domain", "view_domains"],
         ["admin", "domain", "add_domain"],
         ["admin", "domain", "change_domain"],
         ["admin", "domain", "delete_domain"]]
    )
}


@events.observe("GetExtraRoles")
def get_extra_roles(user):
    if user.is_superuser:
        return [("Resellers", _("Reseller")), ]
    return []


@events.observe("GetExtraRolePermissions")