def create_client(): try: examiner = helpers.Examiner(model=Cliente, schema=cliente_schema, unwanted_columns=['id', 'fecha_registro'], json_data=jloads(request.data)) return helpers.insert_row(examiner) except Exception as e: return jsonify({"error": str(e)}), 500
def create_part_type(): try: examiner = helpers.Examiner(model=TipoParte, schema=tipo_parte_schema, unwanted_columns=['id'], json_data=jloads(request.data)) return helpers.insert_row(examiner) except Exception as e: return jsonify({"error": str(e)}), 500
def new_message(): try: examiner = helpers.Examiner(model=Message, schema=message_schema, unwanted_columns=['id'], json_data=jloads(request.data)) return helpers.insert_row(examiner) except Exception as e: return jsonify({'error': str(e)}), 500
def create_repair(): try: examiner = helpers.Examiner( model=Reparacion, schema=reparacion_schema, unwanted_columns=['id', 'fecha_realizacion'], json_data=jloads(request.data)) return helpers.insert_row(examiner) except Exception as e: return jsonify({"error": str(e)}), 500
def create_employee(): try: examiner = helpers.Examiner( model=Empleado, schema=empleado_schema, unwanted_columns=["id", "fecha_contratacion"], json_data=jloads(request.data)) return helpers.insert_row(examiner) except Exception as e: return jsonify({"error": str(e)}), 500
def create_warranty(): try: json_data = jloads(request.data) json_data['codigo'] = uuid.uuid4().hex examiner = helpers.Examiner( model=Garantia, schema=garantia_schema, unwanted_columns=['id', 'fecha_vencimiento', 'fecha_inicio'], json_data=json_data) return helpers.insert_row(examiner) except Exception as e: return jsonify({"error": str(e)}), 500
def create_user(): try: nuevo_usuario = jloads(request.data) nuevo_usuario["contrasena"] = bcrypt.generate_password_hash( nuevo_usuario["contrasena"]) examiner = helpers.Examiner(model=Usuario, schema=usuario_schema, unwanted_columns=['id'], json_data=nuevo_usuario) return helpers.insert_row(examiner) except Exception as e: return jsonify({"error": str(e)}), 500