Conditionally update assets when user's location moves via LDAP #16046
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: [fd-45970]
We added code to change assets' locations if the user's location changes via LDAP. But the way the query was working, it would tweak the 'updated at' attribute on the user whether or not it actually changed the location of the asset in question. This was confusing for one of our customers in how they use the app.
Additionally, if a change was made, there wasn't going to be any log entry in the asset history to explain why it wasn't in the location that it had been before.
This fixes both problems - only making changes to the assets of the user if the user's location has actually changed, and making sure that it's a regular
save()
so that a log entry with an 'update' will still get created.I tested this on our test LDAP server, setting the ldap_location attribute to physicaldeliveryofficename, and setting the 'Office' value of one of the users to one of our locations. Then I changed the user's location on my development environment, did a checkout of an asset to that user, then ran an LDAP sync. When I did that, the asset showed an 'update' action of it moving from the old location to the LDAP-based one.