summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-24 12:43:01 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-31 15:57:52 +0200
commit4f02e545e4c049897fa793d4bfffb419189605ad (patch)
tree057a41c2002597c6375034f9327dcc82179ad8da /ogcp
parentd41089982a839cec991549c1156daf9e9adf526b (diff)
Adapt Delete center to work with several ogServers
This commit makes Delete center 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 bf5c5f3..a7bb5b4 100644
--- a/ogcp/forms/action_forms.py
+++ b/ogcp/forms/action_forms.py
@@ -163,6 +163,7 @@ class CenterForm(FlaskForm):
submit = SubmitField(label=_l('Submit'))
class DeleteCenterForm(FlaskForm):
+ server = HiddenField()
center = SelectField(label=_l('Center'),
validators=[InputRequired()])
submit = SubmitField(label=_l('Submit'))
diff --git a/ogcp/views.py b/ogcp/views.py
index 2327b19..316bcf1 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1276,8 +1276,9 @@ def action_center_add():
def action_center_delete():
form = DeleteCenterForm(request.form)
if request.method == 'POST':
+ server = get_server_from_ip_port(form.server.data)
payload = {"id": form.center.data}
- r = g.server.post('/center/delete', payload)
+ r = server.post('/center/delete', payload)
if r.status_code != requests.codes.ok:
flash(_('Server replied with error code when deleting the center'),
category='error')
@@ -1289,13 +1290,15 @@ def action_center_delete():
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/delete_center.html', form=form,
scopes=scopes)