diff options
author | Javier Hernandez <jhernandez@soleta.eu> | 2024-01-11 13:36:23 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-01-11 13:36:23 +0100 |
commit | b54203119320d63b8c6f1429b0b061035c4c8e0c (patch) | |
tree | 2cc371ea45f9fdc4c8b5a39657bbc5f124dfe025 /ogcp | |
parent | cba7a0c1c617e1039055652318c11f309eda932f (diff) |
views: add room to folder
Support adding a room to a folder
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/forms/action_forms.py | 1 | ||||
-rw-r--r-- | ogcp/views.py | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index c803b02..ed9825a 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -193,6 +193,7 @@ class RoomForm(FlaskForm): validators=[InputRequired()]) gateway = StringField(label=_l('Gateway'), validators=[InputRequired()]) + folder_id = HiddenField() submit = SubmitField(label=_l('Submit')) class DeleteRoomForm(FlaskForm): diff --git a/ogcp/views.py b/ogcp/views.py index 2ca2681..a09e33e 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1596,7 +1596,8 @@ def action_room_add(): payload = {"center": int(form.center.data), "name": form.name.data, "netmask": form.netmask.data, - "gateway": form.gateway.data} + "gateway": form.gateway.data, + "folder_id": int(form.folder_id.data)} r = server.post('/room/add', payload) if r.status_code != requests.codes.ok: flash(_('Server replied with error code when adding the room'), category='error') @@ -1606,7 +1607,7 @@ def action_room_add(): else: params = request.args.to_dict() if not params.get('scope-center'): - flash(_('Please, select one center'), category='error') + flash(_('Please, select a center or a folder'), category='error') return redirect(url_for('scopes')) server = get_server_from_ip_port(params['scope-server']) r = server.get('/scopes') @@ -1617,6 +1618,12 @@ def action_room_add(): form.center.choices = selected_center form.center.render_kw = {'readonly': True} form.server.data = params['scope-server'] + + if params.get('folder'): + form.folder_id.data = params['folder'] + else: + form.folder_id.data = 0 + scopes, clients = get_scopes() return render_template('actions/add_room.html', form=form, scopes=scopes) |