Fakultas Ilmu Komputer UI

Commit 493026c6 authored by addffa's avatar addffa
Browse files

[GREEN] membuat mutasi tambah dan ubah mustahik

parent 083aa62d
......@@ -12,7 +12,7 @@ class Mustahik(models.Model):
name = models.CharField(max_length=32)
no_ktp = models.CharField(max_length=32, unique=True)
phone = models.CharField(max_length=32, blank=True)
phone = models.CharField(max_length=32, blank=True, null=True)
address = models.TextField()
province = models.CharField(max_length=32)
regency = models.CharField(max_length=32)
......@@ -25,4 +25,4 @@ class Mustahik(models.Model):
default=Status.MISKIN,
)
family_size = models.PositiveSmallIntegerField()
description = models.TextField()
description = models.TextField(blank=True, null=True)
import graphene
from django import forms
from graphene_django.forms.mutation import DjangoModelFormMutation
from .models import Mustahik
from .types import MustahikType
class MustahikForm(forms.ModelForm):
class Meta:
model = Mustahik
fields = [
'name',
'no_ktp',
'phone',
'address',
'province',
'regency',
'rt',
'rw',
'birthdate',
'status',
'family_size',
'description',
]
class MustahikMutation(DjangoModelFormMutation):
mustahik = graphene.Field(MustahikType)
class Meta:
form_class = MustahikForm
import graphene
from graphene_django.types import DjangoObjectType
from .models import Mustahik
class MustahikType(DjangoObjectType):
class Meta:
model = Mustahik
from graphene_django import DjangoObjectType
import graphene
from graphene_django import DjangoObjectType
from .apps.mustahik.mutations import MustahikMutation
ABOUT = 'Si Zakat merupakan sistem informasi untuk membantu masjid dalam \
mengelola transaksi zakat. Sistem ini dibuat oleh tim lab 1231, \
yang dipimpin oleh Prof. Dr. Wisnu Jatmiko.'
class Query(graphene.ObjectType):
about = graphene.String()
def resolve_about(self, info):
return ABOUT
schema = graphene.Schema(query=Query)
class Mutation(graphene.ObjectType):
mustahik_mutation = MustahikMutation.Field()
schema = graphene.Schema(query=Query, mutation=Mutation)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment