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)
def provides(self): needs = [RoleNeed('auth'), UserNeed(self.pk)] if self.is_sa: needs.append(RoleNeed('admin')) return needs
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)
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
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
def delete(self): return Permission(UserNeed(self.author.username)) & admin
def default(self): return Permission(UserNeed(self.author.username)) & moderator
def default(self): return Permission(UserNeed(self.owner.username))
def vote(self): needs = [UserNeed(user_id) for user_id in self.votes] needs.append(UserNeed(self.author_id)) return auth & Denial(*needs)
def default(self): return Permission(UserNeed(self.author_id)) & moderator
def set_owned_by(sender, identity): permissions.owned_by = Permission(UserNeed(identity.user)) permissions.modify_own_content = permission(permissions.owned_by, permissions.full_access)
def reply(self): return Permission(UserNeed(self.obj.post.author_id))
def edit(self): return Permission(UserNeed(self.obj.author_id))
def delete(self): return Permission(UserNeed(self.obj.pk)) & sa
def edit(self): return Permission(UserNeed(self.obj.pk)) & sa
def edit(self): return Permission(UserNeed(self.obj.id)) & admin
def delete(self): return Permission(UserNeed(self.obj.author_id), UserNeed(self.obj.post.author_id)) & moderator
def delete(self): return Permission(UserNeed(self.obj.author.pk)) & \ Permission(UserNeed(self.obj.gist.author.pk)) & admin