-
-
Notifications
You must be signed in to change notification settings - Fork 78
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 description argument to fsm_log_description decorator #143
Add description argument to fsm_log_description decorator #143
Conversation
Thanks, I feel the need to challenge your motivation before moving forward with this.
If it's a fixed description, why to you need to store it in your database? |
Well it's fixed but it can change with a new software release, I want it stored in the database so I can have the history of it and even show it to users. Django-fsm-log already does everything, I just personally think it's more intuitive to write it as I am doing. One of the nice things about django-fsm is that by looking at the transition method a developer can easily see all the conditions, the from/to states and so on. Having the log description in another place (typically where you call the transition method) is less intuitive to me. This pull request just adds a new way to set it, while still giving priority to the already present ways. |
It still feel to me, that you intent to store in the database a value that could be, instead, computed. If I understand your use case correctly, you could programmatically provide this description without having to store it in the database. |
It doesn't always be computed. For an example, today I could have a transaction that has the description "Goods packaged and shipped". It's static. In a month, I change it with "Good packaged, shipped, waiting for pick up". I still want the old transitions to have the old description, only the new ones will have the new description. If I want to change the previous ones too I'll use a database migration. |
Ultimately, this business logic can be supported programmatically, since you (as a developer) are in control of when the description changes. There is no user input here. |
I understand but still don't see it as bad practice to store a fixed string in the database. A query to fetch the logs is surely faster than calculating every time the same fixed string in python. |
I really don't want to add this functionality as it motivated by a use case that violates one of my stongest belief that What the rest of the community think about it ? |
Would love to see this implemented. |
I am with Lorenzo on this one. I get his point. As Lorenzo pointed out, you already can achieve that by simply passing the same string over and over, basically every time you call the transaction method. |
alright, thanks everyone for your feedback. |
@ticosax sure, will work on it |
…rator. Add tests for it.
@ticosax let me know if it's starting to look ok, thank you |
Hi, just to understand, are we waiting for #144 ? Or do I need to fix something here? |
More or less, yes. The tests are not passing on master, we need to fix this first, so you can rebase your branch once master it's fixed. |
@lorenzomorandini @ticosax, Initially, I planned on using For example: Since reading this thread I think that this might be a misuse of this decorator. I'm making this assumption since there isn't any official documentation on this decorator at the moment. If this is indeed a misuse, would you have any suggestions on how I can achieve this functionality. |
@samueljoli I guess it can be used like that too, with the runtime "description.set(...)". |
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
==========================================
+ Coverage 95.05% 95.13% +0.07%
==========================================
Files 25 25
Lines 506 534 +28
==========================================
+ Hits 481 508 +27
- Misses 25 26 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
The aim of this pull request is to give the ability to add a default description to the
fsm_log_description
.The priority would be:
allow_inline
isTrue
Example:
I find it quite useful since nearly always I have a fixed description to set when running a transition.