summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-25 17:22:54 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-31 15:57:52 +0200
commit17f91229d6792aa182d1a67adf323488bf2d784d (patch)
treec4ec25c5ecd96f4d137c00c953c7ac2bed153884 /ogcp/views.py
parent0b5dd659f1e5bb3487f58f34b778d90f6c33cebd (diff)
Add ogServer parameter to imagesForm
When users select an image, its ogServer is sent too. Then, the back-end (flask) processes the form to obtain this ogServer and send it the pertinent requests. It also makes "Image details" view use this new parameter, and adds javascript code to ensure that users can only work with several images at the same time if they belong to the same ogServer.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 3b0d134..c2a40b8 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -97,7 +97,7 @@ def validate_elements(elements, min_len=1, max_len=float('inf')):
def parse_elements(checkboxes_dict):
unwanted_elements = ['csrf_token', 'scope-server', 'scope-center',
- 'scope-room']
+ 'scope-room', 'image-server']
elements = set()
for key, elements_list in checkboxes_dict.items():
if key not in unwanted_elements:
@@ -1626,12 +1626,14 @@ def user_delete_post():
@login_required
def action_image_info():
form = ImageDetailsForm()
- ids = parse_elements(request.args.to_dict())
+ params = request.args.to_dict()
+ ids = parse_elements(params)
if not validate_elements(ids, max_len=1):
return redirect(url_for('images'))
id = ids.pop()
- r = g.server.get('/images')
+ server = get_server_from_ip_port(params['image-server'])
+ r = server.get('/images')
images = r.json()['images']
image = next(img for img in images if img['id'] == int(id))