mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Fix errors from settings move
This commit is contained in:
parent
3d4403e997
commit
575eeae94a
@ -7,9 +7,8 @@ from flask import (
|
||||
)
|
||||
from flask_breadcrumbs import register_breadcrumb
|
||||
from flask_login import current_user, login_required
|
||||
import os
|
||||
from app import db
|
||||
from app.models import Avatar, Corpus, ProfilePrivacySettings, User
|
||||
from app.models import Avatar, ProfilePrivacySettings
|
||||
from . import bp
|
||||
from .forms import (
|
||||
ChangePasswordForm,
|
||||
@ -17,16 +16,12 @@ from .forms import (
|
||||
EditProfileSettingsForm,
|
||||
EditPublicProfileInformationForm
|
||||
)
|
||||
from .utils import user_endpoint_arguments_constructor as user_eac
|
||||
|
||||
|
||||
@bp.route('/<hashid:user_id>/edit', methods=['GET', 'POST'])
|
||||
@register_breadcrumb(bp, 'breadcrumbs.settings', '<i class="material-icons left">settings</i>Settings', endpoint_arguments_constructor=user_eac)
|
||||
@bp.route('', methods=['GET', 'POST'])
|
||||
@register_breadcrumb(bp, '.', '<i class="material-icons left">settings</i>Settings')
|
||||
@login_required
|
||||
def edit_profile(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
abort(403)
|
||||
def settings():
|
||||
# region forms
|
||||
edit_profile_settings_form = EditProfileSettingsForm(
|
||||
current_user,
|
||||
@ -52,7 +47,7 @@ def edit_profile(user_id):
|
||||
current_user.username = edit_profile_settings_form.username.data
|
||||
db.session.commit()
|
||||
flash('Profile settings updated')
|
||||
return redirect(url_for('users.user', user_id=user.id))
|
||||
return redirect(url_for('.settings'))
|
||||
# endregion handle edit profile settings forms
|
||||
# region handle edit public profile information form
|
||||
if edit_public_profile_information_form.submit.data and edit_public_profile_information_form.validate():
|
||||
@ -80,29 +75,28 @@ def edit_profile(user_id):
|
||||
current_user.website = edit_public_profile_information_form.website.data
|
||||
current_user.full_name = edit_public_profile_information_form.full_name.data
|
||||
db.session.commit()
|
||||
flash('Profile settings updated')
|
||||
return redirect(url_for('users.user', user_id=user.id))
|
||||
flash('Your changes have been saved')
|
||||
return redirect(url_for('.settings'))
|
||||
# endregion handle edit public profile information form
|
||||
# region handle change_password_form POST
|
||||
if change_password_form.submit.data and change_password_form.validate():
|
||||
current_user.password = change_password_form.new_password.data
|
||||
db.session.commit()
|
||||
flash('Your changes have been saved')
|
||||
return redirect(url_for('.edit_profile', user_id=user.id))
|
||||
return redirect(url_for('.settings'))
|
||||
# endregion handle change_password_form POST
|
||||
# region handle edit_notification_settings_form POST
|
||||
if edit_notification_settings_form.submit and edit_notification_settings_form.validate():
|
||||
current_user.setting_job_status_mail_notification_level = edit_notification_settings_form.job_status_mail_notification_level.data
|
||||
db.session.commit()
|
||||
flash('Your changes have been saved')
|
||||
return redirect(url_for('.edit_profile', user_id=user.id))
|
||||
return redirect(url_for('.settings'))
|
||||
# endregion handle edit_notification_settings_form POST
|
||||
return render_template(
|
||||
'settings/edit_profile.html.j2',
|
||||
'settings/settings.html.j2',
|
||||
edit_profile_settings_form=edit_profile_settings_form,
|
||||
edit_public_profile_information_form=edit_public_profile_information_form,
|
||||
change_password_form=change_password_form,
|
||||
edit_notification_settings_form=edit_notification_settings_form,
|
||||
user=user,
|
||||
title='Settings'
|
||||
)
|
||||
|
@ -33,7 +33,7 @@
|
||||
<ul class="dropdown-content" id="nav-more-dropdown">
|
||||
{# <li><a href="{{ url_for('main.user_manual') }}"><i class="material-icons left">help</i>Manual</a></li> #}
|
||||
{% if current_user.is_authenticated %}
|
||||
<li><a href="{{ url_for('settings.edit_profile', user_id=current_user.id) }}"><i class="material-icons left">settings</i>User settings</a></li>
|
||||
<li><a href="{{ url_for('settings.settings') }}"><i class="material-icons left">settings</i>Settings</a></li>
|
||||
<li class="divider" tabindex="-1"></li>
|
||||
<li><a href="{{ url_for('auth.logout') }}">Log out</a></li>
|
||||
{% else %}
|
||||
|
@ -46,7 +46,7 @@
|
||||
<li><a href="{{ url_for('main.social_area', _anchor='public-corproa') }}"><i class="nopaque-icons">I</i>Public Corpora</a></li>
|
||||
<li class="hide-on-large-only"><div class="divider"></div></li>
|
||||
<li class="hide-on-large-only"><a class="subheader">Account</a></li>
|
||||
<li class="hide-on-large-only"><a href="{{ url_for('users.edit_profile', user_id=current_user.id) }}"><i class="material-icons left">settings</i>User Settings</a></li>
|
||||
<li class="hide-on-large-only"><a href="{{ url_for('settings.settings') }}"><i class="material-icons left">settings</i>Settings</a></li>
|
||||
<li class="hide-on-large-only"><a href="{{ url_for('auth.logout') }}">Log out</a></li>
|
||||
{% if current_user.can('ADMINISTRATE') or current_user.can('USE_API') %}
|
||||
<li><div class="divider"></div></li>
|
||||
|
@ -69,7 +69,7 @@
|
||||
<div class="switch">
|
||||
<label>
|
||||
private
|
||||
<input {% if user.is_public %}checked{% endif %} id="profile-is-public-switch" type="checkbox">
|
||||
<input {% if current_user.is_public %}checked{% endif %} id="profile-is-public-switch" type="checkbox">
|
||||
<span class="lever"></span>
|
||||
public
|
||||
</label>
|
||||
@ -114,7 +114,7 @@
|
||||
<p></p>
|
||||
<div class="row">
|
||||
<div class="col s12 m2">
|
||||
<img src="{{ url_for('users.profile_avatar', user_id=user.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
|
||||
<img src="{{ url_for('users.profile_avatar', user_id=current_user.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
|
||||
</div>
|
||||
<div class="col s12 m6">
|
||||
{{ wtf.render_field(edit_public_profile_information_form.avatar, accept='image/jpeg, image/png, image/gif', placeholder='Choose an image file', id='avatar-upload') }}
|
||||
@ -200,6 +200,7 @@
|
||||
{% endblock page_content %}
|
||||
|
||||
{% block modals %}
|
||||
{{ super() }}
|
||||
<div class="modal" id="delete-avatar-modal">
|
||||
<div class="modal-content">
|
||||
<h4>Confirm Avatar deletion</h4>
|
@ -2,5 +2,5 @@ from flask import Blueprint
|
||||
|
||||
|
||||
bp = Blueprint('users', __name__)
|
||||
from . import events, routes, json_routes
|
||||
from . import events, routes
|
||||
|
||||
|
@ -8,7 +8,6 @@ from flask import (
|
||||
from flask_breadcrumbs import register_breadcrumb
|
||||
from flask_login import current_user, login_required
|
||||
import os
|
||||
from app import db
|
||||
from app.models import Corpus, User
|
||||
from . import bp
|
||||
from .utils import user_dynamic_list_constructor as user_dlc
|
||||
|
Loading…
Reference in New Issue
Block a user