我知道怎么了。lambda自动获取方法的所有参数。by=None是dictionary类型,所以我必须在lambda中指定**kwargs。
更新代码:
@fsm_log_by
@transition(
field=state,
source=[constants.BookingState.on_hold],
target=GET_STATE(
lambda self, **kwargs: constants.BookingState.camop_assigned if self.camera_operator else constants.BookingState.active,
states=[constants.BookingState.active, constants.BookingState.camop_assigned]),
permission=can_make_active,
)
def make_active(self, by=None):
async('some async task', self.pk)
async('some other async task', self.pk)