def validate_rule(self, identifier): """Validates the rule for the current transition""" transitions = transition_config( self.module_label, self.task.activity_ref) return transitions[identifier](self)
def next_activity(self): """Compute the next possible activities""" transitions = transition_config( self.module_label, self.task.activity_ref) return [transition for transition in transitions if transitions[transition]( self)] if transitions else None
def submit(self, module, user, next_activity=None): """Submits the task""" config = flow_config(module) transitions = transition_config(module, self.activity_ref) role = Group.objects.get(name=config.FLOW[next_activity]['role']) self.status = 'Completed' self.save() if transitions is not None: Task.objects.create(request=self.request, assignee=role, updated_by=user, activity_ref=next_activity, status='Not Started') else: self.request.status = 'Completed' self.request.save()
def submit(self, module, user, next_activity=None): """Submits the task""" config = flow_config(module) transitions = transition_config(module, self.activity_ref) role = Group.objects.get( name=config.FLOW[next_activity]['role']) self.status = 'Completed' self.save() if transitions is not None: Task.objects.create( request=self.request, assignee=role, updated_by=user, activity_ref=next_activity, status='Not Started') else: self.request.status = 'Completed' self.request.save()
def is_final(self): """Checks if the current task is final / end task""" transitions = transition_config( self.request.module_ref, self.activity_ref) return not transitions