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('author-list'), 'authors')) for author in authors_published(): nodes.append(NavigationNode(author.username, reverse('author-detail', args=[author.username]), author.pk, 'authors')) return nodes
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 items(self): return authors_published()
"""URLs for blog authors""" from django.conf.urls.defaults import * from blog.managers import authors_published author_conf = {'queryset': authors_published(), 'template_name': 'blog/author_list.html',} urlpatterns = patterns('blog.views.authors', url(r'^$', 'author_list', author_conf, 'author-list'), url(r'^(?P<username>[-\w]+)/$', 'author_detail', name='author-detail'), url(r'^(?P<username>[-\w]+)/page/(?P<page>\d+)/$', 'author_detail', name='author-detail-paginated'), )