From 843bacb82abd2b67881b706fe3193632d7c91c44 Mon Sep 17 00:00:00 2001 From: Lixxday Date: Fri, 18 Dec 2020 17:14:06 +0100 Subject: [PATCH] doc(examples) add custom button names in examples Useful for the next dev to stumble upon this need. --- example/fsm_example/models.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/example/fsm_example/models.py b/example/fsm_example/models.py index 3ce571d..6aea584 100644 --- a/example/fsm_example/models.py +++ b/example/fsm_example/models.py @@ -83,16 +83,26 @@ def check_displayable(self, date): ######################################################## # Workflow (state) Transitions - @transition(field=state, source=[State.APPROVED, State.EXPIRED], + @transition( + field=state, + source=[State.APPROVED, State.EXPIRED], target=State.PUBLISHED, - conditions=[can_display]) + conditions=[can_display], + # Display a button in the admin to trigger the state change. Name it Publish + custom=dict(admin=True, button_name="Publish"), + ) def publish(self): ''' Publish the object. ''' - @transition(field=state, source=State.PUBLISHED, target=State.EXPIRED, - conditions=[has_display_dates]) + @transition( + field=state, + source=State.PUBLISHED, + target=State.EXPIRED, + conditions=[has_display_dates], + # Display a button in the admin with default name : transition_name + model name (expire publishable model) + custom=dict(admin=True)) def expire(self): ''' Automatically called when a object is detected as being not