def test_entries_published(self): self.assertEquals(entries_published(Entry.objects.all()).count(), 1) self.entry_2.status = PUBLISHED self.entry_2.save() self.assertEquals(entries_published(Entry.objects.all()).count(), 2) self.entry_1.sites.clear() self.assertEquals(entries_published(Entry.objects.all()).count(), 1) self.entry_1.sites.add(*self.sites) self.entry_1.start_publication = datetime(2020, 1, 1) self.entry_1.save() self.assertEquals(entries_published(Entry.objects.all()).count(), 1) self.entry_1.start_publication = datetime(2000, 1, 1) self.entry_1.save() self.assertEquals(entries_published(Entry.objects.all()).count(), 2) self.entry_1.end_publication = datetime(2000, 1, 1) self.entry_1.save() self.assertEquals(entries_published(Entry.objects.all()).count(), 1) self.entry_1.end_publication = datetime(2020, 1, 1) self.entry_1.save() self.assertEquals(entries_published(Entry.objects.all()).count(), 2)
def related_published_set(self): """Return only related entries published""" return entries_published(self.related)
def items(self, obj): return entries_published(obj.entry_set)
def lastmod(self, obj): entries = entries_published(obj.entry_set) if not entries: return None return entries[0].creation_date
def author_detail(request, username, page=None): """Display the entries of an author""" author = get_object_or_404(User, username=username) return object_list(request, queryset=entries_published(author.entry_set), paginate_by=PAGINATION, page=page, extra_context={'author': author})