def test_sponsor_ordering(): make(Sponsor, name='a', order=1) make(Sponsor, name='b', order=0) make(Sponsor, name='c', order=-1) s = get_sponsors() assert s.count() is 2, 'expected 2 sponsors' assert s[0].order is 0 and s[0].name == 'b' assert s[1].order is 1 and s[1].name == 'a'
def get_context_data(self, **kwargs): ctx = super(IndexView, self).get_context_data(**kwargs) ctx['sponsors'] = get_sponsors() ctx['communities'] = get_featured_groups() news_items = NewsItem.objects.filter(date__lte=datetime.datetime.now()) ctx['news_items'] = news_items[:3] ctx['images'] = get_images() # for now, limit to max of 8. ctx['diary_entries'] = DiaryEntry.objects.filter(publish=True,show_on_main=True)[:8] return ctx
def test_get_sponsors(self): sponsors = get_sponsors() self.assertIsNotNone(sponsors) self.assertEqual(sponsors.count(), 0)
def get_context_data(self, **kwargs): ctx = super(IndexView, self).get_context_data(**kwargs) ctx['sponsors'] = get_sponsors() news_items = NewsItem.objects.filter(date__lte=datetime.datetime.now()) ctx['news_items'] = news_items[:3] return ctx
def get_context_data(self, **kwargs): ctx = super(IndexView, self).get_context_data(**kwargs) ctx['sponsors'] = get_sponsors() return ctx