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
8db4e2fe
Commit
8db4e2fe
authored
Oct 31, 2020
by
Yusuf T Ardho
Browse files
Merge branch '1706074985-103' into 'master'
[
#103
] Report Abuse/Mistake See merge request
!87
parents
36a53e82
b1b198c2
Pipeline
#60156
passed with stages
in 27 minutes and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/templates/app/detail_materi.html
View file @
8db4e2fe
...
...
@@ -284,6 +284,11 @@ div.review {
<em
class=
"align-self-center far fa-square"
id=
"readLaterText"
></em>
Baca Nanti
</button>
{% endif %}
<button
class=
"btn btn-book shadow-sm p-2 mr-2 bg-white rounded align-self-center"
type=
"button"
aria-haspopup=
"true"
aria-expanded=
"false"
data-toggle=
"modal"
data-target=
"#reportModal"
>
<em></em>
Laporkan
</button>
</div>
</div>
</div>
...
...
@@ -469,6 +474,51 @@ div.review {
</div>
</div>
</div>
<div
class=
"modal fade"
id=
"reportModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"reportModal"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"reportModal"
>
{% if user.is_authenticated %}
Laporkan Materi
{% else %}
Belum Login
{% endif %}
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<form
method=
"POST"
>
<div
class=
"modal-body"
>
{% if user.is_authenticated %}
<p>
Judul materi:
<b>
{{ materi_data.title }}
</b><br></p>
{% csrf_token %}
<div
class=
"form-group"
>
<textarea
placeholder=
"Alasan laporan..."
class=
"form-control"
id=
"exampleFormControlTextarea1"
rows=
"3"
name=
"report"
required
></textarea>
</div>
{% else %}
Login untuk melaporkan materi
{% endif %}
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Batal
</button>
{% if user.is_authenticated %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Laporkan Materi
{% else %}
<button
type=
"button"
class=
"btn btn-primary"
onclick=
"window.location.href = '/login';"
>
Login
{% endif %}
</button>
</div>
</form>
</div>
</div>
</div>
{% endblock content %}
{% block extra_scripts %}
<script
src=
"https://kit.fontawesome.com/bc2cedd6b2.js"
crossorigin=
"anonymous"
></script>
...
...
app/tests.py
View file @
8db4e2fe
...
...
@@ -49,6 +49,7 @@ from .views import (DaftarKatalog, DashboardKontributorView, DetailMateri,
KatalogPerKontributorView
,
MateriFavorite
,
PasswordChangeViews
,
PostsView
,
ProfilView
,
ReqMateriView
,
RevisiMateriView
,
SuksesLoginAdminView
,
LaporanMateri
,
SuksesLoginKontributorView
,
SuntingProfilView
,
UploadMateriExcelView
,
UploadMateriView
,
password_success
)
...
...
@@ -527,6 +528,14 @@ class DetailMateriTest(TestCase):
self
.
assertIn
(
"Anda belum menuliskan komentar"
,
response
.
context
[
"error_message"
])
def
test_post_blank_report
(
self
):
url
=
self
.
url
self
.
client
.
login
(
**
self
.
anonymous_credential
)
response
=
self
.
client
.
post
(
url
,
{
"report"
:
""
})
self
.
assertIn
(
"error_message"
,
response
.
context
)
self
.
assertIn
(
"Anda belum menuliskan komentar"
,
response
.
context
[
"error_message"
])
def
test_comment_rendered_to_template
(
self
):
url
=
self
.
url
self
.
client
.
login
(
**
self
.
contributor_credential
)
...
...
@@ -534,6 +543,13 @@ class DetailMateriTest(TestCase):
response
=
Client
().
get
(
url
)
self
.
assertContains
(
response
,
"This is my new comment"
)
def
test_report_rendered_to_template
(
self
):
url
=
self
.
url
self
.
client
.
login
(
**
self
.
contributor_credential
)
self
.
client
.
post
(
url
,
{
"report"
:
"This is my new comment"
})
response
=
Client
().
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_comment_by_admin
(
self
):
url
=
self
.
url
self
.
client
.
login
(
**
self
.
admin_credential
)
...
...
app/views.py
View file @
8db4e2fe
...
...
@@ -30,6 +30,7 @@ from app.models import (
Comment
,
Review
,
Materi
,
LaporanMateri
,
ReqMaterial
,
Rating
,
RatingContributor
,
SubmitVisitor
,
...
...
@@ -190,7 +191,10 @@ class DetailMateri(TemplateView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
comment_text
=
request
.
POST
.
get
(
"comment"
,
None
)
review_text
=
request
.
POST
.
get
(
"review"
,
None
)
if
((
comment_text
==
None
or
comment_text
==
""
)
and
(
review_text
==
None
or
review_text
==
""
)):
report_text
=
request
.
POST
.
get
(
"report"
,
None
)
if
((
comment_text
==
None
or
comment_text
==
""
)
and
\
(
review_text
==
None
or
review_text
==
""
)
and
\
(
report_text
==
None
or
report_text
==
""
)):
context
=
self
.
get_context_data
(
*
args
,
**
kwargs
)
context
[
"error_message"
]
=
"Anda belum menuliskan komentar"
context
[
"materi_data"
]
=
get_object_or_404
(
Materi
,
pk
=
kwargs
[
"pk"
])
...
...
@@ -226,6 +230,11 @@ class DetailMateri(TemplateView):
review
=
review_text
,
username
=
DetailMateriService
.
get_user_name
(
request
),
materi
=
materi
,
user
=
user_obj
)
review
.
save
()
elif
(
report_text
!=
None
):
laporan_materi
=
LaporanMateri
.
objects
.
create
(
materi
=
materi
,
laporan
=
report_text
,
user
=
user_obj
)
laporan_materi
.
save
()
return
HttpResponseRedirect
(
request
.
path
)
...
...
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