summaryrefslogtreecommitdiffstats
path: root/ogcp/templates
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-07-18 15:34:09 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-07-25 09:48:12 +0200
commitefd0b8acb3f4f098697c8c30bd196dacda39b704 (patch)
tree95959f7e437a531548de90b94ae00181175a04fc /ogcp/templates
parent594d655d6b13edfd1885d555ecda1a6f912db501 (diff)
ogcp: add image restrict functionality
Add center scope restriction using /image/restrict. Add view in Images to update scope permissions. Disable images in Commands for image update and restore if the client belongs to a disabled center. Consolidate template code to render scope selection checkboxes.
Diffstat (limited to 'ogcp/templates')
-rw-r--r--ogcp/templates/actions/image_config.html24
-rw-r--r--ogcp/templates/actions/image_details.html22
-rw-r--r--ogcp/templates/auth/user_form.html13
-rw-r--r--ogcp/templates/images.html4
-rw-r--r--ogcp/templates/scopes_checkbox_group.html16
5 files changed, 63 insertions, 16 deletions
diff --git a/ogcp/templates/actions/image_config.html b/ogcp/templates/actions/image_config.html
new file mode 100644
index 0000000..c286683
--- /dev/null
+++ b/ogcp/templates/actions/image_config.html
@@ -0,0 +1,24 @@
+{% extends 'images.html' %}
+{% import "bootstrap/wtf.html" as wtf %}
+
+{% set btn_back = true %}
+
+{% block content %}
+
+<h2 class="mx-5 subhead-heading">{{_('Update image')}}</h2>
+
+<form class="form mx-5" method="POST" action="{{ url_for('action_image_config') }}">
+ {{ form.hidden_tag() }}
+
+ {{ form.image_id() }}
+ {{ form.server() }}
+ {{ form.name() }}
+
+ {% include 'scopes_checkbox_group.html' %}
+
+ <div class="form-group">
+ {{ form.submit(class="btn btn-primary") }}
+ </div>
+ </form>
+
+{% endblock %}
diff --git a/ogcp/templates/actions/image_details.html b/ogcp/templates/actions/image_details.html
index 87105cb..ab66503 100644
--- a/ogcp/templates/actions/image_details.html
+++ b/ogcp/templates/actions/image_details.html
@@ -7,9 +7,23 @@
<h2 class="mx-5 subhead-heading">{{_('Image details')}}</h2>
-{{ wtf.quick_form(form,
- method='post',
- button_map={'create': 'primary'},
- extra_classes="mx-5") }}
+<div class="container mx-5">
+ <form class="form" method="POST">
+ {{ form.hidden_tag() }}
+
+ {% for field in form if field.type != 'CSRFToken' and field.name not in ['scopes'] %}
+ {% if not field.flags.hidden %}
+ <div class="form-group row">
+ <label for="name" class="col-sm-2 col-form-label">{{ field.label.text }}</label>
+ <div class="col-sm-9">
+ {{ field(class="form-control") }}
+ </div>
+ </div>
+ {% endif %}
+ {% endfor %}
+
+ {% include 'scopes_checkbox_group.html' %}
+ </form>
+</div>
{% endblock %}
diff --git a/ogcp/templates/auth/user_form.html b/ogcp/templates/auth/user_form.html
index bd2f396..ae34490 100644
--- a/ogcp/templates/auth/user_form.html
+++ b/ogcp/templates/auth/user_form.html
@@ -104,18 +104,7 @@
</table>
</div>
- <div class="form-group">
- {{ form.scopes.label(class_='form-label') }}
- <div class="form-text text-muted">{{ form.scopes.description }}</div>
- <div>
- {% for value, label, checked in form.scopes.iter_choices() %}
- <div class="form-check">
- <input class="form-check-input" type="checkbox" name="{{ form.scopes.name }}" value="{{ value }}" {% if checked %} checked {% endif %}>
- <label class="form-check-label">{{ label }}</label>
- </div>
- {% endfor %}
- </div>
- </div>
+ {% include 'scopes_checkbox_group.html' %}
</div>
<div class="form-group">
diff --git a/ogcp/templates/images.html b/ogcp/templates/images.html
index 00bb2e4..462e68d 100644
--- a/ogcp/templates/images.html
+++ b/ogcp/templates/images.html
@@ -67,6 +67,10 @@
<input class="btn btn-light" type="submit" value="{{ _('Delete image') }}"
form="imagesForm" formaction="{{ url_for('action_image_delete') }}" formmethod="get">
{% endif %}
+ {% if current_user.get_permission('IMAGE', 'UPDATE') %}
+ <input class="btn btn-light" type="submit" value="{{ _('Update image') }}"
+ form="imagesForm" formaction="{{ url_for('action_image_config') }}" formmethod="get">
+ {% endif %}
{% endif %}
{% if btn_back %}
<button class="btn btn-danger ml-3" type="button" id="backButton" onclick="history.back()">
diff --git a/ogcp/templates/scopes_checkbox_group.html b/ogcp/templates/scopes_checkbox_group.html
new file mode 100644
index 0000000..0ebf15a
--- /dev/null
+++ b/ogcp/templates/scopes_checkbox_group.html
@@ -0,0 +1,16 @@
+{% if form is defined and form.scopes is defined %}
+
+<div class="form-group">
+ {{ form.scopes.label(class_='form-label') }}
+ <div class="mx-4">
+ <div class="form-text text-muted">{{ form.scopes.description }}</div>
+ {% for value, label, checked in form.scopes.iter_choices() %}
+ <div class="form-check">
+ <input class="form-check-input" type="checkbox" name="{{ form.scopes.name }}" value="{{ value }}" {% if checked %} checked {% endif %}>
+ <label class="form-check-label">{{ label }}</label>
+ </div>
+ {% endfor %}
+ </div>
+</div>
+
+{% endif %} \ No newline at end of file