mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
unicode: Fixed a couple of potential unicode problems in auth module.
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5256 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
abf514053b
commit
0e2043deef
@ -7,13 +7,13 @@ from django.db.models import get_models, signals
|
|||||||
from django.contrib.auth import models as auth_app
|
from django.contrib.auth import models as auth_app
|
||||||
|
|
||||||
def _get_permission_codename(action, opts):
|
def _get_permission_codename(action, opts):
|
||||||
return '%s_%s' % (action, opts.object_name.lower())
|
return u'%s_%s' % (action, opts.object_name.lower())
|
||||||
|
|
||||||
def _get_all_permissions(opts):
|
def _get_all_permissions(opts):
|
||||||
"Returns (codename, name) for all permissions in the given opts."
|
"Returns (codename, name) for all permissions in the given opts."
|
||||||
perms = []
|
perms = []
|
||||||
for action in ('add', 'change', 'delete'):
|
for action in ('add', 'change', 'delete'):
|
||||||
perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name)))
|
perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))
|
||||||
return perms + list(opts.permissions)
|
return perms + list(opts.permissions)
|
||||||
|
|
||||||
def create_permissions(app, created_models, verbosity):
|
def create_permissions(app, created_models, verbosity):
|
||||||
|
@ -4,6 +4,7 @@ from django.db import backend, connection, models
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.utils.translation import ugettext_lazy, ugettext as _
|
from django.utils.translation import ugettext_lazy, ugettext as _
|
||||||
import datetime
|
import datetime
|
||||||
|
import urllib
|
||||||
|
|
||||||
def check_password(raw_password, enc_password):
|
def check_password(raw_password, enc_password):
|
||||||
"""
|
"""
|
||||||
@ -132,7 +133,7 @@ class User(models.Model):
|
|||||||
return self.username
|
return self.username
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return "/users/%s/" % self.username
|
return "/users/%s/" % urllib.quote(smart_str(self.username))
|
||||||
|
|
||||||
def is_anonymous(self):
|
def is_anonymous(self):
|
||||||
"Always returns False. This is a way of comparing User objects to anonymous users."
|
"Always returns False. This is a way of comparing User objects to anonymous users."
|
||||||
@ -145,7 +146,7 @@ class User(models.Model):
|
|||||||
|
|
||||||
def get_full_name(self):
|
def get_full_name(self):
|
||||||
"Returns the first_name plus the last_name, with a space in between."
|
"Returns the first_name plus the last_name, with a space in between."
|
||||||
full_name = '%s %s' % (self.first_name, self.last_name)
|
full_name = u'%s %s' % (self.first_name, self.last_name)
|
||||||
return full_name.strip()
|
return full_name.strip()
|
||||||
|
|
||||||
def set_password(self, raw_password):
|
def set_password(self, raw_password):
|
||||||
@ -206,7 +207,7 @@ class User(models.Model):
|
|||||||
def get_all_permissions(self):
|
def get_all_permissions(self):
|
||||||
if not hasattr(self, '_perm_cache'):
|
if not hasattr(self, '_perm_cache'):
|
||||||
import sets
|
import sets
|
||||||
self._perm_cache = sets.Set(["%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
|
self._perm_cache = sets.Set([u"%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
|
||||||
self._perm_cache.update(self.get_group_permissions())
|
self._perm_cache.update(self.get_group_permissions())
|
||||||
return self._perm_cache
|
return self._perm_cache
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user