# Path: privagal/core/factories.py
# class PageFactory(factory.DjangoModelFactory):
#     """
#     Page factory may not be created directly and thus, the default strategy
#     is forced to BUILD. To save it, you MUST to do it with a parent page.
#     Typically, you need a parent page instance and apply add_child() method:
#     >>> PageParent.add_child(instance=MyPageFactory())
#     <MyPage: Dolorem rem assumenda modi eum.>
#     """
# 
#     class Meta:
#         abstract = True
#         strategy = factory.BUILD_STRATEGY
# 
#     title = factory.Faker('sentence', locale=locale)
#     slug = factory.LazyAttributeSequence(
#         lambda o, n: '{type}_{n}'.format(
#             type=o._LazyStub__model_class._meta.model.__name__.lower(),
#             n=n,
#         )
#     )
# 
#     @classmethod
#     def _setup_next_sequence(cls):
#         """
#         Returns the last ID for persistant sequence (used by slug and so on).
# 
#         IMPORTANT: we should always have pages, at least root and timeline.
#         """
#         return (
#             Page.objects
#             .values('pk')
#             .order_by('-pk')[:1]
#         )[0]['pk'] + 1
# 
# Path: privagal/timeline/models.py
# class Timeline(AuthTokenPageMixin, Page):
# 
#     parent_page_types = []
#     subpage_types = ['gallery.Gallery']
# 
#     paginate_by = 20
# 
#     class Meta:
#         db_table = 'privagal_timeline'
# 
#     def get_context(self, request, *args, **kwargs):
#         context = super(Timeline, self).get_context(request, *args, **kwargs)
# 
#         search_query = request.GET.get('query', None)
#         context['search_query'] = search_query
# 
#         paginator, page = self.get_galleries(request, search_query)
#         context['page_obj'] = page
#         context['object_list'] = page.object_list
#         context['is_paginated'] = page.has_other_pages()
# 
#         return context
# 
#     def get_galleries(self, request, search_query):
#         qs = (
#             Gallery.objects
#             .live()
#             .prefetch_related(
#                 Prefetch(
#                     'images',
#                     queryset=ImageGallery.objects.select_related('image'),
#                 )
#             )
#             .order_by('-date')
#         )
# 
#         if search_query:
#             qs = qs.search(search_query, order_by_relevance=False)
# 
#         return paginate(request, qs, per_page=self.paginate_by)


from django.utils.translation import get_language, to_locale
from faker import Factory as FakerFactory
from privagal.core.factories import PageFactory
from .models import Timeline
import factory
# -*- coding: utf-8 -*-
from __future__ import unicode_literals





language = get_language() or 'en-us'
locale = to_locale(language)
faker = FakerFactory.create(locale)



# Path: privagal/core/factories.py
# class PageFactory(factory.DjangoModelFactory):
#     """
#     Page factory may not be created directly and thus, the default strategy
#     is forced to BUILD. To save it, you MUST to do it with a parent page.
#     Typically, you need a parent page instance and apply add_child() method:
#     >>> PageParent.add_child(instance=MyPageFactory())
#     <MyPage: Dolorem rem assumenda modi eum.>
#     """
# 
#     class Meta:
#         abstract = True
#         strategy = factory.BUILD_STRATEGY
# 
#     title = factory.Faker('sentence', locale=locale)
#     slug = factory.LazyAttributeSequence(
#         lambda o, n: '{type}_{n}'.format(
#             type=o._LazyStub__model_class._meta.model.__name__.lower(),
#             n=n,
#         )
#     )
# 
#     @classmethod
#     def _setup_next_sequence(cls):
#         """
#         Returns the last ID for persistant sequence (used by slug and so on).
# 
#         IMPORTANT: we should always have pages, at least root and timeline.
#         """
#         return (
#             Page.objects
#             .values('pk')
#             .order_by('-pk')[:1]
#         )[0]['pk'] + 1
# 
# Path: privagal/timeline/models.py
# class Timeline(AuthTokenPageMixin, Page):
# 
#     parent_page_types = []
#     subpage_types = ['gallery.Gallery']
# 
#     paginate_by = 20
# 
#     class Meta:
#         db_table = 'privagal_timeline'
# 
#     def get_context(self, request, *args, **kwargs):
#         context = super(Timeline, self).get_context(request, *args, **kwargs)
# 
#         search_query = request.GET.get('query', None)
#         context['search_query'] = search_query
# 
#         paginator, page = self.get_galleries(request, search_query)
#         context['page_obj'] = page
#         context['object_list'] = page.object_list
#         context['is_paginated'] = page.has_other_pages()
# 
#         return context
# 
#     def get_galleries(self, request, search_query):
#         qs = (
#             Gallery.objects
#             .live()
#             .prefetch_related(
#                 Prefetch(
#                     'images',
#                     queryset=ImageGallery.objects.select_related('image'),
#                 )
#             )
#             .order_by('-date')
#         )
# 
#         if search_query:
#             qs = qs.search(search_query, order_by_relevance=False)
# 
#         return paginate(request, qs, per_page=self.paginate_by)


# Path: privagal/timeline/factories.py
from django.utils.translation import get_language, to_locale
from faker import Factory as FakerFactory
from privagal.core.factories import PageFactory
from .models import Timeline
import factory

# -*- coding: utf-8 -*-
from __future__ import unicode_literals





language = get_language() or 'en-us'
locale = to_locale(language)
faker = FakerFactory.create(locale)



class TimelineFactory(PageFactory):