Add start and end to instances and return them as posix.
This commit is contained in:
parent
0f11a77a92
commit
6ef26243f6
|
@ -1,4 +1,6 @@
|
||||||
from django.db.models import Q
|
import time
|
||||||
|
|
||||||
|
import graphene
|
||||||
from graphene import relay
|
from graphene import relay
|
||||||
|
|
||||||
from graphene_django import DjangoObjectType
|
from graphene_django import DjangoObjectType
|
||||||
|
@ -11,85 +13,79 @@ from .models import (
|
||||||
EventTrack,
|
EventTrack,
|
||||||
EventInstance,
|
EventInstance,
|
||||||
Speaker,
|
Speaker,
|
||||||
Url, UrlType)
|
Url,
|
||||||
|
UrlType,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EventTypeNode(DjangoObjectType):
|
class EventTypeNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = EventType
|
model = EventType
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
filter_fields = {
|
filter_fields = {"name": ["iexact"]}
|
||||||
'name': ['iexact'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class EventLocationNode(DjangoObjectType):
|
class EventLocationNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = EventLocation
|
model = EventLocation
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
filter_fields = {
|
filter_fields = {"name": ["iexact"], "camp__slug": ["iexact"]}
|
||||||
'name': ['iexact'],
|
|
||||||
'camp__slug': ['iexact'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class EventTrackNode(DjangoObjectType):
|
class EventTrackNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = EventTrack
|
model = EventTrack
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
filter_fields = {
|
filter_fields = {"name": ["iexact"], "camp__slug": ["iexact"]}
|
||||||
'name': ['iexact'],
|
|
||||||
'camp__slug': ['iexact'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class EventInstanceNode(DjangoObjectType):
|
class EventInstanceNode(DjangoObjectType):
|
||||||
|
|
||||||
|
start = graphene.Int(description="When this instance of the event starts. In posix time.")
|
||||||
|
end = graphene.Int(description="When this instance of the event ends. In posix time.")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = EventInstance
|
model = EventInstance
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
|
only_fields = ("event", "start", "end", "location")
|
||||||
filter_fields = {
|
filter_fields = {
|
||||||
'event__title': ['iexact'],
|
"event__title": ["iexact"],
|
||||||
'event__track__camp__slug': ['iexact'],
|
"event__track__camp__slug": ["iexact"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def resolve_when(self, info):
|
def resolve_start(self, info, **kwargs):
|
||||||
# We need to resolve this ourselves, graphene-django isn't smart enough
|
return time.mktime(self.when.lower.timetuple())
|
||||||
return [self.when.lower, self.when.upper]
|
|
||||||
|
def resolve_end(self, info, **kwargs):
|
||||||
|
return time.mktime(self.when.upper.timetuple())
|
||||||
|
|
||||||
|
|
||||||
class SpeakerNode(DjangoObjectType):
|
class SpeakerNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Speaker
|
model = Speaker
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
only_fields = ('id', 'name', 'biography', 'slug', 'camp', 'events',)
|
only_fields = ("id", "name", "biography", "slug", "camp", "events")
|
||||||
filter_fields = {
|
filter_fields = {"name": ["iexact"], "camp__slug": ["iexact"]}
|
||||||
'name': ['iexact'],
|
|
||||||
'camp__slug': ['iexact'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class EventNode(DjangoObjectType):
|
class EventNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Event
|
model = Event
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
filter_fields = {
|
filter_fields = {"title": ["iexact"], "track__camp__slug": ["iexact"]}
|
||||||
'title': ['iexact'],
|
|
||||||
'track__camp__slug': ['iexact'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class UrlNode(DjangoObjectType):
|
class UrlNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Url
|
model = Url
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
only_fields = ('url', 'urltype',)
|
only_fields = ("url", "urltype")
|
||||||
|
|
||||||
|
|
||||||
class UrlTypeNode(DjangoObjectType):
|
class UrlTypeNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UrlType
|
model = UrlType
|
||||||
interfaces = (relay.Node, )
|
interfaces = (relay.Node,)
|
||||||
|
|
||||||
|
|
||||||
class ProgramQuery(object):
|
class ProgramQuery(object):
|
||||||
|
|
Loading…
Reference in a new issue