summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-23 17:03:57 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-31 15:57:52 +0200
commitc6ef5886f25f89c42849dd567e9f54fabb721e04 (patch)
tree2ae0e6bd96dcfe5fe315f07f3f74f1da444f8d6d
parentea0ce480c70a5eff54bfcb4f33eb339e6b831234 (diff)
Adapt Add room to work with several ogServers
This commit makes Add room view to use ogServer field from scopesForm to send the command to the correct ogServer.
-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 40efd49..092b93e 100644
--- a/ogcp/forms/action_forms.py
+++ b/ogcp/forms/action_forms.py
@@ -166,6 +166,7 @@ class DeleteCenterForm(FlaskForm):
submit = SubmitField(label=_l('Submit'))
class RoomForm(FlaskForm):
+ server = HiddenField()
center = SelectField(label=_l('Center'),
validators=[InputRequired()])
name = StringField(label=_l('Room name'),
diff --git a/ogcp/views.py b/ogcp/views.py
index 72a86bb..dfb3538 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1294,10 +1294,11 @@ def action_center_delete():
def action_room_add():
form = RoomForm(request.form)
if request.method == 'POST':
+ server = get_server_from_ip_port(form.server.data)
payload = {"center": int(form.center.data),
"name": form.name.data,
"netmask": form.netmask.data}
- r = g.server.post('/room/add', payload)
+ r = server.post('/room/add', payload)
if r.status_code != requests.codes.ok:
flash(_('Server replied with error code when adding the room'), category='error')
else:
@@ -1308,13 +1309,15 @@ def action_room_add():
if not params.get('scope-center'):
flash(_('Please, select one center'), 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')
selected_center_id = params['scope-center']
centers = parse_scopes_from_tree(r.json(), 'center')
selected_center = [(center['id'], center['name']) for center in centers
if center['id'] == int(selected_center_id)]
form.center.choices = selected_center
form.center.render_kw = {'readonly': True}
+ form.server.data = params['scope-server']
scopes, clients = get_scopes()
return render_template('actions/add_room.html', form=form,
scopes=scopes)