# Path: puput/models.py
# class BlogPage(BlogRoutes, Page, Blog):
#     extra = BlogManager()
# 
#     content_panels = Page.content_panels + getattr(Blog, 'content_panels', [])
#     settings_panels = Page.settings_panels + getattr(Blog, 'settings_panels', [])
# 
#     subpage_types = ['puput.EntryPage']
# 
#     def get_entries(self):
#         return EntryPage.objects.descendant_of(self).live().order_by('-date').select_related('owner')
# 
#     def get_context(self, request, *args, **kwargs):
#         context = super(BlogPage, self).get_context(request, *args, **kwargs)
#         context['entries'] = self.entries
#         context['blog_page'] = self
#         context['search_type'] = getattr(self, 'search_type', "")
#         context['search_term'] = getattr(self, 'search_term', "")
#         return context
# 
#     @property
#     def last_url_part(self):
#         """
#         Get the BlogPage url without the domain
#         """
#         return self.get_url_parts()[-1]
# 
#     class Meta:
#         verbose_name = _('Blog')


from django import VERSION as DJANGO_VERSION
from django.contrib.contenttypes.models import ContentType
from django.core.management import BaseCommand
from puput.models import BlogPage
from wagtail.core.models import Page, Site



class Command(BaseCommand):
    help = "Load Puput initial dummy data"

    def handle(self, *args, **options):
        # Get blogpage content type
        blogpage_content_type, created = ContentType.objects.get_or_create(
            model='blogpage',
            app_label='puput',
            defaults={'name': 'page'} if DJANGO_VERSION < (1, 8) else {}
        )

        # Get root page

# Path: puput/models.py
# class BlogPage(BlogRoutes, Page, Blog):
#     extra = BlogManager()
# 
#     content_panels = Page.content_panels + getattr(Blog, 'content_panels', [])
#     settings_panels = Page.settings_panels + getattr(Blog, 'settings_panels', [])
# 
#     subpage_types = ['puput.EntryPage']
# 
#     def get_entries(self):
#         return EntryPage.objects.descendant_of(self).live().order_by('-date').select_related('owner')
# 
#     def get_context(self, request, *args, **kwargs):
#         context = super(BlogPage, self).get_context(request, *args, **kwargs)
#         context['entries'] = self.entries
#         context['blog_page'] = self
#         context['search_type'] = getattr(self, 'search_type', "")
#         context['search_term'] = getattr(self, 'search_term', "")
#         return context
# 
#     @property
#     def last_url_part(self):
#         """
#         Get the BlogPage url without the domain
#         """
#         return self.get_url_parts()[-1]
# 
#     class Meta:
#         verbose_name = _('Blog')


# Path: puput/management/commands/puput_initial_data.py
from django import VERSION as DJANGO_VERSION
from django.contrib.contenttypes.models import ContentType
from django.core.management import BaseCommand
from puput.models import BlogPage
from wagtail.core.models import Page, Site




class Command(BaseCommand):
    help = "Load Puput initial dummy data"

    def handle(self, *args, **options):
        # Get blogpage content type
        blogpage_content_type, created = ContentType.objects.get_or_create(
            model='blogpage',
            app_label='puput',
            defaults={'name': 'page'} if DJANGO_VERSION < (1, 8) else {}
        )

        # Get root page

        rootpage = Page.objects.first()