mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-14 01:50:40 +00:00
Hide Community Update code
This commit is contained in:
@ -7,54 +7,54 @@ from app.models import Avatar, User
|
||||
from . import bp
|
||||
|
||||
|
||||
@bp.route('/<hashid:user_id>', methods=['DELETE'])
|
||||
@content_negotiation(produces='application/json')
|
||||
def delete_user(user_id):
|
||||
def _delete_user(app, user_id):
|
||||
with app.app_context():
|
||||
user = User.query.get(user_id)
|
||||
user.delete()
|
||||
db.session.commit()
|
||||
# @bp.route('/<hashid:user_id>', methods=['DELETE'])
|
||||
# @content_negotiation(produces='application/json')
|
||||
# def delete_user(user_id):
|
||||
# def _delete_user(app, user_id):
|
||||
# with app.app_context():
|
||||
# user = User.query.get(user_id)
|
||||
# user.delete()
|
||||
# db.session.commit()
|
||||
|
||||
user = User.query.get_or_404(user_id)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
abort(403)
|
||||
thread = Thread(
|
||||
target=_delete_user,
|
||||
args=(current_app._get_current_object(), user.id)
|
||||
)
|
||||
if user == current_user:
|
||||
logout_user()
|
||||
thread.start()
|
||||
response_data = {
|
||||
'message': f'User "{user.username}" marked for deletion'
|
||||
}
|
||||
return response_data, 202
|
||||
# user = User.query.get_or_404(user_id)
|
||||
# if not (user == current_user or current_user.is_administrator()):
|
||||
# abort(403)
|
||||
# thread = Thread(
|
||||
# target=_delete_user,
|
||||
# args=(current_app._get_current_object(), user.id)
|
||||
# )
|
||||
# if user == current_user:
|
||||
# logout_user()
|
||||
# thread.start()
|
||||
# response_data = {
|
||||
# 'message': f'User "{user.username}" marked for deletion'
|
||||
# }
|
||||
# return response_data, 202
|
||||
|
||||
|
||||
@bp.route('/<hashid:user_id>/avatar', methods=['DELETE'])
|
||||
@content_negotiation(produces='application/json')
|
||||
def delete_user_avatar(user_id):
|
||||
def _delete_avatar(app, avatar_id):
|
||||
with app.app_context():
|
||||
avatar = Avatar.query.get(avatar_id)
|
||||
avatar.delete()
|
||||
db.session.commit()
|
||||
# @bp.route('/<hashid:user_id>/avatar', methods=['DELETE'])
|
||||
# @content_negotiation(produces='application/json')
|
||||
# def delete_user_avatar(user_id):
|
||||
# def _delete_avatar(app, avatar_id):
|
||||
# with app.app_context():
|
||||
# avatar = Avatar.query.get(avatar_id)
|
||||
# avatar.delete()
|
||||
# db.session.commit()
|
||||
|
||||
user = User.query.get_or_404(user_id)
|
||||
if user.avatar is None:
|
||||
abort(404)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
abort(403)
|
||||
thread = Thread(
|
||||
target=_delete_avatar,
|
||||
args=(current_app._get_current_object(), user.avatar.id)
|
||||
)
|
||||
thread.start()
|
||||
response_data = {
|
||||
'message': f'Avatar marked for deletion'
|
||||
}
|
||||
return response_data, 202
|
||||
# user = User.query.get_or_404(user_id)
|
||||
# if user.avatar is None:
|
||||
# abort(404)
|
||||
# if not (user == current_user or current_user.is_administrator()):
|
||||
# abort(403)
|
||||
# thread = Thread(
|
||||
# target=_delete_avatar,
|
||||
# args=(current_app._get_current_object(), user.avatar.id)
|
||||
# )
|
||||
# thread.start()
|
||||
# response_data = {
|
||||
# 'message': f'Avatar marked for deletion'
|
||||
# }
|
||||
# return response_data, 202
|
||||
|
||||
@bp.route('/accept-terms-of-use', methods=['POST'])
|
||||
@content_negotiation(produces='application/json')
|
||||
|
@ -13,36 +13,36 @@ from . import bp
|
||||
from .utils import user_dynamic_list_constructor as user_dlc
|
||||
|
||||
|
||||
@bp.route('')
|
||||
@register_breadcrumb(bp, '.', '<i class="material-icons left">group</i>Users')
|
||||
def users():
|
||||
return redirect(url_for('main.social_area', _anchor='users'))
|
||||
# @bp.route('')
|
||||
# @register_breadcrumb(bp, '.', '<i class="material-icons left">group</i>Users')
|
||||
# def users():
|
||||
# return redirect(url_for('main.social_area', _anchor='users'))
|
||||
|
||||
|
||||
@bp.route('/<hashid:user_id>')
|
||||
@register_breadcrumb(bp, '.entity', '', dynamic_list_constructor=user_dlc)
|
||||
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>')
|
||||
# @register_breadcrumb(bp, '.entity', '', dynamic_list_constructor=user_dlc)
|
||||
# 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(
|
||||
os.path.dirname(user.avatar.path),
|
||||
os.path.basename(user.avatar.path),
|
||||
as_attachment=True,
|
||||
attachment_filename=user.avatar.filename,
|
||||
mimetype=user.avatar.mimetype
|
||||
)
|
||||
# @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(
|
||||
# os.path.dirname(user.avatar.path),
|
||||
# os.path.basename(user.avatar.path),
|
||||
# as_attachment=True,
|
||||
# attachment_filename=user.avatar.filename,
|
||||
# mimetype=user.avatar.mimetype
|
||||
# )
|
||||
|
Reference in New Issue
Block a user