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
Sistem Informasi Zakat
Sizakat 5.0 (Refactoring)
Sizakat Backend
Commits
92fe44ba
Commit
92fe44ba
authored
Aug 03, 2020
by
addffa
Browse files
[REFACTOR] mengubah mutasi upload photo
parent
6123747a
Changes
2
Hide whitespace changes
Inline
Side-by-side
sizakat/mustahik/mutations.py
View file @
92fe44ba
...
...
@@ -24,13 +24,14 @@ class MustahikMutation(DjangoModelFormMutation):
@
classmethod
def
mutate_and_get_payload
(
cls
,
root
,
info
,
**
input
):
form
=
cls
.
get_form
(
root
,
info
,
**
input
)
photo
=
info
.
context
.
FILES
[
'photo'
]
if
not
validate_photo
(
photo
):
photo
=
info
.
context
.
FILES
.
get
(
'photo'
,
None
)
if
photo
and
not
validate_photo
(
photo
):
form
.
add_error
(
'photo'
,
'invalid photo format'
)
if
form
.
is_valid
():
mustahik
=
form
.
save
(
commit
=
False
)
mustahik
.
photo
=
photo
if
photo
:
mustahik
.
photo
=
photo
mustahik
.
save
()
kwargs
=
{
cls
.
_meta
.
return_field_name
:
mustahik
}
return
cls
(
errors
=
[],
**
kwargs
)
...
...
sizakat/mustahik/tests.py
View file @
92fe44ba
...
...
@@ -157,6 +157,7 @@ class MustahikGraphQLTestCase(GraphQLTestCase):
"birthdate"
:
"1998-03-12"
,
"status"
:
"MISKIN"
,
"gender"
:
"L"
,
"photo"
:
""
,
"dataSource"
:
data_source
.
pk
}
)
...
...
@@ -205,6 +206,7 @@ class MustahikGraphQLTestCase(GraphQLTestCase):
"birthdate"
:
"1987-06-05"
,
"status"
:
"MUSAFIR"
,
"gender"
:
"L"
,
"photo"
:
""
,
"id"
:
mustahik
.
pk
,
"dataSource"
:
data_source
.
pk
}
...
...
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