1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 07:52:23 +00:00

[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

View File

@ -54,10 +54,10 @@ class InstancedPermission:
class Permission(models.Model):
PERMISSION_TYPES = [
('C', 'add'),
('R', 'view'),
('U', 'change'),
('D', 'delete')
('add', 'add'),
('view', 'view'),
('change', 'change'),
('delete', 'delete')
]
model = models.ForeignKey(ContentType, on_delete=models.CASCADE, related_name='+')
@ -72,7 +72,7 @@ class Permission(models.Model):
unique_together = ('model', 'permission', 'type', 'field')
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."))
def save(self):