Commit 4ad50263d87746a250597a14fb11a242d782f2b1

Authored by Bartłomiej Nitoń
1 parent b8c0b1ed

Bugfix for long urls while saving frames and lexical units.

semantics/static/js/semantics_frames.js
@@ -461,14 +461,14 @@ function saveFrames() { @@ -461,14 +461,14 @@ function saveFrames() {
461 } 461 }
462 else { 462 else {
463 frameClick(""); 463 frameClick("");
464 - $.getJSON(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){  
465 - getFrames(data.frames_display);  
466 - displayFrames();  
467 - memorizeConnections(data.connections.connected, data.connections.connected_reverse);  
468 - $("#semantic-frames-count").empty();  
469 - $("#semantic-frames-count").append(data.frames_count);  
470 - updateSchemataConnections();  
471 - }); 464 + $.post(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){
  465 + getFrames(data.frames_display);
  466 + displayFrames();
  467 + memorizeConnections(data.connections.connected, data.connections.connected_reverse);
  468 + $("#semantic-frames-count").empty();
  469 + $("#semantic-frames-count").append(data.frames_count);
  470 + updateSchemataConnections();
  471 + }, 'json');
472 frames_operations = []; 472 frames_operations = [];
473 } 473 }
474 } 474 }
semantics/static/js/semantics_lexical_units.js
@@ -100,9 +100,11 @@ function getLocation(luid) { @@ -100,9 +100,11 @@ function getLocation(luid) {
100 // save all changes to meanings (lexical units) 100 // save all changes to meanings (lexical units)
101 function saveMeanings() { 101 function saveMeanings() {
102 $.ajax({ 102 $.ajax({
  103 + type: "POST",
103 dataType: "json", 104 dataType: "json",
104 url: ajax_update_meanings, 105 url: ajax_update_meanings,
105 - data: {"operations": JSON.stringify(units_operations), "lemma_id": lemma_id}, 106 + data: {"operations": JSON.stringify(units_operations),
  107 + "lemma_id": lemma_id},
106 success: function(data){ 108 success: function(data){
107 memorizeLexicalUnits(data.lexical_units); 109 memorizeLexicalUnits(data.lexical_units);
108 basicLexicalUnitsData(data.informations); 110 basicLexicalUnitsData(data.informations);
@@ -110,6 +112,7 @@ function saveMeanings() { @@ -110,6 +112,7 @@ function saveMeanings() {
110 }, 112 },
111 async: false 113 async: false
112 }); 114 });
  115 +
113 $.ajax({ 116 $.ajax({
114 dataType: "json", 117 dataType: "json",
115 url: ajax_examples, 118 url: ajax_examples,
semantics/views.py
@@ -72,13 +72,14 @@ def reorder_history(frames_list): @@ -72,13 +72,14 @@ def reorder_history(frames_list):
72 @render('frames.json') 72 @render('frames.json')
73 @ajax(method='get', encode_result=False) 73 @ajax(method='get', encode_result=False)
74 def ajax_frames(request, lemma_id): 74 def ajax_frames(request, lemma_id):
  75 + context = create_frames_context(lemma_id)
  76 + return context
75 77
  78 +def create_frames_context(lemma_id):
76 lemma = Lemma.objects.get(id=lemma_id, old=False) 79 lemma = Lemma.objects.get(id=lemma_id, old=False)
77 80
78 #lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ')|Q(base__contains=u' '+lemma.entry+u' ')|Q(base__endswith=u' '+lemma.entry)|Q(base=lemma.entry)).order_by('sense') 81 #lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ')|Q(base__contains=u' '+lemma.entry+u' ')|Q(base__endswith=u' '+lemma.entry)|Q(base=lemma.entry)).order_by('sense')
79 lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry)|Q(base = lemma.entry + u' się')).order_by('sense') 82 lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry)|Q(base = lemma.entry + u' się')).order_by('sense')
80 -  
81 -  
82 83
83 alternations = {} 84 alternations = {}
84 frames_dict = {} 85 frames_dict = {}
@@ -210,6 +211,10 @@ def ajax_frames(request, lemma_id): @@ -210,6 +211,10 @@ def ajax_frames(request, lemma_id):
210 @render('units.json') 211 @render('units.json')
211 @ajax(method='get', encode_result=False) 212 @ajax(method='get', encode_result=False)
212 def ajax_units(request, lemma_id): 213 def ajax_units(request, lemma_id):
  214 + context = create_units_context(lemma_id)
  215 + return context
  216 +
  217 +def create_units_context(lemma_id):
213 lemma = Lemma.objects.get(id=lemma_id, old=False) 218 lemma = Lemma.objects.get(id=lemma_id, old=False)
214 lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry, pos="czasownik")|Q(base = lemma.entry + u' się', pos="czasownik")).order_by('base', 'sense') 219 lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry, pos="czasownik")|Q(base = lemma.entry + u' się', pos="czasownik")).order_by('base', 'sense')
215 # lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ', pos="czasownik")|Q(base__contains=u' '+lemma.entry+u' ', pos="czasownik")|Q(base__endswith=u' '+lemma.entry, pos="czasownik")|Q(base=lemma.entry, pos="czasownik")).order_by('base', 'sense') 220 # lexical_units = LexicalUnit.objects.filter(Q(base__startswith=lemma.entry + u' ', pos="czasownik")|Q(base__contains=u' '+lemma.entry+u' ', pos="czasownik")|Q(base__endswith=u' '+lemma.entry, pos="czasownik")|Q(base=lemma.entry, pos="czasownik")).order_by('base', 'sense')
@@ -218,8 +223,8 @@ def ajax_units(request, lemma_id): @@ -218,8 +223,8 @@ def ajax_units(request, lemma_id):
218 'lexical_units': [{"id": lu.id, "luid": lu.luid, "base": lu.base, "sense": lu.sense, "pos": lu.pos, "glossa": lu.glossa, "definition": lu.definition, "location": location(lu)} for lu in lexical_units], 223 'lexical_units': [{"id": lu.id, "luid": lu.luid, "base": lu.base, "sense": lu.sense, "pos": lu.pos, "glossa": lu.glossa, "definition": lu.definition, "location": location(lu)} for lu in lexical_units],
219 'informations': {'base': lemma.entry, 'sense': max(['A'] + [chr(ord(lu.sense) + 1) for lu in lexical_units.filter(luid=-1)])}, # TODO: 2 different free senses for with/whthout 'się' 224 'informations': {'base': lemma.entry, 'sense': max(['A'] + [chr(ord(lu.sense) + 1) for lu in lexical_units.filter(luid=-1)])}, # TODO: 2 different free senses for with/whthout 'się'
220 } 225 }
221 -  
222 return context 226 return context
  227 +
223 228
224 def location(lexical_unit): 229 def location(lexical_unit):
225 if lexical_unit.synset is None: 230 if lexical_unit.synset is None:
@@ -481,17 +486,19 @@ def ajax_create_complement(request, lemma_id, frame, roles): @@ -481,17 +486,19 @@ def ajax_create_complement(request, lemma_id, frame, roles):
481 complement.roles.add(role) 486 complement.roles.add(role)
482 return ajax_frames(request, lemma.id) 487 return ajax_frames(request, lemma.id)
483 488
484 -@ajax(method='get', encode_result=False) 489 +@ajax(method='post', encode_result=True)
485 def ajax_update_meanings(request, operations, lemma_id): 490 def ajax_update_meanings(request, operations, lemma_id):
486 update_meanings(operations) 491 update_meanings(operations)
487 - return ajax_units(request) 492 + units_context = create_units_context(lemma_id)
  493 + return units_context
488 494
489 -@ajax(method='get', encode_result=False) 495 +@ajax(method='post', encode_result=True)
490 def ajax_modify_frames(request, operations, lemma_id): 496 def ajax_modify_frames(request, operations, lemma_id):
491 if not request.user.is_authenticated(): 497 if not request.user.is_authenticated():
492 return 'user logged out' 498 return 'user logged out'
493 modify_frames(lemma_id, operations, request.user) 499 modify_frames(lemma_id, operations, request.user)
494 - return ajax_frames(request) 500 + frames_context = create_frames_context(lemma_id)
  501 + return frames_context
495 502
496 @ajax(method='get', encode_result=True) 503 @ajax(method='get', encode_result=True)
497 def ajax_plWN_context_lookup(request, term): 504 def ajax_plWN_context_lookup(request, term):