def formfield_for_manytomany(self, db_field, request, **kwargs): if db_field.name == 'authors': kwargs['queryset'] = authors_published() if db_field.name == 'tags': kwargs['queryset'] = tags_published() return super(CMSLatestEntriesPlugin, self).formfield_for_manytomany( db_field, request, **kwargs)
def get_nodes(self, request): nodes = [] nodes.append(NavigationNode(_('Authors'), reverse('zinnia_author_list'), 'authors')) for author in authors_published(): nodes.append(NavigationNode(author.username, reverse('zinnia_author_detail', args=[author.username]), author.pk, 'authors')) return nodes
def get_nodes(self, request): """Return menu's node for authors""" nodes = [] nodes.append(NavigationNode(_("Authors"), reverse("zinnia_author_list"), "authors")) for author in authors_published(): nodes.append( NavigationNode( author.username, reverse("zinnia_author_detail", args=[author.username]), author.pk, "authors" ) ) return nodes
def get_content_stats( template='admin/zinnia/widgets/_content_stats.html'): """Return statistics of the contents""" content_type = ContentType.objects.get_for_model(Entry) discussions = Comment.objects.filter( is_public=True, content_type=content_type) return {'template': template, 'entries': Entry.published.count(), 'categories': Category.objects.count(), 'tags': tags_published().count(), 'authors': authors_published().count(), 'comments': discussions.filter(flags=None).count(), 'pingbacks': discussions.filter(flags__flag='pingback').count(), 'trackbacks': discussions.filter(flags__flag='trackback').count(), 'rejects': Comment.objects.filter( is_public=False, content_type=content_type).count(), }
def test_authors_published(self): self.assertEquals(authors_published().count(), 1) self.entry_2.status = PUBLISHED self.entry_2.save() self.assertEquals(authors_published().count(), 2)
def formfield_for_manytomany(self, db_field, request, **kwargs): if db_field.name == "authors": kwargs["queryset"] = authors_published() if db_field.name == "tags": kwargs["queryset"] = tags_published() return super(PiecemakerZinniaPlugin, self).formfield_for_manytomany(db_field, request, **kwargs)
def items(self): """Return published authors""" return authors_published()
def test_authors_published(self): user = User.objects.create_user(username="******", email="*****@*****.**") self.assertEquals(authors_published().count(), 1) self.entry_2.status = PUBLISHED self.entry_2.save() self.assertEquals(authors_published().count(), 2)
def items(self): return authors_published()
"""Urls for the zinnia categories""" from django.conf.urls.defaults import * from zinnia.managers import authors_published author_conf = {'queryset': authors_published(), 'template_name': 'zinnia/author_list.html',} urlpatterns = patterns('', url(r'^$', 'django.views.generic.list_detail.object_list', author_conf, 'zinnia_author_list'), url(r'^(?P<username>\w+)/$', 'zinnia.views.author_detail', name='zinnia_author_detail'), url(r'^(?P<username>[-\w]+)/page/(?P<page>\d+)/$', 'zinnia.views.author_detail', name='zinnia_author_detail_paginated'), )
def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'author': kwargs['queryset'] = authors_published() return db_field.formfield(**kwargs) return super(CMSLatestEntriesPlugin, self).formfield_for_foreignkey( db_field, request, **kwargs)
"""Urls for the zinnia categories""" from django.conf.urls.defaults import * from zinnia.managers import authors_published author_conf = { 'queryset': authors_published(), 'template_name': 'zinnia/author_list.html', } urlpatterns = patterns('', url(r'^$', 'django.views.generic.list_detail.object_list', author_conf, 'author_list'), url(r'^(?P<username>\w+)/$', 'zinnia.views.author_detail', name='author_detail'), )