mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-27 02:43:01 +00:00
[permission] Use full names for permission types
This commit is contained in:
parent
5a831136ae
commit
2a4ab09753
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user