2020-02-12 12:10:41 +00:00
|
|
|
from graphene import ObjectType, Schema, relay
|
2019-03-11 19:26:36 +00:00
|
|
|
from graphene_django import DjangoObjectType
|
|
|
|
from graphene_django.filter import DjangoFilterConnectionField
|
|
|
|
|
|
|
|
from camps.models import Camp
|
|
|
|
from program.schema import ProgramQuery
|
|
|
|
|
|
|
|
|
|
|
|
class CampNode(DjangoObjectType):
|
|
|
|
class Meta:
|
|
|
|
model = Camp
|
2019-06-16 12:32:24 +00:00
|
|
|
interfaces = (relay.Node,)
|
|
|
|
filter_fields = {"title": ["icontains", "iexact"]}
|
2019-03-11 19:26:36 +00:00
|
|
|
only_fields = (
|
2019-06-16 12:32:24 +00:00
|
|
|
"title",
|
|
|
|
"slug",
|
|
|
|
"tagline",
|
|
|
|
"shortslug",
|
|
|
|
"buildup",
|
|
|
|
"camp",
|
|
|
|
"teardown",
|
|
|
|
"colour",
|
2019-03-11 19:26:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def resolve_buildup(self, info):
|
|
|
|
return [self.buildup.lower, self.buildup.upper]
|
|
|
|
|
|
|
|
def resolve_camp(self, info):
|
|
|
|
return [self.camp.lower, self.camp.upper]
|
|
|
|
|
|
|
|
def resolve_teardown(self, info):
|
|
|
|
return [self.teardown.lower, self.teardown.upper]
|
|
|
|
|
|
|
|
|
|
|
|
class CampQuery(object):
|
|
|
|
camp = relay.Node.Field(CampNode)
|
|
|
|
all_camps = DjangoFilterConnectionField(CampNode)
|
|
|
|
|
|
|
|
|
|
|
|
class Query(CampQuery, ProgramQuery, ObjectType):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
schema = Schema(query=Query)
|