mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Found a better solution for default role assignments
This commit is contained in:
parent
ff3ac3658f
commit
c565b08f9c
@ -479,6 +479,8 @@ class CorpusFollowerAssociation(HashidMixin, db.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
if 'role' not in kwargs:
|
||||||
|
kwargs['role'] = CorpusFollowerRole.query.filter_by(default=True).first()
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -575,13 +577,12 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
if 'role' not in kwargs:
|
||||||
|
if kwargs['email'] == current_app.config['NOPAQUE_ADMIN']:
|
||||||
|
kwargs['role'] = Role.query.filter_by(name='Administrator').first()
|
||||||
|
else:
|
||||||
|
kwargs['role'] = Role.query.filter_by(default=True).first()
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
if self.role is not None:
|
|
||||||
return
|
|
||||||
if self.email == current_app.config['NOPAQUE_ADMIN']:
|
|
||||||
self.role = Role.query.filter_by(name='Administrator').first()
|
|
||||||
else:
|
|
||||||
self.role = Role.query.filter_by(default=True).first()
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'<User {self.username}>'
|
return f'<User {self.username}>'
|
||||||
|
Loading…
Reference in New Issue
Block a user