mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into development
This commit is contained in:
		@@ -285,6 +285,12 @@ corpus_followers = db.Table(
 | 
			
		||||
    db.Column('corpus_id', db.ForeignKey('corpora.id'), primary_key=True)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
user_followers = db.Table(
 | 
			
		||||
    'user_followers',
 | 
			
		||||
    db.Model.metadata,
 | 
			
		||||
    db.Column('follower_user_id', db.ForeignKey('users.id'), primary_key=True),
 | 
			
		||||
    db.Column('followed_user_id', db.ForeignKey('users.id'), primary_key=True)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
class User(HashidMixin, UserMixin, db.Model):
 | 
			
		||||
    __tablename__ = 'users'
 | 
			
		||||
@@ -343,6 +349,14 @@ class User(HashidMixin, UserMixin, db.Model):
 | 
			
		||||
        backref=db.backref('followers', lazy='dynamic'),
 | 
			
		||||
        lazy='dynamic'
 | 
			
		||||
    )
 | 
			
		||||
    followed_users = db.relationship(
 | 
			
		||||
        'User',
 | 
			
		||||
        secondary=user_followers,
 | 
			
		||||
        primaryjoin=(user_followers.c.follower_user_id == id),
 | 
			
		||||
        secondaryjoin=(user_followers.c.followed_user_id == id),
 | 
			
		||||
        backref=db.backref('followers', lazy='dynamic'),
 | 
			
		||||
        lazy='dynamic'
 | 
			
		||||
    )
 | 
			
		||||
    jobs = db.relationship(
 | 
			
		||||
        'Job',
 | 
			
		||||
        backref='user',
 | 
			
		||||
@@ -559,17 +573,29 @@ class User(HashidMixin, UserMixin, db.Model):
 | 
			
		||||
    #endregion Profile Privacy settings
 | 
			
		||||
 | 
			
		||||
    def follow_corpus(self, corpus):
 | 
			
		||||
        if not self.is_following(corpus):
 | 
			
		||||
        if not self.is_following_corpus(corpus):
 | 
			
		||||
            self.followed_corpora.append(corpus)
 | 
			
		||||
 | 
			
		||||
    def unfollow_corpus(self, corpus):
 | 
			
		||||
        if self.is_following(corpus):
 | 
			
		||||
        if self.is_following_corpus(corpus):
 | 
			
		||||
            self.followed_corpora.remove(corpus)
 | 
			
		||||
    
 | 
			
		||||
    def is_following_corpus(self, corpus):
 | 
			
		||||
        return self.followed_corpora.filter(
 | 
			
		||||
            corpus_followers.c.corpus_id == corpus.id).count() > 0
 | 
			
		||||
 | 
			
		||||
    def follow_user(self, user):
 | 
			
		||||
        if not self.is_following_user(user):
 | 
			
		||||
            self.followed_users.append(user)
 | 
			
		||||
 | 
			
		||||
    def unfollow_user(self, user):
 | 
			
		||||
        if self.is_following_user(user):
 | 
			
		||||
            self.followed_users.remove(user)
 | 
			
		||||
    
 | 
			
		||||
    def is_following_user(self, user):
 | 
			
		||||
        return self.followed_users.filter(
 | 
			
		||||
            user_followers.c.followed_user_id == user.id).count() > 0
 | 
			
		||||
 | 
			
		||||
    def to_json_serializeable(self, backrefs=False, relationships=False, filter_by_privacy_settings=False):
 | 
			
		||||
        json_serializeable = {
 | 
			
		||||
            'id': self.hashid,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user