summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-22 16:54:45 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-27 09:48:35 +0200
commitf16b1a0347bb587cd4116faf246d4a5176af3cfd (patch)
treef67e60e638c9acee2de64b2c46d8df49b6eadc79
parent028f810a47b2c818a455e25e1319fe88e3cde8df (diff)
Import clients to a room using the scopes tree
With this commit users can select a room from the scopes tree, and then import clients to that room.
-rw-r--r--ogcp/views.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index a60a8d6..560ff5c 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -887,12 +887,20 @@ def action_client_add():
@app.route('/action/clients/import', methods=['GET'])
@login_required
def action_clients_import_get():
+ params = request.args.to_dict()
+ if not params.get('scope-room'):
+ flash(_('Please, select one room'), category='error')
+ return redirect(url_for('scopes'))
+
form = ImportClientsForm()
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/import_clients.html', form=form,
scopes=scopes)