Browse Source

privs: fix #14 (rebased from work by @Dark-Storm)

master
lephe 8 months ago
parent
commit
d33b90aff2
2 changed files with 1 additions and 7 deletions
  1. 0
    6
      app/models/privs.py
  2. 1
    1
      app/models/users.py

+ 0
- 6
app/models/privs.py View File

@@ -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'

+ 1
- 1
app/models/users.py View File

@@ -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…
Cancel
Save