def convert_data(request): try: dict = json.loads(request.raw_post_data) chart_data = utils.import_chart_data(dict['data']) json_data = json.dumps(chart_data) return HttpResponse(json_data) except Exception: utils.save_import_failure(request.user.username, dict['data']) raise
def convert_data(request): if not request.user.is_active: raise PermissionDenied() try: dict = json.loads(request.raw_post_data) chart_data = utils.import_chart_data(dict["data"]) json_data = json.dumps(chart_data) return HttpResponse(json_data) except Exception: utils.save_import_failure(request.user.username, dict["data"]) raise
def new(request): if request.POST: data = request.POST["data"] try: chart_data = utils.import_chart_data(data) except Exception, e: utils.save_import_failure(request.user.username, data) return HttpResponseServerError('Parse error: ' + e.message) chart = Chart(creator=request.user) chart.chart_data = chart_data chart.save() return redirect(reverse('chart.views.edit', args=[chart.id]))