mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54: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_breadcrumbs import register_breadcrumb
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
import os
|
|
||||||
from app import db
|
from app import db
|
||||||
from app.models import Avatar, Corpus, ProfilePrivacySettings, User
|
from app.models import Avatar, ProfilePrivacySettings
|
||||||
from . import bp
|
from . import bp
|
||||||
from .forms import (
|
from .forms import (
|
||||||
ChangePasswordForm,
|
ChangePasswordForm,
|
||||||
@ -17,16 +16,12 @@ from .forms import (
|
|||||||
EditProfileSettingsForm,
|
EditProfileSettingsForm,
|
||||||
EditPublicProfileInformationForm
|
EditPublicProfileInformationForm
|
||||||
)
|
)
|
||||||
from .utils import user_endpoint_arguments_constructor as user_eac
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:user_id>/edit', methods=['GET', 'POST'])
|
@bp.route('', methods=['GET', 'POST'])
|
||||||
@register_breadcrumb(bp, 'breadcrumbs.settings', '<i class="material-icons left">settings</i>Settings', endpoint_arguments_constructor=user_eac)
|
@register_breadcrumb(bp, '.', '<i class="material-icons left">settings</i>Settings')
|
||||||
@login_required
|
@login_required
|
||||||
def edit_profile(user_id):
|
def settings():
|
||||||
user = User.query.get_or_404(user_id)
|
|
||||||
if not (user == current_user or current_user.is_administrator()):
|
|
||||||
abort(403)
|
|
||||||
# region forms
|
# region forms
|
||||||
edit_profile_settings_form = EditProfileSettingsForm(
|
edit_profile_settings_form = EditProfileSettingsForm(
|
||||||
current_user,
|
current_user,
|
||||||
@ -52,7 +47,7 @@ def edit_profile(user_id):
|
|||||||
current_user.username = edit_profile_settings_form.username.data
|
current_user.username = edit_profile_settings_form.username.data
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Profile settings updated')
|
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
|
# endregion handle edit profile settings forms
|
||||||
# region handle edit public profile information form
|
# region handle edit public profile information form
|
||||||
if edit_public_profile_information_form.submit.data and edit_public_profile_information_form.validate():
|
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.website = edit_public_profile_information_form.website.data
|
||||||
current_user.full_name = edit_public_profile_information_form.full_name.data
|
current_user.full_name = edit_public_profile_information_form.full_name.data
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Profile settings updated')
|
flash('Your changes have been saved')
|
||||||
return redirect(url_for('users.user', user_id=user.id))
|
return redirect(url_for('.settings'))
|
||||||
# endregion handle edit public profile information form
|
# endregion handle edit public profile information form
|
||||||
# region handle change_password_form POST
|
# region handle change_password_form POST
|
||||||
if change_password_form.submit.data and change_password_form.validate():
|
if change_password_form.submit.data and change_password_form.validate():
|
||||||
current_user.password = change_password_form.new_password.data
|
current_user.password = change_password_form.new_password.data
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your changes have been saved')
|
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
|
# endregion handle change_password_form POST
|
||||||
# region handle edit_notification_settings_form POST
|
# region handle edit_notification_settings_form POST
|
||||||
if edit_notification_settings_form.submit and edit_notification_settings_form.validate():
|
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
|
current_user.setting_job_status_mail_notification_level = edit_notification_settings_form.job_status_mail_notification_level.data
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Your changes have been saved')
|
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
|
# endregion handle edit_notification_settings_form POST
|
||||||
return render_template(
|
return render_template(
|
||||||
'settings/edit_profile.html.j2',
|
'settings/settings.html.j2',
|
||||||
edit_profile_settings_form=edit_profile_settings_form,
|
edit_profile_settings_form=edit_profile_settings_form,
|
||||||
edit_public_profile_information_form=edit_public_profile_information_form,
|
edit_public_profile_information_form=edit_public_profile_information_form,
|
||||||
change_password_form=change_password_form,
|
change_password_form=change_password_form,
|
||||||
edit_notification_settings_form=edit_notification_settings_form,
|
edit_notification_settings_form=edit_notification_settings_form,
|
||||||
user=user,
|
|
||||||
title='Settings'
|
title='Settings'
|
||||||
)
|
)
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<ul class="dropdown-content" id="nav-more-dropdown">
|
<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> #}
|
{# <li><a href="{{ url_for('main.user_manual') }}"><i class="material-icons left">help</i>Manual</a></li> #}
|
||||||
{% if current_user.is_authenticated %}
|
{% 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 class="divider" tabindex="-1"></li>
|
||||||
<li><a href="{{ url_for('auth.logout') }}">Log out</a></li>
|
<li><a href="{{ url_for('auth.logout') }}">Log out</a></li>
|
||||||
{% else %}
|
{% 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><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"><div class="divider"></div></li>
|
||||||
<li class="hide-on-large-only"><a class="subheader">Account</a></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>
|
<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') %}
|
{% if current_user.can('ADMINISTRATE') or current_user.can('USE_API') %}
|
||||||
<li><div class="divider"></div></li>
|
<li><div class="divider"></div></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<div class="switch">
|
<div class="switch">
|
||||||
<label>
|
<label>
|
||||||
private
|
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>
|
<span class="lever"></span>
|
||||||
public
|
public
|
||||||
</label>
|
</label>
|
||||||
@ -114,7 +114,7 @@
|
|||||||
<p></p>
|
<p></p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12 m2">
|
<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>
|
||||||
<div class="col s12 m6">
|
<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') }}
|
{{ 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 %}
|
{% endblock page_content %}
|
||||||
|
|
||||||
{% block modals %}
|
{% block modals %}
|
||||||
|
{{ super() }}
|
||||||
<div class="modal" id="delete-avatar-modal">
|
<div class="modal" id="delete-avatar-modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4>Confirm Avatar deletion</h4>
|
<h4>Confirm Avatar deletion</h4>
|
@ -2,5 +2,5 @@ from flask import Blueprint
|
|||||||
|
|
||||||
|
|
||||||
bp = Blueprint('users', __name__)
|
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_breadcrumbs import register_breadcrumb
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
import os
|
import os
|
||||||
from app import db
|
|
||||||
from app.models import Corpus, User
|
from app.models import Corpus, User
|
||||||
from . import bp
|
from . import bp
|
||||||
from .utils import user_dynamic_list_constructor as user_dlc
|
from .utils import user_dynamic_list_constructor as user_dlc
|
||||||
|
Loading…
Reference in New Issue
Block a user