diff options
author | Javier Hernandez <jhernandez@soleta.eu> | 2024-02-02 12:30:47 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-02-02 12:48:28 +0100 |
commit | 6a134b63372311706f174516a45ad2af8c7ff225 (patch) | |
tree | 1a94436177fb5c96a461ff2b783a0797435e69d0 /ogcp/views.py | |
parent | a41ad5eec6cefe540cbb5c4a5454c0c4ae24bf1c (diff) |
Make list_images show only selected images
Make list images command show only information of the images the user
has selected in the sidebar.
Improve readability of the information.
Show size and data size attributes rounded
Warn the user if no images have been selected in sidebar
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index c2be721..cdb1582 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -2516,25 +2516,34 @@ def user_delete_get(): def action_image_list(): params = request.args.to_dict() ids = parse_elements(params) + ids = [int(id) for id in ids if id.isdigit()] + if not ids: + flash(_('Please, select an image'), category='error') + return redirect(url_for('images')) server = get_server_from_ip_port(params['image-server']) - r = server.get('/images') - if not r: - return ogserver_down('images') - if r.status_code != requests.codes.ok: - return ogserver_error('images') - tmp = r.json()['images'] - images = [] - for img in tmp: - if img['id'] in ids: - images.append(img) try: - images = get_images_grouped_by_repos() + responses = get_images_grouped_by_repos() + servers = [] + for server in responses: + repos = [] + for unused, repo in server['repos'].items(): + images=[] + for img in repo['images']: + if int(img['id']) in ids: + images.append(img) + if images: + repos.append((repo['name'], images)) + if repos: + s={} + s['name'] = server['server'].name + s['repos'] = repos + servers.append(s) except ServerError: return ogserver_down('images') except ServerErrorCode: return ogserver_error('images') return render_template('actions/list_images.html', - responses=images) + servers=servers, responses=responses) @app.route('/user/delete', methods=['POST']) @login_required |