From cb31afe7236fdf37a43db8b14fa3ecbebac91fac Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 24 Feb 2023 09:44:09 +0100 Subject: [PATCH] small fix --- app/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models.py b/app/models.py index ed36a8ff..4f31c570 100644 --- a/app/models.py +++ b/app/models.py @@ -775,14 +775,17 @@ class User(HashidMixin, UserMixin, db.Model): #endregion Profile Privacy settings def follow_corpus(self, corpus, role=None): + if self.is_following_corpus(corpus): + return if role is None: r = CorpusFollowerRole.query.filter_by(default=True).first() cfa = CorpusFollowerAssociation(corpus=corpus, role=r, follower=self) db.session.add(cfa) def unfollow_corpus(self, corpus): - if self.is_following_corpus(corpus): - self.followed_corpora.remove(corpus) + if not self.is_following_corpus(corpus): + return + self.followed_corpora.remove(corpus) def is_following_corpus(self, corpus): return corpus in self.followed_corpora