def past_projects_json(self, page=1, per_page=10): projects = self.obj.listed_projects.order_by(None) past_projects = projects.filter(Project.state.PUBLISHED, Project.schedule_state.PAST).order_by( Project.schedule_start_at.desc()) pagination = past_projects.paginate(page=page, per_page=per_page) return { 'status': 'ok', 'title': 'Past projects', 'headings': ['Date', 'Project', 'Location'], 'next_page': (pagination.page + 1 if pagination.page < pagination.pages else ''), 'total_pages': pagination.pages, 'past_projects': [{ 'title': p.title, 'datetime': date_filter(p.schedule_start_at_localized, format='dd MMM yyyy'), 'venue': p.primary_venue.city if p.primary_venue else p.location, 'url': p.url_for(), } for p in pagination.items], }
def test_date_localized_short_hi(self): with self.app.test_request_context('/', headers={'Accept-Language': 'hi'}): assert filters.date_filter(self.date, format='short') == '31/1/20'
def test_date_filter(self): with self.app.test_request_context('/'): assert (filters.date_filter(self.date, 'yyyy-MM-dd', usertz=False) == '2020-01-31')
def test_date_mdy(self): with self.app.test_request_context('/'): assert (filters.date_filter(self.datetime, format='short', locale='en_US') == '1/31/20')
def test_month_localized_en(self): with self.app.test_request_context('/'): assert filters.date_filter(self.date, "MMMM") == 'January'
def test_month_localized_hi(self): with self.app.test_request_context('/', headers={'Accept-Language': 'hi'}): assert filters.date_filter(self.date, "MMMM") == 'जनवरी'
def test_date_localized_long_hi(self): with self.app.test_request_context('/', headers={'Accept-Language': 'hi'}): assert filters.date_filter(self.date, format='long') == '31 जनवरी 2020'