mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Bring back community update 2/x
This commit is contained in:
parent
f4d3415c11
commit
0abfe65afa
@ -71,55 +71,55 @@ def get_stopwords():
|
|||||||
response_data = stopwords
|
response_data = stopwords
|
||||||
return response_data, 202
|
return response_data, 202
|
||||||
|
|
||||||
# @bp.route('/<hashid:corpus_id>/generate-share-link', methods=['POST'])
|
@bp.route('/<hashid:corpus_id>/generate-share-link', 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')
|
||||||
# def generate_corpus_share_link(corpus_id):
|
def generate_corpus_share_link(corpus_id):
|
||||||
# data = request.json
|
data = request.json
|
||||||
# if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
# abort(400)
|
abort(400)
|
||||||
# expiration = data.get('expiration')
|
expiration = data.get('expiration')
|
||||||
# if not isinstance(expiration, str):
|
if not isinstance(expiration, str):
|
||||||
# abort(400)
|
abort(400)
|
||||||
# role_name = data.get('role')
|
role_name = data.get('role')
|
||||||
# if not isinstance(role_name, str):
|
if not isinstance(role_name, str):
|
||||||
# abort(400)
|
abort(400)
|
||||||
# expiration_date = datetime.strptime(expiration, '%b %d, %Y')
|
expiration_date = datetime.strptime(expiration, '%b %d, %Y')
|
||||||
# cfr = CorpusFollowerRole.query.filter_by(name=role_name).first()
|
cfr = CorpusFollowerRole.query.filter_by(name=role_name).first()
|
||||||
# if cfr is None:
|
if cfr is None:
|
||||||
# abort(400)
|
abort(400)
|
||||||
# corpus = Corpus.query.get_or_404(corpus_id)
|
corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
# token = current_user.generate_follow_corpus_token(corpus.hashid, role_name, expiration_date)
|
token = current_user.generate_follow_corpus_token(corpus.hashid, role_name, expiration_date)
|
||||||
# corpus_share_link = url_for(
|
corpus_share_link = url_for(
|
||||||
# 'corpora.follow_corpus',
|
'corpora.follow_corpus',
|
||||||
# corpus_id=corpus_id,
|
corpus_id=corpus_id,
|
||||||
# token=token,
|
token=token,
|
||||||
# _external=True
|
_external=True
|
||||||
# )
|
)
|
||||||
# response_data = {
|
response_data = {
|
||||||
# 'message': 'Corpus share link generated',
|
'message': 'Corpus share link generated',
|
||||||
# 'category': 'corpus',
|
'category': 'corpus',
|
||||||
# 'corpusShareLink': corpus_share_link
|
'corpusShareLink': corpus_share_link
|
||||||
# }
|
}
|
||||||
# return response_data, 200
|
return response_data, 200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# @bp.route('/<hashid:corpus_id>/is_public', methods=['PUT'])
|
@bp.route('/<hashid:corpus_id>/is_public', methods=['PUT'])
|
||||||
# @corpus_owner_or_admin_required
|
@corpus_owner_or_admin_required
|
||||||
# @content_negotiation(consumes='application/json', produces='application/json')
|
@content_negotiation(consumes='application/json', produces='application/json')
|
||||||
# def update_corpus_is_public(corpus_id):
|
def update_corpus_is_public(corpus_id):
|
||||||
# is_public = request.json
|
is_public = request.json
|
||||||
# if not isinstance(is_public, bool):
|
if not isinstance(is_public, bool):
|
||||||
# abort(400)
|
abort(400)
|
||||||
# corpus = Corpus.query.get_or_404(corpus_id)
|
corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
# corpus.is_public = is_public
|
corpus.is_public = is_public
|
||||||
# db.session.commit()
|
db.session.commit()
|
||||||
# response_data = {
|
response_data = {
|
||||||
# 'message': (
|
'message': (
|
||||||
# f'Corpus "{corpus.title}" is now'
|
f'Corpus "{corpus.title}" is now'
|
||||||
# f' {"public" if is_public else "private"}'
|
f' {"public" if is_public else "private"}'
|
||||||
# ),
|
),
|
||||||
# 'category': 'corpus'
|
'category': 'corpus'
|
||||||
# }
|
}
|
||||||
# return response_data, 200
|
return response_data, 200
|
||||||
|
@ -68,20 +68,19 @@ def corpus(corpus_id):
|
|||||||
corpus=corpus,
|
corpus=corpus,
|
||||||
cfr=cfr,
|
cfr=cfr,
|
||||||
cfrs=cfrs,
|
cfrs=cfrs,
|
||||||
users = users
|
users=users
|
||||||
)
|
)
|
||||||
if (current_user.is_following_corpus(corpus) or corpus.is_public):
|
if (current_user.is_following_corpus(corpus) or corpus.is_public):
|
||||||
abort(404)
|
cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != corpus.user.id).all()
|
||||||
# cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != corpus.user.id).all()
|
return render_template(
|
||||||
# return render_template(
|
'corpora/public_corpus.html.j2',
|
||||||
# 'corpora/public_corpus.html.j2',
|
title=corpus.title,
|
||||||
# title=corpus.title,
|
corpus=corpus,
|
||||||
# corpus=corpus,
|
cfrs=cfrs,
|
||||||
# cfrs=cfrs,
|
cfr=cfr,
|
||||||
# cfr=cfr,
|
cfas=cfas,
|
||||||
# cfas=cfas,
|
users=users
|
||||||
# users = users
|
)
|
||||||
# )
|
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,9 @@ def terms_of_use():
|
|||||||
@register_breadcrumb(bp, '.social_area', '<i class="material-icons left">group</i>Social Area')
|
@register_breadcrumb(bp, '.social_area', '<i class="material-icons left">group</i>Social Area')
|
||||||
@login_required
|
@login_required
|
||||||
def social_area():
|
def social_area():
|
||||||
|
print('test')
|
||||||
corpora = Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all()
|
corpora = Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all()
|
||||||
|
print(corpora)
|
||||||
users = User.query.filter(User.is_public == True, User.id != current_user.id).all()
|
users = User.query.filter(User.is_public == True, User.id != current_user.id).all()
|
||||||
return render_template(
|
return render_template(
|
||||||
'main/social_area.html.j2',
|
'main/social_area.html.j2',
|
||||||
|
@ -853,7 +853,7 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
json_serializeable = {
|
json_serializeable = {
|
||||||
'id': self.hashid,
|
'id': self.hashid,
|
||||||
'confirmed': self.confirmed,
|
'confirmed': self.confirmed,
|
||||||
# 'avatar': url_for('users.user_avatar', user_id=self.id),
|
'avatar': url_for('users.user_avatar', user_id=self.id),
|
||||||
'email': self.email,
|
'email': self.email,
|
||||||
'last_seen': (
|
'last_seen': (
|
||||||
None if self.last_seen is None
|
None if self.last_seen is None
|
||||||
|
@ -18,7 +18,7 @@ ResourceLists.CorpusFollowerList = class CorpusFollowerList extends ResourceList
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.getUser(this.userId).then((user) => {
|
app.getUser(this.userId).then((user) => {
|
||||||
let corpusFollowerAssociations = Object.values(user.corpora[this.corpusId].corpus_follower_associations);
|
// let corpusFollowerAssociations = Object.values(user.corpora[this.corpusId].corpus_follower_associations);
|
||||||
// let filteredList = corpusFollowerAssociations.filter(association => association.follower.id != currentUserId);
|
// let filteredList = corpusFollowerAssociations.filter(association => association.follower.id != currentUserId);
|
||||||
// this.add(filteredList);
|
// this.add(filteredList);
|
||||||
this.add(Object.values(user.corpora[this.corpusId].corpus_follower_associations));
|
this.add(Object.values(user.corpora[this.corpusId].corpus_follower_associations));
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.ResourceList {
|
ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.ResourceList {
|
||||||
static htmlClass = 'public-corpus-list';
|
static htmlClass = 'public-corpus-list';
|
||||||
|
|
||||||
|
constructor(listContainerElement, options = {}) {
|
||||||
|
super(listContainerElement, options);
|
||||||
|
this.listjs.list.addEventListener('click', (event) => {this.onClick(event)});
|
||||||
|
}
|
||||||
|
|
||||||
get item() {
|
get item() {
|
||||||
return (values) => {
|
return (values) => {
|
||||||
return `
|
return `
|
||||||
@ -16,6 +21,19 @@ ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.Re
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get valueNames() {
|
||||||
|
return [
|
||||||
|
{data: ['id']},
|
||||||
|
{data: ['creation-date']},
|
||||||
|
{name: 'status', attr: 'data-status'},
|
||||||
|
'description',
|
||||||
|
'title',
|
||||||
|
'owner',
|
||||||
|
'is-owner',
|
||||||
|
'current-user-is-following'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
mapResourceToValue(corpus) {
|
mapResourceToValue(corpus) {
|
||||||
return {
|
return {
|
||||||
'id': corpus.id,
|
'id': corpus.id,
|
||||||
@ -54,4 +72,21 @@ ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.Re
|
|||||||
<ul class="pagination"></ul>
|
<ul class="pagination"></ul>
|
||||||
`.trim();
|
`.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClick(event) {
|
||||||
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
|
if (listItemElement === null) {return;}
|
||||||
|
let itemId = listItemElement.dataset.id;
|
||||||
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
|
switch (listAction) {
|
||||||
|
case 'view': {
|
||||||
|
window.location.href = `/corpora/${itemId}`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
ResourceLists.UserList = class UserList extends ResourceLists.ResourceList {
|
ResourceLists.PublicUserList = class PublicUserList extends ResourceLists.ResourceList {
|
||||||
static htmlClass = 'user-list';
|
static htmlClass = 'public-user-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
super(listContainerElement, options);
|
super(listContainerElement, options);
|
@ -80,9 +80,9 @@
|
|||||||
'js/resource-lists/job-list.js',
|
'js/resource-lists/job-list.js',
|
||||||
'js/resource-lists/job-result-list.js',
|
'js/resource-lists/job-result-list.js',
|
||||||
'js/resource-lists/public-corpus-list.js',
|
'js/resource-lists/public-corpus-list.js',
|
||||||
|
'js/resource-lists/public-user-list.js',
|
||||||
'js/resource-lists/spacy-nlp-pipeline-model-list.js',
|
'js/resource-lists/spacy-nlp-pipeline-model-list.js',
|
||||||
'js/resource-lists/tesseract-ocr-pipeline-model-list.js',
|
'js/resource-lists/tesseract-ocr-pipeline-model-list.js'
|
||||||
'js/resource-lists/user-list.js'
|
|
||||||
%}
|
%}
|
||||||
<script src="{{ ASSET_URL }}"></script>
|
<script src="{{ ASSET_URL }}"></script>
|
||||||
{%- endassets %}
|
{%- endassets %}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
let userConfirmedSwitchElement = document.querySelector('#user-confirmed-switch');
|
let userConfirmedSwitchElement = document.querySelector('#user-confirmed-switch');
|
||||||
userConfirmedSwitchElement.addEventListener('change', (event) => {
|
userConfirmedSwitchElement.addEventListener('change', (event) => {
|
||||||
let newConfirmed = userConfirmedSwitchElement.checked;
|
let newConfirmed = userConfirmedSwitchElement.checked;
|
||||||
requests.admin.users.entity.confirmed.update({{ user.hashid|tojson }}, newConfirmed)
|
Requests.admin.users.entity.confirmed.update({{ user.hashid|tojson }}, newConfirmed)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
userConfirmedSwitchElement.checked = !userConfirmedSwitchElement;
|
userConfirmedSwitchElement.checked = !userConfirmedSwitchElement;
|
||||||
});
|
});
|
||||||
|
@ -240,7 +240,7 @@
|
|||||||
{% if current_user.is_following_corpus(corpus) %}
|
{% if current_user.is_following_corpus(corpus) %}
|
||||||
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
|
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
|
||||||
unfollowRequestElement.addEventListener('click', () => {
|
unfollowRequestElement.addEventListener('click', () => {
|
||||||
requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
|
Requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
@ -252,7 +252,7 @@
|
|||||||
let publishingModalIsPublicSwitchElement = document.querySelector('#publishing-modal-is-public-switch');
|
let publishingModalIsPublicSwitchElement = document.querySelector('#publishing-modal-is-public-switch');
|
||||||
publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
|
publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
|
||||||
let newIsPublic = publishingModalIsPublicSwitchElement.checked;
|
let newIsPublic = publishingModalIsPublicSwitchElement.checked;
|
||||||
requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
|
Requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
|
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
|
||||||
});
|
});
|
||||||
@ -262,7 +262,7 @@ publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
|
|||||||
// #region Delete
|
// #region Delete
|
||||||
let deleteModalDeleteButtonElement = document.querySelector('#delete-modal-delete-button');
|
let deleteModalDeleteButtonElement = document.querySelector('#delete-modal-delete-button');
|
||||||
deleteModalDeleteButtonElement.addEventListener('click', (event) => {
|
deleteModalDeleteButtonElement.addEventListener('click', (event) => {
|
||||||
requests.corpora.entity.delete({{ corpus.hashid|tojson }})
|
Requests.corpora.entity.delete({{ corpus.hashid|tojson }})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
window.location.href = {{ url_for('main.dashboard')|tojson }};
|
window.location.href = {{ url_for('main.dashboard')|tojson }};
|
||||||
});
|
});
|
||||||
@ -281,6 +281,7 @@ let users = {
|
|||||||
{% if not loop.last %},{% endif %}
|
{% if not loop.last %},{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
};
|
};
|
||||||
|
console.log(users);
|
||||||
|
|
||||||
let inviteUserModalSearch = M.Chips.init(
|
let inviteUserModalSearch = M.Chips.init(
|
||||||
inviteUserModalSearchElement,
|
inviteUserModalSearchElement,
|
||||||
@ -312,7 +313,7 @@ M.Modal.init(
|
|||||||
|
|
||||||
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
|
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
|
||||||
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
|
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
|
||||||
requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
|
Requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
|
||||||
});
|
});
|
||||||
// #endregion Invite user
|
// #endregion Invite user
|
||||||
|
|
||||||
@ -357,7 +358,7 @@ M.Modal.init(
|
|||||||
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
|
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
|
||||||
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
|
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
|
||||||
let expiration = shareLinkModalExpirationDateDatepickerElement.value
|
let expiration = shareLinkModalExpirationDateDatepickerElement.value
|
||||||
requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
|
Requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
response.json()
|
response.json()
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<p>Find other users and see what corpora they have made public.</p>
|
<p>Find other users and see what corpora they have made public.</p>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="user-list no-autoinit"></div>
|
<div id="public-user-list"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">Public Corpora</span>
|
<span class="card-title">Public Corpora</span>
|
||||||
<div class="public-corpus-list no-autoinit"></div>
|
<div id="public-corpus-list"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -62,15 +62,18 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
let userList = new ResourceLists.UserList(document.querySelector('.user-list'));
|
let publicUserListElement = document.querySelector('#public-user-list');
|
||||||
userList.add(
|
let publicUserList = new ResourceLists.PublicUserList(publicUserListElement);
|
||||||
|
publicUserList.add(
|
||||||
[
|
[
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
{{ user.to_json_serializeable(relationships=True, filter_by_privacy_settings=True)|tojson }},
|
{{ user.to_json_serializeable(relationships=True, filter_by_privacy_settings=True)|tojson }},
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
let publicCorpusList = new ResourceLists.PublicCorpusList(document.querySelector('.public-corpus-list'));
|
|
||||||
|
let publicCorpusListElement = document.querySelector('#public-corpus-list');
|
||||||
|
let publicCorpusList = new ResourceLists.PublicCorpusList(publicCorpusListElement);
|
||||||
publicCorpusList.add(
|
publicCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in corpora %}
|
{% for corpus in corpora %}
|
||||||
|
Loading…
Reference in New Issue
Block a user