Request confirmation before deleting one item

This commit is contained in:
Grégory Soutadé 2012-12-24 09:35:59 +01:00
parent 652b279850
commit 9070fb79dd
4 changed files with 6 additions and 6 deletions

View File

@ -7,7 +7,7 @@
{% else %}
<table>
{% for category in categories %}
<tr><td>{{ category.id }}</td><td>{{ category.name }}</td><td><a href="/category/edit/{{ category.id }}">Edit</a></td><td><a href="/category/delete/{{ category.id }}">Delete</a></td></tr>
<tr><td>{{ category.id }}</td><td>{{ category.name }}</td><td><a href="/category/edit/{{ category.id }}">Edit</a></td><td><a href="/category/delete/{{ category.id }}" onclick="return confirm('Do you really want to delete this item ?')">Delete</a></td></tr>
{% endfor %}
</table>
{% endif %}

View File

@ -7,7 +7,7 @@
{% else %}
<table>
{% for tag in tags %}
<tr><td>{{ tag.id }}</td><td>{{ tag.name }}</td><td><a href="/tag/edit/{{ tag.id }}">Edit</a></td><td><a href="/tag/delete/{{ tag.id }}">Delete</a></td></tr>
<tr><td>{{ tag.id }}</td><td>{{ tag.name }}</td><td><a href="/tag/edit/{{ tag.id }}">Edit</a></td><td><a href="/tag/delete/{{ tag.id }}" onclick="return confirm('Do you really want to delete this item ?')">Delete</a></td></tr>
{% endfor %}
</table>
{% endif %}

View File

@ -6,7 +6,7 @@
<form action="/blog/edit/{{ blog.id }}" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="edit" value="Edit" /><input type="submit" name="delete" value="Delete" />
<input type="submit" name="edit" value="Edit" /><input type="submit" name="delete" value="Delete" onclick="return confirm('Do you really want to delete this item ?')"/>
</form>
{% endif %}
<br/><br/>
@ -19,7 +19,7 @@
<table>
{% for post in posts %}
{% with post.id as cur_id %}
<tr><td><a href="/post/edit/{{ post.id }}">{{ post.id }}</a></td><td>{{ post.title }}</td><td>{{ post.category.name }}</td><td>{{ post.creation_date }}</td><td>{{ post.modification_date }}</td><td>{{ post.published }}</td><td>{{ post.front_page }}</td><td>{{ comments|hash:cur_id|default_if_none:"0" }} comment{{ comments|hash:cur_id|pluralize }}</td><td><a href="/post/delete/{{ post.id }}">Delete</a></td></tr>
<tr><td><a href="/post/edit/{{ post.id }}">{{ post.id }}</a></td><td>{{ post.title }}</td><td>{{ post.category.name }}</td><td>{{ post.creation_date }}</td><td>{{ post.modification_date }}</td><td>{{ post.published }}</td><td>{{ post.front_page }}</td><td>{{ comments|hash:cur_id|default_if_none:"0" }} comment{{ comments|hash:cur_id|pluralize }}</td><td><a href="/post/delete/{{ post.id }}" onclick="return confirm('Do you really want to delete this item ?')">Delete</a></td></tr>
{% endwith %}
{% endfor %}
{% endif %}

View File

@ -222,7 +222,7 @@ def edit_category(request, category_id):
form = CategoryForm(request.POST, instance=category) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
if request.POST['name'] != name:
category.remove()
category.remove(b)
form.save()
return HttpResponseRedirect('/category/' + str(b.id))
else:
@ -241,7 +241,7 @@ def delete_category(request, category_id):
b,_ = have_I_right(request, category.blog.id)
category.remove()
category.remove(b)
category.delete()
return HttpResponseRedirect('/category/' + str(b.id))