-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: develop
Are you sure you want to change the base?
Conversation
* Allow regex renaming of unnamed devices (already allowed actually) * Catch errors relating to unnamed devices or integrity errors as a result of the rename process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be simpler to just replace original values of None with an empty string?
except IntegrityError as e: | ||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes strictly relevant to #14044? If not, we should break them out into a separate bug report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are. This will throw a validation error if we don't use regex (We can easily dump that though if we want to go to None == ''
)
The Integrity error will catch any associated integrity errors. I tried to fine a way to separate the integrity error out and only capture an integrity error that relates to the name field but it wasn't easily do-able.
This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken. |
AFAICT the only change actually needed to address #14044 is to ensure that a null name is always treated as an empty string. (Currently this is true only when regex is enabled.) Have I missed something? |
I can get that fixed up right away then |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken. |
…into 14044-bulkrename-nameless-devices
Fixes: #14044 - Allow regex renaming of unnamed devices
Note: I removed the ^$ requirement as, in my view, as long as there is a valid regex and the regex results in a unique set, we don't need to enforce the ^$ requirement. For example:
^
or.*
or.
would all be equally as valid.The main changes here catch both IntegrityError's from the DB and a validation error to ensure regex is used.