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
6f594867
Commit
6f594867
authored
Aug 01, 2020
by
addffa
Browse files
[REFACTOR] memindahkan fungsi get detil ke model
parent
b752cb6c
Changes
3
Show whitespace changes
Inline
Side-by-side
sizakat/mustahik/models.py
View file @
6f594867
...
...
@@ -51,6 +51,14 @@ class DataSource(models.Model):
category
=
models
.
CharField
(
max_length
=
32
,
choices
=
Category
.
choices
)
def
get_source_detail
(
self
):
if
self
.
category
==
DataSource
.
Category
.
INSTITUSI
:
return
DataSourceInstitusi
.
objects
.
get
(
data_source
=
self
)
if
self
.
category
==
DataSource
.
Category
.
PEKERJA
:
return
DataSourcePekerja
.
objects
.
get
(
data_source
=
self
)
if
self
.
category
==
DataSource
.
Category
.
WARGA
:
return
DataSourceWarga
.
objects
.
get
(
data_source
=
self
)
class
DataSourceDetail
(
models
.
Model
):
class
Meta
:
...
...
sizakat/mustahik/types.py
View file @
6f594867
...
...
@@ -45,12 +45,6 @@ class DataSourceType(DjangoObjectType):
'datasourceinstitusi'
,
'datasourcepekerja'
,
'datasourcewarga'
)
data_source_detail
=
graphene
.
Field
(
DataSourceDetailType
)
def
resolve_data_source_detail
(
self
,
info
):
if
self
.
category
==
DataSource
.
Category
.
INSTITUSI
:
return
DataSourceInstitusi
.
objects
.
get
(
data_source__pk
=
self
.
pk
)
if
self
.
category
==
DataSource
.
Category
.
PEKERJA
:
return
DataSourcePekerja
.
objects
.
get
(
data_source__pk
=
self
.
pk
)
if
self
.
category
==
DataSource
.
Category
.
WARGA
:
return
DataSourceWarga
.
objects
.
get
(
data_source__pk
=
self
.
pk
)
data_source_detail
=
graphene
.
Field
(
DataSourceDetailType
,
source
=
'get_source_detail'
)
sizakat/schema.py
View file @
6f594867
...
...
@@ -2,7 +2,11 @@ import graphene
from
graphene_django
import
DjangoObjectType
from
.mustahik.mutations
import
MustahikMutation
,
DeleteMustahik
,
DataSourceMutation
,
DataSourceWargaMutation
,
DataSourceInstitusiMutation
,
DataSourcePekerjaMutation
from
.mustahik.mutations
import
(
MustahikMutation
,
DeleteMustahik
,
DataSourceMutation
,
DataSourceWargaMutation
,
DataSourceInstitusiMutation
,
DataSourcePekerjaMutation
)
from
.mustahik.query
import
MustahikQuery
ABOUT
=
(
'Si Zakat merupakan sistem informasi untuk membantu masjid dalam '
...
...
Write
Preview
Supports
Markdown
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