Пример #1
0
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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 def entries_published(self):
     """
     Returns author's published entries.
     """
     return entries_published(self.entries)
Пример #5
0
 def items(self, obj):
     """Items are the published entries of the author"""
     return entries_published(obj.entry_set)[:FEEDS_MAX_ITEMS]
Пример #6
0
 def entries_published(self):
     """
     Returns author's published entries.
     """
     return entries_published(self.entries)
Пример #7
0
 def entries_published(self):
     """
     Returns category's published entries.
     """
     return entries_published(self.entries)
Пример #8
0
 def items(self, obj):
     return entries_published(obj.entry_set)[:FEEDS_MAX_ITEMS]
Пример #9
0
 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
Пример #10
0
 def entries_published(self):
     """Return only the entries published"""
     return entries_published(self.entries)
Пример #11
0
 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
Пример #12
0
 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
Пример #13
0
 def lastmod(self, obj):
     entries = entries_published(obj.entry_set)
     if not entries:
         return None
     return entries[0].creation_date
Пример #14
0
 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))
Пример #15
0
 def related_published_set(self):   # FIXME: PUBLISHED FILTER
     """Return only related entries published"""
     return entries_published(self.related)
Пример #16
0
 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
Пример #17
0
 def items(self, obj):
     """Items are the published entries of the author"""
     return entries_published(obj.entries)[:FEEDS_MAX_ITEMS]
Пример #18
0
 def related_published_set(self):
     """Return only related entries published"""
     return entries_published(self.related)
Пример #19
0
 def related_published(self):
     """Return only related entries published"""
     return entries_published(self.related)
Пример #20
0
 def related_published(self):
     """
     Returns only related entries published.
     """
     return entries_published(self.related)
Пример #21
0
 def items(self, obj):
     return entries_published(obj.entry_set)
Пример #22
0
 def entries_published(self):
     """
     Returns category's published entries.
     """
     return entries_published(self.entries)
Пример #23
0
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})
Пример #24
0
 def entries_published(self):
     """Return only the entries published"""
     return entries_published(self.entries)
Пример #25
0
 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)