mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-16 11:00:41 +00:00
make is_administrator a property, add back db events
This commit is contained in:
@ -12,7 +12,7 @@ def get_user(user_hashid):
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
return {'status': 404, 'statusText': 'Not found'}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'status': 403, 'statusText': 'Forbidden'}
|
||||
return {
|
||||
'body': user.to_json_serializeable(backrefs=True, relationships=True),
|
||||
@ -28,7 +28,7 @@ def subscribe_user(user_hashid):
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
return {'status': 404, 'statusText': 'Not found'}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'status': 403, 'statusText': 'Forbidden'}
|
||||
join_room(f'/users/{user.hashid}')
|
||||
return {'status': 200, 'statusText': 'OK'}
|
||||
@ -41,7 +41,7 @@ def unsubscribe_user(user_hashid):
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
return {'status': 404, 'statusText': 'Not found'}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'status': 403, 'statusText': 'Forbidden'}
|
||||
leave_room(f'/users/{user.hashid}')
|
||||
return {'status': 200, 'statusText': 'OK'}
|
||||
|
@ -17,7 +17,7 @@ def delete_user(user_id):
|
||||
db.session.commit()
|
||||
|
||||
user = User.query.get_or_404(user_id)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
abort(403)
|
||||
thread = Thread(
|
||||
target=_delete_user,
|
||||
@ -44,7 +44,7 @@ def delete_user_avatar(user_id):
|
||||
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()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
abort(403)
|
||||
thread = Thread(
|
||||
target=_delete_avatar,
|
||||
|
@ -33,7 +33,7 @@ def get_user(user_hashid):
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
return {'options': {'status': 404, 'statusText': 'Not found'}}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'options': {'status': 403, 'statusText': 'Forbidden'}}
|
||||
return {
|
||||
'body': user.to_json_serializable(),
|
||||
@ -52,7 +52,7 @@ def subscribe_user(user_hashid):
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
return {'options': {'status': 404, 'statusText': 'Not found'}}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'options': {'status': 403, 'statusText': 'Forbidden'}}
|
||||
join_room(f'/users/{user.hashid}')
|
||||
return {'options': {'status': 200, 'statusText': 'OK'}}
|
||||
@ -89,7 +89,7 @@ def get_user(user_hashid):
|
||||
user = User.query.filter_by(id=user_id, is_public=True).first()
|
||||
if user is None:
|
||||
return {'options': {'status': 404, 'statusText': 'Not found'}}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'options': {'status': 403, 'statusText': 'Forbidden'}}
|
||||
return {
|
||||
'body': user.to_json_serializable(filter_by_privacy_settings=True),
|
||||
@ -108,7 +108,7 @@ def subscribe_user(user_hashid):
|
||||
user = User.query.filter_by(id=user_id, is_public=True).first()
|
||||
if user is None:
|
||||
return {'options': {'status': 404, 'statusText': 'Not found'}}
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'options': {'status': 403, 'statusText': 'Forbidden'}}
|
||||
join_room(f'/public_users/{user.hashid}')
|
||||
return {'options': {'status': 200, 'statusText': 'OK'}}
|
||||
|
@ -22,7 +22,7 @@ def users():
|
||||
@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()):
|
||||
if not (user.is_public or user == current_user or current_user.is_administrator):
|
||||
abort(403)
|
||||
return render_template(
|
||||
'users/user.html.j2',
|
||||
@ -34,7 +34,7 @@ def user(user_id):
|
||||
@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()):
|
||||
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'))
|
||||
|
@ -10,7 +10,7 @@ from . import bp
|
||||
@content_negotiation(consumes='application/json', produces='application/json')
|
||||
def update_user_profile_privacy_setting_is_public(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
abort(403)
|
||||
enabled = request.json
|
||||
if not isinstance(enabled, bool):
|
||||
@ -32,7 +32,7 @@ def update_user_profile_privacy_settings(user_id, profile_privacy_setting_name):
|
||||
profile_privacy_setting = ProfilePrivacySettings[profile_privacy_setting_name]
|
||||
except KeyError:
|
||||
abort(404)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
abort(403)
|
||||
enabled = request.json
|
||||
if not isinstance(enabled, bool):
|
||||
|
@ -18,7 +18,7 @@ from .forms import (
|
||||
@register_breadcrumb(bp, '.entity.settings', '<i class="material-icons left">settings</i>Settings', endpoint_arguments_constructor=user_eac)
|
||||
def settings(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
if not (user == current_user or current_user.is_administrator()):
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
abort(403)
|
||||
|
||||
redirect_location_on_post = g.pop(
|
||||
|
Reference in New Issue
Block a user