mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-30 03:41:50 -05:00
Merge pull request #1536 from chrismeyersfsu/fix-protect_instance_groups
prevent instance group delete if running jobs
This commit is contained in:
12
awx/main/utils/polymorphic.py
Normal file
12
awx/main/utils/polymorphic.py
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
|
||||
def build_polymorphic_ctypes_map(cls):
|
||||
# {'1': 'unified_job', '2': 'Job', '3': 'project_update', ...}
|
||||
mapping = {}
|
||||
for ct in ContentType.objects.filter(app_label='main'):
|
||||
ct_model_class = ct.model_class()
|
||||
if ct_model_class and issubclass(ct_model_class, cls):
|
||||
mapping[ct.id] = ct_model_class._camel_to_underscore(ct_model_class.__name__)
|
||||
return mapping
|
||||
Reference in New Issue
Block a user