diff options
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index cdb1582..572b784 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1222,10 +1222,9 @@ def action_folder_delete(): form.submit.render_kw = {"formaction": url_for('action_folder_delete')} scopes, unused = get_scopes() - form.name.render_kw = {'readonly': True} ancestors, children = get_scope_context(int(folder_id), 'folder', scopes) - form.name.data = ancestors[len(ancestors)-1] + del form.name return render_template('actions/folder_delete.html', form=form, parent="scopes.html", scopes=scopes, ancestors=ancestors, children=children) @@ -1885,9 +1884,11 @@ def get_scope_context_rec(elem_id, elem_type, scopes, ancestors): def get_scope_context(elem_id, elem_type, scopes): ancestors, elem = get_scope_context_rec(elem_id, elem_type, scopes['scope'], []) - children = [] + children = {} for c in elem['scope']: - children.append({'name':c['name'], 'type':c['type']}) + if c['type'] not in children: + children[c['type']] = [] + children[c['type']].append(c['name']) return (ancestors, children) @app.route('/action/center/delete', methods=['GET', 'POST']) @@ -1916,15 +1917,10 @@ def action_center_delete(): if r.status_code != requests.codes.ok: return ogserver_error('scopes') - selected_center_id = params['scope-center'] - centers = parse_scopes_from_tree(r.json(), 'center') - 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} + form.center.data = params['scope-center'] form.server.data = params['scope-server'] scopes, clients = get_scopes() - ancestors, children = get_scope_context(int(selected_center_id), 'center', scopes) + ancestors, children = get_scope_context(int(params['scope-center']), 'center', scopes) return render_template('actions/delete_center.html', form=form, scopes=scopes, ancestors=ancestors, children=children) @@ -2000,15 +1996,11 @@ def action_room_delete(): if r.status_code != requests.codes.ok: return ogserver_error('scopes') - rooms = parse_scopes_from_tree(r.json(), 'room') - selected_room_id = params['scope-room'] - selected_room = [(room['id'], room['name'] + " (" + room['parent'] + ")") - for room in rooms if room['id'] == int(selected_room_id)] - form.room.choices = selected_room + form.room.data = params['scope-room'] form.room.render_kw = {'readonly': True} form.server.data = params['scope-server'] scopes, clients = get_scopes() - ancestors, children = get_scope_context(int(selected_room_id), 'room', scopes) + ancestors, children = get_scope_context(int(params['scope-room']), 'room', scopes) return render_template('actions/delete_room.html', form=form, scopes=scopes, ancestors=ancestors, children=children) |