예제 #1
0
class DashboardTripleColumnPage(BaseDashboardPage):
    
    class Meta(object):
        verbose_name = _('3-Column Dashboard Page')
    
    content1 = BetterRichTextField(verbose_name=_('Content (left column)'), blank=True)
    content2 = BetterRichTextField(verbose_name=_('Content (center column)'), blank=True)
    content3 = BetterRichTextField(verbose_name=_('Content (right column)'), blank=True)
    
    # Search index configuraiton
    search_fields = BaseDashboardPage.search_fields + [
        index.SearchField('content1'),
        index.SearchField('content2'),
        index.SearchField('content3'),
    ]

    # Editor panels configuration
    content_panels = BaseDashboardPage.content_panels + [
        FieldPanel('content1', classname="full"),
        FieldPanel('content2', classname="full"),
        FieldPanel('content3', classname="full"),
    ]

    template = 'cosinnus/wagtail/dashboard_triple_column_page.html'
    
    translation_fields = BaseDashboardPage.translation_fields + (
        'content1',
        'content2',
        'content3',
    )
예제 #2
0
class BaseDashboardPage(Page):
    
    class Meta(object):
        abstract = True
        
    # settings fields
    show_register_button = models.BooleanField(_('Show Register Button'), default=True)
    redirect_if_logged_in = models.BooleanField(_('Redirect Logged in Users'),
        help_text=_('If active, this page will only be visible to non-logged-in users. All others will be redirected to the activities page.'),
        default=False)
    
    # Database fields
    banner_left = BetterRichTextField(verbose_name=_('Left banner (top)'), blank=True)
    banner_right = BetterRichTextField(verbose_name=_('Right banner (top)'), blank=True)
    
    header = BetterRichTextField(verbose_name=_('Header'), blank=True)
    
    footer_left = BetterRichTextField(verbose_name=_('Left footer'), blank=True)
    footer_right = BetterRichTextField(verbose_name=_('Right footer'), blank=True)
    
    translation_fields = (
        'title',
        'banner_left',
        'banner_right',
        'header',
        'footer_left',
        'footer_right',
    )
    
    # Search index configuraiton
    search_fields = Page.search_fields + [
        index.SearchField('banner_left'),
        index.SearchField('banner_right'),
        index.SearchField('header'),
        index.SearchField('footer_left'),
        index.SearchField('footer_right'),
    ]

    # Editor panels configuration
    content_panels = Page.content_panels + [
        FieldPanel('banner_left', classname="full"),
        FieldPanel('banner_right', classname="full"),
        FieldPanel('header', classname="full"),
        FieldPanel('footer_left', classname="full"),
        FieldPanel('footer_right', classname="full"),
    ]
    
    # Editor panels configuration
    settings_panels = Page.settings_panels + [
        FieldPanel('show_register_button'),
        FieldPanel('redirect_if_logged_in'),
    ]
    
    def serve(self, request):
        """ If the redirect flag is set, and the user is logged in, redirect to streams, otherwise, show CMS page """
        if request.user.is_authenticated and self.redirect_if_logged_in and not request.GET.get('preview', False):
            return redirect(get_non_cms_root_url(request))
        return super(BaseDashboardPage, self).serve(request)
예제 #3
0
class PortalRootPage(Page):
    
    class Meta(object):
        verbose_name = _('Portal Root Page')
        
    # this template should never be visible, but if it is, the user will see an explanation
    template = 'cosinnus/wagtail/portal_root_page.html'
        
    parent_page_types = ['wagtailcore.Page', ]
    
    portal = models.ForeignKey(CosinnusPortal, verbose_name=_('Assigned Portal'), 
        related_name='wagtail_root_pages', 
        help_text='Only portal admins of the assigned portal can see wagtail pages below this one.',
        null=True, blank=True, on_delete=models.SET_NULL)
    
    footer = BetterRichTextField(verbose_name=_('Footer'), blank=True,
        help_text=_('Will be displayed as a footer on EVERY page on this website (not only dashboard pages!)'))
    
    
    # Editor panels configuration
    content_panels = Page.content_panels + [
        FieldPanel('footer', classname="full"),
    ]
    
    # Editor panels configuration
    settings_panels = Page.settings_panels + [
        FieldPanel('portal'),
    ]
    
    translation_fields = (
        'title',
        'footer',
    )
예제 #4
0
class DashboardSingleColumnPage(BaseDashboardPage):
    class Meta(object):
        verbose_name = _('1-Column Dashboard Page')

    content1 = BetterRichTextField(verbose_name=_('Content'), blank=True)

    # Search index configuraiton
    search_fields = BaseDashboardPage.search_fields + (
        index.SearchField('content1'), )

    # Editor panels configuration
    content_panels = BaseDashboardPage.content_panels + [
        FieldPanel('content1', classname="full"),
    ]

    template = 'cosinnus/wagtail/dashboard_single_column_page.html'

    translation_fields = BaseDashboardPage.translation_fields + ('content1', )
예제 #5
0
class SimpleTwoPage(BaseSimplePage):
    class Meta(object):
        verbose_name = _('Simple Page with Left Navigation')

    # Database fields
    leftnav = BetterRichTextField(verbose_name=_('Left Sidebar'), blank=True)

    # Search index configuraiton
    search_fields = BaseSimplePage.search_fields + (
        index.SearchField('leftnav'), )

    # Editor panels configuration
    content_panels = BaseSimplePage.content_panels + [
        FieldPanel('leftnav', classname="full"),
    ]

    template = 'cosinnus/wagtail/simple_two_page.html'

    translation_fields = SimpleOnePage.translation_fields + ('leftnav', )
예제 #6
0
class BaseSimplePage(SplitMultiLangTabsMixin, TranslationMixin, Page):
    class Meta(object):
        abstract = True

    # Database fields
    content = BetterRichTextField(verbose_name=_('Content'), blank=True)

    # Search index configuraiton
    search_fields = Page.search_fields + (index.SearchField('content'), )

    # Editor panels configuration
    content_panels = Page.content_panels + [
        FieldPanel('content', classname="full"),
    ]

    translation_fields = (
        'content',
        'title',
    )
예제 #7
0
class StreamStartPage(Page):
    """ A simple well-structured StartPage using StreamFields """
    
    class Meta(object):
        verbose_name = _('Start Page (Modular)')
    
    # settings fields
    show_register_button = models.BooleanField(_('Show Register Button'), default=True)
    redirect_if_logged_in = models.BooleanField(_('Redirect Logged in Users'),
        help_text=_('If active, this page will only be visible to non-logged-in users. All others will be redirected to the activities page.'),
        default=False)
    
    # Database fields
    header_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        verbose_name=_('Header image'),
    )
    header_title = BetterRichTextField(verbose_name=_('Header Title'), blank=True)
    header_text = BetterRichTextField(verbose_name=_('Header Text'), blank=True)
    
    header_content = StreamField(STREAMFIELD_BLOCKS, verbose_name=_('Additional Header content'), blank=True)
    site_widgets = StreamField(STREAMFIELD_BLOCKS_WIDGETS, verbose_name=_('Site Widgets'), blank=True)
    bottom_content = StreamField(STREAMFIELD_BLOCKS, verbose_name=_('Bottom content (gray background)'), blank=True)
    
    translation_fields = (
        'title',
        'header_image',
        'header_title',
        'header_text',
        'header_content',
        'bottom_content',
    )
    
    # Search index configuraiton
    search_fields = Page.search_fields + [
        index.SearchField('header_title'),
        index.SearchField('header_text'),
        index.SearchField('header_content'),
        index.SearchField('bottom_content'),
    ]

    # Editor panels configuration
    content_panels = Page.content_panels + [
        ImageChooserPanel('header_image'),
        FieldPanel('header_title'),
        FieldPanel('header_text'),
        
        StreamFieldPanel('header_content'),
        StreamFieldPanel('bottom_content'),
    ]
    
    # Editor panels configuration
    settings_panels = Page.settings_panels + [
        FieldPanel('show_register_button'),
        FieldPanel('redirect_if_logged_in'),
        StreamFieldPanel('site_widgets'),
    ]
    
    template = 'cosinnus/wagtail/stream_start_page.html'
    
    def serve(self, request):
        """ If the redirect flag is set, and the user is logged in, redirect to streams, otherwise, show CMS page """
        if request.user.is_authenticated and self.redirect_if_logged_in and not request.GET.get('preview', False):
            return redirect(get_non_cms_root_url(request))
        return super(StreamStartPage, self).serve(request)