Exemple #1
0
 def test_html_has_header(self):
     make_job_listing_page(
         title='CEO',
         close_date=date(2099, 12, 1)
     )
     table = JobListingTable()
     html = table.render(table.to_python({}))
     self.assertIn('<thead>', html)
Exemple #2
0
 def test_html_has_header(self):
     make_job_listing_page(
         title='CEO',
         close_date=date(2099, 12, 1)
     )
     table = JobListingTable()
     html = table.render(table.to_python({}))
     self.assertIn('<thead>', html)
 def test_html_displays_table_if_row_flag_false(self):
     table = JobListingTable()
     html = table.render(
         table.to_python({'first_row_is_table_header': False}))
     self.assertNotIn('<thead>', html)
     self.assertIn('TITLE', html)
     self.assertIn('GRADE', html)
     self.assertIn('POSTING CLOSES', html)
     self.assertIn('LOCATION', html)
Exemple #4
0
 def test_html_displays_table_if_row_flag_false(self):
     table = JobListingTable()
     html = table.render(table.to_python(
         {'first_row_is_table_header': False}
     ))
     self.assertNotIn('<thead>', html)
     self.assertIn('TITLE', html)
     self.assertIn('GRADE', html)
     self.assertIn('POSTING CLOSES', html)
     self.assertIn('LOCATION', html)
    def test_html_has_job_listings(self):
        make_job_listing_page(title='Manager',
                              grades=['1', '2', '3'],
                              close_date=date(2099, 8, 5))
        make_job_listing_page(title='Assistant',
                              grades=['12'],
                              close_date=date(2099, 4, 21))

        table = JobListingTable()
        html = table.render({})

        self.assertIn('Manager', html)
        self.assertIn('Assistant', html)
        self.assertIn('1, 2, 3', html)
        self.assertIn('12', html)
        self.assertIn('Aug. 5, 2099', html)
        self.assertIn('Apr. 21, 2099', html)
        self.assertEqual(html.count('Silicon Valley'), 2)
    def test_html_has_header(self):
        make_job_listing_page(title='CEO', close_date=date(2099, 12, 1))
        html = JobListingTable().render({})

        self.assertIn('<thead>', html)
        self.assertIn('TITLE', html)
        self.assertIn('GRADE', html)
        self.assertIn('POSTING CLOSES', html)
        self.assertIn('LOCATION', html)
Exemple #7
0
    def test_html_has_job_listings(self):
        make_job_listing_page(
            title='Manager',
            grades=['1', '2', '3'],
            close_date=date(2099, 8, 5)
        )
        make_job_listing_page(
            title='Assistant',
            grades=['12'],
            close_date=date(2099, 4, 21)
        )

        table = JobListingTable()
        html = table.render(table.to_python({}))

        self.assertIn('Manager', html)
        self.assertIn('Assistant', html)
        self.assertIn('1, 2, 3', html)
        self.assertIn('12', html)
        self.assertIn('Aug. 5, 2099', html)
        self.assertIn('Apr. 21, 2099', html)
        self.assertEqual(html.count('Silicon Valley'), 2)
    def test_is_efficient(self):
        for i in range(10):
            make_job_listing_page(title='Manager',
                                  grades=['1', '2', '3'],
                                  close_date=date(2099, 8, 5))

        request = RequestFactory().get('/')

        # We expect four database queries here. First, Wagtail has to look up
        # the site root paths. These get cached on the request object. Then,
        # all of the JobListingPages are retrieved in a single query. Finally,
        # two additional queries are needed to pull back job grades.
        with self.assertNumQueries(4):
            JobListingTable().render({}, context={'request': request})
Exemple #9
0
 def test_html_displays_no_data_message(self):
     table = JobListingTable()
     html = table.render(table.to_python({'empty_table_msg': 'No Jobs'}))
     self.assertInHTML('<h3>No Jobs</h3>', html)
Exemple #10
0
class BrowsePage(CFGOVPage):
    header = StreamField([
        ('text_introduction', molecules.TextIntroduction()),
        ('featured_content', organisms.FeaturedContent()),
    ],
                         blank=True)

    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('expandable_group', organisms.ExpandableGroup()),
        ('expandable', organisms.Expandable()),
        ('well', organisms.Well()),
        ('video_player', organisms.VideoPlayer()),
        ('snippet_list', organisms.ResourceList()),
        ('table_block',
         organisms.AtomicTableBlock(table_options={'renderer': 'html'})),
        ('feedback', v1_blocks.Feedback()),
        ('raw_html_block', blocks.RawHTMLBlock(label='Raw HTML block')),
        ('conference_registration_form', ConferenceRegistrationForm()),
        ('chart_block', organisms.ChartBlock()),
        ('mortgage_chart_block', organisms.MortgageChartBlock()),
        ('mortgage_map_block', organisms.MortgageMapBlock()),
        ('mortgage_downloads_block', MortgageDataDownloads()),
        ('data_snapshot', organisms.DataSnapshot()),
        ('job_listing_table', JobListingTable()),
        ('bureau_structure', organisms.BureauStructure()),
        ('yes_checklist', YESChecklist()),
    ],
                          blank=True)

    secondary_nav_exclude_sibling_pages = models.BooleanField(default=False)

    share_and_print = models.BooleanField(
        default=False,
        help_text="Include share and print buttons above page content.")

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        FieldPanel('share_and_print'),
        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()

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

    @property
    def page_js(self):
        return (super(BrowsePage, self).page_js + ['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
Exemple #11
0
 def test_includes_live_jobs(self):
     job = make_job_listing_page('Job', live=True)
     qs = JobListingTable().get_queryset({})
     self.assertTrue(qs.exists())
     self.assertEqual(job.title, qs[0].title)
 def test_html_displays_no_data_message(self):
     self.assertInHTML(
         '<h3>There are no current openings at this time.</h3>',
         JobListingTable().render({}))
Exemple #13
0
 def test_html_displays_no_data_message(self):
     table = JobListingTable()
     html = table.render(table.to_python({'empty_table_msg': 'No Jobs'}))
     self.assertInHTML('<h3>No Jobs</h3>', html)
 def render_block(self):
     return JobListingTable().render({}, context={'request': self.request})
Exemple #15
0
 def test_excludes_draft_jobs(self):
     make_job_listing_page('Job', live=False)
     qs = JobListingTable().get_queryset({})
     self.assertFalse(qs.exists())
Exemple #16
0
 def test_includes_live_jobs(self):
     job = make_job_listing_page('Job', live=True)
     qs = JobListingTable().get_queryset({})
     self.assertTrue(qs.exists())
     self.assertEqual(job.title, qs[0].title)
Exemple #17
0
 def test_excludes_draft_jobs(self):
     make_job_listing_page('Job', live=False)
     qs = JobListingTable().get_queryset({})
     self.assertFalse(qs.exists())