The original method was very unclear about what it was doing, and also
saved the base object more often than was necessary. I added a lot of comments
to explain what's happening, and restructured the code so that the variables
and the reasons for following certain branches are clearer and the code is
more readable in my view.
I also avoid calling self.changed_object.save(), and call save_base(raw=True)
instead to avoid triggering the pre_save and post_save hooks again, which would
re-moderate the object.
The original method was very unclear about what it was doing, and also saved the base object more often than was necessary. I added a lot of comments to explain what's happening, and restructured the code so that the variables and the reasons for following certain branches are clearer and the code is more readable in my view.
I also avoid calling self.changed_object.save(), and call save_base(raw=True) instead to avoid triggering the pre_save and post_save hooks again, which would re-moderate the object.