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
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)
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)
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)
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()
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)
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()
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()
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)] = {}