mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
Merge pull request #1454 from wwitzel3/fix-role-summary
Fix role summary when role description is overloaded
This commit is contained in:
@@ -484,13 +484,25 @@ def role_summary_fields_generator(content_object, role_field):
|
|||||||
global role_names
|
global role_names
|
||||||
summary = {}
|
summary = {}
|
||||||
description = role_descriptions[role_field]
|
description = role_descriptions[role_field]
|
||||||
|
|
||||||
|
model_name = None
|
||||||
content_type = ContentType.objects.get_for_model(content_object)
|
content_type = ContentType.objects.get_for_model(content_object)
|
||||||
if '%s' in description and content_type:
|
if content_type:
|
||||||
model = content_object.__class__
|
model = content_object.__class__
|
||||||
model_name = re.sub(r'([a-z])([A-Z])', r'\1 \2', model.__name__).lower()
|
model_name = re.sub(r'([a-z])([A-Z])', r'\1 \2', model.__name__).lower()
|
||||||
description = description % model_name
|
|
||||||
|
|
||||||
summary['description'] = description
|
value = description
|
||||||
|
if type(description) == dict:
|
||||||
|
value = None
|
||||||
|
if model_name:
|
||||||
|
value = description.get(model_name)
|
||||||
|
if value is None:
|
||||||
|
value = description.get('default')
|
||||||
|
|
||||||
|
if '%s' in value and model_name:
|
||||||
|
value = value % model_name
|
||||||
|
|
||||||
|
summary['description'] = value
|
||||||
summary['name'] = role_names[role_field]
|
summary['name'] = role_names[role_field]
|
||||||
summary['id'] = getattr(content_object, '{}_id'.format(role_field))
|
summary['id'] = getattr(content_object, '{}_id'.format(role_field))
|
||||||
return summary
|
return summary
|
||||||
|
|||||||
Reference in New Issue
Block a user