Commit 42ca8ac5 authored by James Esguerra's avatar James Esguerra

Added delete button to list of items today to redirect to delete view

parent 7cc208d9
......@@ -14,4 +14,5 @@ urlpatterns = [
path('today/', views.ShowToday, name='today'),
path('add_itemT', views.ShowAddItemT, name='add_itemT'),
path('edit_itemT/<int:pk>', views.ShowEditItemT, name='edit_itemT'),
path('delete_itemT/<int:pk>', views.ShowDeleteItemT, name='delete_itemT'),
]
......@@ -103,3 +103,12 @@ def ShowEditItemT(request, pk):
return redirect('today')
return render(request, 'edit_itemT.html', {'form': form})
def ShowDeleteItemT(request, pk):
if request.method == 'POST':
item = ItemsToday.objects.get(id=pk)
item.delete()
return redirect('today')
return render(request, 'delete_itemT.html')
......@@ -42,7 +42,7 @@ a {
font-size: 1.5em;
}
#key, #this_week, #today {
#key, #this_week, #today, #delete {
margin: 0 auto;
width: 50%;
font-size: 1.5em;
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Key {% endblock %}
{% block header %} Key {% endblock %}
{% block content %}
<div id='today'>
<h3> Are you sure you want to delete this item? </h3>
<form action='' method='POST'>
{% csrf_token %}
<input type='submit' name='Submit' value='Yes'>
<a href='{% url 'today' %}'><button type='button'> No </button></a>
</form>
</div>
{% endblock %}
......@@ -7,10 +7,13 @@
{% block content %}
<form action='' method='POST'>
{% csrf_token %}
<input type='submit' name='Submit' value='Yes'>
<a href='{% url 'this_week' %}'><button type='button'> No </button></a>
</form>
<div id='this_week'>
<h3> Are you sure you want to delete this item? </h3>
<form action='' method='POST'>
{% csrf_token %}
<input type='submit' name='Submit' value='Yes'>
<a href='{% url 'this_week' %}'><button type='button'> No </button></a>
</form>
</div>
{% endblock %}
......@@ -14,6 +14,7 @@
<p>
<b>{{ item.key_type }}:</b> {{ item.details }}
<a href='{% url 'edit_itemT' item.pk %}'><button type='button'> Edit </button></a>
<a href='{% url 'delete_itemT' item.pk %}'><button type='button'> Delete </button></a>
<p>
{% endfor %}
<a href='{% url 'add_itemT' %}'><button type='button'> Add Item </button></a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment