Skip to content

Commit

Permalink
pep8 corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun Sephton committed Jul 24, 2012
1 parent e277882 commit 72b61e6
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 93 deletions.
6 changes: 3 additions & 3 deletions moderator/admin.py
Expand Up @@ -7,13 +7,13 @@ class ClassifiedCommentAdmin(admin.ModelAdmin):
list_display = ('cls', 'comment_text', 'removed')
list_display_links = ('removed', )
list_editable = ('cls', )
list_filter = ('cls',)
list_filter = ('cls', )

def comment_text(self, obj):
return defaultfilters.linebreaks(obj.comment.comment)
comment_text.short_description = 'Comment'
comment_text.allow_tags = True

def removed(self, obj):
return obj.comment.is_removed
removed.boolean = True
Expand Down
4 changes: 2 additions & 2 deletions moderator/management/commands/classifycomments.py
Expand Up @@ -6,13 +6,13 @@

class Command(BaseCommand):
help = 'Classifies comments as either spam or '\
'ham using Bayesian inference.'
'ham using Bayesian inference.'

def handle(self, *args, **options):
self.stdout.write('Classifying, please wait...\n')
classified_comments = ClassifiedComment.objects.all()
unclassified_comments = Comment.objects.exclude(
pk__in=[classified_comment.pk \
pk__in=[classified_comment.pk
for classified_comment in classified_comments]
)
for comment in unclassified_comments:
Expand Down
2 changes: 1 addition & 1 deletion moderator/models.py
Expand Up @@ -16,7 +16,7 @@ class ClassifiedComment(models.Model):
)

class Meta:
ordering = ['-comment__submit_date',]
ordering = ['-comment__submit_date', ]

def save(self, *args, **kwargs):
created = not self.pk
Expand Down
8 changes: 4 additions & 4 deletions moderator/storage.py
Expand Up @@ -89,10 +89,10 @@ def __init__(self, spam_count, ham_count):

spam = self.redis.get(self.state_keys['spam'])
ham = self.redis.get(self.state_keys['ham'])
if spam == None:
if spam is None:
self.redis.set(self.state_keys['spam'], '0')
spam = self.redis.get(self.state_keys['spam'])
if ham == None:
if ham is None:
self.redis.set(self.state_keys['ham'], '0')
ham = self.redis.get(self.state_keys['ham'])

Expand All @@ -114,9 +114,9 @@ def _wordinfoget(self, word):
"""
spam_count = self.redis.get('%s_spam_count' % word)
ham_count = self.redis.get('%s_ham_count' % word)
if spam_count == None:
if spam_count is None:
spam_count = 0
if ham_count == None:
if ham_count is None:
ham_count = 0

word_info = self.WordInfoClass()
Expand Down
5 changes: 3 additions & 2 deletions moderator/templatetags/moderator_inclusion_tags.py
Expand Up @@ -5,14 +5,15 @@
register = template.Library()


@register.inclusion_tag('moderator/inclusion_tags/report_comment_abuse.html', takes_context=True)
@register.inclusion_tag('moderator/inclusion_tags/report_comment_abuse.html',
takes_context=True)
def report_comment_abuse(context, obj):
"""
Checks whether a user can report abuse (has not liked comment previously)
or has reported abuse previously and renders appropriate response.
"""
request = context['request']

can_report = can_vote(obj, request.user, request)
previously_reported = False
if not can_report:
Expand Down

0 comments on commit 72b61e6

Please sign in to comment.