seldon/django-flexi-auth — Issue #19: Unicode problems in models.py
Author: feroda
Created: 2012-01-11 15:49:25+00:00
State: open

The present patch fixes them

---
flexi_auth/models.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flexi_auth/models.py b/flexi_auth/models.py
index 34047a4..5303ba2 100644
--- a/flexi_auth/models.py
+++ b/flexi_auth/models.py
@@ -93,11 +93,11 @@ class Param(models.Model):
value = generic.GenericForeignKey(ct_field="content_type", fk_field="object_id")

def __unicode__(self):
- return u"%s" % self.value
+ return self.value
#return u"%s: %s" % (self.name, self.value)

def __repr__(self):
- return "<%s %s: %s>" % (self.__class__.__name__, self.name, self.value)
+ return u"<%s %s: %s>" % (self.__class__.__name__, self.name, self.value)

class Meta:
# forbid duplicated ``Param`` entries in the DB
@@ -181,8 +181,8 @@ class ParamRole(models.Model):
objects = RoleManager()

def __unicode__(self):
- param_str_list = ["%s" % s for s in self.params]
- return _(u"%(role)s for %(params)s") % { 'role' : ROLES_DICT[self.role.name], 'params': ", ".join(param_str_list)}
+ param_str_list = [unicode(s) for s in self.params]
+ return _(u"%(role)s for %(params)s") % { 'role' : ROLES_DICT[self.role.name], 'params': u", ".join(param_str_list)}

@property
def params(self):
@@ -338,7 +338,7 @@ class PrincipalParamRoleRelation(models.Model):
role = models.ForeignKey(ParamRole, related_name="principal_param_role_set")

def __unicode__(self):
- return _("%(user)s is %(role)s") % { 'user' : self.user, 'role' : self.role }
+ return _(u"%(user)s is %(role)s") % { 'user' : self.user, 'role' : self.role }

def get_principal(self):
"""
--
1.7.8.3