summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2024-02-05 10:48:12 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-02-05 11:48:35 +0100
commit6153ca426f9f880c70564ecb2d5346d64c2802eb (patch)
treeb132e076715caf0ecd46aba52672cb4e808a999c /ogcp
parent6a134b63372311706f174516a45ad2af8c7ff225 (diff)
improve delete confirmation
Make delete confirmations show information in a manner that is easier to read. This includes delete confirmations for centers, room and folder. Messages are now more clear. Also, content table shows the type of the items (folder, room, etc.)
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/forms/action_forms.py6
-rw-r--r--ogcp/templates/actions/delete_center.html30
-rw-r--r--ogcp/templates/actions/delete_room.html18
-rw-r--r--ogcp/templates/actions/folder_delete.html30
-rw-r--r--ogcp/views.py26
5 files changed, 54 insertions, 56 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py
index 3c53d0c..8586665 100644
--- a/ogcp/forms/action_forms.py
+++ b/ogcp/forms/action_forms.py
@@ -175,8 +175,7 @@ class CenterForm(FlaskForm):
class DeleteCenterForm(FlaskForm):
server = HiddenField()
- center = SelectField(label=_l('Center'),
- validators=[InputRequired()])
+ center = HiddenField()
submit = SubmitField(label=_l('Submit'))
class RoomForm(FlaskForm):
@@ -194,8 +193,7 @@ class RoomForm(FlaskForm):
class DeleteRoomForm(FlaskForm):
server = HiddenField()
- room = SelectField(label=_l('Room'),
- validators=[InputRequired()])
+ room = HiddenField()
submit = SubmitField(label=_l('Submit'))
class ImageDetailsForm(FlaskForm):
diff --git a/ogcp/templates/actions/delete_center.html b/ogcp/templates/actions/delete_center.html
index af89364..5379a58 100644
--- a/ogcp/templates/actions/delete_center.html
+++ b/ogcp/templates/actions/delete_center.html
@@ -9,12 +9,11 @@
{% block content %}
<h1 class="m-5">{{_('Delete center')}}</h1>
-{% if children %}
-<p class="text-left mx-5">The following items will be deleted</p>
+<p class="text-left mx-5">The following center and its content will be deleted</p>
<table class="table table-hover mx-5">
<thead class="thead-light">
<tr>
-<th>
+<th colspan="2">
{% for x in ancestors %}
{{x}}
{% if not loop.last %}
@@ -25,19 +24,22 @@
</tr>
</thead>
<tbody class="text-left">
-{% for c in children %}
- <tr>
- <td>
- {% if c['type'] == 'folder' %}
- &#x1F4C1;
- {% endif %}
- {{c['name']}}
- </td>
- </tr>
-{% endfor %}
+{% if children %}
+ {% for type, elements in children.items() %}
+ <tr>
+ <th>{{ type }}</th>
+ <td>
+ {% for e in elements %}
+ {{e}}
+ {% endfor %}
+ </td>
+ </tr>
+ {% endfor %}
+{% else %}
+ <tr><td>This center is empty</td></tr>
+{% endif %}
</tbody>
</table>
-{% endif %}
{{ wtf.quick_form(form,
action=url_for('action_center_delete'),
diff --git a/ogcp/templates/actions/delete_room.html b/ogcp/templates/actions/delete_room.html
index 3fa24cf..b4c3601 100644
--- a/ogcp/templates/actions/delete_room.html
+++ b/ogcp/templates/actions/delete_room.html
@@ -11,11 +11,11 @@
<h1 class="m-5">{{_('Delete room')}}</h1>
{% if children %}
-<p class="text-left mx-5">The following items will be deleted</p>
+<p class="text-left mx-5">The following room and its content will be deleted</p>
<table class="table table-hover mx-5">
<thead class="thead-light">
<tr>
-<th>
+<th colspan="2">
{% for x in ancestors %}
{{x}}
{% if not loop.last %}
@@ -26,16 +26,20 @@
</tr>
</thead>
<tbody class="text-left">
-{% for c in children %}
+{% if children %}
+{% for type, elements in children.items() %}
<tr>
+ <th>{{ type }}</th>
<td>
- {% if c['type'] == 'folder' %}
- &#x1F4C1;
- {% endif %}
- {{c['name']}}
+ {% for e in elements %}
+ {{e}}
+ {% endfor %}
</td>
</tr>
{% endfor %}
+{% else %}
+ <tr><td>This room is empty</td></tr>
+{% endif %}
</tbody>
</table>
{% endif %}
diff --git a/ogcp/templates/actions/folder_delete.html b/ogcp/templates/actions/folder_delete.html
index 8d497e8..0f58026 100644
--- a/ogcp/templates/actions/folder_delete.html
+++ b/ogcp/templates/actions/folder_delete.html
@@ -10,12 +10,11 @@
<h1 class="m-5">{{_('Delete folder')}}</h1>
-{% if children %}
-<p class="text-left mx-5">The following items will be deleted</p>
+<p class="text-left mx-5">The following folder and its content will be deleted</p>
<table class="table table-hover mx-5">
<thead class="thead-light">
<tr>
-<th>
+<th colspan="2">
{% for x in ancestors %}
{{x}}
{% if not loop.last %}
@@ -26,19 +25,22 @@
</tr>
</thead>
<tbody class="text-left">
-{% for c in children %}
- <tr>
- <td>
- {% if c['type'] == 'folder' %}
- &#x1F4C1;
- {% endif %}
- {{c['name']}}
- </td>
- </tr>
-{% endfor %}
+{% if children %}
+ {% for type, elements in children.items() %}
+ <tr>
+ <th>{{ type }}</th>
+ <td>
+ {% for e in elements %}
+ {{e}}
+ {% endfor %}
+ </td>
+ </tr>
+ {% endfor %}
+{% else %}
+ <tr><td>This folder is empty</td></tr>
+{% endif %}
</tbody>
</table>
-{% endif %}
{{ wtf.quick_form(form,
method='post',
diff --git a/ogcp/views.py b/ogcp/views.py
index cdb1582..572b784 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1222,10 +1222,9 @@ def action_folder_delete():
form.submit.render_kw = {"formaction": url_for('action_folder_delete')}
scopes, unused = get_scopes()
- form.name.render_kw = {'readonly': True}
ancestors, children = get_scope_context(int(folder_id), 'folder', scopes)
- form.name.data = ancestors[len(ancestors)-1]
+ del form.name
return render_template('actions/folder_delete.html', form=form,
parent="scopes.html", scopes=scopes, ancestors=ancestors, children=children)
@@ -1885,9 +1884,11 @@ def get_scope_context_rec(elem_id, elem_type, scopes, ancestors):
def get_scope_context(elem_id, elem_type, scopes):
ancestors, elem = get_scope_context_rec(elem_id, elem_type, scopes['scope'], [])
- children = []
+ children = {}
for c in elem['scope']:
- children.append({'name':c['name'], 'type':c['type']})
+ if c['type'] not in children:
+ children[c['type']] = []
+ children[c['type']].append(c['name'])
return (ancestors, children)
@app.route('/action/center/delete', methods=['GET', 'POST'])
@@ -1916,15 +1917,10 @@ def action_center_delete():
if r.status_code != requests.codes.ok:
return ogserver_error('scopes')
- selected_center_id = params['scope-center']
- centers = parse_scopes_from_tree(r.json(), 'center')
- selected_center = [(center['id'], center['name']) for center in centers
- if center['id'] == int(selected_center_id)]
- form.center.choices = selected_center
- form.center.render_kw = {'readonly': True}
+ form.center.data = params['scope-center']
form.server.data = params['scope-server']
scopes, clients = get_scopes()
- ancestors, children = get_scope_context(int(selected_center_id), 'center', scopes)
+ ancestors, children = get_scope_context(int(params['scope-center']), 'center', scopes)
return render_template('actions/delete_center.html', form=form,
scopes=scopes, ancestors=ancestors, children=children)
@@ -2000,15 +1996,11 @@ def action_room_delete():
if r.status_code != requests.codes.ok:
return ogserver_error('scopes')
- rooms = parse_scopes_from_tree(r.json(), 'room')
- selected_room_id = params['scope-room']
- selected_room = [(room['id'], room['name'] + " (" + room['parent'] + ")")
- for room in rooms if room['id'] == int(selected_room_id)]
- form.room.choices = selected_room
+ form.room.data = params['scope-room']
form.room.render_kw = {'readonly': True}
form.server.data = params['scope-server']
scopes, clients = get_scopes()
- ancestors, children = get_scope_context(int(selected_room_id), 'room', scopes)
+ ancestors, children = get_scope_context(int(params['scope-room']), 'room', scopes)
return render_template('actions/delete_room.html', form=form,
scopes=scopes, ancestors=ancestors, children=children)