Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Style fixes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7038 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 332e68d550e152ba762da7da09e6717e1c20a31a 1 parent ff707f5
Gary Wilson Jr. authored January 28, 2008

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

  1. 27  django/contrib/comments/models.py
27  django/contrib/comments/models.py
... ...
@@ -1,25 +1,27 @@
  1
+import datetime
  2
+
1 3
 from django.db import models
2 4
 from django.contrib.contenttypes.models import ContentType
3 5
 from django.contrib.sites.models import Site
4 6
 from django.contrib.auth.models import User
5 7
 from django.utils.translation import ugettext_lazy as _
6 8
 from django.conf import settings
7  
-import datetime
8 9
 
9 10
 MIN_PHOTO_DIMENSION = 5
10 11
 MAX_PHOTO_DIMENSION = 1000
11 12
 
12  
-# option codes for comment-form hidden fields
  13
+# Option codes for comment-form hidden fields.
13 14
 PHOTOS_REQUIRED = 'pr'
14 15
 PHOTOS_OPTIONAL = 'pa'
15 16
 RATINGS_REQUIRED = 'rr'
16 17
 RATINGS_OPTIONAL = 'ra'
17 18
 IS_PUBLIC = 'ip'
18 19
 
19  
-# what users get if they don't have any karma
  20
+# What users get if they don't have any karma.
20 21
 DEFAULT_KARMA = 5
21 22
 KARMA_NEEDED_BEFORE_DISPLAYED = 3
22 23
 
  24
+
23 25
 class CommentManager(models.Manager):
24 26
     def get_security_hash(self, options, photo_options, rating_options, target):
25 27
         """
@@ -61,7 +63,9 @@ def user_is_moderator(self, user):
61 63
                 return True
62 64
         return False
63 65
 
  66
+
64 67
 class Comment(models.Model):
  68
+    """A comment by a registered user."""
65 69
     user = models.ForeignKey(User, raw_id_admin=True)
66 70
     content_type = models.ForeignKey(ContentType)
67 71
     object_id = models.IntegerField(_('object ID'))
@@ -86,10 +90,12 @@ class Comment(models.Model):
86 90
     is_removed = models.BooleanField(_('is removed'), help_text=_('Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.'))
87 91
     site = models.ForeignKey(Site)
88 92
     objects = CommentManager()
  93
+
89 94
     class Meta:
90 95
         verbose_name = _('comment')
91 96
         verbose_name_plural = _('comments')
92 97
         ordering = ('-submit_date',)
  98
+
93 99
     class Admin:
94 100
         fields = (
95 101
             (None, {'fields': ('content_type', 'object_id', 'site')}),
@@ -134,7 +140,7 @@ def get_content_object(self):
134 140
     get_content_object.short_description = _('Content object')
135 141
 
136 142
     def _fill_karma_cache(self):
137  
-        "Helper function that populates good/bad karma caches"
  143
+        """Helper function that populates good/bad karma caches."""
138 144
         good, bad = 0, 0
139 145
         for k in self.karmascore_set:
140 146
             if k.score == -1:
@@ -163,8 +169,9 @@ def get_as_text(self):
163 169
             {'user': self.user.username, 'date': self.submit_date,
164 170
             'comment': self.comment, 'domain': self.site.domain, 'url': self.get_absolute_url()}
165 171
 
  172
+
166 173
 class FreeComment(models.Model):
167  
-    # A FreeComment is a comment by a non-registered user.
  174
+    """A comment by a non-registered user."""
168 175
     content_type = models.ForeignKey(ContentType)
169 176
     object_id = models.IntegerField(_('object ID'))
170 177
     comment = models.TextField(_('comment'), max_length=3000)
@@ -175,10 +182,12 @@ class FreeComment(models.Model):
175 182
     # TODO: Change this to is_removed, like Comment
176 183
     approved = models.BooleanField(_('approved by staff'))
177 184
     site = models.ForeignKey(Site)
  185
+
178 186
     class Meta:
179 187
         verbose_name = _('free comment')
180 188
         verbose_name_plural = _('free comments')
181 189
         ordering = ('-submit_date',)
  190
+
182 191
     class Admin:
183 192
         fields = (
184 193
             (None, {'fields': ('content_type', 'object_id', 'site')}),
@@ -212,6 +221,7 @@ def get_content_object(self):
212 221
 
213 222
     get_content_object.short_description = _('Content object')
214 223
 
  224
+
215 225
 class KarmaScoreManager(models.Manager):
216 226
     def vote(self, user_id, comment_id, score):
217 227
         try:
@@ -233,12 +243,14 @@ def get_pretty_score(self, score):
233 243
             return DEFAULT_KARMA
234 244
         return int(round((4.5 * score) + 5.5))
235 245
 
  246
+
236 247
 class KarmaScore(models.Model):
237 248
     user = models.ForeignKey(User)
238 249
     comment = models.ForeignKey(Comment)
239 250
     score = models.SmallIntegerField(_('score'), db_index=True)
240 251
     scored_date = models.DateTimeField(_('score date'), auto_now=True)
241 252
     objects = KarmaScoreManager()
  253
+
242 254
     class Meta:
243 255
         verbose_name = _('karma score')
244 256
         verbose_name_plural = _('karma scores')
@@ -247,6 +259,7 @@ class Meta:
247 259
     def __unicode__(self):
248 260
         return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self.user}
249 261
 
  262
+
250 263
 class UserFlagManager(models.Manager):
251 264
     def flag(self, comment, user):
252 265
         """
@@ -265,11 +278,13 @@ def flag(self, comment, user):
265 278
             mail_managers('Comment flagged', message, fail_silently=True)
266 279
             f.save()
267 280
 
  281
+
268 282
 class UserFlag(models.Model):
269 283
     user = models.ForeignKey(User)
270 284
     comment = models.ForeignKey(Comment)
271 285
     flag_date = models.DateTimeField(_('flag date'), auto_now_add=True)
272 286
     objects = UserFlagManager()
  287
+
273 288
     class Meta:
274 289
         verbose_name = _('user flag')
275 290
         verbose_name_plural = _('user flags')
@@ -278,10 +293,12 @@ class Meta:
278 293
     def __unicode__(self):
279 294
         return _("Flag by %r") % self.user
280 295
 
  296
+
281 297
 class ModeratorDeletion(models.Model):
282 298
     user = models.ForeignKey(User, verbose_name='moderator')
283 299
     comment = models.ForeignKey(Comment)
284 300
     deletion_date = models.DateTimeField(_('deletion date'), auto_now_add=True)
  301
+
285 302
     class Meta:
286 303
         verbose_name = _('moderator deletion')
287 304
         verbose_name_plural = _('moderator deletions')

0 notes on commit 332e68d

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