Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1740 -- django.contrib.comments no longer uses old-style DB AP…

…I (thanks, ubernostrum)

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2823 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ceecba2973d0ff965936425ab0c9e09a4d50e537 1 parent 3ec6865
Jacob Kaplan-Moss authored

Showing 1 changed file with 8 additions and 8 deletions. Show diff stats Hide diff stats

  1. 16  django/contrib/comments/models.py
16  django/contrib/comments/models.py
@@ -56,7 +56,7 @@ def get_list_with_karma(self, **kwargs):
56 56
     def user_is_moderator(self, user):
57 57
         if user.is_superuser:
58 58
             return True
59  
-        for g in user.get_group_list():
  59
+        for g in user.group_set.all():
60 60
             if g.id == settings.COMMENTS_MODERATORS_GROUP:
61 61
                 return True
62 62
         return False
@@ -124,7 +124,7 @@ def get_content_object(self):
124 124
         """
125 125
         from django.core.exceptions import ObjectDoesNotExist
126 126
         try:
127  
-            return self.get_content_type().get_object_for_this_type(pk=self.object_id)
  127
+            return self.content_type.get_object_for_this_type(pk=self.object_id)
128 128
         except ObjectDoesNotExist:
129 129
             return None
130 130
 
@@ -133,7 +133,7 @@ def get_content_object(self):
133 133
     def _fill_karma_cache(self):
134 134
         "Helper function that populates good/bad karma caches"
135 135
         good, bad = 0, 0
136  
-        for k in self.get_karmascore_list():
  136
+        for k in self.karmascore_set:
137 137
             if k.score == -1:
138 138
                 bad +=1
139 139
             elif k.score == 1:
@@ -158,7 +158,7 @@ def get_karma_total(self):
158 158
     def get_as_text(self):
159 159
         return _('Posted by %(user)s at %(date)s\n\n%(comment)s\n\nhttp://%(domain)s%(url)s') % \
160 160
             {'user': self.user.username, 'date': self.submit_date,
161  
-            'comment': self.comment, 'domain': self.get_site().domain, 'url': self.get_absolute_url()}
  161
+            'comment': self.comment, 'domain': self.site.domain, 'url': self.get_absolute_url()}
162 162
 
163 163
 class FreeComment(models.Model):
164 164
     # A FreeComment is a comment by a non-registered user.
@@ -200,7 +200,7 @@ def get_content_object(self):
200 200
         """
201 201
         from django.core.exceptions import ObjectDoesNotExist
202 202
         try:
203  
-            return self.get_content_type().get_object_for_this_type(pk=self.object_id)
  203
+            return self.content_type.get_object_for_this_type(pk=self.object_id)
204 204
         except ObjectDoesNotExist:
205 205
             return None
206 206
 
@@ -209,9 +209,9 @@ def get_content_object(self):
209 209
 class KarmaScoreManager(models.Manager):
210 210
     def vote(self, user_id, comment_id, score):
211 211
         try:
212  
-            karma = self.objects.get(comment__id__exact=comment_id, user__id__exact=user_id)
  212
+            karma = self.objects.get(comment__pk=comment_id, user__pk=user_id)
213 213
         except self.model.DoesNotExist:
214  
-            karma = self.model(None, user_id, comment_id, score, datetime.datetime.now())
  214
+            karma = self.model(None, user_id=user_id, comment_id=comment_id, score=score, scored_date=datetime.datetime.now())
215 215
             karma.save()
216 216
         else:
217 217
             karma.score = score
@@ -251,7 +251,7 @@ def flag(self, comment, user):
251 251
         if int(comment.user_id) == int(user.id):
252 252
             return # A user can't flag his own comment. Fail silently.
253 253
         try:
254  
-            f = self.objects.get(user__id__exact=user.id, comment__id__exact=comment.id)
  254
+            f = self.objects.get(user__pk=user.id, comment__pk=comment.id)
255 255
         except self.model.DoesNotExist:
256 256
             from django.core.mail import mail_managers
257 257
             f = self.model(None, user.id, comment.id, None)

0 notes on commit ceecba2

Please sign in to comment.
Something went wrong with that request. Please try again.