Ejemplo n.º 1
0
def datatable_data(request):
    dataTable = makeDataTable(request.GET)
    draw = dataTable['draw']
    start = dataTable['start']
    length = dataTable['length']
    search = dataTable['search']['value']
    order_by = dataTable['columns'][dataTable['order']['0']['column']]['data']
    order_dir = '' if dataTable['order']['0']['dir'] == 'asc' else '-'

    start_time, end_time, timespan, model = get_get_args(
        request, 'start_time', 'end_time', 'timespan', 'model')
    model = getattr(AnalysisManage().modules['analysis_db_artenterdefault'], model)
    recordsTotal = model.objects.all().count()
    objects = None
    if search:
        objects = model.objects.filter(
            name__contains=search).order_by(order_dir + order_by)
    else:
        objects = model.objects.all().order_by(order_dir + order_by)
    info = {
        'draw': draw,
        'recordsTotal': recordsTotal,
        'recordsFiltered': objects.count(),
        'data': [{f.attname: getattr(x, f.attname) for f in x._meta.concrete_fields} for x in objects[start:start + length]],
        'chart': {
            'legend': model.__name__,
            'serie_name': model.__name__,
            'data': get_entry_counts_by_time(start_time, end_time, timespan, ModelObjects=objects),
        }
    }
    return JsonResponse(info, safe=False)
Ejemplo n.º 2
0
def analysis_manage_active(request):
    info = {
        'status': 0,
        'message': 'success',
    }
    model_name, active = get_post_args(request, 'model_name', 'active')
    try:
        AnalysisManage().set_active(model_name, bool(active))
    except Exception, e:
        info['status'] = 1
        info['message'] = 'invalid model_name ' + e.message
Ejemplo n.º 3
0
def analysis_manage_delete(request):
    info = {
        'status': 0,
        'message': 'success',
    }
    model_name, = get_post_args(request, 'model_name')
    try:
        AnalysisManage().delete_available(model_name)
    except Exception, e:
        info['status'] = 1
        info['message'] = 'invalid model_name ' + e.message
Ejemplo n.º 4
0
def analysis_manage_update(request):
    info = {
        'status': 0,
        'message': 'success',
    }
    model_name, translated_model_name, cols = get_post_args(
        request, 'model_name', 'translated_model_name', 'cols')
    try:
        AnalysisManage().update_available(model_name, translated_model_name, cols)
    except Exception, e:
        info['status'] = 1
        info['message'] = 'invalid params ' + e.message
Ejemplo n.º 5
0
def analysis_model_all(request):
    info = {
        'data': AnalysisManage().get_candidates()
    }
    return JsonCusResponse(info, safe=False)
Ejemplo n.º 6
0
def analysis_model_available(request):
    info = {
        'data':AnalysisManage().get_availables()
    }
    return JsonResponse(info, safe=False)