Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
leportella opened this issue Nov 8, 2016 · 3 comments
Closed

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

leportella opened this issue Nov 8, 2016 · 3 comments

Comments

@leportella
Copy link
Collaborator

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.

@bmampaey
Copy link
Contributor

I would be very interested in such a functionality, as I need the same thing in my project.

Could you already share the code with us? Either with a pull or a djangosnippet?

@michi88
Copy link

michi88 commented Nov 20, 2016

@leportella Yes! I would love to see this going as a django admin view. There is an old PR #103 that adds a history compare view. Maybe we can combine the 2? Happy to help!

@rossmechanic
Copy link
Collaborator

Closed by #416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants