# Path: website/jdpages/models.py
# class BlogCategoryPage(Page, RichText):
#     """
#     Model for a page that displays a list of posts in a single blog category.
#     """
# 
#     blog_category = models.ForeignKey(BlogCategory, null=False, blank=False)
#     show_excerpt = models.BooleanField(default=False, null=False, blank=False,
#                                        help_text='Show only the first paragraph of a blog post.')
# 
#     class Meta:
#         verbose_name = "Blog categorie pagina"
#         verbose_name_plural = "Blog categorie pagina's"
# 
# Path: website/jdpages/models.py
# class HomePage(Page, RichText):
#     """
#     Page model for the site homepage.
#     Only works properly when url points to the homepage '/' as url.
#     """
#     header_title = models.CharField(max_length=300, blank=True, default="")
#     header_subtitle = models.CharField(max_length=500, blank=True, default="")
#     news_category = models.ForeignKey(BlogCategory, null=True, blank=True)
#     vision_pages = models.ManyToManyField(VisionPage, blank=True, verbose_name="Standpunt pagina's")
# 
#     @property
#     def blog_posts(self):
#         return get_public_blogposts(self.news_category)[:4]
# 
#     class Meta:
#         verbose_name = 'Home pagina'
#         verbose_name_plural = "Home pagina's"
# 
# Path: website/jdpages/models.py
# class OrganisationPage(Page, RichText):
#     """
#     """
#     organisation_part_pages = models.ManyToManyField(OrganisationPartPage, blank=True, verbose_name="Organisatie onderdelen")
# 
#     class Meta:
#         verbose_name = 'Organisatie pagina'
#         verbose_name_plural = "Organisatie pagina's"
# 
# Path: website/jdpages/models.py
# class OrganisationPartPage(Page, RichText):
#     """
#     """
#     image = FileField(max_length=300, format="Image", blank=True, default="", validators=[validate_organisation_image])
# 
#     class Meta:
#         verbose_name = 'Organisatie-onderdeel pagina'
#         verbose_name_plural = "Organisatie-onderdeel pagina's"
# 
# Path: website/jdpages/models.py
# class VisionPage(Page, RichText):
#     """
#     """
#     image = FileField(max_length=300, format="Image", blank=True, default="", validators=[validate_vision_image])
# 
#     class Meta:
#         verbose_name = 'Standpunt pagina'
#         verbose_name_plural = "Standpunt pagina's"
# 
# Path: website/jdpages/models.py
# class VisionsPage(Page, RichText):
#     """
#     """
#     vision_pages = models.ManyToManyField(VisionPage, blank=True, verbose_name="Standpunt pagina's")
# 
#     class Meta:
#         verbose_name = 'Standpunten pagina'
#         verbose_name_plural = "Standpunten pagina's"
# 
# Path: website/jdpages/models.py
# class WordLidPage(Page, RichText):
#     """
#     """
# 
#     class Meta:
#         verbose_name = 'Word lid pagina'
#         verbose_name_plural = "Standpunt pagina's"
# 
# Path: website/jdpages/views.py
# def get_page_header(page):
#     """
#     :returns: the page header for a given page.
#     Uses parent page image when none is defined.
#     Top parent is the HomePage.
#     None when there is no Hompage or when the HomePage has no header.
#     """
# 
#     # Get a random page header, or the first one if there is only one
#     image = PageHeaderImage.objects.filter(page=page).order_by('?').first()
#     if image is not None:
#         return image
# 
#     # No image found! If we received an integer, then do not search further
#     if isinstance(page, int):
#         return None
# 
#     # Try from parent
#     if page.parent:
#         return get_page_header(page.parent)
# 
#     # Try from first homepage
#     homepage = get_homepage_id()
#     if homepage is not None:
#         # Since we give get_page_header an integer, there is no infinite recursion here...
#         return get_page_header(homepage)
# 
#     return None


import logging
from mezzanine.blog.views import blog_post_list
from mezzanine.pages.page_processors import processor_for
from mezzanine.pages.models import RichTextPage
from website.jdpages.models import BlogCategoryPage
from mezzanine.forms.models import Form
from website.jdpages.models import HomePage
from website.jdpages.models import OrganisationPage
from website.jdpages.models import OrganisationPartPage
from website.jdpages.models import VisionPage
from website.jdpages.models import VisionsPage
from website.jdpages.models import WordLidPage
from website.jdpages.views import get_page_header
"""
Mezzanine page processors for jdpages.
Read the mezzanine documentation for more info.
"""




logger = logging.getLogger(__name__)

@processor_for(Form)
@processor_for(HomePage)
@processor_for(VisionPage)
@processor_for(VisionsPage)
@processor_for(OrganisationPage)
@processor_for(OrganisationPartPage)
@processor_for(BlogCategoryPage)
@processor_for(RichTextPage)
@processor_for(WordLidPage)
def add_header_images(request, page):
    page_header = get_page_header(page)

    if page_header:
        page_header.title = page.title
    return {"page_header": page_header}



# Path: website/jdpages/models.py
# class BlogCategoryPage(Page, RichText):
#     """
#     Model for a page that displays a list of posts in a single blog category.
#     """
# 
#     blog_category = models.ForeignKey(BlogCategory, null=False, blank=False)
#     show_excerpt = models.BooleanField(default=False, null=False, blank=False,
#                                        help_text='Show only the first paragraph of a blog post.')
# 
#     class Meta:
#         verbose_name = "Blog categorie pagina"
#         verbose_name_plural = "Blog categorie pagina's"
# 
# Path: website/jdpages/models.py
# class HomePage(Page, RichText):
#     """
#     Page model for the site homepage.
#     Only works properly when url points to the homepage '/' as url.
#     """
#     header_title = models.CharField(max_length=300, blank=True, default="")
#     header_subtitle = models.CharField(max_length=500, blank=True, default="")
#     news_category = models.ForeignKey(BlogCategory, null=True, blank=True)
#     vision_pages = models.ManyToManyField(VisionPage, blank=True, verbose_name="Standpunt pagina's")
# 
#     @property
#     def blog_posts(self):
#         return get_public_blogposts(self.news_category)[:4]
# 
#     class Meta:
#         verbose_name = 'Home pagina'
#         verbose_name_plural = "Home pagina's"
# 
# Path: website/jdpages/models.py
# class OrganisationPage(Page, RichText):
#     """
#     """
#     organisation_part_pages = models.ManyToManyField(OrganisationPartPage, blank=True, verbose_name="Organisatie onderdelen")
# 
#     class Meta:
#         verbose_name = 'Organisatie pagina'
#         verbose_name_plural = "Organisatie pagina's"
# 
# Path: website/jdpages/models.py
# class OrganisationPartPage(Page, RichText):
#     """
#     """
#     image = FileField(max_length=300, format="Image", blank=True, default="", validators=[validate_organisation_image])
# 
#     class Meta:
#         verbose_name = 'Organisatie-onderdeel pagina'
#         verbose_name_plural = "Organisatie-onderdeel pagina's"
# 
# Path: website/jdpages/models.py
# class VisionPage(Page, RichText):
#     """
#     """
#     image = FileField(max_length=300, format="Image", blank=True, default="", validators=[validate_vision_image])
# 
#     class Meta:
#         verbose_name = 'Standpunt pagina'
#         verbose_name_plural = "Standpunt pagina's"
# 
# Path: website/jdpages/models.py
# class VisionsPage(Page, RichText):
#     """
#     """
#     vision_pages = models.ManyToManyField(VisionPage, blank=True, verbose_name="Standpunt pagina's")
# 
#     class Meta:
#         verbose_name = 'Standpunten pagina'
#         verbose_name_plural = "Standpunten pagina's"
# 
# Path: website/jdpages/models.py
# class WordLidPage(Page, RichText):
#     """
#     """
# 
#     class Meta:
#         verbose_name = 'Word lid pagina'
#         verbose_name_plural = "Standpunt pagina's"
# 
# Path: website/jdpages/views.py
# def get_page_header(page):
#     """
#     :returns: the page header for a given page.
#     Uses parent page image when none is defined.
#     Top parent is the HomePage.
#     None when there is no Hompage or when the HomePage has no header.
#     """
# 
#     # Get a random page header, or the first one if there is only one
#     image = PageHeaderImage.objects.filter(page=page).order_by('?').first()
#     if image is not None:
#         return image
# 
#     # No image found! If we received an integer, then do not search further
#     if isinstance(page, int):
#         return None
# 
#     # Try from parent
#     if page.parent:
#         return get_page_header(page.parent)
# 
#     # Try from first homepage
#     homepage = get_homepage_id()
#     if homepage is not None:
#         # Since we give get_page_header an integer, there is no infinite recursion here...
#         return get_page_header(homepage)
# 
#     return None


# Path: website/jdpages/page_processors.py
import logging
from mezzanine.blog.views import blog_post_list
from mezzanine.pages.page_processors import processor_for
from mezzanine.pages.models import RichTextPage
from website.jdpages.models import BlogCategoryPage
from mezzanine.forms.models import Form
from website.jdpages.models import HomePage
from website.jdpages.models import OrganisationPage
from website.jdpages.models import OrganisationPartPage
from website.jdpages.models import VisionPage
from website.jdpages.models import VisionsPage
from website.jdpages.models import WordLidPage
from website.jdpages.views import get_page_header

"""
Mezzanine page processors for jdpages.
Read the mezzanine documentation for more info.
"""




logger = logging.getLogger(__name__)

@processor_for(Form)
@processor_for(HomePage)
@processor_for(VisionPage)
@processor_for(VisionsPage)
@processor_for(OrganisationPage)
@processor_for(OrganisationPartPage)
@processor_for(BlogCategoryPage)
@processor_for(RichTextPage)
@processor_for(WordLidPage)
def add_header_images(request, page):
    page_header = get_page_header(page)

    if page_header:
        page_header.title = page.title
    return {"page_header": page_header}



@processor_for(BlogCategoryPage)