def add_steps_to_db(obj, message): for o in obj: s = Step() if 'name' in o: s['name'] = o['name'] if 'order' in o: s['order'] = o['order'] if 'description' in o: s['description'] = o['description'] if 'parameters' in o: # Query for steps and associate them with template for param in o['parameters']: parameter_object = Parameter.objects.filter(name=param).first() if parameter_object: s['parameter'].append(parameter_object.pk) try: s.save() except ValidationError as e: message.append('Error creating the parameter: ' + str(e)) pass except NotUniqueError: message.append( 'Step with the name "{0}" has already been added.'.format( o['name'])) pass return message
def final_delivery(request, pk): audit = Audit.objects.get(id=pk) audit.is_complete = True audit.save() req = audit.match.requirement req.status = False req.save() step = Step(audit=audit, note='Item foi entregue para a instituicao') step.save() messages.success(request, 'Obrigado!') return redirect('/audits')
def accept_audit(request, pk): audit = Audit.objects.get(id=pk) item = audit.item item.status = False item.save() for au in audit.item.audit_set.all(): au.is_deferred = 'INDEFERIDO' au.save() audit.is_deferred = 'DEFERIDO' audit.save() step = Step(audit=audit, note='Doador confirmou a proposta e irá doar o item') step.save() messages.success(request, 'Proposta Confirmada!') return redirect('/audits-user')