Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions example/fsm_example/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down