Skip to content

Commit

Permalink
fixup! Add handling for non existent components
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Nov 24, 2023
1 parent 9805e9f commit d09d925
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions python/nav/web/maintenance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def components_for_keys(component_keys):
)
if not component_data['service']:
component_data_errors.append(
"service: no elements with the given pks found"
"service: no elements with the given identifiers found"
)
if component_keys['netbox']:
component_data['netbox'] = Netbox.objects.filter(
Expand All @@ -169,28 +169,32 @@ def components_for_keys(component_keys):
'room__location__description',
)
if not component_data['netbox']:
component_data_errors.append("netbox: no elements with the given pks found")
component_data_errors.append(
"netbox: no elements with the given identifiers found"
)
if component_keys['room']:
component_data['room'] = Room.objects.filter(
id__in=component_keys['room']
).values('id', 'description', 'location__id', 'location__description')
if not component_data['room']:
component_data_errors.append("room: no elements with the given pks found")
component_data_errors.append(
"room: no elements with the given identifiers found"
)
if component_keys['location']:
component_data['location'] = Location.objects.filter(
id__in=component_keys['location']
).values('id', 'description')
if not component_data['location']:
component_data_errors.append(
"location: no elements with the given pks found"
"location: no elements with the given identifiers found"
)
if component_keys['netboxgroup']:
component_data['netboxgroup'] = NetboxGroup.objects.filter(
id__in=component_keys['netboxgroup']
).values('id', 'description')
if not component_data['netboxgroup']:
component_data_errors.append(
"netboxgroup: no elements with the given pks found"
"netboxgroup: no elements with the given identifiers found"
)
return component_data, component_data_errors

Expand Down

0 comments on commit d09d925

Please sign in to comment.