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)
示例#3
0
 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)
示例#4
0
 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
示例#5
0
 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(),
            }
示例#7
0
 def render(self, context):
     context[self.context_var] = tags_published()
     return ''
示例#8
0
 def items(self):
     """Return all tags with coeff"""
     tags = tags_published()
     self.cache(tags)
     return tags
示例#9
0
 def render(self, context):
     context[self.context_var] = tags_published()
     return ''
示例#10
0
 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())
示例#11
0
 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())
示例#12
0
文件: sitemaps.py 项目: PhiTheta/ISON
 def items(self):
     """Return all tags with coeff"""
     tags = tags_published()
     self.cache(tags)
     return tags