diff --git a/semantics/static/js/semantics_frames.js b/semantics/static/js/semantics_frames.js index 852b0dc..2c1cf4d 100644 --- a/semantics/static/js/semantics_frames.js +++ b/semantics/static/js/semantics_frames.js @@ -461,14 +461,14 @@ function saveFrames() { } else { frameClick(""); - $.getJSON(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){ - getFrames(data.frames_display); - displayFrames(); - memorizeConnections(data.connections.connected, data.connections.connected_reverse); - $("#semantic-frames-count").empty(); - $("#semantic-frames-count").append(data.frames_count); - updateSchemataConnections(); - }); + $.post(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){ + getFrames(data.frames_display); + displayFrames(); + memorizeConnections(data.connections.connected, data.connections.connected_reverse); + $("#semantic-frames-count").empty(); + $("#semantic-frames-count").append(data.frames_count); + updateSchemataConnections(); + }, 'json'); frames_operations = []; } } diff --git a/semantics/static/js/semantics_lexical_units.js b/semantics/static/js/semantics_lexical_units.js index 70fccd3..56a75ed 100644 --- a/semantics/static/js/semantics_lexical_units.js +++ b/semantics/static/js/semantics_lexical_units.js @@ -100,9 +100,11 @@ function getLocation(luid) { // save all changes to meanings (lexical units) function saveMeanings() { $.ajax({ + type: "POST", dataType: "json", url: ajax_update_meanings, - data: {"operations": JSON.stringify(units_operations), "lemma_id": lemma_id}, + data: {"operations": JSON.stringify(units_operations), + "lemma_id": lemma_id}, success: function(data){ memorizeLexicalUnits(data.lexical_units); basicLexicalUnitsData(data.informations); @@ -110,6 +112,7 @@ function saveMeanings() { }, async: false }); + $.ajax({ dataType: "json", url: ajax_examples, diff --git a/semantics/views.py b/semantics/views.py index 3c75881..d357b99 100644 --- a/semantics/views.py +++ b/semantics/views.py @@ -72,13 +72,14 @@ def reorder_history(frames_list): @render('frames.json') @ajax(method='get', encode_result=False) def ajax_frames(request, lemma_id): + context = create_frames_context(lemma_id) + return context +def create_frames_context(lemma_id): lemma = Lemma.objects.get(id=lemma_id, old=False) #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') lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry)|Q(base = lemma.entry + u' się')).order_by('sense') - - alternations = {} frames_dict = {} @@ -210,6 +211,10 @@ def ajax_frames(request, lemma_id): @render('units.json') @ajax(method='get', encode_result=False) def ajax_units(request, lemma_id): + context = create_units_context(lemma_id) + return context + +def create_units_context(lemma_id): lemma = Lemma.objects.get(id=lemma_id, old=False) lexical_units = LexicalUnit.objects.filter(Q(base = lemma.entry, pos="czasownik")|Q(base = lemma.entry + u' się', pos="czasownik")).order_by('base', 'sense') # 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): '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], '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ę' } - return context + def location(lexical_unit): if lexical_unit.synset is None: @@ -481,17 +486,19 @@ def ajax_create_complement(request, lemma_id, frame, roles): complement.roles.add(role) return ajax_frames(request, lemma.id) -@ajax(method='get', encode_result=False) +@ajax(method='post', encode_result=True) def ajax_update_meanings(request, operations, lemma_id): update_meanings(operations) - return ajax_units(request) + units_context = create_units_context(lemma_id) + return units_context -@ajax(method='get', encode_result=False) +@ajax(method='post', encode_result=True) def ajax_modify_frames(request, operations, lemma_id): if not request.user.is_authenticated(): return 'user logged out' modify_frames(lemma_id, operations, request.user) - return ajax_frames(request) + frames_context = create_frames_context(lemma_id) + return frames_context @ajax(method='get', encode_result=True) def ajax_plWN_context_lookup(request, term):