make add_relation view cleaner for schuyler to work on:P; correct RELATIONSHIP_OPTIONS based on changes in models.py

This commit is contained in:
Sanj 2011-09-01 08:39:23 +05:30
parent 439b063cee
commit b3abe1e12d
2 changed files with 8 additions and 4 deletions

View File

@ -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.'})

View File

@ -14,7 +14,7 @@ $(function() {
});
});
var RELATIONSHIP_OPTIONS = ['conflates', 'contains', 'consumes', 'supersedes']
var RELATIONSHIP_OPTIONS = ['conflates', 'contains', 'replaces', 'supplants']
function getRow(d) {
var $tr = $('<tr />').data("id", d.id);