Skip to content

Commit

Permalink
Bug 585494: nickname blacklist is all utf-8'd up now
Browse files Browse the repository at this point in the history
  • Loading branch information
chenba committed Aug 10, 2010
1 parent 9da9d71 commit b3e06b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/users/admin.py
@@ -1,5 +1,6 @@
from django.contrib import admin, messages
from django.db.utils import IntegrityError
from django.utils.encoding import smart_unicode

import jingo

Expand Down Expand Up @@ -52,7 +53,7 @@ def add_view(self, request, form_url='', extra_context=None):
if BlacklistedNickname.blocked(n):
duplicates += 1
continue
n = n.decode().lower().encode('utf-8')
n = smart_unicode(n).lower().encode('utf-8')
try:
BlacklistedNickname.objects.create(nickname=n)
inserted += 1
Expand Down
3 changes: 2 additions & 1 deletion apps/users/models.py
Expand Up @@ -10,6 +10,7 @@
from django.core.mail import send_mail
from django.db import models
from django.template import Context, loader
from django.utils.encoding import smart_unicode

import caching.base as caching
import commonware.log
Expand Down Expand Up @@ -204,7 +205,7 @@ def __unicode__(self):
@classmethod
def blocked(cls, nick):
"""Check to see if a nickname is in the (cached) blacklist."""
nick = nick.decode().lower().encode('utf-8')
nick = smart_unicode(nick).lower()
qs = cls.objects.all()
f = lambda: dict(qs.values_list('nickname', 'id'))
blacklist = caching.cached_with(qs, f, 'blocked')
Expand Down

0 comments on commit b3e06b9

Please sign in to comment.