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
4515ac27
Commit
4515ac27
authored
Oct 23, 2020
by
Muhammad Indra Ramadhan
Browse files
[
#87
] Material Statistic: Comment Count (User View)
parent
2b1f0814
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/models.py
View file @
4515ac27
...
...
@@ -99,6 +99,11 @@ class Materi(models.Model):
def
like_count
(
self
):
count
=
Like
.
objects
.
filter
(
materi
=
self
).
count
()
return
count
@
property
def
comment_count
(
self
):
count
=
Comment
.
objects
.
filter
(
materi
=
self
).
count
()
return
count
@
property
def
is_like
(
self
):
...
...
app/templates/app/detail_materi.html
View file @
4515ac27
...
...
@@ -268,6 +268,7 @@
</div>
{% if materi_data.status == "APPROVE" %}
<div
id=
"komentar"
class=
"container-fluid comments-wrapper p-0"
>
<h1>
Komentar ({{ materi_data.comment_count }})
</h1>
{% if is_authenticated %}
<div
class=
"add-comments col col-8 bg-white shadow-sm rounded p-3 mb-3"
>
<form
method=
"POST"
>
...
...
app/tests.py
View file @
4515ac27
...
...
@@ -439,6 +439,20 @@ class DetailMateriTest(TestCase):
comment_like_counter
=
LikeComment
.
objects
.
filter
(
comment
=
comment
,
session_id
=
session_id
).
count
()
self
.
assertEqual
(
comment_like_counter
,
0
)
def
test_detail_materi_contains_comment_count
(
self
):
url
=
self
.
url
self
.
client
.
login
(
**
self
.
contributor_credential
)
response
=
self
.
client
.
get
(
url
)
self
.
assertContains
(
response
,
"Komentar (0)"
)
self
.
client
.
post
(
url
,
{
"comment"
:
"This is new comment by Contributor"
})
self
.
client
.
post
(
url
,
{
"comment"
:
"This is new comment by Contributor"
})
response
=
self
.
client
.
get
(
url
)
self
.
assertContains
(
response
,
"Komentar (2)"
)
def
test_detail_materi_contains_form_comment
(
self
):
self
.
client
.
login
(
**
self
.
contributor_credential
)
response
=
self
.
client
.
get
(
self
.
url
)
...
...
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