Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
DIGIPUS
Commits
a987c69c
Commit
a987c69c
authored
Nov 17, 2020
by
Nurma Ayu Wigati S. Subroto
Browse files
Merge branch '1906438014-45' into 'master'
[
#45
] Update Rating See merge request
!115
parents
bdacd895
3a3c5e56
Pipeline
#60708
passed with stages
in 23 minutes and 55 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
app/templates/given-rating.html
View file @
a987c69c
...
...
@@ -89,6 +89,7 @@
<th
scope=
"col"
>
Judul Materi
</th>
<th
scope=
"col"
>
Tanggal
</th>
<th
scope=
"col"
>
Rating
</th>
<th
scope=
"col"
>
Keterangan
</th>
</tr>
</thead>
<tbody>
...
...
@@ -98,6 +99,9 @@
<td><a
href=
"/materi/1/"
>
{{ i.materi.title }}
</a></td>
<td>
{{ i.timestamp }}
</td>
<td>
{{ i.score }}
</td>
<td>
<a
href=
"/edit/{{ i.score }}"
><span
class=
"glyphicon glyphicon-pencil"
>
Edit
</span></a>
</td>
</tr>
{% endfor %}
...
...
app/tests.py
View file @
a987c69c
...
...
@@ -49,7 +49,7 @@ from app.forms import SuntingProfilForm, year_choices, GuestBookForm
from
app.utils.fileManagementUtil
import
(
get_random_filename
,
remove_image_exifdata
)
from
app.utils.PasswordValidator
import
PasswordPolicyValidator
from
app.views
import
UploadMateriHTML
,
add_rating_materi
from
app.views
import
UploadMateriHTML
,
add_rating_materi
,
edit_rating_materi
from
.models
import
(
Category
,
Comment
,
DislikeComment
,
DownloadStatistics
,
Like
,
LikeComment
,
Materi
,
Rating
,
RatingContributor
,
...
...
@@ -2338,6 +2338,10 @@ class RatingMateriTest(TestCase):
def
test_rating_materi_url_use_add_rating_materi_function
(
self
):
found
=
resolve
(
self
.
url_rate
)
self
.
assertEqual
(
found
.
func
,
add_rating_materi
)
def
test_rating_materi_url_use_edit_rating_materi_function
(
self
):
found
=
resolve
(
self
.
url_rate
)
self
.
assertEqual
(
found
.
func
,
add_rating_materi
)
def
test_rating_materi_get_method_should_return_403_forbidden
(
self
):
response
=
self
.
client
.
get
(
self
.
url_rate
)
...
...
@@ -2589,6 +2593,11 @@ class RatingContributorTest(TransactionTestCase):
score
=
3
,
contributor
=
self
.
contributor
,
user
=
self
.
anonymous
)
self
.
assertEqual
(
1
,
RatingContributor
.
objects
.
count
())
def
test_edit_rating_contributor
(
self
):
RatingContributor
.
objects
.
create
(
score
=
3
,
contributor
=
self
.
contributor
,
user
=
self
.
anonymous
)
self
.
assertEqual
(
1
,
RatingContributor
.
objects
.
count
())
def
test_add_rating_contributor_should_failed_when_negative
(
self
):
with
self
.
assertRaises
(
ValidationError
):
RatingContributor
.
objects
.
create
(
...
...
app/urls.py
View file @
a987c69c
...
...
@@ -40,6 +40,7 @@ urlpatterns = [
path
(
"profil/<str:email>/"
,
KatalogPerKontributorView
.
as_view
(),
name
=
"katalog-per-kontributor"
),
path
(
"materi/rate/"
,
views
.
add_rating_materi
,
name
=
"rate-materi"
),
path
(
"edit/rate/"
,
views
.
edit_rating_materi
,
name
=
"edit-materi"
),
path
(
"materi/<int:pk>/save-to-gdrive/"
,
views
.
save_to_gdrive
,
name
=
"save-to-gdrive"
),
path
(
"favorite/"
,
MateriFavorite
.
as_view
(),
name
=
"favorite"
),
...
...
app/views.py
View file @
a987c69c
...
...
@@ -331,8 +331,10 @@ def add_rating_materi(request):
{
"success"
:
True
,
"msg"
:
"Rating successfully created"
,
"rating_score"
:
rating_score
},
status
=
201
)
return
JsonResponse
({
"success"
:
False
,
"msg"
:
"Forbidden"
},
status
=
403
)
def
edit_rating_materi
(
request
,
pk
):
rating
=
get_object_or_404
(
Rating
,
pk
=
pk
)
def
download_materi
(
request
,
pk
):
materi
=
get_object_or_404
(
Materi
,
pk
=
pk
)
path
=
materi
.
content
.
path
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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