From 0e4203cbc09a14f9ffd8b94bc30cad7a92efabf4 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Tue, 23 Aug 2022 17:05:48 +0200 Subject: Delete room using the scopes tree With this commit users can select a room from the scopes tree, and then delete it. --- ogcp/views.py | 12 +++++++++--- 1 file 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) -- cgit v1.2.3-18-g5258