def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context=parent_context) jobs = context['jobs'] request = context.get('request') header = [['TITLE', 'GRADE', 'POSTING CLOSES', 'LOCATION']] data = [[ '<a href="%s">%s</a>' % ( job.get_url(request=request), job.title, ), ', '.join(map(str, job.grades.all())), extended_strftime(job.close_date, '%_m %_d, %Y'), str(job.location), ] for job in jobs] return { 'value': { 'data': header + data, 'empty_table_msg': context['no_jobs_message'], 'first_row_is_table_header': True, 'has_data': bool(data), 'is_stacked': True, }, }
def make_close_date_value(self, instance, value): return extended_strftime(value, '%_m %_d, %Y')
def test_date_formatted_with_default_pattern(self): test_date=date(2018, 9, 5) formatted_date = util.extended_strftime(test_date, '%b %d, %Y') self.assertEqual(formatted_date, 'Sep 05, 2018')
def test_date_formatted_with_custom_month_abbreviation(self): test_date=date(2018, 9, 5) formatted_date = util.extended_strftime(test_date, '%_m %d, %Y') self.assertEqual(formatted_date, 'Sept. 05, 2018')
def test_date_formatted_without_leading_zero_in_day(self): test_date=date(2018, 4, 5) formatted_date = util.extended_strftime(test_date, '%b %_d, %Y') self.assertEqual(formatted_date, 'Apr 5, 2018')
def date_formatter(dt, text_format=False): format = '%_m %_d, %Y' if text_format else '%b %d, %Y' return extended_strftime(dt, format)
def test_date_formatted_with_default_pattern(self): test_date = date(2018, 9, 5) formatted_date = util.extended_strftime(test_date, '%b %d, %Y') self.assertEqual(formatted_date, 'Sep 05, 2018')
def test_date_formatted_with_custom_month_abbreviation(self): test_date = date(2018, 9, 5) formatted_date = util.extended_strftime(test_date, '%_m %d, %Y') self.assertEqual(formatted_date, 'Sept. 05, 2018')
def test_date_formatted_without_leading_zero_in_day(self): test_date = date(2018, 4, 5) formatted_date = util.extended_strftime(test_date, '%b %_d, %Y') self.assertEqual(formatted_date, 'Apr 5, 2018')