summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2023-12-13 13:10:04 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-13 13:28:02 +0100
commitaa6061dad7e90ef9761d2d64940cf38eed51c990 (patch)
tree42a7b3409346de29e92b1cf5164b987cbad06dbc
parent131404dfd741846d304ac2c1d5c4204a1145384b (diff)
Limit allowed scopes to only centers
Modify the add/edit users menu to make the 'allowed scopes' field only display centers
-rw-r--r--ogcp/views.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 0d80cc7..b008673 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1678,6 +1678,15 @@ def users():
return render_template('users.html', users=users)
+def get_available_centers():
+ responses = multi_request('get', '/scopes')
+ available_centers = list()
+ for resp in responses:
+ centers = parse_scopes_from_tree(resp['json'], 'center')
+ centers = [(center['name'], center['name']) for center in centers]
+ available_centers.extend(centers)
+ return available_centers
+
def get_available_scopes():
responses = multi_request('get', '/scopes')
available_scopes = list()
@@ -1809,7 +1818,7 @@ def delete_user(username):
@login_required
def user_add_get():
form = UserForm()
- form.scopes.choices = get_available_scopes()
+ form.scopes.choices = get_available_centers()
return render_template('auth/add_user.html', form=form)
@@ -1847,7 +1856,7 @@ def user_edit_get():
form.username.render_kw = {'readonly': True}
form.admin.data = user.get('ADMIN')
form.scopes.data = user.get('SCOPES')
- form.scopes.choices = get_available_scopes()
+ form.scopes.choices = get_available_centers()
return render_template('auth/edit_user.html', form=form)