diff --git a/app/models.py b/app/models.py index d73b01b6..df992ccb 100644 --- a/app/models.py +++ b/app/models.py @@ -479,6 +479,8 @@ class CorpusFollowerAssociation(HashidMixin, db.Model): ) def __init__(self, **kwargs): + if 'role' not in kwargs: + kwargs['role'] = CorpusFollowerRole.query.filter_by(default=True).first() super().__init__(**kwargs) def __repr__(self): @@ -575,13 +577,12 @@ class User(HashidMixin, UserMixin, db.Model): ) 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) - 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): return f''