本文整理汇总了Python中zinnia.managers.entries_published函数的典型用法代码示例。如果您正苦于以下问题:Python entries_published函数的具体用法?Python entries_published怎么用?Python entries_published使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了entries_published函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: author_detail
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: test_entries_published
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)
示例3: items
def items(self, obj):
"""Items are the published entries of the author"""
return entries_published(obj.entries)[:FEEDS_MAX_ITEMS]
示例4: entries_published
def entries_published(self):
"""
Returns author's published entries.
"""
return entries_published(self.entries)
示例5: entries_published
def entries_published(self):
"""
Returns category's published entries.
"""
return entries_published(self.entries)
示例6: author_detail
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})
示例7: get_query_set
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
示例8: items
def items(self, obj):
return entries_published(obj.entry_set)[:FEEDS_MAX_ITEMS]
示例9: entries_published_set
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))
示例10: lastmod
def lastmod(self, obj):
entries = entries_published(obj.entry_set)
if not entries:
return None
return entries[0].creation_date
示例11: related_published_set
def related_published_set(self): # FIXME: PUBLISHED FILTER
"""Return only related entries published"""
return entries_published(self.related)
示例12: cache
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
示例13: items
def items(self, obj):
return entries_published(obj.entry_set)
示例14: related_published
def related_published(self):
"""Return only related entries published"""
return entries_published(self.related)
示例15: lastmod
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