mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
(Public-)Corpus List fix+highligting owner status
This commit is contained in:
parent
8a85dd9e61
commit
b07addc5c3
@ -51,7 +51,8 @@ def create_corpus():
|
|||||||
def corpus(corpus_id):
|
def corpus(corpus_id):
|
||||||
corpus = Corpus.query.get_or_404(corpus_id)
|
corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
cfrs = CorpusFollowerRole.query.all()
|
cfrs = CorpusFollowerRole.query.all()
|
||||||
users = User.query.filter(User.is_public == True, User.id != current_user.id).all()
|
# TODO: Better solution for filtering admin
|
||||||
|
users = User.query.filter(User.is_public == True, User.id != current_user.id, User.id != corpus.user.id, User.role_id < 4).all()
|
||||||
cfa = CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=current_user.id).first()
|
cfa = CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=current_user.id).first()
|
||||||
if cfa is None:
|
if cfa is None:
|
||||||
if corpus.user == current_user or current_user.is_administrator():
|
if corpus.user == current_user or current_user.is_administrator():
|
||||||
|
@ -3,6 +3,7 @@ from flask_breadcrumbs import register_breadcrumb
|
|||||||
from flask_login import current_user, login_required, login_user
|
from flask_login import current_user, login_required, login_user
|
||||||
from app.auth.forms import LoginForm
|
from app.auth.forms import LoginForm
|
||||||
from app.models import Corpus, User
|
from app.models import Corpus, User
|
||||||
|
from sqlalchemy import or_
|
||||||
from . import bp
|
from . import bp
|
||||||
|
|
||||||
|
|
||||||
@ -38,8 +39,10 @@ def faq():
|
|||||||
@register_breadcrumb(bp, '.dashboard', '<i class="material-icons left">dashboard</i>Dashboard')
|
@register_breadcrumb(bp, '.dashboard', '<i class="material-icons left">dashboard</i>Dashboard')
|
||||||
@login_required
|
@login_required
|
||||||
def dashboard():
|
def dashboard():
|
||||||
|
corpora = Corpus.query.filter(or_(Corpus.followers.any(id=current_user.id), Corpus.user == current_user)).all()
|
||||||
return render_template(
|
return render_template(
|
||||||
'main/dashboard.html.j2',
|
'main/dashboard.html.j2',
|
||||||
|
corpora=corpora,
|
||||||
title='Dashboard'
|
title='Dashboard'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -81,15 +84,7 @@ 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():
|
||||||
# corpora = [
|
|
||||||
# c.to_json_serializeable() for c
|
|
||||||
# in 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()
|
corpora = Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all()
|
||||||
# users = [
|
|
||||||
# u.to_json_serializeable(relationships=True, filter_by_privacy_settings=True,) for u
|
|
||||||
# in 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()
|
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',
|
||||||
|
@ -16,15 +16,6 @@ class CorpusList extends ResourceList {
|
|||||||
if (this.isInitialized) {this.onPatch(patch);}
|
if (this.isInitialized) {this.onPatch(patch);}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.getUser(this.userId).then((user) => {
|
|
||||||
let followedCorpora = [];
|
|
||||||
for (let cfa of Object.values(user.corpus_follower_associations)) {
|
|
||||||
followedCorpora.push(cfa.corpus);
|
|
||||||
}
|
|
||||||
this.add(Object.values(user.corpora));
|
|
||||||
this.add(followedCorpora);
|
|
||||||
this.isInitialized = true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// #region Mandatory getters and methods to implement
|
// #region Mandatory getters and methods to implement
|
||||||
@ -33,6 +24,7 @@ class CorpusList extends ResourceList {
|
|||||||
<tr class="list-item clickable hoverable">
|
<tr class="list-item clickable hoverable">
|
||||||
<td><a class="btn-floating disabled"><i class="material-icons service-color darken" data-service="corpus-analysis">book</i></a></td>
|
<td><a class="btn-floating disabled"><i class="material-icons service-color darken" data-service="corpus-analysis">book</i></a></td>
|
||||||
<td><b class="title"></b><br><i class="description"></i></td>
|
<td><b class="title"></b><br><i class="description"></i></td>
|
||||||
|
<td><span class="owner"></span></td>
|
||||||
<td><span class="status badge new corpus-status-color corpus-status-text" data-badge-caption=""></span></td>
|
<td><span class="status badge new corpus-status-color corpus-status-text" data-badge-caption=""></span></td>
|
||||||
<td class="right-align">
|
<td class="right-align">
|
||||||
<a class="list-action-trigger btn-floating red waves-effect waves-light" data-list-action="delete-request"><i class="material-icons">delete</i></a>
|
<a class="list-action-trigger btn-floating red waves-effect waves-light" data-list-action="delete-request"><i class="material-icons">delete</i></a>
|
||||||
@ -48,7 +40,9 @@ class CorpusList extends ResourceList {
|
|||||||
{data: ['creation-date']},
|
{data: ['creation-date']},
|
||||||
{name: 'status', attr: 'data-status'},
|
{name: 'status', attr: 'data-status'},
|
||||||
'description',
|
'description',
|
||||||
'title'
|
'title',
|
||||||
|
'owner',
|
||||||
|
{data: ['is-owner']}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +62,7 @@ class CorpusList extends ResourceList {
|
|||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Title and Description</th>
|
<th>Title and Description</th>
|
||||||
|
<th>Owner</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -84,7 +79,9 @@ class CorpusList extends ResourceList {
|
|||||||
'creation-date': corpus.creation_date,
|
'creation-date': corpus.creation_date,
|
||||||
'description': corpus.description,
|
'description': corpus.description,
|
||||||
'status': corpus.status,
|
'status': corpus.status,
|
||||||
'title': corpus.title
|
'title': corpus.title,
|
||||||
|
'owner': corpus.user.username,
|
||||||
|
'is-owner': corpus.user.id === currentUserId ? true : false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
class FollowedCorpusList extends CorpusList {
|
|
||||||
get item() {
|
|
||||||
return `
|
|
||||||
<tr class="list-item clickable hoverable">
|
|
||||||
<td><a class="btn-floating disabled"><i class="material-icons service-color darken" data-service="corpus-analysis">book</i></a></td>
|
|
||||||
<td><b class="title"></b><br><i class="description"></i></td>
|
|
||||||
<td><span class="status badge new corpus-status-color corpus-status-text" data-badge-caption=""></span></td>
|
|
||||||
<td class="right-align">
|
|
||||||
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light" data-list-action="view" data-service="corpus-analysis"><i class="material-icons">send</i></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
`.trim();
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,7 @@ class PublicCorpusList extends CorpusList {
|
|||||||
<tr class="list-item clickable hoverable">
|
<tr class="list-item clickable hoverable">
|
||||||
<td><a class="btn-floating disabled"><i class="material-icons service-color darken" data-service="corpus-analysis">book</i></a></td>
|
<td><a class="btn-floating disabled"><i class="material-icons service-color darken" data-service="corpus-analysis">book</i></a></td>
|
||||||
<td><b class="title"></b><br><i class="description"></i></td>
|
<td><b class="title"></b><br><i class="description"></i></td>
|
||||||
|
<td><span class="owner"></span></td>
|
||||||
<td><span class="status badge new corpus-status-color corpus-status-text" data-badge-caption=""></span></td>
|
<td><span class="status badge new corpus-status-color corpus-status-text" data-badge-caption=""></span></td>
|
||||||
<td class="right-align">
|
<td class="right-align">
|
||||||
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light" data-list-action="view" data-service="corpus-analysis"><i class="material-icons">send</i></a>
|
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light" data-list-action="view" data-service="corpus-analysis"><i class="material-icons">send</i></a>
|
||||||
|
@ -110,8 +110,8 @@
|
|||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<p></p>
|
<p></p>
|
||||||
{% if not current_user.is_following_corpus(corpus) %}
|
{% if not current_user.is_following_corpus(corpus) and corpus.user.has_profile_privacy_setting('SHOW_EMAIL') %}
|
||||||
<a class="waves-effect waves-light btn-small">Request Corpus</a>
|
<a class="waves-effect waves-light btn-small" href="mailto:{{ corpus.user.email }}">Request Corpus</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="waves-effect waves-light btn-small" href="{{ url_for('users.user', user_id=corpus.user.id) }}">View profile</a>
|
<a class="waves-effect waves-light btn-small" href="{{ url_for('users.user', user_id=corpus.user.id) }}">View profile</a>
|
||||||
</div>
|
</div>
|
||||||
@ -153,7 +153,7 @@
|
|||||||
{% block modals %}
|
{% block modals %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
|
||||||
{% if cfr.has_permission('MANAGE_FOLLOWERS') %}
|
{% if current_user == corpus.user or current_user.is_administrator() %}
|
||||||
<div class="modal" id="publishing-modal">
|
<div class="modal" id="publishing-modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4>Change your Corpus publishing status</h4>
|
<h4>Change your Corpus publishing status</h4>
|
||||||
@ -172,9 +172,7 @@
|
|||||||
<a class="modal-close waves-effect waves-green btn-flat">Close</a>
|
<a class="modal-close waves-effect waves-green btn-flat">Close</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if current_user == corpus.user or current_user.is_administrator() %}
|
|
||||||
<div class="modal" id="delete-modal">
|
<div class="modal" id="delete-modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4>Confirm Corpus deletion</h4>
|
<h4>Confirm Corpus deletion</h4>
|
||||||
@ -221,9 +219,9 @@
|
|||||||
You can set different roles via the link, you can also edit them later in the menu below.
|
You can set different roles via the link, you can also edit them later in the menu below.
|
||||||
It is recommended not to set the expiration date of the link too far.
|
It is recommended not to set the expiration date of the link too far.
|
||||||
</p>
|
</p>
|
||||||
<h5>Please make sure that the invited users are legally allowed to view the included corpus files.</h5>
|
<p><b>Please make sure that the invited users are legally allowed to view the included corpus files.</b></p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12 l3">
|
<div class="col s12 l2">
|
||||||
<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">
|
||||||
@ -241,12 +239,12 @@
|
|||||||
<label for="expiration-date">Expiration date</label>
|
<label for="expiration-date">Expiration date</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12 l3">
|
<div class="col s12 l2">
|
||||||
<br class="hide-on-med-and-down">
|
<br class="hide-on-med-and-down">
|
||||||
<a class="btn waves-effect waves-light" id="share-link-modal-create-button">Create<i class="material-icons right">send</i></a>
|
<a class="btn waves-effect waves-light" id="share-link-modal-create-button">Create<i class="material-icons right">send</i></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s12 l6">
|
<div class="col s12 l5">
|
||||||
<div class="row hide" id="share-link-modal-output-container">
|
<div class="row hide" id="share-link-modal-output-container">
|
||||||
<div class="col s9">
|
<div class="col s9">
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
@ -275,13 +273,6 @@
|
|||||||
let corpusDisplay = new CorpusDisplay(document.querySelector('#corpus-display'));
|
let corpusDisplay = new CorpusDisplay(document.querySelector('#corpus-display'));
|
||||||
|
|
||||||
{% if current_user.is_following_corpus(corpus) %}
|
{% if current_user.is_following_corpus(corpus) %}
|
||||||
{% if cfr.has_permission('MANAGE_FILES') %}
|
|
||||||
let buildButton = document.querySelector('#build-button');
|
|
||||||
buildButton.addEventListener('click', () => {
|
|
||||||
Requests.corpora.entity.build({{ corpus.hashid|tojson }})
|
|
||||||
});
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
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 }})
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="corpus-list" data-user-id="{{ current_user.hashid }}"></div>
|
<div class="corpus-list no-autoinit" data-user-id="{{ current_user.hashid }}"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action right-align">
|
<div class="card-action right-align">
|
||||||
<a class="btn disabled waves-effect waves-light" href="{{ url_for('corpora.import_corpus') }}">Import Corpus<i class="material-icons right">import_export</i></a>
|
<a class="btn disabled waves-effect waves-light" href="{{ url_for('corpora.import_corpus') }}">Import Corpus<i class="material-icons right">import_export</i></a>
|
||||||
@ -135,3 +135,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock modals %}
|
{% endblock modals %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
let corpusList = new CorpusList(document.querySelector('.corpus-list'));
|
||||||
|
corpusList.add(
|
||||||
|
[
|
||||||
|
{% for corpus in corpora %}
|
||||||
|
{{ corpus.to_json_serializeable(backrefs=True)|tojson }},
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
corpusItems = document.querySelectorAll('[data-is-owner="false"]');
|
||||||
|
corpusItems.forEach((item) => {
|
||||||
|
item.classList.add('deep-purple', 'lighten-5');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock scripts %}
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
publicCorpusList.add(
|
publicCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in corpora %}
|
{% for corpus in corpora %}
|
||||||
{{ corpus.to_json_serializeable()|tojson }},
|
{{ corpus.to_json_serializeable(backrefs=True)|tojson }},
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -122,19 +122,23 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
let followedCorpusList = new FollowedCorpusList(document.querySelector('.followed-corpus-list'));
|
let followedCorpusList = new PublicCorpusList(document.querySelector('.followed-corpus-list'));
|
||||||
followedCorpusList.add(
|
followedCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in user.followed_corpora %}
|
{% for corpus in user.followed_corpora %}
|
||||||
{{ corpus.to_json_serializeable()|tojson }},
|
{% if (corpus.is_public or corpus.user == current_user) %}
|
||||||
|
{{ corpus.to_json_serializeable(backrefs=True)|tojson }},
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
let publicCorpusList = new PublicCorpusList(document.querySelector('.public-corpus-list'));
|
let publicCorpusList = new PublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||||
publicCorpusList.add(
|
publicCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in user.corpora if corpus.is_public %}
|
{% for corpus in user.corpora %}
|
||||||
{{ corpus.to_json_serializeable()|tojson }},
|
{% if corpus.is_public %}
|
||||||
|
{{ corpus.to_json_serializeable(backrefs=True)|tojson }},
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user