Skip to content

Add a "ModelDelta" and "__sub__" method to have a timeline info #244

Closed
@leportella

Description

@leportella

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions