Exemple #1
0
def grant_access_to_all_objects(user, role):
    from django.contrib.contenttypes.models import ContentType
    from modoboa.lib.permissions import grant_access_to_objects
    from modoboa.core.models import User

    if role != "SuperAdmins":
        return
    grant_access_to_objects(
        user, User.objects.all(),
        ContentType.objects.get_for_model(User)
    )
    grant_access_to_objects(
        user, Domain.objects.all(),
        ContentType.objects.get_for_model(Domain)
    )
    grant_access_to_objects(
        user, DomainAlias.objects.all(),
        ContentType.objects.get_for_model(DomainAlias)
    )
    grant_access_to_objects(
        user, Mailbox.objects.all(),
        ContentType.objects.get_for_model(Mailbox)
    )
    grant_access_to_objects(
        user, Alias.objects.all(),
        ContentType.objects.get_for_model(Alias)
    )
Exemple #2
0
def grant_access_to_all_objects(user, role):
    from django.contrib.contenttypes.models import ContentType
    from modoboa.lib.permissions import grant_access_to_objects
    from modoboa.core.models import User

    if role != "SuperAdmins":
        return
    grant_access_to_objects(
        user, User.objects.all(),
        ContentType.objects.get_for_model(User)
    )
    grant_access_to_objects(
        user, Domain.objects.all(),
        ContentType.objects.get_for_model(Domain)
    )
    grant_access_to_objects(
        user, DomainAlias.objects.all(),
        ContentType.objects.get_for_model(DomainAlias)
    )
    grant_access_to_objects(
        user, Mailbox.objects.all(),
        ContentType.objects.get_for_model(Mailbox)
    )
    grant_access_to_objects(
        user, Alias.objects.all(),
        ContentType.objects.get_for_model(Alias)
    )
Exemple #3
0
    def grant_access_to_all_objects(self):
        """Give access to all objects defined in the database

        Must be used when an account is promoted as a super user.
        """
        from modoboa.lib.permissions import grant_access_to_objects, get_content_type
        grant_access_to_objects(self, User.objects.all(), get_content_type(User))
        grant_access_to_objects(self, Domain.objects.all(), get_content_type(Domain))
        grant_access_to_objects(self, DomainAlias.objects.all(), get_content_type(DomainAlias))
        grant_access_to_objects(self, Mailbox.objects.all(), get_content_type(Mailbox))
        grant_access_to_objects(self, Alias.objects.all(), get_content_type(Alias))
Exemple #4
0
    def grant_access_to_all_objects(self):
        """Give access to all objects defined in the database

        Must be used when an account is promoted as a super user.
        """
        from modoboa.lib.permissions import grant_access_to_objects, get_content_type
        grant_access_to_objects(self, User.objects.all(), get_content_type(User))
        grant_access_to_objects(self, Domain.objects.all(), get_content_type(Domain))
        grant_access_to_objects(self, DomainAlias.objects.all(), get_content_type(DomainAlias))
        grant_access_to_objects(self, Mailbox.objects.all(), get_content_type(Mailbox))
        grant_access_to_objects(self, Alias.objects.all(), get_content_type(Alias))
Exemple #5
0
def grant_access_to_all_objects(sender, account, role, **kwargs):
    """Grant all permissions if new role is SuperAdmin."""
    if role != "SuperAdmins":
        return
    perm_models = [
        core_models.User, models.Domain, models.DomainAlias, models.Mailbox,
        models.Alias
    ]
    for model in perm_models:
        permissions.grant_access_to_objects(
            account, model.objects.all(),
            ContentType.objects.get_for_model(model))
Exemple #6
0
def grant_access_to_all_objects(sender, account, role, **kwargs):
    """Grant all permissions if new role is SuperAdmin."""
    if role != "SuperAdmins":
        return
    perm_models = [
        core_models.User, models.Domain, models.DomainAlias, models.Mailbox,
        models.Alias]
    for model in perm_models:
        permissions.grant_access_to_objects(
            account, model.objects.all(),
            ContentType.objects.get_for_model(model)
        )