summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-23 17:05:48 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-27 09:48:35 +0200
commitf009a188b1a8bb523fe8bc7706150438d75363a9 (patch)
tree4119f15068f287c6f7a3cedcc2c395dc731c2229 /ogcp
parentbf4192a5d4172d3a444ef22b212ae058f69e1095 (diff)
Delete room using the scopes tree
With this commit users can select a room from the scopes tree, and then delete it.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index dfb3538..8601522 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1336,11 +1336,17 @@ def action_room_delete():
flash(_('Room deleted successfully'), category='info')
return redirect(url_for("scopes"))
else:
+ params = request.args.to_dict()
+ if not params.get('scope-room'):
+ flash(_('Please, select one room'), category='error')
+ return redirect(url_for('scopes'))
r = g.server.get('/scopes')
rooms = parse_scopes_from_tree(r.json(), 'room')
- rooms = [(room['id'], room['name'] + " (" + room['parent'] + ")")
- for room in rooms]
- form.room.choices = list(rooms)
+ selected_room_id = params['scope-room']
+ selected_room = [(room['id'], room['name'] + " (" + room['parent'] + ")")
+ for room in rooms if room['id'] == int(selected_room_id)]
+ form.room.choices = selected_room
+ form.room.render_kw = {'readonly': True}
scopes, clients = get_scopes()
return render_template('actions/delete_room.html', form=form,
scopes=scopes)