From 20da5cebb1e7b3966da88b23c81793486597b17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 14 Mar 2018 09:57:39 +0100 Subject: [PATCH] add a confirmation page before removing a file (#16825) --- fargo/fargo/models.py | 3 +++ fargo/static/fargo/css/style.css | 17 +++++++++-------- fargo/templates/fargo/table.html | 5 +---- fargo/templates/fargo/userdocument_confirm_delete.html | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 fargo/templates/fargo/userdocument_confirm_delete.html diff --git a/fargo/fargo/models.py b/fargo/fargo/models.py index 37ba6c7..f620d3c 100644 --- a/fargo/fargo/models.py +++ b/fargo/fargo/models.py @@ -82,6 +82,9 @@ class UserDocument(models.Model): def filename_encoded(self): return urlquote(self.filename, safe='') + def __unicode__(self): + return self.title or self.filename + def get_download_url(self): return reverse('download', kwargs={'pk': self.id, 'filename': self.filename_encoded}) diff --git a/fargo/static/fargo/css/style.css b/fargo/static/fargo/css/style.css index 0ea5af3..803bf2a 100644 --- a/fargo/static/fargo/css/style.css +++ b/fargo/static/fargo/css/style.css @@ -6,14 +6,6 @@ font-style: normal; } -button.icon-remove-sign { - border: none; - background: none; - box-shadow: none; - padding: 2px; - line-height: 100%; -} - td.thumbnail > img { height: 6em; } @@ -144,3 +136,12 @@ thead th.orderable.desc > a:after { text-decoration: none; content: "\f040"; /* pencil */ } + +.icon-remove::before { + font-family: FontAwesome; + font-weight: normal; + font-style: normal; + display: inline-block; + text-decoration: none; + content: "\f057"; /* times-circle */ +} diff --git a/fargo/templates/fargo/table.html b/fargo/templates/fargo/table.html index dcd2544..7d99a32 100644 --- a/fargo/templates/fargo/table.html +++ b/fargo/templates/fargo/table.html @@ -40,10 +40,7 @@ {% endif %} {% if row.record.deletable_by_user %} -
- {% csrf_token %} - -
+ {% endif %} {% endblock %} diff --git a/fargo/templates/fargo/userdocument_confirm_delete.html b/fargo/templates/fargo/userdocument_confirm_delete.html new file mode 100644 index 0000000..34190fb --- /dev/null +++ b/fargo/templates/fargo/userdocument_confirm_delete.html @@ -0,0 +1,15 @@ +{% extends "fargo/base.html" %} +{% load i18n %} + +{% block content %} +
+ {% csrf_token %} +

+ {% blocktrans %}Are you sure you want to delete "{{ object }}"?{% endblocktrans %} +

+
+ + {% trans 'Cancel' %} +
+
+{% endblock %} -- 2.16.2