Commit f98aef07 authored by Amyll Angelin's avatar Amyll Angelin

Delete Works Now

^
parent 23538543
......@@ -81,10 +81,12 @@ def edit_week_view(request, *args, **kwargs):
form.save()
return render(request, "edit_week.html", {"form": form})
def delete_week_view(request, *args, **kwargs):
task = Week.objects.first()
def delete_week_view(request, pk):
task = Week.objects.get(pk=pk)
if request.method == "POST":
task.delete()
return redirect("/this_week")
return render(request, "delete_week.html", {"task": task} )
......@@ -108,7 +110,9 @@ def edit_today_view(request, *args, **kwargs):
return render(request, "edit_today.html", {"form": form})
def delete_today_view(request, *args, **kwargs):
task = Today.objects.first()
task = Today.objects.get(pk=pk)
if request.method == "POST":
task.delete()
return render(request, "delete_week.html", {"task": task} )
\ No newline at end of file
return redirect("/today")
return render(request, "delete_today.html", {"task": task} )
\ No newline at end of file
......@@ -7,7 +7,7 @@
<h1>Delete Task</h1>
<form method ="POST"> {% csrf_token %}
Are you sure you would like to delete the {{task}}? <br> <br>
<a href="{% url 'this_week' %}"><input button type="submit" value="Yes"></a> </input> </form>
<a href="{% url 'this_week' % pk=task.pk()}"><input button type="submit" value="Yes"></a> </input> </form>
<a href="{% url 'this_week' %}"><button> No </button></a> <br> <br>
<br>
......
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