summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-23 17:21:22 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-27 09:48:35 +0200
commit3d42c2c66c5fe4cfb3fcab6847234b6e27ad4eb1 (patch)
treef97e1af2ba5ad5ccad6ab4441723de55b43520be /ogcp
parentf009a188b1a8bb523fe8bc7706150438d75363a9 (diff)
Adapt Delete room to work with several ogServers
This commit makes Delete room view to use ogServer field from scopesForm to send the command to the correct ogServer.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/forms/action_forms.py1
-rw-r--r--ogcp/views.py7
2 files changed, 6 insertions, 2 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py
index 092b93e..93c8075 100644
--- a/ogcp/forms/action_forms.py
+++ b/ogcp/forms/action_forms.py
@@ -176,6 +176,7 @@ class RoomForm(FlaskForm):
submit = SubmitField(label=_l('Submit'))
class DeleteRoomForm(FlaskForm):
+ server = HiddenField()
room = SelectField(label=_l('Room'),
validators=[InputRequired()])
submit = SubmitField(label=_l('Submit'))
diff --git a/ogcp/views.py b/ogcp/views.py
index 8601522..6b10321 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1328,7 +1328,8 @@ def action_room_delete():
form = DeleteRoomForm(request.form)
if request.method == 'POST':
payload = {"id": form.room.data}
- r = g.server.post('/room/delete', payload)
+ server = get_server_from_ip_port(form.server.data)
+ r = server.post('/room/delete', payload)
if r.status_code != requests.codes.ok:
flash(_('Server replied with error code when deleting the room'),
category='error')
@@ -1340,13 +1341,15 @@ def action_room_delete():
if not params.get('scope-room'):
flash(_('Please, select one room'), category='error')
return redirect(url_for('scopes'))
- r = g.server.get('/scopes')
+ server = get_server_from_ip_port(params['scope-server'])
+ r = server.get('/scopes')
rooms = parse_scopes_from_tree(r.json(), 'room')
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}
+ form.server.data = params['scope-server']
scopes, clients = get_scopes()
return render_template('actions/delete_room.html', form=form,
scopes=scopes)