Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #14044 - Allow regex renaming of unnamed devices #17212

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions netbox/netbox/views/generic/bulk_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ def _rename_objects(self, form, selected_objects):
renamed_pks = []

for obj in selected_objects:

# Take a snapshot of change-logged models
if hasattr(obj, 'snapshot'):
obj.snapshot()
Expand All @@ -748,7 +747,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 @@ -783,6 +782,10 @@ def post(self, request):
)
return redirect(self.get_return_url(request))

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

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