Closed
Description
We needed to implement a timeline considering the changes made in a specific model. For that, we basically needed the "difference" between two records.
In order to do that, we created a __sub__
method that allowed us to simply do something like this:
history[1] - history[0]
.
The result of this operation is an instance of a class called ModelDelta, that gives us the following information:
- the new value
- the old value
- the fields that changed in the process
- user that made the change (to the new value)
On this ModelDelta class we implemented a function to_timeline
that get every changed field and apply a function to create a timeline entry with some messages like This user changed this fields at this hour
.
I would like to know if you would think this is interesting to be a feature in the project, and if you have suggestion for better approach.