diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-07-29 14:17:55 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-07-29 16:44:14 +0200 |
commit | df25ec62a863d05f5c16584cd1344011a3d66a0f (patch) | |
tree | 0c37949158f78fe70425b4ddf26db88b92843038 /ogcp | |
parent | 05bab71162ddd382e7662f0774ca6b90a5c154d5 (diff) |
Add "Delete client" action
Adds a new button in the scopes view.
This action handles clients deletion on one or multiple scopes. Users
must select clients using the scopes tree.
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/templates/scopes.html | 2 | ||||
-rw-r--r-- | ogcp/views.py | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/ogcp/templates/scopes.html b/ogcp/templates/scopes.html index 934177f..07d9b7f 100644 --- a/ogcp/templates/scopes.html +++ b/ogcp/templates/scopes.html @@ -22,6 +22,8 @@ form="scopesForm" formaction="{{ url_for('action_room_add') }}" formmethod="get"> <input class="btn btn-light" type="submit" value="{{ _('Add center') }}" form="scopesForm" formaction="{{ url_for('action_center_add') }}" formmethod="get"> + <input class="btn btn-light" type="submit" value="{{ _('Delete client') }}" + form="scopesForm" formaction="{{ url_for('action_client_delete') }}" formmethod="post"> <input class="btn btn-light" type="submit" value="{{ _('Delete room') }}" form="scopesForm" formaction="{{ url_for('action_room_delete') }}" formmethod="get"> {% endblock %} diff --git a/ogcp/views.py b/ogcp/views.py index b6db089..48770a2 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -543,6 +543,21 @@ def action_client_add(): form.create.render_kw = {"formaction": url_for('action_client_add')} return render_template('actions/client_details.html', form=form) +@app.route('/action/client/delete', methods=['POST']) +@login_required +def action_client_delete(): + ips = parse_ips(request.form.to_dict()) + if not validate_ips(ips): + return redirect(url_for('scopes')) + + payload = {'clients': list(ips)} + r = g.server.post('/client/delete', payload) + if r.status_code != requests.codes.ok: + flash(_('OgServer replied with a non ok status code'), category='error') + else: + flash(_('Delete client request processed successfully'), category='info') + return redirect(url_for('scopes')) + @app.route('/action/mode', methods=['GET', 'POST']) @login_required def action_mode(): |