misc: bring welco/wcs errors to the UI as alerts

This commit is contained in:
Frédéric Péters 2015-11-17 14:41:45 +01:00
parent 7069da02dd
commit eecbc602f9
2 changed files with 16 additions and 6 deletions

View File

@ -121,7 +121,7 @@ $(function() {
if (data.result == 'ok') {
window.location.reload();
} else {
/* TODO: display error notification */
alert(data.msg);
}
},
error: function(error) { console.log(':(', error); }
@ -464,7 +464,7 @@ $(function() {
window.open(data.url, '_blank');
refresh_bottom_cells();
} else {
/* TODO: display error notification */
alert(data.msg);
}
},
error: function(error) { console.log(':(', error); }

View File

@ -139,7 +139,12 @@ def qualification_done(request):
for association in Association.objects.filter(
source_type=request.POST['source_type'],
source_pk=request.POST['source_pk']):
association.push(request)
try:
association.push(request)
except Exception, e:
response = HttpResponse(content_type='application/json')
json.dump({'err': '1', 'msg': str(e)}, response, indent=2)
return response
source_object.save()
response = HttpResponse(content_type='application/json')
json.dump({'result': 'ok'}, response, indent=2)
@ -173,10 +178,15 @@ def create_formdata(request, *args, **kwargs):
response = HttpResponse(content_type='application/json')
if request.method != 'POST':
json.dump({'err': 1}, response)
else:
qualif = Association.objects.get(id=kwargs.get('pk'))
return response
qualif = Association.objects.get(id=kwargs.get('pk'))
try:
qualif.push(request)
json.dump({'result': 'ok', 'url': qualif.formdata_url}, response)
except Exception, e:
json.dump({'err': 1, 'msg': str(e)}, response)
return response
json.dump({'result': 'ok', 'url': qualif.formdata_url}, response)
return response
@login_required