diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-06-17 17:03:30 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-06-17 17:10:05 +0200 |
commit | a7423d29436f20b440f81f7bf3c18d80cf1e6114 (patch) | |
tree | a58225c0a787e33dcfa5434158294c7561729d53 /ogcp/views.py | |
parent | d135a4806dc12d24240fd50fcbcb5ab6f5c89db1 (diff) |
ogcp: add room details view to scopes management
Add a readonly view for the room data.
Mark all the form fields as readonly and set the hidden attribute
to the submit field.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 9e1a028..d022d04 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -2410,6 +2410,38 @@ def action_room_update(): return render_template('actions/room_update.html', form=form, scopes=scopes) +@app.route('/action/room/info', methods=['GET']) +@login_required +def action_room_info(): + form = RoomForm(request.form) + params = request.args.to_dict() + room_id = params.get('scope-room') + if not room_id: + flash(_('Please, select a room to update'), category='error') + return redirect(url_for('scopes')) + server = get_server_from_ip_port(params['scope-server']) + + del form.center + + payload = {"id": int(room_id)} + r = server.get('/room/info', payload) + if not r: + return ogserver_down('scopes') + if r.status_code != requests.codes.ok: + return ogserver_error('scopes') + form.name.data = r.json()['name'] + form.name.render_kw = {'readonly': True} + form.gateway.data = r.json()['gateway'] + form.gateway.render_kw = {'readonly': True} + form.netmask.data = r.json()['netmask'] + form.netmask.render_kw = {'readonly': True} + + form.submit.render_kw = {'readonly': True, 'hidden': True} + + scopes, clients = get_scopes() + return render_template('actions/room_details.html', form=form, + scopes=scopes) + @app.route('/action/room/delete', methods=['GET', 'POST']) @login_required def action_room_delete(): |