Request confirmation before deleting one item
This commit is contained in:
parent
652b279850
commit
9070fb79dd
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
4
views.py
4
views.py
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user