mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-26 03:14:19 +00:00
Merge branch 'public-corpus' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into public-corpus
This commit is contained in:
commit
6e9a6fa5a1
@ -35,13 +35,13 @@ def dashboard():
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('/user_manual')
|
@bp.route('/user_manual')
|
||||||
@register_breadcrumb(bp, '.user_manual', 'User manual')
|
@register_breadcrumb(bp, '.user_manual', '<i class="material-icons left">help</i>User manual')
|
||||||
def user_manual():
|
def user_manual():
|
||||||
return render_template('main/user_manual.html.j2', title='User manual')
|
return render_template('main/user_manual.html.j2', title='User manual')
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/news')
|
@bp.route('/news')
|
||||||
@register_breadcrumb(bp, '.news', 'News')
|
@register_breadcrumb(bp, '.news', '<i class="material-icons left">email</i>News')
|
||||||
def news():
|
def news():
|
||||||
return render_template('main/news.html.j2', title='News')
|
return render_template('main/news.html.j2', title='News')
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ def terms_of_use():
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('/social-area')
|
@bp.route('/social-area')
|
||||||
@register_breadcrumb(bp, '.social_area', 'Social Area')
|
@register_breadcrumb(bp, '.social_area', '<i class="material-icons left">group</i>Social Area')
|
||||||
def social_area():
|
def social_area():
|
||||||
users = [
|
users = [
|
||||||
u.to_json_serializeable(relationships=True, filter_by_privacy_settings=True,) for u
|
u.to_json_serializeable(relationships=True, filter_by_privacy_settings=True,) for u
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<div id="user-settings" class="card section scrollspy">
|
<div id="user-settings" class="card section scrollspy">
|
||||||
<form method="POST" enctype="multipart/form-data">
|
<form method="POST" enctype="multipart/form-data">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<span class="card-title">User Settings</span>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s6">
|
<div class="col s6">
|
||||||
{{ edit_profile_settings_form.hidden_tag() }}
|
{{ edit_profile_settings_form.hidden_tag() }}
|
||||||
@ -69,11 +70,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s2"></div>
|
<div class="col s2"></div>
|
||||||
<div class="col s8">
|
<div class="col s8">
|
||||||
{% if user.avatar %}
|
|
||||||
<img src="{{ url_for('.profile_avatar', user_id=user.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
|
<img src="{{ url_for('.profile_avatar', user_id=user.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
|
||||||
{% else %}
|
|
||||||
<img src="{{ url_for('static', filename='images/user_avatar.png') }}" alt="user-image" class="circle responsive-img" id="avatar">
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col s2"></div>
|
<div class="col s2"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -190,3 +187,50 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock modals %}
|
{% endblock modals %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
let publicProfile = document.querySelector('#public-profile');
|
||||||
|
let disableButtons = document.querySelectorAll('[data-action="disable"]');
|
||||||
|
let deleteButton = document.querySelector('#delete-avatar');
|
||||||
|
let avatar = document.querySelector('#avatar');
|
||||||
|
let avatarUpload = document.querySelector('#avatar-upload');
|
||||||
|
|
||||||
|
for (let disableButton of disableButtons) {
|
||||||
|
disableButton.disabled = !publicProfile.checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
publicProfile.addEventListener('change', () => {
|
||||||
|
if (publicProfile.checked) {
|
||||||
|
for (let disableButton of disableButtons) {
|
||||||
|
disableButton.disabled = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let disableButton of disableButtons) {
|
||||||
|
disableButton.checked = false;
|
||||||
|
disableButton.disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
avatarUpload.addEventListener('change', function() {
|
||||||
|
let file = this.files[0];
|
||||||
|
avatar.src = URL.createObjectURL(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteButton.addEventListener('click', () => {
|
||||||
|
Requests.users.entity.deleteAvatar(currentUserId)
|
||||||
|
.then(
|
||||||
|
(response) => {
|
||||||
|
avatar.src = "{{ url_for('static', filename='images/user_avatar.png') }}";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector('#delete-user-button').addEventListener('click', (event) => {
|
||||||
|
Requests.users.entity.delete(currentUserId)
|
||||||
|
.then((response) => {window.location.href = '/';});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock scripts %}
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
let publicProfile = document.querySelector('#public-profile');
|
|
||||||
let disableButtons = document.querySelectorAll('[data-action="disable"]');
|
|
||||||
let deleteButton = document.querySelector('#delete-avatar');
|
|
||||||
let avatar = document.querySelector('#avatar');
|
|
||||||
let avatarUpload = document.querySelector('#avatar-upload');
|
|
||||||
|
|
||||||
for (let disableButton of disableButtons) {
|
|
||||||
disableButton.disabled = !publicProfile.checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
publicProfile.addEventListener('change', () => {
|
|
||||||
if (publicProfile.checked) {
|
|
||||||
for (let disableButton of disableButtons) {
|
|
||||||
disableButton.disabled = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let disableButton of disableButtons) {
|
|
||||||
disableButton.checked = false;
|
|
||||||
disableButton.disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
avatarUpload.addEventListener('change', function() {
|
|
||||||
let file = this.files[0];
|
|
||||||
avatar.src = URL.createObjectURL(file);
|
|
||||||
});
|
|
||||||
|
|
||||||
deleteButton.addEventListener('click', () => {
|
|
||||||
Requests.users.entity.deleteAvatar({{ user.hashid|tojson }})
|
|
||||||
.then(
|
|
||||||
(response) => {
|
|
||||||
avatar.src = "{{ url_for('static', filename='images/user_avatar.png') }}";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector('#delete-user-button').addEventListener('click', (event) => {
|
|
||||||
Requests.users.entity.delete(currentUserId)
|
|
||||||
.then((response) => {window.location.href = '/';});
|
|
||||||
});
|
|
@ -12,17 +12,17 @@
|
|||||||
<div class="col s3">
|
<div class="col s3">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
{% if user.avatar %}
|
|
||||||
<img src="{{ url_for('.profile_avatar', user_id=user_id) }}" alt="user-image" class="circle responsive-img">
|
<img src="{{ url_for('.profile_avatar', user_id=user_id) }}" alt="user-image" class="circle responsive-img">
|
||||||
{% else %}
|
|
||||||
<img src="{{ url_for('static', filename='images/user_avatar.png') }}" alt="user-image" class="circle responsive-img">
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col s1"></div>
|
<div class="col s1"></div>
|
||||||
<div class="col s7">
|
<div class="col s7">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<h3 style="float:left">{{ user.username }}<span class="new badge green" id="public-information-badge" data-badge-caption="" style="margin-top:20px;"></span></h3>
|
{% if user.is_public %}
|
||||||
|
<h3 style="float:left">{{ user.username }}<span class="new badge green" id="public-information-badge" data-badge-caption="Your profile is public" style="margin-top:20px;"></span></h3>
|
||||||
|
{% else %}
|
||||||
|
<h3 style="float:left">{{ user.username }}<span class="new badge red" id="public-information-badge" data-badge-caption="Your profile is private" style="margin-top:20px;"></span></h3>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col 12">
|
<div class="col 12">
|
||||||
{% if user.show_last_seen %}
|
{% if user.show_last_seen %}
|
||||||
@ -111,3 +111,12 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endblock page_content %}
|
{% endblock page_content %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
let followedCorpusList = new FollowedCorpusList(document.querySelector('.followed-corpus-list'));
|
||||||
|
followedCorpusList.add({{ followed_corpora|tojson }});
|
||||||
|
let publicCorpusList = new PublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||||
|
publicCorpusList.add({{ own_public_corpora|tojson }});
|
||||||
|
</script>
|
||||||
|
{% endblock scripts %}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
let publicInformationBadge = document.querySelector('#public-information-badge');
|
|
||||||
if ("{{ user.id }}" == "{{ current_user.hashid }}") {
|
|
||||||
if ("{{ user.is_public }}" == "True") {
|
|
||||||
publicInformationBadge.dataset.badgeCaption = 'Your profile is public';
|
|
||||||
publicInformationBadge.classList.add('green');
|
|
||||||
publicInformationBadge.classList.remove('red');
|
|
||||||
} else {
|
|
||||||
publicInformationBadge.dataset.badgeCaption = 'Your profile is private';
|
|
||||||
publicInformationBadge.classList.add('red');
|
|
||||||
publicInformationBadge.classList.remove('green');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
publicInformationBadge.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
let followedCorpusList = new FollowedCorpusList(document.querySelector('.followed-corpus-list'));
|
|
||||||
followedCorpusList.add({{ followed_corpora|tojson }});
|
|
||||||
let publicCorpusList = new PublicCorpusList(document.querySelector('.public-corpus-list'));
|
|
||||||
publicCorpusList.add({{ own_public_corpora|tojson }});
|
|
@ -26,7 +26,7 @@ from .utils import (
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('')
|
@bp.route('')
|
||||||
@register_breadcrumb(bp, '.', '<i class="material-icons left">group</i>Users')
|
@register_breadcrumb(bp, '.', '<i class="material-icons left">group</i>Social Area')
|
||||||
@login_required
|
@login_required
|
||||||
def users():
|
def users():
|
||||||
return redirect(url_for('main.social_area', _anchor='users'))
|
return redirect(url_for('main.social_area', _anchor='users'))
|
||||||
@ -65,7 +65,7 @@ def user(user_id):
|
|||||||
def profile_avatar(user_id):
|
def profile_avatar(user_id):
|
||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
if user.avatar is None:
|
if user.avatar is None:
|
||||||
return redirect(url_for('static', filename='images/default_avatar.png'))
|
return redirect(url_for('static', filename='images/user_avatar.png'))
|
||||||
if not user.is_public and not (user == current_user or current_user.is_administrator()):
|
if not user.is_public and not (user == current_user or current_user.is_administrator()):
|
||||||
abort(403)
|
abort(403)
|
||||||
return send_from_directory(
|
return send_from_directory(
|
||||||
@ -78,7 +78,7 @@ def profile_avatar(user_id):
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:user_id>/edit', methods=['GET', 'POST'])
|
@bp.route('/<hashid:user_id>/edit', methods=['GET', 'POST'])
|
||||||
@register_breadcrumb(bp, '.entity.edit', 'Edit', endpoint_arguments_constructor=user_eac)
|
@register_breadcrumb(bp, '.entity.edit', '<i class="material-icons left">settings</i>Edit', endpoint_arguments_constructor=user_eac)
|
||||||
@login_required
|
@login_required
|
||||||
def edit_profile(user_id):
|
def edit_profile(user_id):
|
||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
|
@ -11,7 +11,7 @@ def user_dynamic_list_constructor():
|
|||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'text': f'<i class="material-icons left">account_circle</i>{user.username}',
|
'text': f'<i class="material-icons left">person</i>{user.username}',
|
||||||
'url': url_for('.user', user_id=user_id)
|
'url': url_for('.user', user_id=user_id)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user