Пример #1
0
        def vote(self):
            needs = [
                UserNeed(User.query.get(user_id).username)
                for user_id in self.votes
            ]
            needs.append(UserNeed(self.author.username))

            return auth & Denial(*needs)
Пример #2
0
    def provides(self):
        needs = [RoleNeed('auth'), UserNeed(self.pk)]

        if self.is_sa:
            needs.append(RoleNeed('admin'))

        return needs
Пример #3
0
        def send_message(self):
            if not self.receive_email:
                return null

            needs = [UserNeed(username) for username in self.friends]
            if not needs:
                return null

            return Permission(*needs)
Пример #4
0
    def provides(self):
        needs = [RoleNeed('authenticated'), UserNeed(self.id)]

        if self.is_moderator:
            needs.append(RoleNeed('moderator'))

        if self.is_admin:
            needs.append(RoleNeed('admin'))

        return needs
Пример #5
0
        def view(self):
            if self.access == Post.PUBLIC:
                return Permission()

            if self.access == Post.FRIENDS:
                needs = [UserNeed(User.query.get(user_id).username) for user_id in \
                            self.author.friends]

                return self.default & Permission(*needs)

            return self.default
Пример #6
0
 def delete(self):
     return Permission(UserNeed(self.author.username)) & admin
Пример #7
0
 def default(self):
     return Permission(UserNeed(self.author.username)) & moderator
Пример #8
0
 def default(self):
     return Permission(UserNeed(self.owner.username)) 
Пример #9
0
        def vote(self):

            needs = [UserNeed(user_id) for user_id in self.votes]
            needs.append(UserNeed(self.author_id))

            return auth & Denial(*needs)
Пример #10
0
 def default(self):
     return Permission(UserNeed(self.author_id)) & moderator
Пример #11
0
def set_owned_by(sender, identity):
    permissions.owned_by = Permission(UserNeed(identity.user))
    permissions.modify_own_content = permission(permissions.owned_by,
                                                permissions.full_access)
Пример #12
0
 def reply(self):
     return Permission(UserNeed(self.obj.post.author_id))
Пример #13
0
 def edit(self):
     return Permission(UserNeed(self.obj.author_id))
Пример #14
0
 def delete(self):
     return Permission(UserNeed(self.obj.pk)) & sa
Пример #15
0
 def edit(self):
     return Permission(UserNeed(self.obj.pk)) & sa
Пример #16
0
 def edit(self):
     return Permission(UserNeed(self.obj.id)) & admin
Пример #17
0
 def delete(self):
     return Permission(UserNeed(self.obj.author_id),
                       UserNeed(self.obj.post.author_id)) & moderator
Пример #18
0
 def delete(self):
     return Permission(UserNeed(self.obj.author.pk)) & \
             Permission(UserNeed(self.obj.gist.author.pk)) & admin