summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-23 17:41:27 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-31 15:57:52 +0200
commit025d78c643d9f2998f9c68796215bfc3f727573f (patch)
tree43ea49a5310006621fcc58931a5fd455b97c0496
parent60b773607b4a4f9d9ab4dd8c59aaf8934a9c1071 (diff)
Adapt Add center to work with several ogServers
This commit adds a new select input with all available ogServers to "Add center" view. The ogCP creates the center in the ogServer selected by the user.
-rw-r--r--ogcp/forms/action_forms.py2
-rw-r--r--ogcp/views.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py
index 93c8075..bf5c5f3 100644
--- a/ogcp/forms/action_forms.py
+++ b/ogcp/forms/action_forms.py
@@ -155,6 +155,8 @@ class ImageUpdateForm(FlaskForm):
class CenterForm(FlaskForm):
+ server = SelectField(label=_l('Server'),
+ validators=[InputRequired()])
name = StringField(label=_l('Center name'),
validators=[InputRequired()])
comment = StringField(label=_l('Comment'))
diff --git a/ogcp/views.py b/ogcp/views.py
index 6b10321..8a0d8ba 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1255,7 +1255,8 @@ def action_center_add():
if request.method == 'POST':
payload = {"name": form.name.data,
"comment": form.comment.data}
- r = g.server.post('/center/add', payload)
+ server = get_server_from_ip_port(form.server.data)
+ r = server.post('/center/add', payload)
if r.status_code != requests.codes.ok:
flash(_('Server replied with error code when adding the center'),
category='error')
@@ -1263,6 +1264,9 @@ def action_center_add():
flash(_('Center added successfully'), category='info')
return redirect(url_for("scopes"))
else:
+ server_choices = [(server.ip + ':' + str(server.port), server.name)
+ for server in servers]
+ form.server.choices = server_choices
scopes, clients = get_scopes()
return render_template('actions/add_center.html', form=form,
scopes=scopes)