bornhack-website/src/bornhack/schema.py
Thomas Steen Rasmussen 00af109e2f
add flake8 and isort to pre-commit config, make flake8 and isort happy (#441)
* add flake8 to pre-commit config, and fixup many things to make flake8 happy

* add isort and sort all imports, add to pre-commit and requirements
2020-02-12 13:10:41 +01:00

45 lines
1.1 KiB
Python

from graphene import ObjectType, Schema, relay
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
interfaces = (relay.Node,)
filter_fields = {"title": ["icontains", "iexact"]}
only_fields = (
"title",
"slug",
"tagline",
"shortslug",
"buildup",
"camp",
"teardown",
"colour",
)
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)