Fakultas Ilmu Komputer UI

Commit bdacd895 authored by Edward Partogi Gembira Abyatar's avatar Edward Partogi Gembira Abyatar
Browse files

Merge branch '1706979215-129' into 'master'

[#129] Dropdown template fixing

See merge request !113
parents 8e7e67a9 ade89b7d
Pipeline #60647 passed with stages
in 20 minutes and 46 seconds
# Generated by Django 3.1 on 2020-10-31 19:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('app', '0028_notifikasikontributor'),
('app', '0028_adminnotification'),
]
operations = [
]
# Generated by Django 3.1 on 2020-11-01 10:29
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('app', '0030_merge_20201101_0621'),
('app', '0029_merge_20201101_0217'),
]
operations = [
]
......@@ -23,6 +23,9 @@
<!-- Custom styles for this page -->
<link href="{% static 'vendor/datatables/dataTables.bootstrap4.min.css' %}" rel="stylesheet">
<!-- Bootstrap CSS -->
{% block stylesheets %}{% endblock %}
{% block scripts %}{% endblock %}
</head>
......@@ -69,6 +72,10 @@
<em class="fas fa-angle-up"></em>
</a>
<!-- Bootstrap scripts -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
......@@ -71,6 +71,10 @@
<em class="fas fa-angle-up"></em>
</a>
<!-- Bootstrap scripts -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
......@@ -11,19 +11,26 @@
<ul class="navbar-nav ml-auto">
{% if request.user.is_contributor %}
<li class="nav-item dropdown">
<a id="notifBtn" class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Notifikasi</a>
<div class="dropdown-menu show" aria-labelledby="notifBtn">
<li class="nav-item">
<div class="dropdown">
{% if kontributor_notif %}
{% for notif in kontributor_notif %}
<a class="dropdown-item" style="white-space: break-spaces;" href="{% url 'dashboard' %}">Materi "{{notif.materi.title}}" <br>{{ notif }}</a>
<div class="dropdown-divider"></div>
{% endfor %}
<a id="notifBtn" class="nav-link dropdown-toggle" data-toggle="dropdown" href="#"role="button" aria-haspopup="true" aria-expanded="false" style="color: #4e73df;">
Notifikasi</a>
<div class="dropdown-menu" aria-labelledby="notifBtn">
{% for notif in kontributor_notif %}
<div class="dropdown-divider"></div>
<a class="dropdown-item" style="white-space: break-spaces;" href="{% url 'dashboard' %}">Materi "{{notif.materi.title}}" <br>{{ notif }}</a>
<div class="dropdown-divider"></div>
{% endfor %}
{% else %}
<a id="notifBtn" class="nav-link dropdown-toggle" data-toggle="dropdown" href="#"role="button" aria-haspopup="true" aria-expanded="false">
Notifikasi</a>
<div class="dropdown-menu" aria-labelledby="notifBtn">
<a class="dropdown-item disabled" href="#" style="white-space: break-spaces;">Anda tidak memiliki notifikasi baru</a>
{% endif %}
</div>
</a>
</div>
</a>
</div>
</li>
<li class="nav-item">
......
......@@ -4300,6 +4300,7 @@ class NotifikasiKontributorTest(TestCase):
self.content = SimpleUploadedFile("ExampleFile221.pdf", b"Test file")
self.category = Category.objects.create(id="1", name="medis", description="kategori medis")
VerificationSetting.objects.create(title="Kriteria 1", description="memenuhi kriteria 1", archived=False, pk=1)
self.make_materi()
@override_settings(MEDIA_ROOT=tempfile.gettempdir())
def setUpImage(self):
......@@ -4312,14 +4313,7 @@ class NotifikasiKontributorTest(TestCase):
charset='utf-8',
)
def test_no_notification(self):
self.client.login(**self.contributor_credential)
notifs = NotifikasiKontributor.objects.filter(user=self.contributor)
self.assertEqual(notifs.count(), 0)
self.client.logout()
def test_notification(self):
# Client as Kontributor posting new Materi
def make_materi(self):
self.client.login(**self.contributor_credential)
self.client.post(
"/unggah/", data={"title":"Materi 1", "author":"Agas", "publisher":"Kelas SC", "release_year":"2000",
......@@ -4329,16 +4323,25 @@ class NotifikasiKontributorTest(TestCase):
)
self.client.logout()
# Client as Admin disapproving the Materi
def admin_disapprove_materi(self, materi, pk_new_materi):
self.client.login(**self.admin_credential)
materi = Materi.objects.get(title="Materi 1", uploader=self.contributor)
pk_new_materi = materi.id
self.client.post(
"/administration/detail-verif/"+str(pk_new_materi)+"/", data={
'kriteria-1':'0','feedback':"a", 'action':"disapprove"
}
)
self.client.logout()
def test_no_notification(self):
self.client.login(**self.contributor_credential)
notifs = NotifikasiKontributor.objects.filter(user=self.contributor)
self.assertEqual(notifs.count(), 0)
self.client.logout()
def test_notification(self):
materi = Materi.objects.get(title="Materi 1", uploader=self.contributor)
pk_new_materi = materi.id
self.admin_disapprove_materi(materi, pk_new_materi)
self.assertEqual(NotifikasiKontributor.objects.filter(materi=materi, user=self.contributor).count(), 1)
# Client as Kontributor get notifications
......@@ -4347,10 +4350,36 @@ class NotifikasiKontributorTest(TestCase):
html = self.client.get("/dashboard/").content.decode("utf-8")
self.assertIn(str(notif), html)
def test_notifications_reset_when_it_is_revised(self):
materi = Materi.objects.get(title="Materi 1", uploader=self.contributor)
pk_new_materi = materi.id
self.admin_disapprove_materi(materi, pk_new_materi)
self.assertEqual(NotifikasiKontributor.objects.filter(materi=materi, user=self.contributor).count(), 1)
self.client.login(**self.contributor_credential)
notif = NotifikasiKontributor.objects.get(materi=materi, user=self.contributor)
# Client as Kontributor check Materi detail, and the notification should be gone
self.client.get("/materi/"+str(materi.id)+"/")
response = self.client.post(
"/revisi/materi/"+str(pk_new_materi)+"/",
data={"title":"Materi 2", "author":"Agas", "publisher":"Kelas SC", "release_year":"2000",
"descriptions":"Deskripsi Materi 2", 'categories':"1", "cover":self.cover, "content":self.content,
"yt_video_id":"jNwz4L9MGVY"}
)
self.assertEqual(NotifikasiKontributor.objects.filter(materi=materi, user=self.contributor).count(), 0)
def test_notifications_reset_when_it_is_opened_in_detail(self):
materi = Materi.objects.get(title="Materi 1", uploader=self.contributor)
pk_new_materi = materi.id
self.admin_disapprove_materi(materi, pk_new_materi)
self.assertEqual(NotifikasiKontributor.objects.filter(materi=materi, user=self.contributor).count(), 1)
self.client.login(**self.contributor_credential)
notif = NotifikasiKontributor.objects.get(materi=materi, user=self.contributor)
# Client as Kontributor check Materi detail, and the notification should be gone
self.client.get("/materi/"+str(materi.id)+"/")
self.assertEqual(NotifikasiKontributor.objects.filter(materi=materi, user=self.contributor).count(), 0)
class AdminNotificationTest(TestCase):
......
......@@ -701,6 +701,11 @@ class RevisiMateriView(TemplateView):
raise PermissionDenied(request)
current_materi = get_object_or_404(Materi, pk=kwargs["pk"])
if request.user.is_authenticated and request.user.is_contributor:
opened_notif = NotifikasiKontributor.objects.filter(user=request.user, materi=current_materi)
opened_notif.delete()
form = UploadMateriForm(
request.POST, request.FILES, instance=current_materi)
if form.is_valid():
......
Markdown is supported
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