summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py33
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