示例#1
0
文件: views.py 项目: finid/modoboa
def check_domain_access(user, pattern):
    """Check if an administrator can access a domain/relay domain.

    If a non super administrator asks for the global view, we give him
    a view on the first domain he manage instead.

    :return: a domain name (str) or None.
    """
    targets = [Domain]
    if exts_pool.is_extension_enabled("postfix_relay_domains"):
        from modoboa.extensions.postfix_relay_domains.models import RelayDomain
        targets.append(RelayDomain)

    if pattern in [None, "global"]:
        if not user.is_superuser:
            for target in targets:
                if not target.objects.get_for_admin(user).count():
                    continue
                return target.objects.get_for_admin(user)[0].name
            return None
        return "global"

    for target in targets:
        results = target.objects.filter(name__startswith=pattern)
        if results.count() != 1:
            continue
        if not user.can_access(results[0]):
            raise PermDeniedException
        return results[0].name
    return None
示例#2
0
    def load(self):
        from .app_settings import AdminParametersForm

        parameters.register(AdminParametersForm,
                            ugettext_lazy("Relay domains"))
        events.declare(extension_events)
        from modoboa.extensions.postfix_relay_domains import general_callbacks
        if 'modoboa.extensions.postfix_relay_domains.general_callbacks' in sys.modules:
            reload(general_callbacks)
        if exts_pool.is_extension_enabled('limits'):
            import limits_callbacks
            if 'modoboa.extensions.postfix_relay_domains.limits_callbacks' in sys.modules:
                reload(limits_callbacks)
        if exts_pool.is_extension_enabled('amavis'):
            import amavis_callbacks
            if 'modoboa.extensions.postfix_relay_domains.amavis_callbacks' in sys.modules:
                reload(amavis_callbacks)
示例#3
0
文件: __init__.py 项目: JHei/modoboa
    def load(self):
        from .app_settings import AdminParametersForm

        parameters.register(
            AdminParametersForm, ugettext_lazy("Relay domains")
        )
        events.declare(extension_events)
        from modoboa.extensions.postfix_relay_domains import general_callbacks
        if 'modoboa.extensions.postfix_relay_domains.general_callbacks' in sys.modules:
            reload(general_callbacks)
        if exts_pool.is_extension_enabled('limits'):
            import limits_callbacks
            if 'modoboa.extensions.postfix_relay_domains.limits_callbacks' in sys.modules:
                reload(limits_callbacks)
        if exts_pool.is_extension_enabled('amavis'):
            import amavis_callbacks
            if 'modoboa.extensions.postfix_relay_domains.amavis_callbacks' in sys.modules:
                reload(amavis_callbacks)
示例#4
0
    def load(self):
        from .app_settings import AdminParametersForm

        parameters.register(
            AdminParametersForm, ugettext_lazy("Relay domains")
        )
        events.declare(EXTENSION_EVENTS)
        from modoboa.extensions.postfix_relay_domains import general_callbacks
        prefix = "modoboa.extensions.postfix_relay_domains."
        if prefix + "general_callbacks" in sys.modules:
            reload(general_callbacks)
        if exts_pool.is_extension_enabled('limits'):
            import limits_callbacks
            if prefix + "limits_callbacks" in sys.modules:
                reload(limits_callbacks)
        if exts_pool.is_extension_enabled('amavis'):
            import amavis_callbacks
            if prefix + "amavis_callbacks" in sys.modules:
                reload(amavis_callbacks)
示例#5
0
    def init(self):
        """Initialisation method.

        Only run once, when the extension is enabled. Populates the
        service table with default entries.
        """
        for service_name in ['relay', 'smtp']:
            Service.objects.get_or_create(name=service_name)
        if exts_pool.is_extension_enabled('limits'):
            init_limits_dependant_features()
示例#6
0
文件: views.py 项目: finid/modoboa
def get_domain_list(request):
    """Get the list of domains (and relay domains) the user can see."""
    doms = [dom.name for dom in Domain.objects.get_for_admin(request.user)]
    if exts_pool.is_extension_enabled("postfix_relay_domains"):
        from modoboa.extensions.postfix_relay_domains.models import RelayDomain
        doms += [
            rdom.name
            for rdom in RelayDomain.objects.get_for_admin(request.user)
        ]
    return render_to_json_response(doms)
示例#7
0
文件: __init__.py 项目: JHei/modoboa
    def init(self):
        """Initialisation method.

        Only run once, when the extension is enabled. Populates the
        service table with default entries.
        """
        for service_name in ['relay', 'smtp']:
            Service.objects.get_or_create(name=service_name)
        if exts_pool.is_extension_enabled('limits'):
            init_limits_dependant_features()
示例#8
0
 def init(self):
     """Plugin initialization.
     """
     add_permissions_to_group(
         "DomainAdmins",
         [("radicale", "usercalendar", "add_usercalendar"),
          ("radicale", "usercalendar", "change_usercalendar"),
          ("radicale", "usercalendar", "delete_usercalendar"),
          ("radicale", "sharedcalendar", "add_sharedcalendar"),
          ("radicale", "sharedcalendar", "change_sharedcalendar"),
          ("radicale", "sharedcalendar", "delete_sharedcalendar")])
     if exts_pool.is_extension_enabled('limits'):
         init_limits_dependant_features()
示例#9
0
 def init(self):
     """Plugin initialization.
     """
     add_permissions_to_group(
         "DomainAdmins",
         [("radicale", "usercalendar", "add_usercalendar"),
          ("radicale", "usercalendar", "change_usercalendar"),
          ("radicale", "usercalendar", "delete_usercalendar"),
          ("radicale", "sharedcalendar", "add_sharedcalendar"),
          ("radicale", "sharedcalendar", "change_sharedcalendar"),
          ("radicale", "sharedcalendar", "delete_sharedcalendar")]
     )
     if exts_pool.is_extension_enabled('limits'):
         init_limits_dependant_features()
示例#10
0
    def _load_domain_list(self):
        """Load the list of allowed domains.

        Since the relay domains feature is an extension of the admin
        panel, we don't use an event to get the list of all supported
        domains...

        """
        for dom in Domain.objects.all():
            self.domains += [str(dom.name)]
            self.data[str(dom.name)] = {}
        if not exts_pool.is_extension_enabled("postfix_relay_domains"):
            return
        from modoboa.extensions.postfix_relay_domains.models import RelayDomain
        for rdom in RelayDomain.objects.all():
            self.domains += [str(rdom.name)]
            self.data[str(rdom.name)] = {}
示例#11
0
    def _load_domain_list(self):
        """Load the list of allowed domains.

        Since the relay domains feature is an extension of the admin
        panel, we don't use an event to get the list of all supported
        domains...

        """
        for dom in Domain.objects.all():
            self.domains += [str(dom.name)]
            self.data[str(dom.name)] = {}
        if not exts_pool.is_extension_enabled("postfix_relay_domains"):
            return
        from modoboa.extensions.postfix_relay_domains.models import RelayDomain
        for rdom in RelayDomain.objects.all():
            self.domains += [str(rdom.name)]
            self.data[str(rdom.name)] = {}