mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
cascade delete labels
This commit is contained in:
@@ -1204,7 +1204,7 @@ class LabelAccess(BaseAccess):
|
|||||||
def can_read(self, obj):
|
def can_read(self, obj):
|
||||||
if self.user.is_superuser:
|
if self.user.is_superuser:
|
||||||
return True
|
return True
|
||||||
return obj.organization and obj.organization.accessible_by(self.user, {'read': True})
|
return obj.organization.accessible_by(self.user, {'read': True})
|
||||||
|
|
||||||
def can_add(self, data):
|
def can_add(self, data):
|
||||||
if self.user.is_superuser:
|
if self.user.is_superuser:
|
||||||
@@ -1224,7 +1224,7 @@ class LabelAccess(BaseAccess):
|
|||||||
if self.can_add(data) is False:
|
if self.can_add(data) is False:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return obj.organization and obj.organization.accessible_by(self.user, ALL_PERMISSIONS)
|
return obj.organization.accessible_by(self.user, ALL_PERMISSIONS)
|
||||||
|
|
||||||
def can_delete(self, obj):
|
def can_delete(self, obj):
|
||||||
return self.can_change(obj, None)
|
return self.can_change(obj, None)
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ class Label(CommonModelNameNotUnique):
|
|||||||
organization = models.ForeignKey(
|
organization = models.ForeignKey(
|
||||||
'Organization',
|
'Organization',
|
||||||
related_name='labels',
|
related_name='labels',
|
||||||
blank=True,
|
|
||||||
null=True,
|
|
||||||
default=None,
|
|
||||||
help_text=_('Organization this label belongs to.'),
|
help_text=_('Organization this label belongs to.'),
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.CASCADE,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user