App Engine Python SDK version 1.9.12
[gae.git] / python / lib / django-1.2 / django / contrib / comments / managers.py
blob499feee6c3ee8cfa835c5c9d41686e0117fa45ab
1 from django.db import models
2 from django.contrib.contenttypes.models import ContentType
3 from django.utils.encoding import force_unicode
5 class CommentManager(models.Manager):
7 def in_moderation(self):
8 """
9 QuerySet for all comments currently in the moderation queue.
10 """
11 return self.get_query_set().filter(is_public=False, is_removed=False)
13 def for_model(self, model):
14 """
15 QuerySet for all comments for a particular model (either an instance or
16 a class).
17 """
18 ct = ContentType.objects.get_for_model(model)
19 qs = self.get_query_set().filter(content_type=ct)
20 if isinstance(model, models.Model):
21 qs = qs.filter(object_pk=force_unicode(model._get_pk_val()))
22 return qs