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
Sistem Informasi Zakat
Sizakat 5.0 (Refactoring)
Sizakat Backend
Commits
d78e988f
Commit
d78e988f
authored
Aug 07, 2020
by
addffa
Browse files
[GREEN] implementasi query search datasource
parent
d8bfe8e2
Pipeline
#51317
passed with stage
in 8 minutes and 36 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
sizakat/mustahik/query.py
View file @
d78e988f
...
...
@@ -14,7 +14,10 @@ class MustahikQuery(graphene.ObjectType):
name_contains
=
graphene
.
String
()
)
mustahik
=
graphene
.
Field
(
MustahikType
,
id
=
graphene
.
ID
(
required
=
True
))
data_sources
=
graphene
.
List
(
DataSourceType
,
category
=
graphene
.
String
())
data_sources
=
graphene
.
List
(
DataSourceType
,
category
=
graphene
.
String
(),
name_contains
=
graphene
.
String
()
)
data_source
=
graphene
.
Field
(
DataSourceType
,
id
=
graphene
.
ID
(
required
=
True
))
def
resolve_mustahiks
(
self
,
info
,
**
kwargs
):
...
...
@@ -37,11 +40,22 @@ class MustahikQuery(graphene.ObjectType):
return
Mustahik
.
objects
.
get
(
pk
=
id
)
def
resolve_data_sources
(
self
,
info
,
**
kwargs
):
category
=
kwargs
.
get
(
'category'
)
category
=
kwargs
.
get
(
'category'
,
None
)
query
=
kwargs
.
get
(
'name_contains'
,
None
)
filter_query
=
Q
()
if
category
:
filter_query
&=
Q
(
category
=
category
)
if
query
:
filter_query
&=
(
Q
(
datasourceinstitusi__name__icontains
=
query
)
|
Q
(
datasourcepekerja__profession__icontains
=
query
)
|
Q
(
datasourcepekerja__location__icontains
=
query
)
|
Q
(
datasourcewarga__rt__icontains
=
query
)
|
Q
(
datasourcewarga__rw__icontains
=
query
)
|
Q
(
datasourcewarga__village__icontains
=
query
)
)
return
DataSource
.
objects
.
filter
(
filter_query
)
def
resolve_data_source
(
self
,
info
,
id
):
...
...
Write
Preview
Markdown
is supported
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