[permission] Use full names for permission types

This commit is contained in:
Benjamin Graillot 2019-09-18 16:39:37 +02:00
parent 5a831136ae
commit 2a4ab09753
1 changed files with 5 additions and 5 deletions

View File

@ -54,10 +54,10 @@ class InstancedPermission:
class Permission(models.Model): class Permission(models.Model):
PERMISSION_TYPES = [ PERMISSION_TYPES = [
('C', 'add'), ('add', 'add'),
('R', 'view'), ('view', 'view'),
('U', 'change'), ('change', 'change'),
('D', 'delete') ('delete', 'delete')
] ]
model = models.ForeignKey(ContentType, on_delete=models.CASCADE, related_name='+') model = models.ForeignKey(ContentType, on_delete=models.CASCADE, related_name='+')
@ -72,7 +72,7 @@ class Permission(models.Model):
unique_together = ('model', 'permission', 'type', 'field') unique_together = ('model', 'permission', 'type', 'field')
def clean(self): def clean(self):
if self.field and self.type not in {'R', 'U'}: if self.field and self.type not in {'view', 'change'}:
raise ValidationError(_("Specifying field applies only to view and change permission types.")) raise ValidationError(_("Specifying field applies only to view and change permission types."))
def save(self): def save(self):