diff options
author | Javier Hernandez <jhernandez@soleta.eu> | 2024-01-11 13:36:19 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-01-11 13:36:19 +0100 |
commit | cba7a0c1c617e1039055652318c11f309eda932f (patch) | |
tree | 0c5424dd702c735f3757a73408a51b21dfc0a65e /ogcp/views.py | |
parent | 2509cacc005832b37e181f6a6a4795f5c7e1fff9 (diff) |
views: Add computers to folder
Add support for adding computers to a folder.
It uses a js script that when selecting a folder in the html form, it
will also select the parent of the folder. For instance, if the user
were to select a folder that is contained inside a room, the room would
also get selected. This allows the view to know which parent contains
the folder.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 1203ffd..2ca2681 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1095,7 +1095,8 @@ def action_client_add(): "remote": form.remote.data, "repo_id": int(form.repo.data), "room": int(form.room.data), - "serial_number": form.serial_number.data} + "serial_number": form.serial_number.data, + "folder_id": int(form.folder_id.data) } server = get_server_from_ip_port(form.server.data) r = server.post('/client/add', payload) @@ -1108,7 +1109,7 @@ def action_client_add(): else: params = request.args.to_dict() if not params.get('scope-room'): - flash(_('Please, select one room'), category='error') + flash(_('Please, select a room or a folder'), category='error') return redirect(url_for('scopes')) form.server.data = params['scope-server'] server = get_server_from_ip_port(params['scope-server']) @@ -1128,6 +1129,11 @@ def action_client_add(): repositories = get_repositories(server) form.repo.choices = [(repo["id"], repo["name"]) for repo in repositories] + if params.get('folder'): + form.folder_id.data = params['folder'] + else: + form.folder_id.data = 0 + form.submit.render_kw = {"formaction": url_for('action_client_add')} scopes, clients = get_scopes() return render_template('actions/client_details.html', form=form, |