Fakultas Ilmu Komputer UI

Commit df2e3aef authored by Yumna Pratista Tastaftian's avatar Yumna Pratista Tastaftian
Browse files

commited implementaion of delete all

parent c5d3ed03
Pipeline #28379 passed with stages
in 10 minutes and 24 seconds
db.sqlite3
geckodriver.log
__pycache__
*.pyc
.DS_Store
# Created by https://www.gitignore.io
### OSX ###
......@@ -91,5 +85,5 @@ target/
__pycache__/
local_settings.py
virtualenv
db.sqlite3
.env
db.sqlite3
\ No newline at end of file
......@@ -5,4 +5,5 @@ urlpatterns = [
url(r'^new$', views.new_list, name='new_list'),
url(r'^(\d+)/$', views.view_list, name='view_list'),
url(r'^(\d+)/add_item$', views.add_item, name='add_item'),
url(r'^delete-all$', views.delete_all, name='delete_list'),
]
\ No newline at end of file
......@@ -27,4 +27,13 @@ def new_list(request):
def add_item(request, list_id):
list_ = List.objects.get(id=list_id)
Item.objects.create(text=request.POST['item_text'], list=list_)
return redirect(f'/lists/{list_.id}/')
\ No newline at end of file
return redirect(f'/lists/{list_.id}/')
def delete_all(request):
dict = {}
List.objects.all().delete()
if(List.objects.count() == 0):
dict['status'] = 'all deleted'
else:
dict['status'] = 'not all deleted'
return redirect('/')
\ No newline at end of file
Supports Markdown
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