Ejemplo n.º 1
0
Archivo: tests.py Proyecto: srosro/dlog
 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)
Ejemplo n.º 2
0
 def related_published_set(self):
     """Return only related entries published"""
     return entries_published(self.related)
Ejemplo n.º 3
0
Archivo: feeds.py Proyecto: srosro/dlog
 def items(self, obj):
     return entries_published(obj.entry_set)
Ejemplo n.º 4
0
 def lastmod(self, obj):
     entries = entries_published(obj.entry_set)
     if not entries:
         return None
     return entries[0].creation_date
Ejemplo n.º 5
0
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})