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
ppl-fasilkom-ui
2020
PPL-C
PPTI-Mobile Apps Monitoring Wabah Tuberkolosis
Neza-Backend
Commits
a1311b23
Commit
a1311b23
authored
May 07, 2020
by
Dave Nathanael
Browse files
Add query param to include Positive cases on InvestigationCase list endpoint
parent
4af8c772
Changes
3
Hide whitespace changes
Inline
Side-by-side
apps/accounts/views.py
View file @
a1311b23
...
...
@@ -65,7 +65,7 @@ class AccountViewSet(viewsets.ModelViewSet):
if
User
.
objects
.
filter
(
username
=
username
).
exists
():
return
Response
(
{
"username"
:
[
"User with that username already exists."
]},
{
"username"
:
[
"User with that username already exists."
]},
status
=
status
.
HTTP_409_CONFLICT
)
...
...
apps/cases/tests/test_units/test_investigation_cases.py
View file @
a1311b23
...
...
@@ -111,6 +111,24 @@ class InvestigationCaseViewTest(APITestCase):
self
.
assertIn
(
str
(
self
.
reference_case
.
case_subject
.
id
),
response_string
)
self
.
assertIn
(
str
(
self
.
reference_case
.
author
.
id
),
response_string
)
def
test_list_all_investigation_cases_success
(
self
):
url
=
self
.
BASE_URL
+
"?include_positive=true"
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
response_string
=
response
.
rendered_content
.
decode
(
"utf-8"
)
self
.
assertIn
(
'"count":2'
,
response_string
)
self
.
assertIn
(
'"next":null'
,
response_string
)
self
.
assertIn
(
'"previous":null'
,
response_string
)
self
.
assertIn
(
str
(
self
.
case
.
id
),
response_string
)
self
.
assertIn
(
str
(
self
.
case
.
case_subject
.
id
),
response_string
)
self
.
assertIn
(
str
(
self
.
case
.
author
.
id
),
response_string
)
self
.
assertIn
(
str
(
self
.
reference_case
.
id
),
response_string
)
self
.
assertIn
(
str
(
self
.
reference_case
.
case_subject
.
id
),
response_string
)
self
.
assertIn
(
str
(
self
.
reference_case
.
author
.
id
),
response_string
)
def
test_retrieve_investigation_case_fails_on_deleted_subject
(
self
):
url
=
self
.
BASE_URL
+
str
(
self
.
other_deleted_case
.
id
)
+
"/"
...
...
apps/cases/views.py
View file @
a1311b23
...
...
@@ -68,6 +68,9 @@ class InvestigationCaseViewSet(viewsets.ModelViewSet):
def
get_queryset
(
self
):
if
self
.
action
==
'list'
:
query_include_positive
=
self
.
request
.
query_params
.
get
(
'include_positive'
,
None
)
if
query_include_positive
is
not
None
:
return
self
.
queryset
return
self
.
queryset
.
filter
(
Q
(
outcome__isnull
=
True
)
|
Q
(
outcome__icontains
=
"-"
))
return
self
.
queryset
...
...
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