mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 07:56:06 -03:30
cleaner get/create impl
This commit is contained in:
@@ -136,11 +136,8 @@ class Role(CommonModelNameNotUnique):
|
||||
|
||||
@staticmethod
|
||||
def singleton(name):
|
||||
try:
|
||||
return Role.objects.get(singleton_name=name)
|
||||
except Role.DoesNotExist:
|
||||
ret = Role.objects.create(singleton_name=name, name=name)
|
||||
return ret
|
||||
role, _ = Role.objects.get_or_create(singleton_name=name, name=name)
|
||||
return role
|
||||
|
||||
def is_ancestor_of(self, role):
|
||||
return role.ancestors.filter(id=self.id).exists()
|
||||
|
||||
Reference in New Issue
Block a user