From 713516c6ae8c880ef1e876855921ce2135e4b8c6 Mon Sep 17 00:00:00 2001 From: Alan Roberts Date: Mon, 2 Sep 2024 17:50:20 -0400 Subject: [PATCH] removing the admin bits and just making it a user export --- app/templates/user/show_profile.html | 7 ---- app/user/routes.py | 49 ++-------------------------- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/app/templates/user/show_profile.html b/app/templates/user/show_profile.html index 46318018..14ca3598 100644 --- a/app/templates/user/show_profile.html +++ b/app/templates/user/show_profile.html @@ -220,13 +220,6 @@ {% endif %} -
- {% if user_access('manage users', current_user.id) %} - - {% endif %} -
{% endif %} diff --git a/app/user/routes.py b/app/user/routes.py index 192910d4..1c8393e1 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -213,9 +213,7 @@ def remove_cover(): return '
' + _('Banner removed!') + '
' # export settings function. used in the /user/settings for a user to export their own settings -# used in the admin moderation /u//export_settings call to let admins -# export the user settings plus admin relevant settings -def export_user_settings(user, admin_request=False): +def export_user_settings(user): # make the empty dict user_dict = {} @@ -272,19 +270,6 @@ def export_user_settings(user, admin_request=False): user_subscribed_communities.append(c.ap_profile_id) user_dict['followed_communities'] = user_subscribed_communities - # if this is an admin level export request - if admin_request: - user_dict['public_key'] = user.public_key - user_dict['private_key'] = user.private_key - - user_roles = [] - for r in user.roles.all(): - user_roles.append(r.name) - user_dict['roles'] = user_roles - - user_dict['reputation'] = user.reputation - user_dict['attitude'] = user.attitude - # setup the BytesIO buffer buffer = BytesIO() buffer.write(str(python_json.dumps(user_dict)).encode('utf-8')) @@ -313,7 +298,7 @@ def change_settings(): # seperate if to handle just the 'Export' button being clicked if form.export_settings.data and form.validate(): # get the user settings for this user - buffer = export_user_settings(user, admin_request=False) + buffer = export_user_settings(user) # confirmation displayed to user when the page loads up again flash(_l('Export Complete.')) @@ -604,36 +589,6 @@ def delete_profile(actor): goto = request.args.get('redirect') if 'redirect' in request.args else f'/u/{actor}' return redirect(goto) -@bp.route('/u//export_settings', methods=['GET']) -@login_required -def export_settings(actor): - if user_access('manage users', current_user.id): - actor = actor.strip() - user:User = User.query.filter_by(user_name=actor, deleted=False).first() - if user is None: - user = User.query.filter_by(ap_id=actor, deleted=False).first() - if user is None: - abort(404) - # get the user settings for this user - buffer = export_user_settings(user, admin_request=True) - - # send the file to the user as a download - # the as_attachment=True results in flask - # redirecting to the current page, so no - # url_for needed here - return send_file( - buffer, - download_name=f'{user.user_name}_piefed_settings.json', - as_attachment=True, - mimetype='application/json' - ) - - else: - abort(401) - - goto = request.args.get('redirect') if 'redirect' in request.args else f'/u/{actor}' - return redirect(goto) - @bp.route('/instance//unblock', methods=['GET']) @login_required def instance_unblock(instance_id):