mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
admin user editing - roles
This commit is contained in:
parent
472f7348d2
commit
889120287d
1 changed files with 3 additions and 5 deletions
|
@ -565,9 +565,7 @@ def admin_user_edit(user_id):
|
||||||
user.ap_manually_approves_followers = form.manually_approves_followers.data
|
user.ap_manually_approves_followers = form.manually_approves_followers.data
|
||||||
|
|
||||||
# Update user roles. The UI only lets the user choose 1 role but the DB structure allows for multiple roles per user.
|
# Update user roles. The UI only lets the user choose 1 role but the DB structure allows for multiple roles per user.
|
||||||
for role in user.roles:
|
db.session.execute(text('DELETE FROM user_role WHERE user_id = :user_id'), {'user_id': user.id})
|
||||||
if role.id != form.role.data:
|
|
||||||
user.roles.remove(role)
|
|
||||||
user.roles.append(Role.query.get(form.role.data))
|
user.roles.append(Role.query.get(form.role.data))
|
||||||
if form.role.data == 4:
|
if form.role.data == 4:
|
||||||
flash(_("Permissions are cached for 50 seconds so new admin roles won't take effect immediately."))
|
flash(_("Permissions are cached for 50 seconds so new admin roles won't take effect immediately."))
|
||||||
|
@ -575,7 +573,7 @@ def admin_user_edit(user_id):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
user.flush_cache()
|
user.flush_cache()
|
||||||
flash(_('Saved'))
|
flash(_('Saved'))
|
||||||
return redirect(url_for('admin.admin_users'))
|
return redirect(url_for('admin.admin_users', local_remote='local' if user.is_local() else 'remote'))
|
||||||
else:
|
else:
|
||||||
if not user.is_local():
|
if not user.is_local():
|
||||||
flash(_('This is a remote user - most settings here will be regularly overwritten with data from the original server.'), 'warning')
|
flash(_('This is a remote user - most settings here will be regularly overwritten with data from the original server.'), 'warning')
|
||||||
|
@ -592,7 +590,7 @@ def admin_user_edit(user_id):
|
||||||
form.searchable.data = user.searchable
|
form.searchable.data = user.searchable
|
||||||
form.indexable.data = user.indexable
|
form.indexable.data = user.indexable
|
||||||
form.manually_approves_followers.data = user.ap_manually_approves_followers
|
form.manually_approves_followers.data = user.ap_manually_approves_followers
|
||||||
if user.roles:
|
if user.roles and user.roles.count() > 0:
|
||||||
form.role.data = user.roles[0].id
|
form.role.data = user.roles[0].id
|
||||||
|
|
||||||
return render_template('admin/edit_user.html', title=_('Edit user'), form=form, user=user,
|
return render_template('admin/edit_user.html', title=_('Edit user'), form=form, user=user,
|
||||||
|
|
Loading…
Reference in a new issue