Skip to content

Commit

Permalink
Update to treat null name an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps committed Sep 12, 2024
1 parent ec3a7f3 commit f5e1b5a
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions netbox/netbox/views/generic/bulk_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,6 @@ def _rename_objects(self, form, selected_objects):
renamed_pks = []

for obj in selected_objects:
# Validate that the rename will be successful and not trigger an error
if not form.cleaned_data['use_regex'] and not obj.name:
raise ValidationError({
'use_regex': 'You must use regex to rename and must pass uniqueness checks'
})

# Take a snapshot of change-logged models
if hasattr(obj, 'snapshot'):
obj.snapshot()
Expand All @@ -746,7 +740,7 @@ def _rename_objects(self, form, selected_objects):
except re.error:
obj.new_name = obj.name
else:
obj.new_name = obj.name.replace(find, replace)
obj.new_name = (obj.name or '').replace(find, replace)
renamed_pks.append(obj.pk)

return renamed_pks
Expand Down Expand Up @@ -785,10 +779,6 @@ def post(self, request):
messages.error(self.request, ", ".join(e.args))
clear_events.send(sender=self)

except ValidationError as e:
messages.error(self.request, ", ".join(e.messages))
clear_events.send(sender=self)

except (AbortRequest, PermissionsViolation) as e:
logger.debug(e.message)
form.add_error(None, e.message)
Expand Down

0 comments on commit f5e1b5a

Please sign in to comment.