Beispiel #1
0
    def post(self, request):
        if request.POST['motivo'] == '':
            return JSONResponse(
                {'mensaje': 'El campo de motivo no debe estar vacio!'})
        else:
            ds_llamada = DescripcionLlamada.objects.get(id=request.POST['id'])
            if ds_llamada:

                ds_llamada.registrado = True
                ds_llamada.nombre = 'L'
                ds_llamada.motivo = request.POST['motivo']
                ds_llamada.save()
            else:
                return JSONResponse({'mensaje': 'ERROR DEL SISTEMA'})
            return JSONResponse({})
Beispiel #2
0
def render_to_json(response, *args, **kwargs):
    """
    Creates the main structure and returns the JSON response.
    """
    # determine the status code
    if hasattr(response, 'status_code'):
        status_code = response.status_code
    elif issubclass(type(response), Http404):
        status_code = 404
    elif issubclass(type(response), Exception):
        status_code = 500
        logger.exception(str(response), extra={'request': kwargs.pop('request', None)})
        
        if settings.DEBUG:
            import sys
            reporter = ExceptionReporter(None, *sys.exc_info())
            text = reporter.get_traceback_text()
            response = HttpResponseServerError(text, content_type='text/plain')
        else:
            response = HttpResponseServerError("An error occured while processing an AJAX request.", content_type='text/plain')
    else:
        status_code = 200

    # creating main structure
    data = {
        'status': status_code,
        'statusText': REASON_PHRASES.get(status_code, 'UNKNOWN STATUS CODE'),
        'content': response
    }

    return JSONResponse(data,  *args, **kwargs)
Beispiel #3
0
 def test_json_response(self):
     """
     test http json response
     """
     data = {'test': True}
     response = JSONResponse(data)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response['Content-Type'], 'application/json')
     self.assertEqual(response.content, '{"test": true}')
Beispiel #4
0
def jqgrid_llamadas(request, *kwargs):
    grid = jqgrid_generic(request, 'jgrid_llamadas', [
        'id',
        'usuario',
        'hora',
        'fecha',
        'duracion',
        'numero',
        'interno',
        'costo',
        'tipo_llamada',
        'codigo_usuario',
        'horario'
        ])

    return JSONResponse(grid)
Beispiel #5
0
def get_tarifas(request):
    tarifas = procedure('grid_tarifas')
    return JSONResponse(tarifas)
Beispiel #6
0
def get_horarios(request):
    horarios = procedure('grid_horario')
    return JSONResponse(horarios)