def create_letter_template(request):

    # Validate body parameters
    args = PostParametersList(request)
    args.check_parameter(key='id_admin', required=True)
    args.check_parameter(key='descripcion', required=True)

    print(args['id_admin'])
    print(args['descripcion'])

    # Save file to templates
    uploadedFile = request.FILES['file']
    handle_uploaded_file(uploadedFile)

    args = args.__dict__()

    ts = datetime.now().timestamp()

    # Sumbmit created letter data to db
    carta = Carta.objects.create(creado_por=args['id_admin'],
                                 nombre=uploadedFile.name,
                                 descripcion=args['descripcion'],
                                 fecha_creacion=ts,
                                 fecha_modificacion=ts,
                                 modificado_por=args['id_admin'])

    return JsonResponse({'message': 'File uploaded successfully'})
def pasos_procesos(request):
    args = PostParametersList(request)
    args.check_parameter(key='proceso', required=True)
    args = args.__dict__()
    pasos = Paso.objects.filter(proceso_id=args['proceso']).values()
    pasos = [dict(p) for p in pasos]
    return JsonResponse(pasos, safe=False)
def get_pasos_tramites(request):
    args = PostParametersList(request)
    args.check_parameter(key='id', required=True)
    args = args.__dict__()
    tra = Paso.objects.filter(
        proceso_id=args['id']).order_by('numero').values()
    tra = [dict(t) for t in tra]
    return JsonResponse(tra, safe=False)
示例#4
0
def registro_administradores(request):
    args = PostParametersList(request)
    args.check_parameter(key='email', required=True)
    args.check_parameter(key='nombre', required=True)
    args = args.__dict__()
    user = Usuario.objects.create_admin(email=args['email'],
                                        password=12345678,
                                        nombre=args['nombre'])
    return JsonResponse(1, safe=False)
def registro_administradores(request):
    args = PostParametersList(request)
    args.check_parameter(key='email', required=True)
    args.check_parameter(key='nombre', required=True)
    args = args.__dict__()
    try:
        user = Usuario.objects.create_admin(email=args['email'],
                                            password=12345678,
                                            nombre=args['nombre'])
    except IntegrityError as e:
        raise exceptions.PermissionDenied(detail="Email ya registrado")
    return JsonResponse(1, safe=False)
示例#6
0
def registro_Alumnos(request):
    args = PostParametersList(request)
    args.check_parameter(key='email', required=True)
    args.check_parameter(key='password', required=True)
    args.check_parameter(key='nombre', required=True)
    args.check_parameter(key='apellido', required=True)
    args = args.__dict__()
    if not re.match(EMAIL_REGEX, args['email']):
        raise exceptions.PermissionDenied(detail="Email invalido")
    user = Usuario.objects.create_alumno(email=args['email'],
                                         password=args['password'],
                                         nombre=args['nombre'],
                                         apellido=args['apellido'])
    return JsonResponse(1, safe=False)