summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ogcp/forms/action_forms.py6
-rw-r--r--ogcp/templates/actions/add_center.html15
-rw-r--r--ogcp/templates/scopes.html2
-rw-r--r--ogcp/views.py19
4 files changed, 41 insertions, 1 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py
index 0404e71..2286941 100644
--- a/ogcp/forms/action_forms.py
+++ b/ogcp/forms/action_forms.py
@@ -113,6 +113,12 @@ class ImageCreateForm(FlaskForm):
description = StringField(label=_('Description'))
create = SubmitField(label=_('Create'))
+class CenterForm(FlaskForm):
+ name = StringField(label=_('Center name'),
+ validators=[InputRequired()])
+ comment = StringField(label=_('Comment'))
+ submit = SubmitField(label=_('Submit'))
+
class RoomForm(FlaskForm):
center = SelectField(label=_('Center'),
validators=[InputRequired()])
diff --git a/ogcp/templates/actions/add_center.html b/ogcp/templates/actions/add_center.html
new file mode 100644
index 0000000..10759c7
--- /dev/null
+++ b/ogcp/templates/actions/add_center.html
@@ -0,0 +1,15 @@
+{% extends 'base.html' %}
+{% import "bootstrap/wtf.html" as wtf %}
+
+{% block content %}
+
+<h1 class="m-5">{{_('Add center form')}}</h1>
+
+{{ wtf.quick_form(form,
+ action=url_for('action_center_add'),
+ method='post',
+ button_map={'submit': 'primary'},
+ extra_classes="mx-5") }}
+
+{% endblock %}
+
diff --git a/ogcp/templates/scopes.html b/ogcp/templates/scopes.html
index 746acff..934177f 100644
--- a/ogcp/templates/scopes.html
+++ b/ogcp/templates/scopes.html
@@ -20,6 +20,8 @@
form="scopesForm" formaction="{{ url_for('action_client_add') }}" formmethod="get">
<input class="btn btn-light" type="submit" value="{{ _('Add room') }}"
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 room') }}"
form="scopesForm" formaction="{{ url_for('action_room_delete') }}" formmethod="get">
{% endblock %}
diff --git a/ogcp/views.py b/ogcp/views.py
index 0505f66..1221478 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -11,7 +11,7 @@ from flask import (
from ogcp.forms.action_forms import (
WOLForm, PartitionForm, NewPartitionForm, ClientDetailsForm, HardwareForm,
SessionForm, ImageRestoreForm, ImageCreateForm, SoftwareForm, BootModeForm,
- RoomForm, DeleteRoomForm
+ RoomForm, DeleteRoomForm, CenterForm
)
from flask_login import (
current_user, LoginManager,
@@ -700,6 +700,23 @@ def action_refresh():
flash(_('Refresh request processed successfully'), category='info')
return redirect(url_for("scopes"))
+@app.route('/action/center/add', methods=['GET', 'POST'])
+@login_required
+def action_center_add():
+ form = CenterForm(request.form)
+ if request.method == 'POST':
+ payload = {"name": form.name.data,
+ "comment": form.comment.data}
+ r = g.server.post('/center/add', payload)
+ if r.status_code != requests.codes.ok:
+ flash(_('Server replied with error code when adding the center'),
+ category='error')
+ else:
+ flash(_('Center added successfully'), category='info')
+ return redirect(url_for("scopes"))
+ else:
+ return render_template('actions/add_center.html', form=form)
+
@app.route('/action/room/add', methods=['GET', 'POST'])
@login_required
def action_room_add():