Ejemplo n.º 1
0
    def __init__(self,content='',json_opts={},mimetype="application/json",*args,**kwargs):

        if content:
            content = serialize_to_json(content,**json_opts)
        else:
            content = serialize_to_json([],**json_opts)
        super(JSONResponse,self).__init__(content,mimetype,*args,**kwargs)
Ejemplo n.º 2
0
def return_uploaders_that_can_parse_file(request):
    file = request.FILES['data_upload']
    file_id = request.POST.get('file_id') or None
    duc = DataUploadController(file_id, uploaded_file=file)
    if not duc.is_valid():
        return HttpResponse(serialize_to_json({'uploaders':[]}))
    uploaders = duc.list_available_uploaders()
    if not uploaders:
        return HttpResponse(serialize_to_json({'uploaders':[]}))
    duc.persist_file()
    return HttpResponse(serialize_to_json({'uploaders':uploaders}))
Ejemplo n.º 3
0
 def __init__(self,content='',json_opts={},mimetype="application/json",*args,**kwargs):
     """
     This returns a object that we send as json content using 
     utils.serialize_to_json, that is a wrapper to simplejson.dumps
     method using a custom class to handle models and querysets. Put your
     options to serialize_to_json in json_opts, other options are used by
     response.
     """
     if content:
         content = serialize_to_json(content,**json_opts)
     else:
         content = serialize_to_json([],**json_opts)
     super(JSONResponse,self).__init__(content,mimetype,*args,**kwargs)
Ejemplo n.º 4
0
 def __init__(self,content='',json_opts={},mimetype="application/json",*args,**kwargs):
     """
     This returns a object that we send as json content using
     utils.serialize_to_json, that is a wrapper to json.dumps
     method using a custom class to handle models and querysets. Put your
     options to serialize_to_json in json_opts, other options are used by
     response.
     """
     if content:
         content = serialize_to_json(content,**json_opts)
     else:
         content = serialize_to_json([],**json_opts)
     super(JSONResponse,self).__init__(content,mimetype,*args,**kwargs)
Ejemplo n.º 5
0
 def __init__(self, request, content='',json_opts={},mimetype="application/json",*args,**kwargs):
     """
     This returns a object that we send as json content using 
     utils.serialize_to_json, that is a wrapper to simplejson.dumps
     method using a custom class to handle models and querysets. Put your
     options to serialize_to_json in json_opts, other options are used by
     response.
     """
     if not isinstance(content, basestring):
         if content:
             content = serialize_to_json(content,**json_opts)
         else:
             content = serialize_to_json([],**json_opts)
     mimetype = "text/javascript";
     if (JSONP_CALLBACK in request.REQUEST):
         content = '%s(%s)' % (request.REQUEST[JSONP_CALLBACK], serialize_to_json(content));
     super(JSONResponse,self).__init__(content,mimetype,*args,**kwargs)
Ejemplo n.º 6
0
def process_file_with_datauploader(request):
    file_id = request.GET.get('file_id')
    datauploader_name = request.GET.get('datauploader_name')
    data_point_type = request.GET.get('data_point_type')
    duc = DataUploadController(file_id, data_point_type=data_point_type, datauploader_name=datauploader_name)
    data_point, errors = duc.run_datauploader()
    if not errors:
        duc.clean_up()
    return HttpResponse(serialize_to_json({'data_point':data_point, 'errors':errors or []}))
Ejemplo n.º 7
0
def insight(request, user_name, insight_id):
    template_data = _base_template_data(request)
    DashboardsController.RecordDashboardView(insight_id)
    user = UserController.GetUserByUserName(user_name)
    dashboard = DashboardsController.GetDashboardById(insight_id)
    dashboard_json = serialize_to_json(dashboard.__dict__)
    template_data['profile_user'] = user
    template_data['insight'] = dashboard
    template_data['insight_json'] = dashboard_json
    template_data['trending_insights'] = DashboardsController.GetTendingDashboards(9)
    return render_to_response(
        'thecommunity/insight_page/insight_page.html',
        template_data,
        context_instance=RequestContext(request)
    )
Ejemplo n.º 8
0
 def __init__(self, content='', json_opts={}, mimetype="text/html", *args, **kwargs):
     if content:
         content = serialize_to_json(content, **json_opts)
     else:
         content = serialize_to_json([], **json_opts)
     super(JsonResponse, self).__init__(content, *args, mimetype=mimetype, **kwargs)