• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python permissions.ungrant_access_to_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中modoboa.lib.permissions.ungrant_access_to_object函数的典型用法代码示例。如果您正苦于以下问题:Python ungrant_access_to_object函数的具体用法?Python ungrant_access_to_object怎么用?Python ungrant_access_to_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ungrant_access_to_object函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delete

    def delete(self, fromuser, *args, **kwargs):
        """Custom delete method

        To check permissions properly, we need to make a distinction
        between 2 cases:

        * If the user owns a mailbox, the check is made on that object
          (useful for domain admins)

        * Otherwise, the check is made on the user
        """
        from modoboa.lib.permissions import \
            get_object_owner, grant_access_to_object, ungrant_access_to_object

        if fromuser == self:
            raise PermDeniedException(
                _("You can't delete your own account")
            )

        if not fromuser.can_access(self):
            raise PermDeniedException

        owner = get_object_owner(self)
        for ooentry in self.objectaccess_set.filter(is_owner=True):
            if ooentry.content_object is not None:
                grant_access_to_object(owner, ooentry.content_object, True)

        events.raiseEvent("AccountDeleted", self, fromuser, **kwargs)
        ungrant_access_to_object(self)
        super(User, self).delete()
开发者ID:JHei,项目名称:modoboa,代码行数:30,代码来源:models.py


示例2: delete

    def delete(self, fromuser, keepdir=False):
        from modoboa.lib.permissions import \
            ungrant_access_to_object, ungrant_access_to_objects

        if self.domainalias_set.count():
            events.raiseEvent("DomainAliasDeleted", self.domainalias_set.all())
            ungrant_access_to_objects(self.domainalias_set.all())
        if self.mailbox_set.count():
            Quota.objects.filter(username__contains='@%s' % self.name).delete()
            events.raiseEvent("DeleteMailbox", self.mailbox_set.all())
            ungrant_access_to_objects(self.mailbox_set.all())
            hm = parameters.get_admin("HANDLE_MAILBOXES", raise_error=False)
            if hm == "yes" and not keepdir:
                for mb in self.mailbox_set.all():
                    MailboxOperation.objects.create(
                        type='delete', argument=mb.mail_home
                    )
        if self.alias_set.count():
            events.raiseEvent("MailboxAliasDelete", self.alias_set.all())
            ungrant_access_to_objects(self.alias_set.all())
        if parameters.get_admin("AUTO_ACCOUNT_REMOVAL") == "yes":
            for account in User.objects.filter(mailbox__domain__name=self.name):
                account.delete(fromuser, keepdir)
        events.raiseEvent("DeleteDomain", self)
        ungrant_access_to_object(self)
        super(Domain, self).delete()
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:26,代码来源:models.py


示例3: mailbox_deleted_handler

def mailbox_deleted_handler(sender, **kwargs):
    """``Mailbox`` pre_delete signal receiver.

    In order to properly handle deletions (ie. we don't want to leave
    orphan records into the db), we define this custom receiver.

    It manually removes the mailbox from the aliases it is linked to
    and then remove all empty aliases.
    """
    from modoboa.lib.permissions import ungrant_access_to_object

    mb = kwargs["instance"]
    ungrant_access_to_object(mb)
    for ralias in mb.aliasrecipient_set.select_related("alias"):
        alias = ralias.alias
        ralias.delete()
        if not alias.aliasrecipient_set.exists():
            alias.delete()
    models.Quota.objects.filter(username=mb.full_address).delete()
    request = lib_signals.get_request()
    if not request.localconfig.parameters.get_value(
            "handle_mailboxes", raise_exception=False):
        return
    keepdir = request.POST.get("keepdir", "false") == "true"
    if keepdir:
        return
    mb.delete_dir()
开发者ID:bearstech,项目名称:modoboa,代码行数:27,代码来源:handlers.py


示例4: update_permissions

def update_permissions(sender, instance, **kwargs):
    """Permissions cleanup."""
    request = get_request()
    # request migth be None (management command context)
    if request:
        from_user = request.user
        if from_user == instance:
            raise exceptions.PermDeniedException(
                _("You can't delete your own account")
            )

        if not from_user.can_access(instance):
            raise exceptions.PermDeniedException

    # We send an additional signal before permissions are removed
    core_signals.account_deleted.send(
        sender="update_permissions", user=instance)
    owner = permissions.get_object_owner(instance)
    if owner == instance:
        # The default admin is being removed...
        owner = from_user
    # Change ownership of existing objects
    for ooentry in instance.objectaccess_set.filter(is_owner=True):
        if ooentry.content_object is not None:
            permissions.grant_access_to_object(
                owner, ooentry.content_object, True)
            permissions.ungrant_access_to_object(
                ooentry.content_object, instance)
    # Remove existing permissions on this user
    permissions.ungrant_access_to_object(instance)
开发者ID:brucewu16899,项目名称:modoboa,代码行数:30,代码来源:handlers.py


示例5: mailbox_deleted_handler

def mailbox_deleted_handler(sender, **kwargs):
    """``Mailbox`` pre_delete signal receiver

    In order to properly handle deletions (ie. we don't want to leave
    orphan records into the db), we define this custom receiver.

    It manually removes the mailbox from the aliases it is linked to
    and then remove all empty aliases.
    """
    from modoboa.lib.permissions import ungrant_access_to_object

    mb = kwargs['instance']
    events.raiseEvent("DeleteMailbox", mb)
    ungrant_access_to_object(mb)
    for alias in mb.alias_set.all():
        alias.mboxes.remove(mb)
        if alias.mboxes.count() == 0:
            alias.delete()
开发者ID:schiiz1,项目名称:modoboa,代码行数:18,代码来源:mailbox.py


示例6: mailbox_deleted_handler

def mailbox_deleted_handler(sender, **kwargs):
    """``Mailbox`` pre_delete signal receiver

    In order to properly handle deletions (ie. we don't want to leave
    orphan records into the db), we define this custom receiver.

    It manually removes the mailbox from the aliases it is linked to
    and then remove all empty aliases.
    """
    from modoboa.lib import events
    from modoboa.lib.permissions import ungrant_access_to_object

    mb = kwargs['instance']
    events.raiseEvent("MailboxDeleted", mb)
    ungrant_access_to_object(mb)
    for ralias in mb.aliasrecipient_set.select_related("alias"):
        alias = ralias.alias
        ralias.delete()
        if not alias.aliasrecipient_set.exists():
            alias.delete()
开发者ID:iecsp,项目名称:modoboa,代码行数:20,代码来源:handlers.py


示例7: delete

    def delete(self, fromuser, keepdir=False):
        from modoboa.lib.permissions import \
            ungrant_access_to_object, ungrant_access_to_objects

        if self.domainalias_set.count():
            events.raiseEvent("DomainAliasDeleted", self.domainalias_set.all())
            ungrant_access_to_objects(self.domainalias_set.all())
        if self.mailbox_set.count():
            Quota.objects.filter(username__contains='@%s' % self.name).delete()
            events.raiseEvent("DeleteMailbox", self.mailbox_set.all())
            ungrant_access_to_objects(self.mailbox_set.all())
        if self.alias_set.count():
            events.raiseEvent("MailboxAliasDelete", self.alias_set.all())
            ungrant_access_to_objects(self.alias_set.all())
        if parameters.get_admin("AUTO_ACCOUNT_REMOVAL") == "yes":
            for account in User.objects.filter(mailbox__domain__name=self.name):
                account.delete(fromuser, keepdir)
        events.raiseEvent("DeleteDomain", self)
        ungrant_access_to_object(self)
        super(Domain, self).delete()
开发者ID:Tdey,项目名称:modoboa,代码行数:20,代码来源:models.py


示例8: remove_admin

    def remove_admin(self, account):
        """Remove an administrator for this domain

        :param User account: the administrotor to remove
        """
        from modoboa.lib.permissions import ungrant_access_to_object
        ungrant_access_to_object(self, account)
        for mb in self.mailbox_set.all():
            if mb.user.has_perm("admin.add_domain"):
                continue
            ungrant_access_to_object(mb, account)
            ungrant_access_to_object(mb.user, account)
        for al in self.alias_set.all():
            ungrant_access_to_object(al, account)
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:14,代码来源:models.py


示例9: remove_admin

    def remove_admin(self, account):
        """Remove an administrator of this domain.

        :param User account: administrator to remove
        """
        from modoboa.lib.permissions import \
            ungrant_access_to_object, get_object_owner

        if get_object_owner(self) == account:
            events.raiseEvent('DomainOwnershipRemoved', account, self)
        ungrant_access_to_object(self, account)
        for mb in self.mailbox_set.all():
            if mb.user.has_perm("admin.add_domain"):
                continue
            ungrant_access_to_object(mb, account)
            ungrant_access_to_object(mb.user, account)
        for al in self.alias_set.all():
             ungrant_access_to_object(al, account)
开发者ID:finid,项目名称:modoboa,代码行数:18,代码来源:domain.py


示例10: delete

 def delete(self):
     events.raiseEvent("%sDeleted" % self.objectname, self)
     ungrant_access_to_object(self)
     super(AdminObject, self).delete()
开发者ID:JHei,项目名称:modoboa,代码行数:4,代码来源:base.py


示例11: delete

 def delete(self):
     ungrant_access_to_object(self)
     super(AdminObject, self).delete()
开发者ID:bearstech,项目名称:modoboa,代码行数:3,代码来源:base.py



注:本文中的modoboa.lib.permissions.ungrant_access_to_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sysutils.exec_cmd函数代码示例发布时间:2022-05-27
下一篇:
Python permissions.grant_access_to_object函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap