mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54:18 +00:00
Merge branch 'public-corpus' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into public-corpus
This commit is contained in:
commit
8b01777318
@ -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):
|
||||||
@ -542,7 +544,8 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
)
|
)
|
||||||
followed_corpora = association_proxy(
|
followed_corpora = association_proxy(
|
||||||
'corpus_follower_associations',
|
'corpus_follower_associations',
|
||||||
'corpus'
|
'corpus',
|
||||||
|
creator=lambda c: CorpusFollowerAssociation(corpus=c)
|
||||||
)
|
)
|
||||||
jobs = db.relationship(
|
jobs = db.relationship(
|
||||||
'Job',
|
'Job',
|
||||||
@ -574,13 +577,13 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
if 'role' not in kwargs:
|
||||||
|
kwargs['role'] = (
|
||||||
|
Role.query.filter_by(name='Administrator').first()
|
||||||
|
if kwargs['email'] == current_app.config['NOPAQUE_ADMIN']
|
||||||
|
else 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}>'
|
||||||
@ -1532,7 +1535,8 @@ class Corpus(HashidMixin, db.Model):
|
|||||||
)
|
)
|
||||||
followers = association_proxy(
|
followers = association_proxy(
|
||||||
'corpus_follower_associations',
|
'corpus_follower_associations',
|
||||||
'follower'
|
'follower',
|
||||||
|
creator=lambda u: CorpusFollowerAssociation(follower=u)
|
||||||
)
|
)
|
||||||
user = db.relationship('User', back_populates='corpora')
|
user = db.relationship('User', back_populates='corpora')
|
||||||
# "static" attributes
|
# "static" attributes
|
||||||
|
Loading…
Reference in New Issue
Block a user