# Path: tests/core/external.py
# class BaseDocument (seeker.Indexable):
#     base_field = dsl.String()
# 
# Path: tests/core/models.py
# class Book (models.Model):
#     title = models.CharField(max_length=200)
#     authors = models.ManyToManyField(Author, related_name='books', blank=True)
#     category = models.ForeignKey(Category, related_name='books', null=True, blank=True)
#     date_published = models.DateField(default=datetime.date.today)
#     pages = models.IntegerField(default=0)
#     in_print = models.BooleanField(default=True)
# 
#     def __str__(self):
#         return self.title
# 
# class Magazine (models.Model):
#     name = models.CharField(max_length=200)
#     issue_date = models.DateField(default=datetime.date.today)
# 
#     def __str__(self):
#         return self.name


import elasticsearch_dsl as dsl
import seeker
from .external import BaseDocument
from .models import Book, Magazine




BookDocument = seeker.document_from_model(Book, module=__name__)
MagazineDocument = seeker.document_from_model(Magazine, module=__name__)


class DjangoBookDocument (seeker.ModelIndex):

    class Meta:
        mapping = seeker.build_mapping(Book, doc_type='django_book')

    @classmethod
    def queryset(cls):

# Path: tests/core/external.py
# class BaseDocument (seeker.Indexable):
#     base_field = dsl.String()
# 
# Path: tests/core/models.py
# class Book (models.Model):
#     title = models.CharField(max_length=200)
#     authors = models.ManyToManyField(Author, related_name='books', blank=True)
#     category = models.ForeignKey(Category, related_name='books', null=True, blank=True)
#     date_published = models.DateField(default=datetime.date.today)
#     pages = models.IntegerField(default=0)
#     in_print = models.BooleanField(default=True)
# 
#     def __str__(self):
#         return self.title
# 
# class Magazine (models.Model):
#     name = models.CharField(max_length=200)
#     issue_date = models.DateField(default=datetime.date.today)
# 
#     def __str__(self):
#         return self.name


# Path: tests/core/mappings.py
import elasticsearch_dsl as dsl
import seeker
from .external import BaseDocument
from .models import Book, Magazine





BookDocument = seeker.document_from_model(Book, module=__name__)
MagazineDocument = seeker.document_from_model(Magazine, module=__name__)


class DjangoBookDocument (seeker.ModelIndex):

    class Meta:
        mapping = seeker.build_mapping(Book, doc_type='django_book')

    @classmethod
    def queryset(cls):

        return Book.objects.filter(title__icontains='django')