From 439b063cee0197a8422717100b2bb5e0bc7d0c64 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 1 Sep 2011 08:30:49 +0530 Subject: [PATCH] handle responses in JS; clarify TODOs in views.py --- gazetteer/places/views.py | 2 +- gazetteer/static/js/feature_admin.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index dca9f83..7958a18 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -134,7 +134,7 @@ def add_relation(request): relation = request.GET.get("relation", "") if feature1 == None or feature2 == None or not request.user.is_staff(): #TODO: split up errors :/ -- not imp. return render_to_json_response({'error': 'bad request'}) - #TODO: handle saving m2m between feature1 and feature2 with relation + #TODO: handle saving m2m between feature1 and feature2 with relation. BIG QUESTION: Here it can also deal with is_primary logic - if it sets stuff to is_primary or not, though, this needs to be conveyed to the front-end / a logic figured out to toggle the check-boxes display. return render_to_json_response({'success': 'relation made successfully.'}) diff --git a/gazetteer/static/js/feature_admin.js b/gazetteer/static/js/feature_admin.js index 2e1aceb..d8a99d4 100644 --- a/gazetteer/static/js/feature_admin.js +++ b/gazetteer/static/js/feature_admin.js @@ -60,9 +60,12 @@ function getRow(d) { 'feature2': feature2, 'relation': relation }, function(response) { - - }); - + if (response.error) { + alert(response.error); + } else { + alert(response.success); + } + }); }); return $tr;