Esempio n. 1
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(CMSLatestGbobjectsPlugin, self).formfield_for_manytomany(
         db_field, request, **kwargs)
Esempio n. 2
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(CMSLatestGbobjectsPlugin,
                  self).formfield_for_manytomany(db_field, request,
                                                 **kwargs)
Esempio n. 3
0
 def get_nodes(self, request):
     """Return menu's node for tags"""
     nodes = []
     nodes.append(
         NavigationNode(_('Tags'), reverse('objectapp_tag_list'), 'tags'))
     for tag in tags_published():
         nodes.append(
             NavigationNode(
                 tag.name, reverse('objectapp_tag_detail', args=[tag.name]),
                 tag.pk, 'tags'))
     return nodes
Esempio n. 4
0
 def get_nodes(self, request):
     """Return menu's node for tags"""
     nodes = []
     nodes.append(NavigationNode(_('Tags'), reverse('objectapp_tag_list'),
                                 'tags'))
     for tag in tags_published():
         nodes.append(NavigationNode(tag.name,
                                     reverse('objectapp_tag_detail',
                                             args=[tag.name]),
                                     tag.pk, 'tags'))
     return nodes
def get_content_stats(
    template='admin/objectapp/widgets/_content_stats.html'):
    """Return statistics of the contents"""
    content_type = ContentType.objects.get_for_model(Gbobject)

    discussions = comments.get_model().objects.filter(
        is_public=True, content_type=content_type)

    return {'template': template,
            'gbobjects': Gbobject.published.count(),
            'objecttypes': Objecttype.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 get_content_stats(
    template='admin/objectapp/widgets/_content_stats.html'):
    """Return statistics of the contents"""
    content_type = ContentType.objects.get_for_model(Gbobject)

    discussions = comments.get_model().objects.filter(
        is_public=True, content_type=content_type)

    return {'template': template,
            'gbobjects': Gbobject.published.count(),
            'objecttypes': Objecttype.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(),
            }
Esempio n. 7
0
 def render(self, context):
     context[self.context_var] = tags_published()
     return ''
 def render(self, context):
     context[self.context_var] = tags_published()
     return ''
Esempio n. 9
0
 def items(self):
     """Return all tags with coeff"""
     tags = tags_published()
     self.cache(tags)
     return tags
Esempio n. 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())
Esempio n. 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())