Fakultas Ilmu Komputer UI

Commit 6b9886c2 authored by Putu Agastya's avatar Putu Agastya
Browse files

[CHORES] Pull latest code from master

parents f7455f7d 68ae0470
Pipeline #58159 failed with stages
in 13 minutes and 17 seconds
......@@ -15,6 +15,7 @@ media
/static/
media/
.coverage
virtualenv
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
......
......@@ -30,12 +30,6 @@ UnitTest:
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)%/'
before_script:
- export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_DB
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
- apt-get update -yy
- apt-get update -qq && apt-get install -y -qq unzip
- apt-get install -y google-chrome-stable
- apt-get install -y xvfb
- pip install -r requirements.txt
- python manage.py makemigrations
- python manage.py migrate
......
......@@ -133,6 +133,9 @@
<li>
<a href="?sort=pengunggah">pengunggah</a>
</li>
<li>
<a href="?sort=jumlah_unduh">jumlah unduh</a>
</li>
</div>
</div>
</div>
......
......@@ -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>
......
import json, tempfile, os, mock
import pandas as pd
from io import StringIO
import time
from bs4 import BeautifulSoup
from datetime import datetime
......@@ -136,6 +137,45 @@ class DaftarKatalogTest(TestCase):
self.assertSequenceEqual(search_result, expected_search_result)
class DaftarKatalogSortingByJumlahUnduhTest(TestCase):
def setUp(self):
self.client = Client()
self.contributor_credential = {
"email": "kontributor@gov.id",
"password": "passwordtest"
}
self.contributor_credential_2 = {
"email": "kontributor2@gov.id",
"password": "passwordtest"
}
self.contributor = get_user_model().objects.create_user(
**self.contributor_credential, name="Kontributor 1", is_contributor=True)
self.contributor2 = get_user_model().objects.create_user(
**self.contributor_credential_2, name="Kontributor 2", is_contributor=True)
self.cover = SimpleUploadedFile(
"Cherprang_Areekul40_nJM9dGt.jpg", b"Test file")
self.content = SimpleUploadedFile("Bahan_PA_RKK.pdf", b"Test file")
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()
time.sleep(1)
Materi(title="Materi 2", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 2",
status="APPROVE", cover=self.cover, content=self.content).save()
self.last_uploaded_material = Materi.objects.last()
material_unduh_url = f"/materi/{self.last_uploaded_material.id}/unduh"
self.client.get(material_unduh_url)
def test_sorting_by_jumlah_unduh(self):
response = self.client.get("/?sort=jumlah_unduh")
self.assertRegex(str(response.content), rf'.*Materi 2.*Materi 1.*')
class DaftarKatalogPerKontributorTest(TestCase):
def setUp(self):
......@@ -877,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()
......@@ -1420,36 +1479,6 @@ class RevisiMateriTest(TestCase):
self.client.logout()
class NameBannerFunctionalTest(LiveServerTestCase):
selenium = None
@classmethod
def setUpClass(cls):
super().setUpClass()
options = Options()
options.add_argument("--headless")
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_argument("--no-sandbox")
cls.selenium = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)
cls.selenium.implicitly_wait(10)
@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()
def test_list_todo_available(self):
self.selenium.get(f"{self.live_server_url}")
try:
self.assertIn("Digipus", self.selenium.find_element_by_css_selector("nav.katalog-navbar").text)
except NoSuchElementException:
self.fail("No such element: Katalog Brand")
class GenerateDummyCommandTest(TestCase):
def setUp(self):
self.material_numbers = [5, 10, 25, 100]
......
This diff is collapsed.
......@@ -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"),
......
......@@ -78,18 +78,20 @@ class DaftarKatalog(TemplateView):
getSort = request.GET.get("sort")
if getSort:
url = url + "&sort={0}".format(getSort)
if getSort == "judul":
lstMateri = lstMateri.order_by("title")
elif getSort == "penulis":
lstMateri = lstMateri.order_by("author")
elif getSort == "pengunggah":
lstMateri = lstMateri.order_by("uploader")
elif getSort == "terbaru":
lstMateri = lstMateri.order_by("-date_created")
elif getSort == "terlama":
lstMateri = lstMateri.order_by("date_created")
elif getSort == "terpopuler":
lstMateri = lstMateri.annotate(count=Count("like__id")).order_by("-count")
if(getSort == "judul"):
lstMateri = lstMateri.order_by('title')
elif(getSort == "penulis"):
lstMateri = lstMateri.order_by('author')
elif(getSort == "pengunggah"):
lstMateri = lstMateri.order_by('uploader')
elif(getSort == "terbaru"):
lstMateri = lstMateri.order_by('-date_created')
elif(getSort == "terlama"):
lstMateri = lstMateri.order_by('date_created')
elif(getSort == "terpopuler"):
lstMateri = lstMateri.annotate(count=Count('like__id')).order_by('-count')
elif(getSort == "jumlah_unduh"):
lstMateri = lstMateri.annotate(count=Count('unduh__id')).order_by('-count')
context["materi_list"] = lstMateri
paginator = Paginator(context["materi_list"], 15)
......@@ -346,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