Fakultas Ilmu Komputer UI

Commit 68ae0470 authored by Selvy Fitriani's avatar Selvy Fitriani
Browse files

Merge branch '1706039446-36' into 'master'

1706039446 36

See merge request !43
parents 26195ff4 f69dbb97
Pipeline #58152 passed with stages
in 33 minutes and 4 seconds
......@@ -3,7 +3,7 @@
{% block title %}
<title>Riwayat Unggah | Digipus</title>
{% endblock %}
{% endblock %}
{% block content %}
<!-- Page Heading -->
......@@ -43,10 +43,12 @@
<td class="verif-buttons">
<span>
<a href="/materi/{{materi.id}}/" class="accept-button button-decoration"
style="background-color:#4e73df">Detail</a>
style="background-color:#4e73df">Detail</a>
{% if materi.get_status_display == "Ditolak" or materi.get_status_display == "Perbaikan" %}
<a href="/revisi/materi/{{materi.id}}/" class="reject-button button-decoration">Revisi</a>
{% endif %}
<a type="button" href="/materi/{{materi.id}}/delete" class="reject-button button-decoration"
style="background-color:red">Hapus</a>
</span>
</td>
</tr>
......
......@@ -917,6 +917,25 @@ class DashboardKontributorViewTest(TestCase):
self.assertIn(ERROR_403_MESSAGE, html)
class DeleteMateriTest(TestCase):
def setUp(self):
self.client = Client()
self.content = SimpleUploadedFile(
"content.txt", b"Test")
self.cover = SimpleUploadedFile(
"flower.jpg", b"Test file")
self.contributor = User.objects.create_contributor(email="kontributor@gov.id",
password="kontributor")
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="APPROVE", cover=self.cover, content=self.content).save()
self.materi1 = Materi.objects.first()
self.url = "/materi/" + str(self.materi1.id) + "/delete"
def test_url_delete_materi_is_success(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 302)
class ProfilAdminTest(TestCase):
def setUp(self):
self.client = Client()
......
......@@ -13,6 +13,7 @@ urlpatterns = [
path("materi/like/", views.toggle_like, name="PostLikeToggle"),
path("delete/<int:pk_materi>/<int:pk_comment>",
views.delete_comment, name="delete-comment"),
path("materi/<int:pk>/delete", views.delete_materi, name="detele-materi"),
path("materi/<int:pk>/unduh", views.download_materi, name="download-materi"),
path("materi/<int:pk>/view", views.view_materi, name="view-materi"),
path("dashboard/", DashboardKontributorView.as_view(), name="dashboard"),
......
......@@ -348,6 +348,11 @@ def view_materi(request, pk):
raise Http404("File tidak dapat ditemukan.")
def delete_materi(request, pk):
materi = get_object_or_404(Materi, pk=pk)
materi.delete()
return HttpResponseRedirect("/dashboard/")
class UploadMateriView(TemplateView):
template_name = "unggah.html"
context = {}
......
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