Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
DIGIPUS
Commits
ade89b7d
Commit
ade89b7d
authored
Nov 01, 2020
by
Edward Partogi Gembira Abyatar
Browse files
[
#129
] Dropdown template fixing
parent
8e7e67a9
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/migrations/0029_merge_20201101_0217.py
0 → 100644
View file @
ade89b7d
# 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
=
[
]
app/migrations/0031_merge_20201101_1729.py
0 → 100644
View file @
ade89b7d
# 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
=
[
]
app/templates/app/base_dashboard.html
View file @
ade89b7d
...
...
@@ -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
app/templates/app/base_profile.html
View file @
ade89b7d
...
...
@@ -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
app/templates/app/includes/navigation.html
View file @
ade89b7d
...
...
@@ -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"
>
...
...
app/tests.py
View file @
ade89b7d
...
...
@@ -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 A
dmin
disapprov
ing the M
ateri
def
a
dmin
_
disapprov
e_materi
(
self
,
materi
,
pk_new_m
ateri
):
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
):
...
...
app/views.py
View file @
ade89b7d
...
...
@@ -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
():
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment