From b6908eece142d773b292b0bdccc9d465e420f6ee Mon Sep 17 00:00:00 2001 From: mcarloni Date: Mon, 13 Nov 2023 16:32:08 -0500 Subject: [PATCH] deploy config default hotfix --- roundabout/builds/views_deployments.py | 45 +++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/roundabout/builds/views_deployments.py b/roundabout/builds/views_deployments.py index b53ecce9..0f6e49dc 100644 --- a/roundabout/builds/views_deployments.py +++ b/roundabout/builds/views_deployments.py @@ -461,28 +461,29 @@ def form_valid(self, form): self.request.user, ) # generate inventory configevent with default values on deyployed to field - if not item.inventory_configevents.exists(): - config_event, event_added = ConfigEvent.objects.get_or_create( - inventory=item, - config_type="conf", - configuration_date = action_date, - deployment = self.object - ) - _create_action_history(config_event, Action.ADD, self.request.user, data={}) - if item.assembly_part is not None: - if item.assembly_part.assemblypart_configdefaultevents.exists(): - conf_def_event = item.assembly_part.assemblypart_configdefaultevents.first() - names = ConfigName.objects.filter(config_name_event = item.part.part_confignameevents.first(), config_type ='conf') - for name in names: - try: - default_value = ConfigDefault.objects.get(conf_def_event = conf_def_event, config_name = name).default_value - except ConfigDefault.DoesNotExist: - default_value = None - ConfigValue.objects.create( - config_event = config_event, - config_name = name, - config_value = default_value, - ) + if action_type == Action.DEPLOYMENTTOFIELD: + if not item.inventory_configevents.exists(): + config_event, event_added = ConfigEvent.objects.get_or_create( + inventory=item, + config_type="conf", + configuration_date = action_date, + deployment = self.object + ) + _create_action_history(config_event, Action.ADD, self.request.user, data={}) + if item.assembly_part is not None: + if item.assembly_part.assemblypart_configdefaultevents.exists(): + conf_def_event = item.assembly_part.assemblypart_configdefaultevents.first() + names = ConfigName.objects.filter(config_name_event = item.part.part_confignameevents.first(), config_type ='conf') + for name in names: + try: + default_value = ConfigDefault.objects.get(conf_def_event = conf_def_event, config_name = name).default_value + except ConfigDefault.DoesNotExist: + default_value = None + ConfigValue.objects.create( + config_event = config_event, + config_name = name, + config_value = default_value, + )