# Path: bucketlistapp/bucketlist/models.py
# class Bucketlist(models.Model):
# 
#     '''Bucketlist Models defined here.'''
# 
#     name = models.CharField(max_length=100, blank=True)
#     date_created = models.DateTimeField(auto_now_add=True)
#     date_modified = models.DateTimeField(auto_now=True)
#     created_by = models.CharField(max_length=100, blank=True)
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="buckets")
# 
#     def __unicode__(self):
#         return "Bucketlist: %s user: %s" % (self.name, self.user)
# 
#     class Meta:
#         ordering = ('-date_created',)
# 
# class BucketlistItem(models.Model):
# 
#     '''BucketlistItem Models defined here.'''
# 
#     name = models.CharField(max_length=500, blank=True)
#     date_created = models.DateTimeField(auto_now_add=True)
#     date_modified = models.DateTimeField(auto_now=True)
#     done = models.BooleanField()
#     bucketlist = models.ForeignKey(Bucketlist, related_name="items")
# 
#     def __unicode__(self):
#         return "BucketlistItem: %s" % (self.name)
# 
#     class Meta:
#         ordering = ('-date_created',)


import graphene
from graphene import relay, ObjectType
from graphene.contrib.django.filter import DjangoFilterConnectionField
from graphene.contrib.django.types import DjangoNode
from graphene.contrib.django.debug import DjangoDebugMiddleware, DjangoDebug
from .models import Bucketlist, BucketlistItem
    class Meta:
        model = Bucketlist
        filter_fields = {
            'name': ['icontains', 'istartswith', 'exact'],
            'user': ['exact'],
        }
        filter_order_by = ['name']


class BucketlistItemNode(DjangoNode):

    class Meta:
        model = BucketlistItem
        # Allow for some more advanced filtering here
        filter_fields = {
            'name': ['exact', 'icontains', 'istartswith'],
            'bucketlist': ['exact'],
            'bucketlist__name': ['exact'],
        }
        filter_order_by = ['name', 'bucketlist__name']


class Query(ObjectType):

    bucketlist = relay.NodeField(BucketlistNode)
    all_bucketlist = DjangoFilterConnectionField(BucketlistNode)

    Bucketlistitem = relay.NodeField(BucketlistItemNode)
    all_bucketlistitem = DjangoFilterConnectionField(BucketlistItemNode)


# Path: bucketlistapp/bucketlist/models.py
# class Bucketlist(models.Model):
# 
#     '''Bucketlist Models defined here.'''
# 
#     name = models.CharField(max_length=100, blank=True)
#     date_created = models.DateTimeField(auto_now_add=True)
#     date_modified = models.DateTimeField(auto_now=True)
#     created_by = models.CharField(max_length=100, blank=True)
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="buckets")
# 
#     def __unicode__(self):
#         return "Bucketlist: %s user: %s" % (self.name, self.user)
# 
#     class Meta:
#         ordering = ('-date_created',)
# 
# class BucketlistItem(models.Model):
# 
#     '''BucketlistItem Models defined here.'''
# 
#     name = models.CharField(max_length=500, blank=True)
#     date_created = models.DateTimeField(auto_now_add=True)
#     date_modified = models.DateTimeField(auto_now=True)
#     done = models.BooleanField()
#     bucketlist = models.ForeignKey(Bucketlist, related_name="items")
# 
#     def __unicode__(self):
#         return "BucketlistItem: %s" % (self.name)
# 
#     class Meta:
#         ordering = ('-date_created',)


# Path: bucketlistapp/bucketlist/schema.py
import graphene
from graphene import relay, ObjectType
from graphene.contrib.django.filter import DjangoFilterConnectionField
from graphene.contrib.django.types import DjangoNode
from graphene.contrib.django.debug import DjangoDebugMiddleware, DjangoDebug
from .models import Bucketlist, BucketlistItem

    class Meta:
        model = Bucketlist
        filter_fields = {
            'name': ['icontains', 'istartswith', 'exact'],
            'user': ['exact'],
        }
        filter_order_by = ['name']


class BucketlistItemNode(DjangoNode):

    class Meta:
        model = BucketlistItem
        # Allow for some more advanced filtering here
        filter_fields = {
            'name': ['exact', 'icontains', 'istartswith'],
            'bucketlist': ['exact'],
            'bucketlist__name': ['exact'],
        }
        filter_order_by = ['name', 'bucketlist__name']


class Query(ObjectType):

    bucketlist = relay.NodeField(BucketlistNode)
    all_bucketlist = DjangoFilterConnectionField(BucketlistNode)

    Bucketlistitem = relay.NodeField(BucketlistItemNode)
    all_bucketlistitem = DjangoFilterConnectionField(BucketlistItemNode)


    debug = graphene.Field(DjangoDebug, name='__debug')