mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-27 08:20:34 +00:00
profile page update for other users
This commit is contained in:
@ -10,7 +10,7 @@ from flask import (
|
||||
from flask_login import current_user, login_required
|
||||
import os
|
||||
from app import db
|
||||
from app.models import Avatar
|
||||
from app.models import Avatar, User
|
||||
from . import bp
|
||||
from .forms import (
|
||||
EditProfileSettingsForm
|
||||
@ -22,14 +22,15 @@ def before_request():
|
||||
pass
|
||||
|
||||
|
||||
@bp.route('')
|
||||
def profile():
|
||||
@bp.route('/<hashid:user_id>')
|
||||
def profile(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
return render_template('profile/profile_page.html.j2',
|
||||
user=current_user)
|
||||
user=user)
|
||||
|
||||
@bp.route('/avatars/<hashid:avatar_id>')
|
||||
def avatar_download(avatar_id):
|
||||
avatar_file = Avatar.query.get_or_404(avatar_id)
|
||||
@bp.route('/<hashid:user_id>/avatars/<hashid:avatar_id>')
|
||||
def avatar_download(user_id, avatar_id):
|
||||
avatar_file = Avatar.query.filter_by(user_id = user_id, id = avatar_id).first_or_404()
|
||||
if not (avatar_file and avatar_file.filename):
|
||||
abort(404)
|
||||
return send_from_directory(
|
||||
@ -40,8 +41,9 @@ def avatar_download(avatar_id):
|
||||
mimetype=avatar_file.mimetype
|
||||
)
|
||||
|
||||
@bp.route('/edit-profile', methods=['GET', 'POST'])
|
||||
def edit_profile():
|
||||
@bp.route('/<hashid:user_id>/edit-profile', methods=['GET', 'POST'])
|
||||
def edit_profile(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
edit_profile_settings_form = EditProfileSettingsForm(
|
||||
current_user,
|
||||
data=current_user.to_json_serializeable(),
|
||||
@ -63,7 +65,8 @@ def edit_profile():
|
||||
db.session.commit()
|
||||
message = Markup(f'Profile settings updated')
|
||||
flash(message, 'success')
|
||||
return redirect(url_for('.profile'))
|
||||
return redirect(url_for('.profile', user_id=user.id))
|
||||
return render_template('profile/edit_profile.html.j2',
|
||||
edit_profile_settings_form=edit_profile_settings_form,
|
||||
user=user,
|
||||
title='Edit Profile')
|
||||
|
Reference in New Issue
Block a user