Add the __str__ method and stored_permission proxy property to the Permission class
This commit is contained in:
@@ -81,10 +81,17 @@ class Permission(object):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(self.label)
|
return unicode(self.label)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.__unicode__())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def uuid(self):
|
def uuid(self):
|
||||||
return u'%s.%s' % (self.namespace.name, self.name)
|
return u'%s.%s' % (self.namespace.name, self.name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stored_permission(self):
|
||||||
|
return self.get_stored_permission()
|
||||||
|
|
||||||
def get_stored_permission(self):
|
def get_stored_permission(self):
|
||||||
stored_permission, created = StoredPermission.objects.get_or_create(
|
stored_permission, created = StoredPermission.objects.get_or_create(
|
||||||
namespace=self.namespace.name,
|
namespace=self.namespace.name,
|
||||||
@@ -101,8 +108,7 @@ class Permission(object):
|
|||||||
return stored_permission.requester_has_this(requester)
|
return stored_permission.requester_has_this(requester)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
return self.get_stored_permission(
|
return self.get_stored_permission()
|
||||||
)
|
|
||||||
|
|
||||||
Permission.objects = PermissionManager(Permission)
|
Permission.objects = PermissionManager(Permission)
|
||||||
Permission._default_manager = Permission.objects
|
Permission._default_manager = Permission.objects
|
||||||
|
|||||||
Reference in New Issue
Block a user