mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Merge branch 'public-corpus' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into public-corpus
This commit is contained in:
commit
c2471e1848
@ -11,6 +11,7 @@ from app.models import (
|
|||||||
from ..decorators import corpus_follower_permission_required
|
from ..decorators import corpus_follower_permission_required
|
||||||
from . import bp
|
from . import bp
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/followers', methods=['POST'])
|
@bp.route('/<hashid:corpus_id>/followers', methods=['POST'])
|
||||||
@corpus_follower_permission_required('MANAGE_FOLLOWERS')
|
@corpus_follower_permission_required('MANAGE_FOLLOWERS')
|
||||||
@content_negotiation(consumes='application/json', produces='application/json')
|
@content_negotiation(consumes='application/json', produces='application/json')
|
||||||
|
@ -787,11 +787,17 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
#endregion Profile Privacy settings
|
#endregion Profile Privacy settings
|
||||||
|
|
||||||
def follow_corpus(self, corpus, role=None):
|
def follow_corpus(self, corpus, role=None):
|
||||||
|
if role is None:
|
||||||
|
cfr = CorpusFollowerRole.query.filter_by(default=True).first()
|
||||||
|
else:
|
||||||
|
cfr = role
|
||||||
if self.is_following_corpus(corpus):
|
if self.is_following_corpus(corpus):
|
||||||
return
|
cfa = CorpusFollowerAssociation.query.filter_by(corpus=corpus, follower=self).first()
|
||||||
r = CorpusFollowerRole.query.filter_by(default=True).first() if role is None else role
|
if cfa.role != cfr:
|
||||||
cfa = CorpusFollowerAssociation(corpus=corpus, role=r, follower=self)
|
cfa.role = cfr
|
||||||
db.session.add(cfa)
|
else:
|
||||||
|
cfa = CorpusFollowerAssociation(corpus=corpus, role=cfr, follower=self)
|
||||||
|
db.session.add(cfa)
|
||||||
|
|
||||||
def unfollow_corpus(self, corpus):
|
def unfollow_corpus(self, corpus):
|
||||||
if not self.is_following_corpus(corpus):
|
if not self.is_following_corpus(corpus):
|
||||||
@ -840,7 +846,7 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
if role is None:
|
if role is None:
|
||||||
return False
|
return False
|
||||||
self.follow_corpus(corpus, role)
|
self.follow_corpus(corpus, role)
|
||||||
db.session.add(self)
|
# db.session.add(self)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def to_json_serializeable(self, backrefs=False, relationships=False, filter_by_privacy_settings=False):
|
def to_json_serializeable(self, backrefs=False, relationships=False, filter_by_privacy_settings=False):
|
||||||
|
@ -192,7 +192,7 @@
|
|||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">badge</i>
|
<i class="material-icons prefix">badge</i>
|
||||||
<select id="share-link-modal-corpus-follower-role-select">
|
<select id="share-link-modal-corpus-follower-role-select">
|
||||||
{% for cfr in cfrs %}
|
{% for cfr in cfrs if cfr.name != 'Anonymous' %}
|
||||||
<option value="{{ cfr.name }}">{{ cfr.name }}</option>
|
<option value="{{ cfr.name }}">{{ cfr.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user