Fakultas Ilmu Komputer UI

Commit 3d06c0ac authored by addffa's avatar addffa
Browse files

[GREEN] implementasi query transaction

parent 90b2dfea
......@@ -8,13 +8,14 @@ from .mustahik.mutations import (
DataSourcePekerjaMutation, DeleteDataSource
from .mustahik.query import MustahikQuery
from .transaction.query import TransactionQuery
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(MustahikQuery, graphene.ObjectType):
class Query(MustahikQuery, TransactionQuery, graphene.ObjectType):
about = graphene.String()
def resolve_about(self, info):
from django.contrib import admin
# Register your models here.
from .models import ZakatType
......@@ -27,6 +27,9 @@ class ZakatType(models.Model):
name = models.CharField(max_length=50)
item_type = models.CharField(max_length=32, choices=ItemType.choices)
def __str__(self):
return '%s - %s' % (self.name, self.ItemType[self.item_type].label)
class Transaction(models.Model):
class PaymentType(models.TextChoices):
import graphene
from .models import Transaction, ZakatType as ZakatTypeModel
from .types import TransactionType, ZakatType
class TransactionQuery(graphene.ObjectType):
transactions = graphene.List(TransactionType)
transaction = graphene.Field(
TransactionType, transaction_id=graphene.ID(required=True)
zakat_types = graphene.List(ZakatType)
def resolve_transactions(self, info, **kwargs):
return Transaction.objects.all()
def resolve_transaction(self, info, transaction_id):
return Transaction.objects.get(pk=transaction_id)
def resolve_zakat_types(self, info, **kwargs):
return ZakatTypeModel.objects.all()
import graphene
from graphene_django.types import DjangoObjectType
from .models import (
Muzakki, Transaction, ZakatTransaction, ZakatType as ZakatTypeModel
class MuzakkiType(DjangoObjectType):
class Meta:
model = Muzakki
class TransactionType(DjangoObjectType):
class Meta:
model = Transaction
class ZakatTransactionType(DjangoObjectType):
class Meta:
model = ZakatTransaction
class ZakatType(DjangoObjectType):
class Meta:
model = ZakatTypeModel
exclude = ('zakattransaction_set', )
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