Skip to content
Snippets Groups Projects
Commit 8b017773 authored by Inga Kirschnick's avatar Inga Kirschnick
Browse files

Merge branch 'public-corpus' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into public-corpus

parents e2ddbf26 3147bed9
No related branches found
No related tags found
No related merge requests found
...@@ -479,6 +479,8 @@ class CorpusFollowerAssociation(HashidMixin, db.Model): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment