From d1025317f4c46f632f3796fbb744f2e05fd6c763 Mon Sep 17 00:00:00 2001
From: Dwi Nanda Susanto <dwi.nanda@ui.ac.id>
Date: Mon, 23 Dec 2019 20:53:43 +0700
Subject: [PATCH] hotfix reset button when item is not exist, modify views on
 viewlist returning the length of list, replacing reset button from base html
 to list html

---
 db.sqlite3                | Bin 155648 -> 155648 bytes
 lists/templates/base.html |   3 ---
 lists/templates/list.html |   7 +++++++
 lists/views.py            |   6 ++----
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/db.sqlite3 b/db.sqlite3
index 04bb060b8d6de13d7ed64d1b85ecb634f5128a5f..cdd176496e4ea75aa3d47133288f1dc3419016d1 100644
GIT binary patch
delta 225
zcmZoTz}awsbAmKu#zYxs#*B>#iu#P&lbiHY7)6_(>u-Oq&nSC=S(JaxRCXp+HvTRA
z8~E337EGw(=VlURVqg+sVqg+xn!cT%DTw<dKO9aM5MWZ;ZYIDqnctg%fx%puu_(Pn
zl!1XkSCFwh1;kK+F{EJ(AsB-b%-~{RU|<knVBo)lfYSvOK*lOCE$3HZU{Dd&W?*2D
l6V+m1V2}{iWME(r64hW}VBir|XJBAp6IJ8g%(&sdJ^+USFgO4J

delta 214
zcmZoTz}awsbAmKu<U|=~#>kBciu#O-lbiHY7=@aj>u-Oq&nSC=S%`nfRCXrS&4LL%
z{L^>vGX=7~;eW$_ZMuR0lh||v0VXyuvE4v`X(qp`l`vysc?uH)1A~DuBLf42mNa8|
zVoGXSagiVc1A~k-V@f##1A~YlV^Nt90|NuMC}Vj_YMKxi0|Ntt00RU67yd8&@1`p#
zfQ(iE8Lhy?w%tI1X)V8s8Z$cs1A_t+8v_G_6cZ~*2ZNBHJOcv*kB}k*0|T3o0`F$V
H4gd84!2>Ot

diff --git a/lists/templates/base.html b/lists/templates/base.html
index 51fdf59..02c3e93 100644
--- a/lists/templates/base.html
+++ b/lists/templates/base.html
@@ -46,9 +46,6 @@
         </div>
         
     </div>
-    <form action="reset_items/" method="GET" style="text-align:center;">
-        <button type='submit'>RESET ITEM</button>
-    </form>
     <div class="footer">
         <p id="footer" style="text-align:center;">Dwi Nanda S</p>
     </div>
diff --git a/lists/templates/list.html b/lists/templates/list.html
index 85549f5..bdf511d 100644
--- a/lists/templates/list.html
+++ b/lists/templates/list.html
@@ -10,6 +10,13 @@
 </table>
 
 <h2 id="text"> {{ text }} </h2>
+{% if item_length < 1 %}
+<form action="reset_items/" method="GET" style="text-align:center;display:none;">
+{% else %}
+<form action="reset_items/" method="GET" style="text-align:center;">
+{% endif %}
+    <button type='submit'>RESET ITEM</button>
+</form>
 
 
 {% endblock %}
\ No newline at end of file
diff --git a/lists/views.py b/lists/views.py
index 235df8b..d507e6e 100644
--- a/lists/views.py
+++ b/lists/views.py
@@ -18,7 +18,7 @@ def view_list(request, list_id):
     else:
         text = 'oh tidak'
 
-    return render(request, 'list.html', {'list': list_, 'text': text})
+    return render(request, 'list.html', {'list': list_, 'text': text, 'item_length': item_length})
 
 def new_list(request):
     list_ = List.objects.create()
@@ -30,9 +30,7 @@ def add_item(request, list_id):
     Item.objects.create(text=request.POST['item_text'], list=list_)
     return redirect(f'/lists/{list_.id}/')
 
-def reset_items(request, list_id):
-    print("AAAAAAAAAAAAAAAAA----")
-    
+def reset_items(request, list_id):    
     if request.method == 'GET':
         Item.objects.all().delete()
         return redirect('/')
-- 
GitLab