def get_content_stats(template='admin/gstudio/widgets/_content_stats.html'): """Return statistics of the contents""" content_type = ContentType.objects.get_for_model(Nodetype) discussions = comments.get_model().objects.filter( is_public=True, content_type=content_type) return { 'template': template, 'nodetypes': Nodetype.published.count(), 'metatypes': Metatype.objects.count(), 'tags': tags_published().count(), 'authors': Author.published.count(), 'comments': discussions.filter(flags=None).count(), 'pingbacks': discussions.filter(flags__flag='pingback').count(), 'trackbacks': discussions.filter(flags__flag='trackback').count(), 'rejects': comments.get_model().objects.filter(is_public=False, content_type=content_type).count(), }
def formfield_for_manytomany(self, db_field, request, **kwargs): """Filtering manytomany field""" if db_field.name == 'authors': kwargs['queryset'] = Author.published.all() if db_field.name == 'tags': kwargs['queryset'] = tags_published() return super(CMSLatestNodetypesPlugin, self).formfield_for_manytomany( db_field, request, **kwargs)
def formfield_for_manytomany(self, db_field, request, **kwargs): """Filtering manytomany field""" if db_field.name == 'authors': kwargs['queryset'] = Author.published.all() if db_field.name == 'tags': kwargs['queryset'] = tags_published() return super(CMSLatestObjecttypesPlugin, self).formfield_for_manytomany( db_field, request, **kwargs)
def get_nodes(self, request): """Return menu's node for tags""" nodes = [] nodes.append(NavigationNode(_('Tags'), reverse('gstudio_tag_list'), 'tags')) for tag in tags_published(): nodes.append(NavigationNode(tag.name, reverse('gstudio_tag_detail', args=[tag.name]), tag.pk, 'tags')) return nodes
def get_content_stats( template='admin/gstudio/widgets/_content_stats.html'): """Return statistics of the contents""" content_type = ContentType.objects.get_for_model(Nodetype) discussions = comments.get_model().objects.filter( is_public=True, content_type=content_type) return {'template': template, 'nodetypes': Nodetype.published.count(), 'metatypes': Metatype.objects.count(), 'tags': tags_published().count(), 'authors': Author.published.count(), 'comments': discussions.filter(flags=None).count(), 'pingbacks': discussions.filter(flags__flag='pingback').count(), 'trackbacks': discussions.filter(flags__flag='trackback').count(), 'rejects': comments.get_model().objects.filter( is_public=False, content_type=content_type).count(), }
def render(self, context): context[self.context_var] = tags_published() return ''
def items(self): """Return all tags with coeff""" tags = tags_published() self.cache(tags) return tags
def test_tags_published(self): self.assertEquals(tags_published().count(), Tag.objects.count()) Tag.objects.create(name='out') self.assertNotEquals(tags_published().count(), Tag.objects.count())