def __init__(self, f, request, params, model, model_admin, field_path=None): super(WorkflowStatusSpec, self).__init__( f, request, params, model, model_admin, field_path=field_path) queryset = workflow_api.workflow_by_model(model).states.all() self.lookup_choices = [(x._get_pk_val(), smart_unicode(x)) for x in queryset]
def populate_workflow_status(self, force_update=False, raw=False): """ Populates the workflow status from the status slug """ from merengue.workflow.utils import workflow_by_model workflow_status = getattr(self, 'workflow_status', None) if not workflow_status: workflow = workflow_by_model(self.__class__) self.workflow_status = workflow.get_initial_state() workflow_status = self.workflow_status if force_update or (getattr(self, 'status', None) is not None and workflow_status and self.status != self.workflow_status.slug): self.update_status(raw)
def current_workflow(self, obj): return workflow_by_model(obj.model_class())