django-model-utils
django-model-utils copied to clipboard
HistoryModel and status transition signals?
Hi!
I've discovered this package a little late, after we have implemented something similar for our projects. I would like to either release what we have to open source or perhaps make a pull request to this package to have the missing functionality.
-
We have something similar to the MonitorField, but actually a model that keeps a history of status changes, i.e. timestamp, old_status, new_status, user (who has done the change - from django_user middleware)
-
We have defined transition graph between statuses, i.e. draft can only go active or template but not to sold
TRANSITIONS = {
DRAFT: [ACTIVE, TEMPLATE],
ACTIVE: [SOLD, EXPIRED],
SOLD: [ACTIVE],
EXPIRED: [ACTIVE],
TEMPLATE: [ACTIVE]
}
-
We also have signals on transitions of the status, i.e. Order pending -> confirmed would send a signal to the notification handler (send push notification to the customer for example)
-
We use drf to ensure that the api gets display_name of the status, so that when you get the object status, it is not 0, 1, 2, 3, but draft, confirmed etc
Would this be something to integrate into this package?
@ayushin I can't answer that but LOVE this idea!
@mgrdcm i found something similar already existing https://github.com/viewflow/django-fsm