mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Use a better redirect mechanic in the proxied settings route
This commit is contained in:
		@@ -8,7 +8,4 @@ from . import bp
 | 
			
		||||
@bp.route('/settings', methods=['GET', 'POST'])
 | 
			
		||||
@register_breadcrumb(bp, '.', '<i class="material-icons left">settings</i>Settings')
 | 
			
		||||
def settings():
 | 
			
		||||
    return settings_route(
 | 
			
		||||
        current_user.id,
 | 
			
		||||
        redirect_location_on_post=url_for('.settings')
 | 
			
		||||
    )
 | 
			
		||||
    return settings_route(current_user.id)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
{% extends "settings/settings.html.j2" %}
 | 
			
		||||
 | 
			
		||||
{% block admin_settings %}
 | 
			
		||||
<div class="col s12"></div>
 | 
			
		||||
 | 
			
		||||
<div class="col s12 l4">
 | 
			
		||||
  <h4>Administrator Settings</h4>
 | 
			
		||||
  <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
 | 
			
		||||
 
 | 
			
		||||
@@ -102,6 +102,8 @@
 | 
			
		||||
      </ul>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="col s12"></div>
 | 
			
		||||
 | 
			
		||||
    <div class="col s12 l4">
 | 
			
		||||
      <h4>General Settings</h4>
 | 
			
		||||
      <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
from flask import abort, flash, redirect, render_template, url_for
 | 
			
		||||
from flask import abort, flash, g, redirect, render_template, url_for
 | 
			
		||||
from flask_breadcrumbs import register_breadcrumb
 | 
			
		||||
from flask_login import current_user, login_required
 | 
			
		||||
from app import db
 | 
			
		||||
@@ -17,12 +17,16 @@ from .forms import (
 | 
			
		||||
@bp.route('/<hashid:user_id>/settings', methods=['GET', 'POST'])
 | 
			
		||||
@register_breadcrumb(bp, '.entity.settings', '<i class="material-icons left">settings</i>Settings', endpoint_arguments_constructor=user_eac)
 | 
			
		||||
@login_required
 | 
			
		||||
def settings(user_id, redirect_location_on_post=None):
 | 
			
		||||
def settings(user_id):
 | 
			
		||||
    user = User.query.get_or_404(user_id)
 | 
			
		||||
    if not (user == current_user or current_user.is_administrator()):
 | 
			
		||||
        abort(403)
 | 
			
		||||
    if redirect_location_on_post is None:
 | 
			
		||||
        redirect_location_on_post = url_for('.settings', user_id=user_id)
 | 
			
		||||
 | 
			
		||||
    redirect_location_on_post = g.pop(
 | 
			
		||||
        'redirect_location_on_post',
 | 
			
		||||
        url_for('.settings', user_id=user_id)
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    update_account_information_form = UpdateAccountInformationForm(user)
 | 
			
		||||
    update_profile_information_form = UpdateProfileInformationForm(user)
 | 
			
		||||
    update_avatar_form = UpdateAvatarForm()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user