Commit 4ad50263d87746a250597a14fb11a242d782f2b1
1 parent
b8c0b1ed
Bugfix for long urls while saving frames and lexical units.
Showing
3 changed files
with
26 additions
and
16 deletions
semantics/static/js/semantics_frames.js
... | ... | @@ -461,14 +461,14 @@ function saveFrames() { |
461 | 461 | } |
462 | 462 | else { |
463 | 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 | 472 | frames_operations = []; |
473 | 473 | } |
474 | 474 | } |
... | ... |
semantics/static/js/semantics_lexical_units.js
... | ... | @@ -100,9 +100,11 @@ function getLocation(luid) { |
100 | 100 | // save all changes to meanings (lexical units) |
101 | 101 | function saveMeanings() { |
102 | 102 | $.ajax({ |
103 | + type: "POST", | |
103 | 104 | dataType: "json", |
104 | 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 | 108 | success: function(data){ |
107 | 109 | memorizeLexicalUnits(data.lexical_units); |
108 | 110 | basicLexicalUnitsData(data.informations); |
... | ... | @@ -110,6 +112,7 @@ function saveMeanings() { |
110 | 112 | }, |
111 | 113 | async: false |
112 | 114 | }); |
115 | + | |
113 | 116 | $.ajax({ |
114 | 117 | dataType: "json", |
115 | 118 | url: ajax_examples, |
... | ... |
semantics/views.py
... | ... | @@ -72,13 +72,14 @@ def reorder_history(frames_list): |
72 | 72 | @render('frames.json') |
73 | 73 | @ajax(method='get', encode_result=False) |
74 | 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 | 79 | lemma = Lemma.objects.get(id=lemma_id, old=False) |
77 | 80 | |
78 | 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 | 82 | lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry)|Q(base = lemma.entry + u' się')).order_by('sense') |
80 | - | |
81 | - | |
82 | 83 | |
83 | 84 | alternations = {} |
84 | 85 | frames_dict = {} |
... | ... | @@ -210,6 +211,10 @@ def ajax_frames(request, lemma_id): |
210 | 211 | @render('units.json') |
211 | 212 | @ajax(method='get', encode_result=False) |
212 | 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 | 218 | lemma = Lemma.objects.get(id=lemma_id, old=False) |
214 | 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 | 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 | 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 | 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 | 226 | return context |
227 | + | |
223 | 228 | |
224 | 229 | def location(lexical_unit): |
225 | 230 | if lexical_unit.synset is None: |
... | ... | @@ -481,17 +486,19 @@ def ajax_create_complement(request, lemma_id, frame, roles): |
481 | 486 | complement.roles.add(role) |
482 | 487 | return ajax_frames(request, lemma.id) |
483 | 488 | |
484 | -@ajax(method='get', encode_result=False) | |
489 | +@ajax(method='post', encode_result=True) | |
485 | 490 | def ajax_update_meanings(request, operations, lemma_id): |
486 | 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 | 496 | def ajax_modify_frames(request, operations, lemma_id): |
491 | 497 | if not request.user.is_authenticated(): |
492 | 498 | return 'user logged out' |
493 | 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 | 503 | @ajax(method='get', encode_result=True) |
497 | 504 | def ajax_plWN_context_lookup(request, term): |
... | ... |