Skip to content

Commit

Permalink
fix: 🐛 Ensure that D42 SSoT doesn't create CustomFields with dashes b…
Browse files Browse the repository at this point in the history
…y accident.
  • Loading branch information
jdrew82 committed Nov 17, 2023
1 parent af03bde commit 9d33dc2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nautobot_ssot/integrations/device42/utils/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,16 @@ def update_custom_fields(new_cfields: dict, update_obj: object):
)
removed_cf.delete()
for new_cf, new_cf_dict in new_cfields.items():
new_key = new_cf_dict["key"].replace(" ", "_").replace("-", "_")
if new_cf not in current_cf:
_cf_dict = {
"key": new_cf_dict["key"],
"key": new_key,
"type": CustomFieldTypeChoices.TYPE_TEXT,
"label": new_cf_dict["key"],
}
field, _ = CustomField.objects.get_or_create(key=_cf_dict["key"], defaults=_cf_dict)
field.content_types.add(ContentType.objects.get_for_model(type(update_obj)).id)
update_obj.custom_field_data.update({new_cf_dict["key"]: new_cf_dict["value"]})
update_obj.custom_field_data.update({new_key: new_cf_dict["value"]})


def verify_circuit_type(circuit_type: str) -> CircuitType:
Expand Down

0 comments on commit 9d33dc2

Please sign in to comment.