mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 14:09:28 -02:30
Making labels additive and not adding a many item to config if already in parent
This commit is contained in:
committed by
Alan Rominger
parent
68e11d2b81
commit
e076f1ee2a
@@ -531,13 +531,16 @@ def copy_m2m_relationships(obj1, obj2, fields, kwargs=None):
|
||||
src_field_value = getattr(obj1, field_name)
|
||||
if kwargs and field_name in kwargs:
|
||||
override_field_val = kwargs[field_name]
|
||||
# TODO: Should we spike this our or just put the for loop inside the next if and make everything respect order?
|
||||
if field_name == 'instance_groups':
|
||||
# instance_groups are a list but we need to preserve the order
|
||||
for ig_id in override_field_val:
|
||||
getattr(obj2, field_name).add(ig_id)
|
||||
continue
|
||||
if isinstance(override_field_val, (set, list, QuerySet)):
|
||||
# Labels are additive so we are going to add any src labels in addition to the override labels
|
||||
if field_name == 'labels':
|
||||
for jt_label in src_field_value.all():
|
||||
getattr(obj2, field_name).add(jt_label.id)
|
||||
getattr(obj2, field_name).add(*override_field_val)
|
||||
continue
|
||||
if override_field_val.__class__.__name__ == 'ManyRelatedManager':
|
||||
|
||||
Reference in New Issue
Block a user