Esempio n. 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)
Esempio n. 2
0
    def provides(self):
        needs = [RoleNeed('auth'), UserNeed(self.pk)]

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

        return needs
Esempio n. 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)
Esempio n. 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
Esempio n. 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
Esempio n. 6
0
 def delete(self):
     return Permission(UserNeed(self.author.username)) & admin
Esempio n. 7
0
 def default(self):
     return Permission(UserNeed(self.author.username)) & moderator
Esempio n. 8
0
 def default(self):
     return Permission(UserNeed(self.owner.username)) 
Esempio n. 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)
Esempio n. 10
0
 def default(self):
     return Permission(UserNeed(self.author_id)) & moderator
Esempio n. 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)
Esempio n. 12
0
 def reply(self):
     return Permission(UserNeed(self.obj.post.author_id))
Esempio n. 13
0
 def edit(self):
     return Permission(UserNeed(self.obj.author_id))
Esempio n. 14
0
 def delete(self):
     return Permission(UserNeed(self.obj.pk)) & sa
Esempio n. 15
0
 def edit(self):
     return Permission(UserNeed(self.obj.pk)) & sa
Esempio n. 16
0
 def edit(self):
     return Permission(UserNeed(self.obj.id)) & admin
Esempio n. 17
0
 def delete(self):
     return Permission(UserNeed(self.obj.author_id),
                       UserNeed(self.obj.post.author_id)) & moderator
Esempio n. 18
0
 def delete(self):
     return Permission(UserNeed(self.obj.author.pk)) & \
             Permission(UserNeed(self.obj.gist.author.pk)) & admin