add a confirmation page before removing a file (#16825)

This commit is contained in:
Frédéric Péters 2018-03-14 09:57:39 +01:00
parent 334ea5b5a8
commit 35fd40d6d6
4 changed files with 28 additions and 12 deletions

View File

@ -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})

View File

@ -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 */
}

View File

@ -40,10 +40,7 @@
<a class="icon-edit" rel="popup" href="{% url 'edit' pk=row.record.pk %}"></a>
{% endif %}
{% if row.record.deletable_by_user %}
<form method="post" action="{% url 'delete' pk=row.record.pk %}{% querystring %}">
{% csrf_token %}
<button class="icon-remove-sign"></button>
</form>
<a class="icon-remove" rel="popup" href="{% url 'delete' pk=row.record.pk %}"></a>
{% endif %}
{% endblock %}
</td>

View File

@ -0,0 +1,15 @@
{% extends "fargo/base.html" %}
{% load i18n %}
{% block content %}
<form method="post">
{% csrf_token %}
<p>
{% blocktrans %}Are you sure you want to delete "{{ object }}"?{% endblocktrans %}
</p>
<div class="buttons">
<button class="delete-button">{% trans 'Delete' %}</button>
<a class="cancel" href="{% url 'home' %}">{% trans 'Cancel' %}</a>
</div>
</form>
{% endblock %}