This PR addresses an issue which occured when trying to change a plant's device.
While I don't fully understand exactly why the issue was occuring, merging the user inside of the user_can_use_object() function resulted in the sessions being somehow messed up, and caused the plant name to not be updated despite other parameters of the plant updating.
The fix I found worked was to re-merge the user after calling this function, I have placed the code to remerge after every usage of the user_can_use_object() function just incase. I tried adding this call at the end of the function and creating a wrapper for the function which could merge the sessions after calling, but none of these solutions worked so while I don't love the look, I settled with this.
Inside of the culprit function as well, I changed the functionality so that superusers can edit plants from devices they are not a user on without being added as a user automatically.
This PR addresses an issue which occured when trying to change a plant's device. While I don't fully understand exactly why the issue was occuring, merging the user inside of the
user_can_use_object()
function resulted in the sessions being somehow messed up, and caused the plant name to not be updated despite other parameters of the plant updating.The fix I found worked was to re-merge the user after calling this function, I have placed the code to remerge after every usage of the
user_can_use_object()
function just incase. I tried adding this call at the end of the function and creating a wrapper for the function which could merge the sessions after calling, but none of these solutions worked so while I don't love the look, I settled with this.Inside of the culprit function as well, I changed the functionality so that superusers can edit plants from devices they are not a user on without being added as a user automatically.