evg-app-back/organisations/gqlTypes.py

82 lines
1.8 KiB
Python
Raw Normal View History

2021-01-10 15:51:59 +03:00
import graphene_django
2021-01-20 22:10:57 +03:00
from .models import Organisation, Role, Group, Teacher, Child, Organisator
from graphene import relay
import graphene
2021-01-10 15:51:59 +03:00
print(Teacher, Child)
2021-01-20 22:10:57 +03:00
class OrganisatorType(graphene_django.DjangoObjectType):
class Meta:
model = Organisator
interfaces = (relay.Node,)
filter_fields = {
"name": ("exact", "contains"),
"surname": ("exact", "contains"),
"midname": ("exact", "contains"),
"org" : ("exact",),
"profile" : ("exact",),
"groups" : ("contains",)
}
2021-01-10 15:51:59 +03:00
class OrganisationType(graphene_django.DjangoObjectType):
class Meta:
model = Organisation
2021-01-20 22:10:57 +03:00
interfaces = (relay.Node,)
filter_fields = {
"name" : ("exact", "contains",),
}
2021-01-10 15:51:59 +03:00
class RoleType(graphene_django.DjangoObjectType):
class Meta:
model = Role
class TeacherType(graphene_django.DjangoObjectType):
class Meta:
model = Teacher
2021-01-20 22:10:57 +03:00
interfaces = (relay.Node,)
filter_fields = {
"name": ("exact", "contains"),
"surname": ("exact", "contains"),
"midname": ("exact", "contains"),
"org" : ("exact",),
"profile" : ("exact",),
"groups" : ("contains",)
}
pk = graphene.Int()
def resolve_pk(self, info): return self.pk
2021-01-10 15:51:59 +03:00
class ChildType(graphene_django.DjangoObjectType):
class Meta:
2021-01-20 22:10:57 +03:00
model = Child
interfaces = (relay.Node,)
filter_fields = {
"name": ("exact", "contains"),
"surname": ("exact", "contains"),
"midname": ("exact", "contains"),
"org" : ("exact",),
"profile" : ("exact",),
"groups" : ("contains",)
}
pk = graphene.Int()
def resolve_pk(self, info): return self.pk
class GroupType(graphene_django.DjangoObjectType):
class Meta:
model = Group
interfaces = (relay.Node,)
filter_fields = {
"name" : ("exact", "contains"),
}
pk = graphene.Int()
def resolve(self, info):
return self.pk