mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-27 03:44:19 +00:00
485a0155c6
- breadcrumbs (!flask-breadcrumbs) - manual modal button - api blueprint (!flask-marshmallow/!marshmallow-sqlalchemy)
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
from flask import (
|
|
abort,
|
|
redirect,
|
|
render_template,
|
|
send_from_directory,
|
|
url_for
|
|
)
|
|
from flask_login import current_user
|
|
from app.models import User
|
|
from . import bp
|
|
|
|
|
|
@bp.route('')
|
|
def users():
|
|
return redirect(url_for('main.social_area', _anchor='users'))
|
|
|
|
|
|
@bp.route('/<hashid:user_id>')
|
|
def user(user_id):
|
|
user = User.query.get_or_404(user_id)
|
|
if not (user.is_public or user == current_user or current_user.is_administrator):
|
|
abort(403)
|
|
return render_template(
|
|
'users/user.html.j2',
|
|
title=user.username,
|
|
user=user
|
|
)
|
|
|
|
|
|
@bp.route('/<hashid:user_id>/avatar')
|
|
def user_avatar(user_id):
|
|
user = User.query.get_or_404(user_id)
|
|
if not (user.is_public or user == current_user or current_user.is_administrator):
|
|
abort(403)
|
|
if user.avatar is None:
|
|
return redirect(url_for('static', filename='images/user_avatar.png'))
|
|
return send_from_directory(
|
|
user.avatar.path.parent,
|
|
user.avatar.path.name,
|
|
as_attachment=True,
|
|
download_name=user.avatar.filename,
|
|
mimetype=user.avatar.mimetype
|
|
)
|