Commit 517e0a7e40b3adc1042549ebb197f582e5d0d031

Authored by Bartłomiej Nitoń
1 parent 64213eab

Adding new examples and semantic connections bugfix.

dictionary/ajax_lemma_view.py
@@ -51,7 +51,8 @@ from dictionary.forms import AddPositionForm, FrameForm, Pos_Cat_Form, \ @@ -51,7 +51,8 @@ from dictionary.forms import AddPositionForm, FrameForm, Pos_Cat_Form, \
51 ExampleOpinionForm, \ 51 ExampleOpinionForm, \
52 FrameConversionForm, CreatePositionForm, AssignPhraseologicFrameForm 52 FrameConversionForm, CreatePositionForm, AssignPhraseologicFrameForm
53 from dictionary.saving import connect_example_operation, disconnect_all_examples_operations, \ 53 from dictionary.saving import connect_example_operation, disconnect_all_examples_operations, \
54 - get_semantic_operations, update_connections, reconnect_examples 54 + get_semantic_operations, update_connections, reconnect_examples, \
  55 + disconnect_example_operation
55 56
56 from common.decorators import render, ajax, AjaxError 57 from common.decorators import render, ajax, AjaxError
57 from common.util import triple_arg_poss 58 from common.util import triple_arg_poss
@@ -2546,7 +2547,10 @@ def save_new_frames(request, data, id, examples, lemma_examples): @@ -2546,7 +2547,10 @@ def save_new_frames(request, data, id, examples, lemma_examples):
2546 nkjp_example_obj.arguments.add(argument_selection) 2547 nkjp_example_obj.arguments.add(argument_selection)
2547 new_lemma_ver.nkjp_examples.add(nkjp_example_obj) 2548 new_lemma_ver.nkjp_examples.add(nkjp_example_obj)
2548 if example['lexical_unit'] > 0: 2549 if example['lexical_unit'] > 0:
2549 - reconnect_examples_operations.append(connect_example_operation(example, nkjp_example_obj)) 2550 + try:
  2551 + reconnect_examples_operations.remove(disconnect_example_operation(example, nkjp_example_obj))
  2552 + except ValueError:
  2553 + reconnect_examples_operations.append(connect_example_operation(example, nkjp_example_obj))
2550 reconnect_examples(reconnect_examples_operations) 2554 reconnect_examples(reconnect_examples_operations)
2551 2555
2552 # dodawanie przykladow nkjp do czasownika 2556 # dodawanie przykladow nkjp do czasownika
dictionary/saving.py
@@ -107,6 +107,10 @@ def connect_example_operation(example_dict, example_obj): @@ -107,6 +107,10 @@ def connect_example_operation(example_dict, example_obj):
107 lu = LexicalUnit.objects.get(id=example_dict['lexical_unit']) 107 lu = LexicalUnit.objects.get(id=example_dict['lexical_unit'])
108 return {'operation': 'add_example', 'unit': lu.id, 'example': example_obj.id} 108 return {'operation': 'add_example', 'unit': lu.id, 'example': example_obj.id}
109 109
  110 +def disconnect_example_operation(example_dict, example_obj):
  111 + lu = LexicalUnit.objects.get(id=example_dict['lexical_unit'])
  112 + return {'operation': 'remove_example', 'unit': lu.id, 'example': example_obj.id}
  113 +
110 def reconnect_examples(operations): 114 def reconnect_examples(operations):
111 update_meanings(operations) 115 update_meanings(operations)
112 116
113 \ No newline at end of file 117 \ No newline at end of file
dictionary/static/js/lemma-view.js
@@ -578,6 +578,7 @@ function Nkjp_example(example_id, frame_id, arguments_ids, sentence, source, opi @@ -578,6 +578,7 @@ function Nkjp_example(example_id, frame_id, arguments_ids, sentence, source, opi
578 this.opinion = opinion; 578 this.opinion = opinion;
579 this.comment = comment; 579 this.comment = comment;
580 this.semantic = semantic; 580 this.semantic = semantic;
  581 + this.lexical_unit = -1;
581 } 582 }
582 583
583 function Nkjp_example_ajax(frame, arg_selections, sentence, source, opinion, comment, semantic, lexical_unit) 584 function Nkjp_example_ajax(frame, arg_selections, sentence, source, opinion, comment, semantic, lexical_unit)