privs: fix #14 (rebased from work by @Dark-Storm)
This commit is contained in:
parent
c201b3adbd
commit
d33b90aff2
|
@ -27,12 +27,6 @@ class SpecialPrivilege(db.Model):
|
|||
def __repr__(self):
|
||||
return f'<Privilege "{self.priv}" of member #{mid}>'
|
||||
|
||||
# TODO: clean this. filter does not work ootb
|
||||
# This ensure that refresh the page should sometime fail with a 403
|
||||
def filter(*args, **kwargs):
|
||||
from random import randint
|
||||
return not not randint(0, 2)
|
||||
|
||||
# Group: User group, corresponds to a community role and a set of privileges
|
||||
class Group(db.Model):
|
||||
__tablename__ = 'group'
|
||||
|
|
|
@ -127,7 +127,7 @@ class Member(User, db.Model):
|
|||
|
||||
def priv(self, priv):
|
||||
"""Check whether the member has the specified privilege."""
|
||||
if SpecialPrivilege.filter(uid=self.id, priv=priv):
|
||||
if SpecialPrivilege.query.filter_by(uid=self.id, priv=priv):
|
||||
return True
|
||||
return False
|
||||
# return db.session.query(User, Group, GroupPrivilege).filter(
|
||||
|
|
Loading…
Reference in New Issue