# Path: core/models.py
# class HomePage(Page, IndexPage):
#     """
#     HomePage class, inheriting from wagtailcore.Page straight away
#     """
# 
#     subpage_types = [
#         'core.CompanyIndex',
#         'core.SubmitFormPage',
#     ]
#     feed_image = models.ForeignKey(
#         'wagtailimages.Image',
#         null=True,
#         blank=True,
#         on_delete=models.SET_NULL,
#         related_name='+'
#     )
#     search_fields = []
# 
#     body = RichTextField(blank=True, features=['bold', 'italic', 'ol', 'ul', 'link', 'cleanhtml'])
# 
#     @property
#     def og_image(self):
#         # Returns image and image type of feed_image, if exists
#         image = {'image': None, 'type': None}
#         if self.feed_image:
#             image['image'] = self.feed_image
#         name, extension = os.path.splitext(image['image'].file.url)
#         image['type'] = extension[1:]
#         return image
# 
#     def children(self):
#         return self.get_children().live()
# 
#     def get_context(self, request, *args, **kwargs):
#         # Get pages
#         pages = WagtailSitePage.objects\
#             .live()\
#             .descendant_of(self)\
#             .order_by('-is_featured', '-latest_revision_created_at')
# 
#         # Filter by tag
#         tag = request.GET.get('tag')
#         if tag:
#             pages = pages.filter(tags__slug__iexact=tag)
# 
#         # Pagination
#         page = request.GET.get('page')
#         paginator = Paginator(pages, 12)  # Show 12 pages per page
#         try:
#             pages = paginator.page(page)
#         except PageNotAnInteger:
#             pages = paginator.page(1)
#         except EmptyPage:
#             pages = paginator.page(paginator.num_pages)
# 
#         # Update template context
#         context = super(HomePage, self).get_context(request, *args, **kwargs)
#         context['pages'] = pages
#         context['tag'] = tag
#         # Only tags used by live pages
#         context['tags'] = Tag.objects.filter(
#             core_pagetag_items__isnull=False,
#             core_pagetag_items__content_object__live=True
#         ).annotate(count=Count('core_pagetag_items')).distinct().order_by('-count', 'name')
# 
#         return context
# 
#     class Meta:
#         verbose_name = "Home Page"
# 
#     content_panels = panels.HOME_PAGE_CONTENT_PANELS
#     promote_panels = panels.WAGTAIL_PAGE_PROMOTE_PANELS
# 
# Path: core/tests/utils.py
# class WagtailTest(TestCase):
#     """
#     TestCase that loads a number fo fixtures before each execution.
#     """
#     def setUp(self):
#         call_command('loaddata', FIXTURES_FILE, verbosity=1)
#         self.client = Client()


from bs4 import BeautifulSoup
from django.template import Context, Template
from core.models import HomePage
from core.tests.utils import WagtailTest



class TemplateTagsTestCase(WagtailTest):

    def setUp(self):
        super(TemplateTagsTestCase, self).setUp()

# Path: core/models.py
# class HomePage(Page, IndexPage):
#     """
#     HomePage class, inheriting from wagtailcore.Page straight away
#     """
# 
#     subpage_types = [
#         'core.CompanyIndex',
#         'core.SubmitFormPage',
#     ]
#     feed_image = models.ForeignKey(
#         'wagtailimages.Image',
#         null=True,
#         blank=True,
#         on_delete=models.SET_NULL,
#         related_name='+'
#     )
#     search_fields = []
# 
#     body = RichTextField(blank=True, features=['bold', 'italic', 'ol', 'ul', 'link', 'cleanhtml'])
# 
#     @property
#     def og_image(self):
#         # Returns image and image type of feed_image, if exists
#         image = {'image': None, 'type': None}
#         if self.feed_image:
#             image['image'] = self.feed_image
#         name, extension = os.path.splitext(image['image'].file.url)
#         image['type'] = extension[1:]
#         return image
# 
#     def children(self):
#         return self.get_children().live()
# 
#     def get_context(self, request, *args, **kwargs):
#         # Get pages
#         pages = WagtailSitePage.objects\
#             .live()\
#             .descendant_of(self)\
#             .order_by('-is_featured', '-latest_revision_created_at')
# 
#         # Filter by tag
#         tag = request.GET.get('tag')
#         if tag:
#             pages = pages.filter(tags__slug__iexact=tag)
# 
#         # Pagination
#         page = request.GET.get('page')
#         paginator = Paginator(pages, 12)  # Show 12 pages per page
#         try:
#             pages = paginator.page(page)
#         except PageNotAnInteger:
#             pages = paginator.page(1)
#         except EmptyPage:
#             pages = paginator.page(paginator.num_pages)
# 
#         # Update template context
#         context = super(HomePage, self).get_context(request, *args, **kwargs)
#         context['pages'] = pages
#         context['tag'] = tag
#         # Only tags used by live pages
#         context['tags'] = Tag.objects.filter(
#             core_pagetag_items__isnull=False,
#             core_pagetag_items__content_object__live=True
#         ).annotate(count=Count('core_pagetag_items')).distinct().order_by('-count', 'name')
# 
#         return context
# 
#     class Meta:
#         verbose_name = "Home Page"
# 
#     content_panels = panels.HOME_PAGE_CONTENT_PANELS
#     promote_panels = panels.WAGTAIL_PAGE_PROMOTE_PANELS
# 
# Path: core/tests/utils.py
# class WagtailTest(TestCase):
#     """
#     TestCase that loads a number fo fixtures before each execution.
#     """
#     def setUp(self):
#         call_command('loaddata', FIXTURES_FILE, verbosity=1)
#         self.client = Client()


# Path: core/tests/test_template_tags.py
from bs4 import BeautifulSoup
from django.template import Context, Template
from core.models import HomePage
from core.tests.utils import WagtailTest




class TemplateTagsTestCase(WagtailTest):

    def setUp(self):
        super(TemplateTagsTestCase, self).setUp()

        self.home_page = HomePage.objects.all()[0]