mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
cleaner get/create impl
This commit is contained in:
parent
e84008fe51
commit
a1d1ddee2b
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user