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
db50eef5
Commit
db50eef5
authored
Jul 18, 2020
by
Ilma Ainur Rohma
Browse files
[GREEN] add read detail query and delete mutation
parent
549622a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
sizakat/mustahik/mutations.py
View file @
db50eef5
...
...
@@ -32,4 +32,15 @@ class MustahikMutation(DjangoModelFormMutation):
mustahik
=
graphene
.
Field
(
MustahikType
)
class
Meta
:
form_class
=
MustahikForm
\ No newline at end of file
form_class
=
MustahikForm
class
DeleteMustahik
(
graphene
.
Mutation
):
class
Arguments
:
id
=
graphene
.
ID
()
mustahik
=
graphene
.
Field
(
MustahikType
)
def
mutate
(
self
,
info
,
id
):
mustahik
=
Mustahik
.
objects
.
get
(
pk
=
id
)
if
mustahik
is
not
None
:
mustahik
.
delete
()
sizakat/mustahik/query.py
View file @
db50eef5
...
...
@@ -6,6 +6,7 @@ from .types import MustahikType
class
MustahikQuery
(
graphene
.
ObjectType
):
mustahiks
=
graphene
.
List
(
MustahikType
,
statuses
=
graphene
.
List
(
graphene
.
String
))
mustahik
=
graphene
.
Field
(
MustahikType
,
id
=
graphene
.
ID
())
def
resolve_mustahiks
(
self
,
info
,
statuses
=
[],
**
kwargs
):
if
statuses
and
len
(
statuses
)
>
0
:
...
...
@@ -16,3 +17,8 @@ class MustahikQuery(graphene.ObjectType):
return
Mustahik
.
objects
.
all
()
def
resolve_mustahik
(
self
,
info
,
id
):
mustahik
=
Mustahik
.
objects
.
get
(
pk
=
id
)
if
mustahik
is
not
None
:
return
mustahik
sizakat/mustahik/tests.py
View file @
db50eef5
...
...
@@ -279,6 +279,8 @@ class MustahikGraphQLTestCase(GraphQLTestCase):
op_name
=
'detailMustahikQuery'
,
variables
=
{
'id'
:
mustahik_id
}
)
self
.
assertResponseNoErrors
(
response
)
content
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
len
(
content
[
'data'
]),
1
)
self
.
assertEqual
(
content
[
'data'
][
'mustahik'
][
'name'
],
'mustahik'
)
...
...
sizakat/schema.py
View file @
db50eef5
...
...
@@ -2,7 +2,7 @@ import graphene
from
graphene_django
import
DjangoObjectType
from
.mustahik.mutations
import
MustahikMutation
from
.mustahik.mutations
import
MustahikMutation
,
DeleteMustahik
from
.mustahik.query
import
MustahikQuery
ABOUT
=
'Si Zakat merupakan sistem informasi untuk membantu masjid dalam \
...
...
@@ -19,6 +19,7 @@ class Query(MustahikQuery, graphene.ObjectType):
class
Mutation
(
graphene
.
ObjectType
):
mustahik_mutation
=
MustahikMutation
.
Field
()
delete_mustahik
=
DeleteMustahik
.
Field
()
schema
=
graphene
.
Schema
(
query
=
Query
,
mutation
=
Mutation
)
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