Commit 517e0a7e40b3adc1042549ebb197f582e5d0d031
1 parent
64213eab
Adding new examples and semantic connections bugfix.
Showing
3 changed files
with
11 additions
and
2 deletions
dictionary/ajax_lemma_view.py
... | ... | @@ -51,7 +51,8 @@ from dictionary.forms import AddPositionForm, FrameForm, Pos_Cat_Form, \ |
51 | 51 | ExampleOpinionForm, \ |
52 | 52 | FrameConversionForm, CreatePositionForm, AssignPhraseologicFrameForm |
53 | 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 | 57 | from common.decorators import render, ajax, AjaxError |
57 | 58 | from common.util import triple_arg_poss |
... | ... | @@ -2546,7 +2547,10 @@ def save_new_frames(request, data, id, examples, lemma_examples): |
2546 | 2547 | nkjp_example_obj.arguments.add(argument_selection) |
2547 | 2548 | new_lemma_ver.nkjp_examples.add(nkjp_example_obj) |
2548 | 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 | 2554 | reconnect_examples(reconnect_examples_operations) |
2551 | 2555 | |
2552 | 2556 | # dodawanie przykladow nkjp do czasownika |
... | ... |
dictionary/saving.py
... | ... | @@ -107,6 +107,10 @@ def connect_example_operation(example_dict, example_obj): |
107 | 107 | lu = LexicalUnit.objects.get(id=example_dict['lexical_unit']) |
108 | 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 | 114 | def reconnect_examples(operations): |
111 | 115 | update_meanings(operations) |
112 | 116 | |
113 | 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 | 578 | this.opinion = opinion; |
579 | 579 | this.comment = comment; |
580 | 580 | this.semantic = semantic; |
581 | + this.lexical_unit = -1; | |
581 | 582 | } |
582 | 583 | |
583 | 584 | function Nkjp_example_ajax(frame, arg_selections, sentence, source, opinion, comment, semantic, lexical_unit) |
... | ... |