summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-24 12:24:00 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-31 15:57:52 +0200
commitd41089982a839cec991549c1156daf9e9adf526b (patch)
tree3a9269cc1470fa024d6f862a1998ec683c4ab5b2 /ogcp
parent025d78c643d9f2998f9c68796215bfc3f727573f (diff)
Delete center using the scopes tree
With this commit users can select a center from the scopes tree, and then delete it.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 8a0d8ba..2327b19 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1285,10 +1285,17 @@ def action_center_delete():
flash(_('Center deleted successfully'), category='info')
return redirect(url_for("scopes"))
else:
+ params = request.args.to_dict()
+ if not params.get('scope-center'):
+ flash(_('Please, select one center'), category='error')
+ return redirect(url_for('scopes'))
r = g.server.get('/scopes')
+ selected_center_id = params['scope-center']
centers = parse_scopes_from_tree(r.json(), 'center')
- centers = [(center['id'], center['name']) for center in centers]
- form.center.choices = list(centers)
+ 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}
scopes, clients = get_scopes()
return render_template('actions/delete_center.html', form=form,
scopes=scopes)