From e199960355e3620e2edcc1050ed7b33f325abf86 Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Tue, 17 Nov 2020 21:42:00 +0700
Subject: [PATCH 1/7] [#46] Delete Rating

---
 app/templates/given-rating.html | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/templates/given-rating.html b/app/templates/given-rating.html
index 80223ca..e5ab023 100644
--- a/app/templates/given-rating.html
+++ b/app/templates/given-rating.html
@@ -100,7 +100,8 @@
                             <td>{{ i.timestamp }}</td>
                             <td>{{ i.score }}</td>
                             <td>
-                                <a href="/edit/{{ i.score }}"><span class="glyphicon glyphicon-pencil" >Edit</span></a>  
+                                <a href="/edit/{{ i.score }}"><span class="glyphicon glyphicon-pencil" >Edit</span></a>
+                                <a href="/delete/{{ i.score }}"><span class="glyphicon glyphicon-pencil" >Delete</span></a>  
                             </td>
                         </tr>
                     {% endfor %}
-- 
GitLab


From b8cd74aa1d4947e137f69e09a2ae26bf6ee22a8a Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Tue, 17 Nov 2020 22:05:27 +0700
Subject: [PATCH 2/7] [#46] Delete Rating

---
 app/views.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/views.py b/app/views.py
index f61b0a7..41409c4 100644
--- a/app/views.py
+++ b/app/views.py
@@ -335,6 +335,9 @@ def add_rating_materi(request):
 def edit_rating_materi(request, pk):
     rating = get_object_or_404(Rating, pk=pk)
     
+def delete_rating_materi(request, pk):
+    rating = Rating.objects.filter(pk=pk).delete()
+    
 def download_materi(request, pk):
     materi = get_object_or_404(Materi, pk=pk)
     path = materi.content.path
-- 
GitLab


From 2109d90e20a7f7d4055dccdd06fb069eceac81df Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Tue, 17 Nov 2020 22:28:23 +0700
Subject: [PATCH 3/7] [#46] Delete Rating

---
 app/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/views.py b/app/views.py
index 41409c4..8f864ba 100644
--- a/app/views.py
+++ b/app/views.py
@@ -336,7 +336,7 @@ def edit_rating_materi(request, pk):
     rating = get_object_or_404(Rating, pk=pk)
     
 def delete_rating_materi(request, pk):
-    rating = Rating.objects.filter(pk=pk).delete()
+    rating = Rating.objects.filter(pk=pk)
     
 def download_materi(request, pk):
     materi = get_object_or_404(Materi, pk=pk)
-- 
GitLab


From 637ec6e050bc8e5aaec0264343ad12945c2aa41a Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Tue, 17 Nov 2020 22:53:19 +0700
Subject: [PATCH 4/7] [#46] Delete Rating

---
 app/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/views.py b/app/views.py
index 8f864ba..99e820e 100644
--- a/app/views.py
+++ b/app/views.py
@@ -336,7 +336,7 @@ def edit_rating_materi(request, pk):
     rating = get_object_or_404(Rating, pk=pk)
     
 def delete_rating_materi(request, pk):
-    rating = Rating.objects.filter(pk=pk)
+    materi = get_object_or_404(Rating, pk=pk)
     
 def download_materi(request, pk):
     materi = get_object_or_404(Materi, pk=pk)
-- 
GitLab


From 0c82253863517396ac29c8c9347d8b7e2181ad2d Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Tue, 17 Nov 2020 23:16:20 +0700
Subject: [PATCH 5/7] [#46] Delete Rating

---
 app/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/views.py b/app/views.py
index 99e820e..08a496a 100644
--- a/app/views.py
+++ b/app/views.py
@@ -336,7 +336,7 @@ def edit_rating_materi(request, pk):
     rating = get_object_or_404(Rating, pk=pk)
     
 def delete_rating_materi(request, pk):
-    materi = get_object_or_404(Rating, pk=pk)
+    rating = get_object_or_404(Rating, pk=pk)
     
 def download_materi(request, pk):
     materi = get_object_or_404(Materi, pk=pk)
-- 
GitLab


From eb882e5f881bc900d1a4e16ba0d25f7425e20cba Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Tue, 17 Nov 2020 23:41:09 +0700
Subject: [PATCH 6/7] [#46] Delete Rating

---
 app/views.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/app/views.py b/app/views.py
index 08a496a..f61b0a7 100644
--- a/app/views.py
+++ b/app/views.py
@@ -335,9 +335,6 @@ def add_rating_materi(request):
 def edit_rating_materi(request, pk):
     rating = get_object_or_404(Rating, pk=pk)
     
-def delete_rating_materi(request, pk):
-    rating = get_object_or_404(Rating, pk=pk)
-    
 def download_materi(request, pk):
     materi = get_object_or_404(Materi, pk=pk)
     path = materi.content.path
-- 
GitLab


From 646eac879d6dce07a37074bebeb21915539e01e4 Mon Sep 17 00:00:00 2001
From: "Nurma Ayu Wigati S. Subroto" <nurma.ayu@ui.ac.id>
Date: Wed, 18 Nov 2020 00:03:28 +0700
Subject: [PATCH 7/7] [#46] Delete Rating

---
 app/tests.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/app/tests.py b/app/tests.py
index 530364f..8c6724f 100644
--- a/app/tests.py
+++ b/app/tests.py
@@ -2342,6 +2342,13 @@ class RatingMateriTest(TestCase):
     def test_rating_materi_url_use_edit_rating_materi_function(self):
         found = resolve(self.url_rate)
         self.assertEqual(found.func, add_rating_materi)
+        
+    def test_rating_materi_url_use_delete_rating_materi_function(self):
+        response = self.client.get(self.url_rate)
+        response_json = json.loads(response.content)
+        self.assertEqual(response_json.get("success", None), False)
+        self.assertEqual(response_json.get("msg", None), "Forbidden")
+        self.assertEqual(response.status_code, 403)
 
     def test_rating_materi_get_method_should_return_403_forbidden(self):
         response = self.client.get(self.url_rate)
-- 
GitLab