def author_detail(request, **kwargs): """Display the entries of an author""" username = kwargs.pop('username') page = kwargs['page'] if 'page' in kwargs else None author = get_object_or_404(User, username=username) extra_context = {'author': author} filter = {} if ZINNIA_BLOG_ACTIVE: blog_slug = kwargs.pop('blog_slug') blog = get_object_or_404(Blog, slug = blog_slug) # We check if author is a blog author if author not in blog.authors.all(): raise Http404('User not valid') filter = {'blog__slug': blog_slug} extra_context.update({'blog': blog, 'filters': filter}) queryset = entries_published(author.entry_set).filter(**filter) return object_list(request, queryset=queryset, paginate_by=PAGINATION, page=page, extra_context=extra_context)
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 test_entries_published(self): self.assertEqual(entries_published(Entry.objects.all()).count(), 1) self.entry_2.status = PUBLISHED self.entry_2.save() self.assertEqual(entries_published(Entry.objects.all()).count(), 2) self.entry_1.sites.clear() self.assertEqual(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.assertEqual(entries_published(Entry.objects.all()).count(), 1) self.entry_1.start_publication = datetime(2000, 1, 1) self.entry_1.save() self.assertEqual(entries_published(Entry.objects.all()).count(), 2) self.entry_1.end_publication = datetime(2000, 1, 1) self.entry_1.save() self.assertEqual(entries_published(Entry.objects.all()).count(), 1) self.entry_1.end_publication = datetime(2020, 1, 1) self.entry_1.save() self.assertEqual(entries_published(Entry.objects.all()).count(), 2)
def entries_published(self): """ Returns author's published entries. """ return entries_published(self.entries)
def items(self, obj): """Items are the published entries of the author""" return entries_published(obj.entry_set)[:FEEDS_MAX_ITEMS]
def entries_published(self): """ Returns category's published entries. """ return entries_published(self.entries)
def items(self, obj): return entries_published(obj.entry_set)[:FEEDS_MAX_ITEMS]
def lastmod(self, obj): """Return last modification of an author""" entries = entries_published(obj.entry_set) if not entries: return None return entries[0].creation_date
def entries_published(self): """Return only the entries published""" return entries_published(self.entries)
def get_query_set(self): language = get_lang() result = entries_published(super(EntryPublishedManager, self).get_query_set()) if language: result = result.filter(language=language) return result
def lastmod(self, obj): entries = entries_published(obj.entry_set) if not entries: return None return entries[0].creation_date
def entries_published_set(self, blog_slug=''): """Return only the entries published""" filter = {} if ZINNIA_BLOG_ACTIVE: filter.update({'blog__slug': blog_slug}) return entries_published(self.entry_set.filter(**filter))
def related_published_set(self): # FIXME: PUBLISHED FILTER """Return only related entries published""" return entries_published(self.related)
def cache(self, categories=[]): len_entries = float(Entry.published.count()) self.cache_categories = {} for cat in categories: self.cache_categories[cat.pk] = entries_published(cat.entry_set).count() / len_entries
def items(self, obj): """Items are the published entries of the author""" return entries_published(obj.entries)[:FEEDS_MAX_ITEMS]
def related_published_set(self): """Return only related entries published""" return entries_published(self.related)
def related_published(self): """Return only related entries published""" return entries_published(self.related)
def related_published(self): """ Returns only related entries published. """ return entries_published(self.related)
def items(self, obj): return entries_published(obj.entry_set)
def author_detail(request, username): """Display the entries of an author""" author = get_object_or_404(User, username=username) return object_list(request, queryset=entries_published(author.entry_set), extra_context={'author': author})
def items(self, obj): queryset = obj.entry_set if self.blog_slug: queryset = obj.entry_set.filter(blog__slug = self.blog_slug) return entries_published(queryset)