Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified my_app/db.sqlite3
Binary file not shown.
Binary file modified my_app/todo_list/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified my_app/todo_list/__pycache__/views.cpython-310.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions my_app/todo_list/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
{% if things.completed %}
<tr class="table-secondary">
<td class="striker">{{ things.item }}</td>
<td><center>{{ things.completed }}</center></td>
<td><center><a href = "{% url 'uncross' things.id%}">Uncross</a></center></td>
<td><center><a href = "{% url 'delete' things.id %}">Delete</a></center></td>
</tr>
{% else %}
<tr>
<td>{{ things.item }}</td>
<td><center>{{ things.completed }}</center></td>
<td><center><a href = "{% url 'cross_off' things.id%}">Cross Off</a></center></td>
<td><center><a href = "{% url 'delete' things.id %}">Delete</a></center></td>
</tr>
{% endif %}
{% endfor %}
</table>
{% endif %}
{% endblock %}
{% endblock %}
3 changes: 3 additions & 0 deletions my_app/todo_list/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
path('', views.home, name='home'),
path('about/', views.about, name='about'),
path('delete/<list_id>',views.delete,name='delete'),
path('cross_off/<list_id>',views.cross_off,name ='cross_off'),
path('uncross/<list_id>',views.uncross,name ='uncross'),

]
15 changes: 14 additions & 1 deletion my_app/todo_list/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,17 @@ def delete(request,list_id):
item = List.objects.get(pk = list_id)
item.delete()
messages.success(request, ('Item has been deleted!'))
return redirect('home')
return redirect('home')

def cross_off(request,list_id):
item = List.objects.get(pk = list_id)
item.completed = True
item.save()
return redirect('home')

def uncross(request,list_id):
item = List.objects.get(pk = list_id)
item.completed = False
item.save()
return redirect('home')