From b3abe1e12d547e4b173dd5911671943225dc2150 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 1 Sep 2011 08:39:23 +0530 Subject: [PATCH] make add_relation view cleaner for schuyler to work on:P; correct RELATIONSHIP_OPTIONS based on changes in models.py --- gazetteer/places/views.py | 10 +++++++--- gazetteer/static/js/feature_admin.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index 7958a18..54c528d 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -131,10 +131,14 @@ def time_frame_json(request): def add_relation(request): feature1 = request.GET.get("feature1", None) feature2 = request.GET.get("feature2", None) - relation = request.GET.get("relation", "") - if feature1 == None or feature2 == None or not request.user.is_staff(): #TODO: split up errors :/ -- not imp. + relation = request.GET.get("relation", None) + if feature1 == None or feature2 == None or relation == None: #TODO: split up errors :/ -- not imp. return render_to_json_response({'error': 'bad request'}) - #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. + if not request.user.is_staff(): + return render_to_json_response({'error': 'insufficient permissions error. try logging in again? are you staff / admin?'}) + + #TODO: handle saving m2m between feature1 and feature2 with relation. If relation='', either remove existing relation between feature1 and feature2, or ignore if no such existing relation exists. 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 d8a99d4..a741bdf 100644 --- a/gazetteer/static/js/feature_admin.js +++ b/gazetteer/static/js/feature_admin.js @@ -14,7 +14,7 @@ $(function() { }); }); -var RELATIONSHIP_OPTIONS = ['conflates', 'contains', 'consumes', 'supersedes'] +var RELATIONSHIP_OPTIONS = ['conflates', 'contains', 'replaces', 'supplants'] function getRow(d) { var $tr = $('').data("id", d.id);