Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

'target' in transition may be callable #61

Closed
wants to merge 1 commit into from

Conversation

belegnar
Copy link

it is useful when FSMKeyField is in use
also, using instance.setattr instead of instace.dict in FSMKeyField().set_state()

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented Sep 30, 2014

It should be in meta.next_state function, elsewhere signal data and set_proxy calls gots wrong state

django-fsm init py at callable_target belegnar django-fsm

Also please add separate test case file with all proxy state tests and non fk fields tests.

Readme also need to be updated.

Also please check graph_transition command.

And test should works (yep with python 2.6 and django 1.6 support)

@kmmbvnr
Copy link
Collaborator

kmmbvnr commented May 14, 2016

Target states could be any State object

    @transition(
        field=state,
        source='for_moderators',
        target=GET_STATE(
            lambda self, allowed: 'published' if allowed else 'rejected',
            states=['published', 'rejected']
        )
    )
    def moderate(self, allowed):
        pass

@kmmbvnr kmmbvnr closed this May 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants