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
0044d8e4
Commit
0044d8e4
authored
Oct 08, 2020
by
Steven Kusuman
Browse files
[
#113
] Bugfix: dashboard
parent
8fd552b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/tests.py
View file @
0044d8e4
...
...
@@ -365,13 +365,15 @@ class UploadPageTest(TestCase):
self
.
client
=
Client
()
self
.
user
=
User
.
objects
.
_create_user
(
email
=
"kontributor@gov.id"
,
password
=
"kontributor"
,
is_contributor
=
True
)
self
.
admin
=
User
.
objects
.
create_admin
(
email
=
"admin@gov.id"
,
password
=
"admin"
)
def
test_upload_page_using_login_func
(
self
):
found
=
resolve
(
"/unggah/"
)
self
.
assertEqual
(
found
.
func
.
__name__
,
UploadMateriView
.
as_view
().
__name__
)
def
test_upl
a
od_page_url_is_exist
(
self
):
def
test_uplo
a
d_page_url_is_exist
(
self
):
# Positive test
self
.
client
.
login
(
email
=
"kontributor@gov.id"
,
password
=
"kontributor"
)
...
...
@@ -384,6 +386,18 @@ class UploadPageTest(TestCase):
response
=
Client
().
get
(
"/fake/"
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_upload_page_url_admin_doesnt_exist
(
self
):
self
.
client
.
login
(
email
=
"admin@gov.id"
,
password
=
"admin"
)
response
=
self
.
client
.
get
(
"/unggah/"
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_upload_page_url_admin_cant_upload
(
self
):
self
.
client
.
login
(
email
=
"admin@gov.id"
,
password
=
"admin"
)
response
=
self
.
client
.
post
(
"/unggah/"
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_upload_page_template
(
self
):
url
=
"/unggah/"
self
.
client
.
login
(
email
=
"kontributor@gov.id"
,
...
...
app/views.py
View file @
0044d8e4
...
...
@@ -282,7 +282,7 @@ class UploadMateriView(TemplateView):
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
user
.
is_authenticated
==
False
:
if
request
.
user
.
is_authenticated
==
False
or
not
request
.
user
.
is_contributor
:
raise
PermissionDenied
(
request
)
form
=
UploadMateriForm
(
request
.
POST
,
request
.
FILES
)
if
form
.
is_valid
():
...
...
@@ -308,8 +308,9 @@ class UploadMateriView(TemplateView):
return
self
.
render_to_response
(
context
)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
user
.
is_authenticated
==
False
:
if
request
.
user
.
is_authenticated
==
False
or
not
request
.
user
.
is_contributor
:
raise
PermissionDenied
(
request
)
context
=
self
.
get_context_data
(
**
kwargs
)
context
[
"form"
]
=
UploadMateriForm
return
self
.
render_to_response
(
context
)
...
...
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