Ejemplo n.º 1
0
class BrowsePage(CFGOVPage):
    header = StreamField([
        ('text_introduction', molecules.TextIntroduction()),
        ('featured_content', molecules.FeaturedContent()),
    ],
                         blank=True)

    content = StreamField([
        ('bureau_structure', organisms.BureauStructure()),
        ('image_text_25_75_group', organisms.ImageText2575Group()),
        ('image_text_50_50_group', organisms.ImageText5050Group()),
        ('half_width_link_blob_group', organisms.HalfWidthLinkBlobGroup()),
        ('third_width_link_blob_group', organisms.ThirdWidthLinkBlobGroup()),
        ('well', organisms.Well()),
        ('full_width_text', organisms.FullWidthText()),
        ('expandable', organisms.Expandable()),
        ('expandable_group', organisms.ExpandableGroup()),
        ('table', organisms.Table(editable=False)),
        ('table_block',
         organisms.AtomicTableBlock(table_options={'renderer': 'html'})),
        ('job_listing_table', JobListingTable()),
        ('feedback', v1_blocks.Feedback()),
        ('conference_registration_form', ConferenceRegistrationForm()),
        ('html_block', organisms.HTMLBlock()),
        ('chart_block', organisms.ChartBlock()),
        ('snippet_list', organisms.SnippetList()),
    ],
                          blank=True)

    secondary_nav_exclude_sibling_pages = models.BooleanField(default=False)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    sidefoot_panels = CFGOVPage.sidefoot_panels + [
        FieldPanel('secondary_nav_exclude_sibling_pages'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'browse-basic/index.html'

    objects = PageManager()

    def add_page_js(self, js):
        super(BrowsePage, self).add_page_js(js)
        js['template'] += ['secondary-navigation.js']

    def get_context(self, request, *args, **kwargs):
        context = super(BrowsePage, self).get_context(request, *args, **kwargs)
        context.update({'get_secondary_nav_items': get_secondary_nav_items})
        return context
Ejemplo n.º 2
0
class BlogPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('expandable', organisms.Expandable()),
        ('well', organisms.Well()),
        ('email_signup', organisms.EmailSignUp()),
        ('feedback', v1_blocks.Feedback()),
    ])
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    objects = PageManager()
    search_fields = AbstractFilterPage.search_fields + [
        index.SearchField('content')
    ]

    def get_context(self, request, *args, **kwargs):
        context = super(BlogPage, self).get_context(request, *args, **kwargs)

        context['rss_feed'] = get_appropriate_rss_feed_url_for_page(
            self, request=request)

        return context
class ActivityLogPage(SublandingFilterablePage):
    template = 'activity-log/index.html'

    objects = PageManager()

    @classmethod
    def eligible_categories(cls):
        categories = dict(ref.categories)
        return sorted(itertools.chain(*(
            dict(categories[category]).keys()
            for category in ('Blog', 'Newsroom', 'Research Report')
        )))

    @classmethod
    def base_query(cls, hostname):
        """
        Activity log pages should only show content from certain categories.
        """
        eligible_pages = AbstractFilterPage.objects.live()

        return eligible_pages.filter(
            categories__name__in=cls.eligible_categories()
        )

    def per_page_limit(self):
        return 100
Ejemplo n.º 4
0
class LandingPage(CFGOVPage):
    header = StreamField([
        ('hero', molecules.Hero()),
        ('text_introduction', molecules.TextIntroduction()),
    ],
                         blank=True)

    content = StreamField([
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('well', organisms.Well()),
        ('feedback', v1_blocks.Feedback()),
    ],
                          blank=True)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'landing-page/index.html'

    objects = PageManager()

    search_fields = CFGOVPage.search_fields + [
        index.SearchField('content'),
        index.SearchField('header')
    ]
class SublandingFilterablePage(FilterableFeedPageMixin,
                               FilterableListMixin,
                               CFGOVPage):
    header = StreamField([
        ('hero', molecules.Hero()),
    ], blank=True)
    content = StreamField([
        ('text_introduction', molecules.TextIntroduction()),
        ('full_width_text', organisms.FullWidthText()),
        ('filter_controls', organisms.FilterControls()),
        ('featured_content', molecules.FeaturedContent()),
        ('feedback', v1_blocks.Feedback()),
    ])

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'sublanding-page/index.html'

    objects = PageManager()
class ActivityLogPage(SublandingFilterablePage):
    template = 'activity-log/index.html'
    filterable_categories = ('Blog', 'Newsroom', 'Research Report')
    filterable_children_only = False
    filterable_per_page_limit = 100

    objects = PageManager()
Ejemplo n.º 7
0
class LandingPage(CFGOVPage):
    header = StreamField([
        ('hero', molecules.Hero()),
        ('text_introduction', molecules.TextIntroduction()),
    ], blank=True)

    content = StreamField([
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('image_text_25_75_group', organisms.ImageText2575Group()),
        ('image_text_50_50_group', organisms.ImageText5050Group()),
        ('half_width_link_blob_group', organisms.HalfWidthLinkBlobGroup()),
        ('third_width_link_blob_group', organisms.ThirdWidthLinkBlobGroup()),
        ('well', organisms.Well()),
        ('feedback', v1_blocks.Feedback()),
    ], blank=True)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'landing-page/index.html'

    objects = PageManager()
class SublandingFilterablePage(FilterableFeedPageMixin, FilterableListMixin,
                               CFGOVPage):
    header = StreamField([
        ('hero', molecules.Hero()),
    ], blank=True)
    content = StreamField(SublandingFilterableContent)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'sublanding-page/index.html'

    objects = PageManager()

    search_fields = CFGOVPage.search_fields + [
        index.SearchField('content'),
        index.SearchField('header')
    ]
Ejemplo n.º 9
0
class LearnPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('expandable_group', organisms.ExpandableGroup()),
        ('expandable', organisms.Expandable()),
        ('well', organisms.Well()),
        ('call_to_action', molecules.CallToAction()),
        ('email_signup', organisms.EmailSignUp()),
        ('video_player', organisms.VideoPlayer()),
        ('table_block',
         organisms.AtomicTableBlock(table_options={'renderer': 'html'})),
        ('feedback', v1_blocks.Feedback()),
        ('contact_expandable_group', organisms.ContactExpandableGroup()),
    ],
                          blank=True)

    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'learn-page/index.html'

    objects = PageManager()

    search_fields = AbstractFilterPage.search_fields + [
        index.SearchField('content')
    ]
Ejemplo n.º 10
0
class JobListingPage(CFGOVPage):
    description = RichTextField('Description')
    open_date = models.DateField('Open date')
    close_date = models.DateField('Close date')
    salary_min = models.DecimalField('Minimum salary',
                                     max_digits=11,
                                     decimal_places=2)
    salary_max = models.DecimalField('Maximum salary',
                                     max_digits=11,
                                     decimal_places=2)
    division = models.ForeignKey(JobCategory,
                                 on_delete=models.PROTECT,
                                 null=True)

    content_panels = CFGOVPage.content_panels + [
        MultiFieldPanel([
            FieldPanel('division', classname='full'),
            InlinePanel('grades', label='Grades'),
            InlinePanel('regions', label='Regions'),
            FieldRowPanel([
                FieldPanel('open_date', classname='col6'),
                FieldPanel('close_date', classname='col6'),
            ]),
            FieldRowPanel([
                FieldPanel('salary_min', classname='col6'),
                FieldPanel('salary_max', classname='col6'),
            ]),
        ],
                        heading='Details'),
        FieldPanel('description', classname='full'),
        InlinePanel('usajobs_application_links',
                    label='USAJobs application links'),
        InlinePanel('email_application_links',
                    label='Email application links'),
    ]

    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'job-description-page/index.html'

    objects = PageManager()

    @property
    def ordered_grades(self):
        """Return a list of job grades in numerical order.

        Non-numeric grades are sorted alphabetically after numeric grades.
        """
        grades = set(g.grade.grade for g in self.grades.all())
        return sorted(grades, key=lambda g: int(g) if g.isdigit() else g)

    @property
    def ordered_regions(self):
        """Return a list of job regions in alphabetical order."""
        regions = set(r.region.region_long for r in self.regions.all())
        return sorted(regions)
class EventArchivePage(BrowseFilterablePage):
    template = 'browse-filterable/index.html'

    objects = PageManager()

    @staticmethod
    def get_form_class():
        from .. import forms
        return forms.EventArchiveFilterForm
Ejemplo n.º 12
0
class BlogPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('image_text_50_50_group', organisms.ImageText5050Group()),
        ('feedback', v1_blocks.Feedback()),
    ])
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    objects = PageManager()
Ejemplo n.º 13
0
class DemoPage(CFGOVPage):
    molecules = StreamField([
        ('number', atoms.NumberBlock()),
        ('half_width_link_blob', molecules.HalfWidthLinkBlob()),
        ('text_introduction', molecules.TextIntroduction()),
        ('image_text_2575', molecules.ImageText2575()),
        ('image_text_5050', molecules.ImageText5050()),
        ('hero', molecules.Hero()),
        ('formfield_with_button', molecules.FormFieldWithButton()),
        ('call_to_action', molecules.CallToAction()),
        ('expandable', organisms.Expandable()),
        ('featured_content', molecules.FeaturedContent()),

    ], blank=True)

    organisms = StreamField([
        ('well', organisms.Well()),
        ('full_width_text', organisms.FullWidthText()),
        ('expandable_group', organisms.ExpandableGroup()),
        ('item_intro', organisms.ItemIntroduction()),
    ], blank=True)

    contact = models.ForeignKey(
        Contact,
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('molecules'),
        StreamFieldPanel('organisms'),
        SnippetChooserPanel('contact'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Settings',
                   classname="settings"),
    ])

    objects = PageManager()

    def get_context(self, request):
        context = super(DemoPage, self).get_context(request)
        return context

    def get_template(self, request):
        return 'wagtail/demo/index.html'
Ejemplo n.º 14
0
class AnswerLandingPage(LandingPage):
    """
    Page type for Ask CFPB's landing page.
    """
    content_panels = [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(LandingPage.settings_panels, heading='Configuration'),
    ])
    objects = PageManager()
    template = 'ask-cfpb/landing-page.html'
Ejemplo n.º 15
0
class AgendaItemBlock(blocks.StructBlock):
    start_time = blocks.TimeBlock(label="Start", required=False)
    end_time = blocks.TimeBlock(label="End", required=False)
    description = blocks.CharBlock(max_length=100, required=False)
    location = blocks.CharBlock(max_length=100, required=False)
    speakers = blocks.ListBlock(blocks.StructBlock([
        ('name', blocks.CharBlock(required=False)),
        ('url', blocks.URLBlock(required=False)),
    ], icon='user', required=False))

    objects = PageManager()

    class Meta:
        icon = 'date'
Ejemplo n.º 16
0
class HomePage(CFGOVPage):
    header = StreamField([
        ('info_unit', molecules.InfoUnit()),
        ('half_width_link_blob', molecules.HalfWidthLinkBlob()),
    ],
                         blank=True)

    latest_updates = StreamField([
        ('posts',
         blocks.ListBlock(
             blocks.StructBlock([
                 ('categories',
                  blocks.ChoiceBlock(choices=ref.limited_categories,
                                     required=False)),
                 ('link', atoms.Hyperlink()),
                 ('date', blocks.DateTimeBlock(required=False)),
             ]))),
    ],
                                 blank=True)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('latest_updates'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    # Sets page to only be createable at the root
    parent_page_types = ['wagtailcore.Page']

    template = 'index.html'

    objects = PageManager()

    search_fields = CFGOVPage.search_fields + [index.SearchField('header')]

    def get_category_name(self, category_icon_name):
        cats = dict(ref.limited_categories)
        return cats[str(category_icon_name)]

    def get_context(self, request):
        context = super(HomePage, self).get_context(request)
        return context
Ejemplo n.º 17
0
class DocumentDetailPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('expandable', organisms.Expandable()),
        ('expandable_group', organisms.ExpandableGroup()),
        ('table_block',
         organisms.AtomicTableBlock(table_options={'renderer': 'html'})),
        ('feedback', v1_blocks.Feedback()),
    ],
                          blank=True)
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'document-detail/index.html'

    objects = PageManager()
Ejemplo n.º 18
0
class BlogPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('expandable', organisms.Expandable()),
        ('well', organisms.Well()),
        ('email_signup', organisms.EmailSignUp()),
        ('feedback', v1_blocks.Feedback()),
        ('image_text_50_50_group', organisms.ImageText5050Group()),
    ])
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content')
    )
    template = 'blog/blog_page.html'

    objects = PageManager()
Ejemplo n.º 19
0
class NewsroomLandingPage(BrowseFilterablePage):
    template = 'newsroom/index.html'

    objects = PageManager()

    @classmethod
    def eligible_categories(cls):
        categories = dict(ref.categories)
        return sorted(
            itertools.chain(*(dict(categories[category]).keys()
                              for category in ('Blog', 'Newsroom'))))

    @classmethod
    def base_query(cls, hostname):
        """Newsroom pages should only show content from certain categories."""
        eligible_pages = AbstractFilterPage.objects.live()

        return eligible_pages.filter(
            categories__name__in=cls.eligible_categories())
class BrowseFilterablePage(FilterableFeedPageMixin,
                           FilterableListMixin,
                           CFGOVPage):
    header = StreamField([
        ('text_introduction', molecules.TextIntroduction()),
        ('featured_content', organisms.FeaturedContent()),
    ])
    content = StreamField(BrowseFilterableContent)

    secondary_nav_exclude_sibling_pages = models.BooleanField(default=False)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    sidefoot_panels = CFGOVPage.sidefoot_panels + [
        FieldPanel('secondary_nav_exclude_sibling_pages'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(sidefoot_panels, heading='SideFoot'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'browse-filterable/index.html'

    objects = PageManager()

    search_fields = CFGOVPage.search_fields + [
        index.SearchField('content'),
        index.SearchField('header')
    ]

    @property
    def page_js(self):
        return (
            super(BrowseFilterablePage, self).page_js
            + ['secondary-navigation.js']
        )
Ejemplo n.º 21
0
class LearnPage(AbstractFilterPage):
    content = StreamField([
        ('image_text_25_75_group', organisms.ImageText2575Group()),
        ('well', organisms.Well()),
        ('full_width_text', organisms.FullWidthText()),
        ('expandable', organisms.Expandable()),
        ('expandable_group', organisms.ExpandableGroup()),
        ('table', organisms.Table(editable=False)),
        ('table_block',
         organisms.AtomicTableBlock(table_options={'renderer': 'html'})),
        ('call_to_action', molecules.CallToAction()),
        ('feedback', v1_blocks.Feedback()),
        ('video_player', organisms.VideoPlayer()),
    ],
                          blank=True)
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'learn-page/index.html'

    objects = PageManager()
Ejemplo n.º 22
0
class Place(Page):
    description = RichTextField("Описание", blank=True)

    top_image = models.ForeignKey(
        "wagtailimages.Image",
        verbose_name="Заглавная картинка",
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )
    address = models.CharField("Адрес", max_length=256, blank=True)
    tel = models.CharField("Телефон", max_length=15, blank=True)
    administrator = models.ForeignKey(
        "PlaceAdministrator",
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
        verbose_name="Менеджер",
        help_text="Человек, отвечающий за бронирование билетов для"
        " данной площадки (должен быть зарегистрирован на сайте)")
    content_panels = Page.content_panels + [
        FieldPanel('description'),
        FieldPanel('address'),
        FieldPanel('tel'),
        FieldPanel('administrator'),
        ImageChooserPanel('top_image'),
    ]

    search_fields = Page.search_fields + [
        index.SearchField('description'),
    ]

    objects = PageManager()
    scheduled = ScheduledPlaceManager()

    class Meta:
        ordering = ["title"]
        verbose_name = "Площадка"
        verbose_name_plural = "Площадки"
Ejemplo n.º 23
0
class MortgagePerformancePage(BrowsePage):
    """
    A model for data_research pages about mortgage delinquency
    and related data visualizations.
    """

    objects = PageManager()
    template = 'browse-basic/index.html'

    def get_mortgage_meta(self):
        meta_names = ['sampling_dates', 'download_files']
        meta_set = MortgageMetaData.objects.filter(name__in=meta_names)
        meta = {obj.name: obj.json_value for obj in meta_set}
        thru_date = parser.parse(meta['sampling_dates'][-1])
        from_date = parser.parse(meta['sampling_dates'][0])
        meta['thru_month'] = thru_date.strftime("%Y-%m")
        meta['thru_month_formatted'] = thru_date.strftime("%B %Y")
        meta['from_month_formatted'] = from_date.strftime("%B %Y")
        meta['pub_date_formatted'] = meta.get('download_files')[
            meta['thru_month']]['pub_date']
        download_dates = sorted(meta['download_files'].keys(), reverse=True)
        meta['archive_dates'] = download_dates[1:]
        return meta

    def get_context(self, request, *args, **kwargs):
        context = super(MortgagePerformancePage,
                        self).get_context(request, *args, **kwargs)
        context.update(self.get_mortgage_meta())
        if '30-89' in self.url:
            context.update({
                'delinquency': 'percent_30_60',
                'time_frame': '30-89'
            })
        elif '90' in self.url:
            context.update({'delinquency': 'percent_90', 'time_frame': '90'})
        return context

    class Media:
        css = ['secondary-navigation.css']
Ejemplo n.º 24
0
class AnswerCategoryPage(FilterableFeedPageMixin, FilterableListMixin,
                         CFGOVPage):
    """
    Page type for Ask CFPB parent-category pages.
    """
    from .django import Category

    objects = PageManager()
    content = StreamField([
        ('filter_controls', FilterControls()),
    ], null=True)
    ask_category = models.ForeignKey(Category,
                                     blank=True,
                                     null=True,
                                     on_delete=models.PROTECT,
                                     related_name='category_page')
    content_panels = CFGOVPage.content_panels + [
        FieldPanel('ask_category', Category),
        StreamFieldPanel('content'),
    ]
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])
    template = 'ask-cfpb/category-page.html'

    def add_page_js(self, js):
        super(AnswerCategoryPage, self).add_page_js(js)
        js['template'] += ['secondary-navigation.js']

    def get_context(self, request, *args, **kwargs):
        context = super(AnswerCategoryPage,
                        self).get_context(request, *args, **kwargs)
        context.update({
            'choices':
            self.ask_category.subcategories.all().values_list('slug', 'name')
        })
        return context
Ejemplo n.º 25
0
class BrowseFilterablePage(FilterableFeedPageMixin, FilterableListMixin,
                           CFGOVPage):
    header = StreamField([
        ('text_introduction', molecules.TextIntroduction()),
        ('featured_content', molecules.FeaturedContent()),
    ])
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('filter_controls', organisms.FilterControls()),
        ('feedback', v1_blocks.Feedback()),
    ])

    secondary_nav_exclude_sibling_pages = models.BooleanField(default=False)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('content'),
    ]

    sidefoot_panels = CFGOVPage.sidefoot_panels + [
        FieldPanel('secondary_nav_exclude_sibling_pages'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(sidefoot_panels, heading='SideFoot'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'browse-filterable/index.html'

    objects = PageManager()

    def add_page_js(self, js):
        super(BrowseFilterablePage, self).add_page_js(js)
        js['template'] += ['secondary-navigation.js']
Ejemplo n.º 26
0
class Performance(Page):
    subtitle = models.CharField("Подзаголовок", blank=True, max_length=255)
    top_image = models.ForeignKey(
        "wagtailimages.Image",
        verbose_name="Заглавная картинка",
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )
    video = models.ForeignKey('theatre.YouTubeEmbedSnippet',
                              verbose_name="Видео с YouTube",
                              null=True,
                              blank=True,
                              related_name='+',
                              on_delete=models.SET_NULL)
    description = RichTextField("Описание", blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle', classname='full'),
        ImageChooserPanel('top_image'),
        FieldPanel('description'),
        InlinePanel('gallery_items', label="Фотогалерея"),
        SnippetChooserPanel('video'),
    ]

    search_fields = Page.search_fields + [
        index.SearchField('description'),
    ]

    objects = PageManager()
    scheduled = ScheduledPerformanceManager()

    class Meta:
        ordering = ["title"]
        verbose_name = "Спектакль"
        verbose_name_plural = "Спектакли"
Ejemplo n.º 27
0
class JobListingPage(CFGOVPage):
    description = RichTextField('Summary')
    open_date = models.DateField('Open date')
    close_date = models.DateField('Close date')
    salary_min = models.DecimalField('Minimum salary',
                                     max_digits=11,
                                     decimal_places=2)
    salary_max = models.DecimalField('Maximum salary',
                                     max_digits=11,
                                     decimal_places=2)
    division = models.ForeignKey(JobCategory,
                                 on_delete=models.PROTECT,
                                 null=True)
    job_length = models.ForeignKey(JobLength,
                                   on_delete=models.PROTECT,
                                   null=True,
                                   verbose_name="Position length",
                                   blank=True)
    service_type = models.ForeignKey(ServiceType,
                                     on_delete=models.PROTECT,
                                     null=True,
                                     blank=True)
    location = models.ForeignKey(JobLocation,
                                 related_name='job_listings',
                                 on_delete=models.PROTECT)
    allow_remote = models.BooleanField(
        default=False,
        help_text='Adds remote option to jobs with office locations.',
        verbose_name="Location can also be remote")
    responsibilities = RichTextField('Responsibilities', null=True, blank=True)
    travel_required = models.BooleanField(
        blank=False,
        default=False,
        help_text=('Optional: Check to add a "Travel required" section to the '
                   'job description. Section content defaults to "Yes".'))
    travel_details = RichTextField(
        null=True,
        blank=True,
        help_text='Optional: Add content for "Travel required" section.')
    additional_section_title = models.CharField(
        max_length=255,
        null=True,
        blank=True,
        help_text='Optional: Add title for an additional section '
        'that will display at end of job description.')
    additional_section_content = RichTextField(
        null=True,
        blank=True,
        help_text='Optional: Add content for an additional section '
        'that will display at end of job description.')
    content_panels = CFGOVPage.content_panels + [
        MultiFieldPanel([
            FieldPanel('division', classname='full'),
            InlinePanel('grades', label='Grades'),
            FieldRowPanel([
                FieldPanel('open_date', classname='col6'),
                FieldPanel('close_date', classname='col6'),
            ]),
            FieldRowPanel([
                FieldPanel('salary_min', classname='col6'),
                FieldPanel('salary_max', classname='col6'),
            ]),
            FieldRowPanel([
                FieldPanel('service_type', classname='col6'),
                FieldPanel('job_length', classname='col6'),
            ]),
        ],
                        heading='Details'),
        MultiFieldPanel([
            FieldPanel('location', classname='full'),
            FieldPanel('allow_remote', classname='full'),
        ],
                        heading='Location'),
        MultiFieldPanel([
            FieldPanel('description', classname='full'),
            FieldPanel('responsibilities', classname='full'),
            FieldPanel('travel_required', classname='full'),
            FieldPanel('travel_details', classname='full'),
            FieldPanel('additional_section_title', classname='full'),
            FieldPanel('additional_section_content', classname='full'),
        ],
                        heading='Description'),
        InlinePanel('usajobs_application_links',
                    label='USAJobs application links'),
        InlinePanel('email_application_links',
                    label='Email application links'),
    ]

    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    template = 'job-description-page/index.html'

    objects = PageManager()

    def get_context(self, request, *args, **kwargs):
        context = super(JobListingPage, self).get_context(request)
        try:
            context['about_us'] = ReusableText.objects.get(
                title='About us (For consumers)')
        except Exception:
            pass
        if hasattr(self.location, 'region'):
            context['states'] = [
                state.abbreviation
                for state in self.location.region.states.all()
            ]
            context['location_type'] = 'region'
        else:
            context['states'] = []
            context['location_type'] = 'office'
        context['cities'] = self.location.cities.all()
        return context

    @property
    def page_js(self):
        return super(JobListingPage, self).page_js + ['read-more.js']

    @property
    def ordered_grades(self):
        """Return a list of job grades in numerical order.
        Non-numeric grades are sorted alphabetically after numeric grades.
        """
        grades = set(g.grade.grade for g in self.grades.all())
        return sorted(grades, key=lambda g: '{0:0>8}'.format(g))
Ejemplo n.º 28
0
class SpanishHomePage(HomePage):
    objects = PageManager()
    parent_page_types = ['v1.HomePage']
Ejemplo n.º 29
0
class HomePage(CFGOVPage):
    header = StreamField([
        ('info_unit', molecules.InfoUnit()),
        ('half_width_link_blob', molecules.HalfWidthLinkBlob()),
    ],
                         blank=True)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        InlinePanel(
            'excluded_updates',
            label='Pages excluded from Latest Updates',
            help_text=('This block automatically displays the six most '
                       'recently published blog posts, press releases, '
                       'speeches, testimonies, events, or op-eds. If you want '
                       'to exclude a page from appearing as a recent update '
                       'in this block, add it as an excluded page.')),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    # Sets page to only be createable at the root
    parent_page_types = ['wagtailcore.Page']

    objects = PageManager()

    search_fields = CFGOVPage.search_fields + [index.SearchField('header')]

    @property
    def page_js(self):
        return super(HomePage, self).page_js + ['home-page.js']

    def get_category_name(self, category_icon_name):
        cats = dict(ref.limited_categories)
        return cats[str(category_icon_name)]

    def get_context(self, request):
        context = super(HomePage, self).get_context(request)
        context.update({
            'carousel_items': self.get_carousel_items(),
            'info_units': self.get_info_units(),
            'latest_updates': self.get_latest_updates(request),
        })
        return context

    def get_carousel_items(self):
        return _carousel_items_by_language[self.language]

    def get_info_units(self):
        return [
            molecules.InfoUnit().to_python(info_unit)
            for info_unit in _info_units_by_language[self.language]
        ]

    def get_latest_updates(self, request):
        # TODO: There should be a way to express this as part of the query
        # rather than evaluating it in Python.
        excluded_updates_pks = [
            e.excluded_page.pk for e in self.excluded_updates.all()
        ]

        latest_pages = CFGOVPage.objects.in_site(
            request.site).exclude(pk__in=excluded_updates_pks).filter(
                Q(content_type__app_label='v1') &
                (Q(content_type__model='blogpage')
                 | Q(content_type__model='eventpage')
                 | Q(content_type__model='newsroompage')),
                live=True,
            ).distinct().order_by('-first_published_at')[:6]

        return latest_pages

    def get_template(self, request):
        if flag_enabled('NEW_HOME_PAGE', request=request):
            return 'home-page/index_new.html'
        else:
            return 'home-page/index_%s.html' % self.language
Ejemplo n.º 30
0
class RegulationsSearchPage(RoutablePageMixin, CFGOVPage):
    """A page for the custom search interface for regulations."""

    objects = PageManager()

    parent_page_types = ['regulations3k.RegulationLandingPage']
    subpage_types = []
    results = {}
    content_panels = CFGOVPage.content_panels
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    def get_template(self, request):
        return 'regulations3k/search-regulations.html'

    @route(r'^results/')
    def regulation_results_page(self, request):
        all_regs = Part.objects.order_by('part_number')
        regs = []
        sqs = SearchQuerySet()
        if 'regs' in request.GET:
            regs = request.GET.getlist('regs')
        if len(regs) == 1:
            sqs = sqs.filter(part=regs[0])
        elif regs:
            sqs = sqs.filter(part__in=regs)
        search_query = request.GET.get('q', '')  # haystack cleans this string
        if search_query:
            query_sqs = sqs.filter(content=search_query).models(Section)
        else:
            query_sqs = sqs.models(Section)
        payload = {
            'search_query':
            search_query,
            'results': [],
            'total_results':
            query_sqs.count(),
            'regs':
            regs,
            'all_regs': [{
                'name':
                "Regulation {}".format(reg.letter_code),
                'id':
                reg.part_number,
                'num_results':
                query_sqs.filter(part=reg.part_number).count(),
                'selected':
                reg.part_number in regs
            } for reg in all_regs]
        }
        for hit in query_sqs:
            label_bits = hit.object.label.partition('-')
            _part, _section = label_bits[0], label_bits[2]
            letter_code = LETTER_CODES.get(_part)
            snippet = Truncator(hit.text).words(40, truncate=' ...')
            snippet = snippet.replace('*', '').replace('#', '')
            hit_payload = {
                'id': hit.object.pk,
                'reg': 'Regulation {}'.format(letter_code),
                'label': hit.title,
                'snippet': snippet,
                'url': "/regulations/{}/{}/".format(_part, _section),
            }
            payload['results'].append(hit_payload)
        self.results = payload

        # if we want to paginate results:

        # def get_context(self, request, **kwargs):
        #     context = super(RegulationsSearchPage, self).get_context(
        #         request, **kwargs)
        #     context.update(**kwargs)
        #     paginator = Paginator(payload['results'], 25)
        #     page_number = validate_page_number(request, paginator)
        #     paginated_page = paginator.page(page_number)
        #     context['current_page'] = page_number
        #     context['paginator'] = paginator
        #     context['results'] = paginated_page
        #     return context

        context = self.get_context(request)
        return TemplateResponse(request, self.get_template(request), context)