Commit 54f5a47a6295414dc777bd21914bdb5fd349e645
1 parent
3a22a50c
Schemata are now reloading after saving semantics.
Showing
10 changed files
with
114 additions
and
21 deletions
LICENSE
accounts/admin.py
... | ... | @@ -39,7 +39,8 @@ class RealizedPhraseologyAdmin(admin.ModelAdmin): |
39 | 39 | readonly_fields = ('date',) |
40 | 40 | search_fields = ('lemma__entry',) |
41 | 41 | |
42 | -class RealizedSemanticsAdmin(admin.ModelAdmin): | |
42 | +class RealizedSemanticsAdmin(admin.ModelAdmin): | |
43 | + exclude = ('entry',) | |
43 | 44 | list_filter = ('status', 'bonus',) |
44 | 45 | search_fields = ('entry__name',) |
45 | 46 | |
... | ... |
dictionary/ajax_lemma_view.py
... | ... | @@ -3193,3 +3193,21 @@ def delete_user(request, user_id): |
3193 | 3193 | def deselect_preview_tab(request): |
3194 | 3194 | request.session['lemma_preview'] = False |
3195 | 3195 | return {} |
3196 | + | |
3197 | +@ajax(method='get') | |
3198 | +def get_schemata(request, lemma_id): | |
3199 | + lemma = Lemma.objects.get(id=lemma_id) | |
3200 | + schemata = lemma.frames.order_by('text_rep') | |
3201 | + serialized_schemata = [frameObjToSerializableDict(lemma, schema, True) for schema in schemata] | |
3202 | + json_schemata = json_encode(serialized_schemata) | |
3203 | + return {'schemata': json_schemata, | |
3204 | + 'can_modify': user_can_modify(lemma, request.user)} | |
3205 | + | |
3206 | +@ajax(method='get') | |
3207 | +def get_examples(request, lemma_id): | |
3208 | + lemma = Lemma.objects.get(id=lemma_id) | |
3209 | + examples = lemma.nkjp_examples.all() | |
3210 | + examples_js = nkjpExamplesObjToJs(examples, request.user, lemma) | |
3211 | + json_examples = json_encode(examples_js) | |
3212 | + return {'examples': json_examples, | |
3213 | + 'can_modify': user_can_modify(lemma, request.user)} | |
... | ... |
dictionary/saving.py
... | ... | @@ -23,21 +23,22 @@ def get_reconnect_operations_and_extend_connections(frames, connections, schema, |
23 | 23 | operations = [] |
24 | 24 | used_poss_ids = [] |
25 | 25 | for js_position in js_schema['positions']: |
26 | - position = get_position(schema, js_position, used_poss_ids) | |
27 | - for js_phrase_type in js_position['arguments']: | |
28 | - phrase_type = Argument.objects.get(text_rep=js_phrase_type['text_rep']) | |
29 | - new_connection_target = {'schema': schema, | |
30 | - 'position': position, | |
31 | - 'phrase_type': phrase_type} | |
32 | - for conn in js_phrase_type['connections']: | |
33 | - operations.extend(reconnect_operations(frames, conn, new_connection_target)) | |
34 | - conn_dict = next((conn_dict | |
35 | - for conn_dict in connections if conn_dict['compl'] == conn['compl']), None) | |
36 | - if conn_dict: | |
37 | - conn_dict['realizations'].extend(conn['realizations']) | |
38 | - else: | |
39 | - connections.append({'compl': conn['compl'], | |
40 | - 'realizations': conn['realizations']}) | |
26 | + if len(js_position['arguments']) > 0: | |
27 | + position = get_position(schema, js_position, used_poss_ids) | |
28 | + for js_phrase_type in js_position['arguments']: | |
29 | + phrase_type = Argument.objects.get(text_rep=js_phrase_type['text_rep']) | |
30 | + new_connection_target = {'schema': schema, | |
31 | + 'position': position, | |
32 | + 'phrase_type': phrase_type} | |
33 | + for conn in js_phrase_type['connections']: | |
34 | + operations.extend(reconnect_operations(frames, conn, new_connection_target)) | |
35 | + conn_dict = next((conn_dict | |
36 | + for conn_dict in connections if conn_dict['compl'] == conn['compl']), None) | |
37 | + if conn_dict: | |
38 | + conn_dict['realizations'].extend(conn['realizations']) | |
39 | + else: | |
40 | + connections.append({'compl': conn['compl'], | |
41 | + 'realizations': conn['realizations']}) | |
41 | 42 | return operations |
42 | 43 | |
43 | 44 | def get_position(schema, js_position, used_poss_ids): |
... | ... |
dictionary/static/js/lemma-view.js
... | ... | @@ -75,6 +75,15 @@ var nkjp_source_tab = ax_nkjp_source_vals; |
75 | 75 | function alertUserNotAuthenticated() { |
76 | 76 | error_alert('Przed wykonaniem działania odśwież okno przeglądarki, a następnie zaloguj się ponownie do narzędzia.'); |
77 | 77 | } |
78 | + | |
79 | +function resetLemmaVersions() { | |
80 | + window.frames_modif = new Array(); | |
81 | + window.frames_modif_idx = 0; | |
82 | + var lemma_version = new Lemma_Version(window.schemas, | |
83 | + window.nkjp_examples, | |
84 | + window.nkjp_lemma_examples); | |
85 | + frames_modif.push(lemma_version); | |
86 | +} | |
78 | 87 | |
79 | 88 | function initiateFrameFilters() |
80 | 89 | { |
... | ... | @@ -437,7 +446,7 @@ function load_content(id) { |
437 | 446 | window.notesNotSaved = false; |
438 | 447 | window.lemmaExNotSaved = false; |
439 | 448 | |
440 | - $('#new_frames').load(ajax_new_frames, 'id='+id, function(){ | |
449 | + $('#new_frames').load(ajax_new_frames, 'id='+id, function(){ | |
441 | 450 | window.lemma_id = id; |
442 | 451 | createSplitter('framesSplit','new-frame-tables', 'tabs'); |
443 | 452 | if(window.can_modify) |
... | ... |
dictionary/static/js/semantics_coupling.js
1 | -function schemaGotAssignedSemantics(element_id) | |
2 | -{ | |
1 | +function schemaGotAssignedSemantics(element_id) { | |
3 | 2 | var semanticsAssigned = true; |
4 | 3 | var id_map = parseId(element_id); |
5 | 4 | var schema_id = id_map['frame_id']; |
... | ... | @@ -93,3 +92,63 @@ function clearPositionConnections(position) { |
93 | 92 | function clearPhraseTypeConnections(phraseType) { |
94 | 93 | phraseType.connections = []; |
95 | 94 | } |
95 | + | |
96 | +function updateSchemataConnections() { | |
97 | + $('#new-frame-tables').empty(); | |
98 | + $("#show_nkjp_table").empty(); | |
99 | + $.ajaxJSON({ | |
100 | + method: 'get', | |
101 | + url: ajax_get_schemata, | |
102 | + data: { | |
103 | + lemma_id: window.lemma_id | |
104 | + }, | |
105 | + | |
106 | + callback: function(result) { | |
107 | + window.schemas = serializedObjToObj(result['schemata']); | |
108 | + resetLemmaVersions(); | |
109 | + var frame_class = 'InactiveFrameTable'; | |
110 | + if(result['can_modify']) { | |
111 | + frame_class = 'ActiveFrameTable'; | |
112 | + } | |
113 | + draw_filtered_frames(window.schemas, 'new-frame-tables', 'new-frame-table', | |
114 | + 'frame_filter', window.nkjp_examples, frame_class, | |
115 | + window.lemma_entry, window.lemma_entry); | |
116 | + }, | |
117 | + error_callback: function(xhr, status, error) { | |
118 | + error_alert(status + ': ' + error); | |
119 | + }, | |
120 | + bad_data_callback: function(result) { | |
121 | + return true; | |
122 | + }, | |
123 | + }); | |
124 | +} | |
125 | + | |
126 | +function updateExamplesConnections() { | |
127 | + $('#new-frame-tables').empty(); | |
128 | + $("#show_nkjp_table").empty(); | |
129 | + $.ajaxJSON({ | |
130 | + method: 'get', | |
131 | + url: ajax_get_examples, | |
132 | + data: { | |
133 | + lemma_id: window.lemma_id | |
134 | + }, | |
135 | + | |
136 | + callback: function(result) { | |
137 | + window.nkjp_examples = serializedNkjpToObj(result['examples']); | |
138 | + resetLemmaVersions(); | |
139 | + var frame_class = 'InactiveFrameTable'; | |
140 | + if(result['can_modify']) { | |
141 | + frame_class = 'ActiveFrameTable'; | |
142 | + } | |
143 | + draw_filtered_frames(window.schemas, 'new-frame-tables', 'new-frame-table', | |
144 | + 'frame_filter', window.nkjp_examples, frame_class, | |
145 | + window.lemma_entry, window.lemma_entry); | |
146 | + }, | |
147 | + error_callback: function(xhr, status, error) { | |
148 | + error_alert(status + ': ' + error); | |
149 | + }, | |
150 | + bad_data_callback: function(result) { | |
151 | + return true; | |
152 | + }, | |
153 | + }); | |
154 | +} | |
... | ... |
dictionary/views.py
... | ... | @@ -191,6 +191,8 @@ def lemma_view(request): |
191 | 191 | 'ajax_get_compatible_schema_chars' : reverse('get_compatible_schema_chars'), |
192 | 192 | |
193 | 193 | 'ajax_deselect_preview_tab': reverse('deselect_preview_tab'), |
194 | + 'ajax_get_schemata': reverse('get_schemata'), | |
195 | + 'ajax_get_examples': reverse('get_examples'), | |
194 | 196 | |
195 | 197 | # powiazywanie hasel (nieczasownikowe) |
196 | 198 | 'ajax_relate_entries' : reverse('relate_entries'), |
... | ... |
semantics/static/js/semantics_frames.js
... | ... | @@ -463,8 +463,8 @@ function saveFrames() { |
463 | 463 | memorizeConnections(data.connections.connected, data.connections.connected_reverse); |
464 | 464 | $("#semantic-frames-count").empty(); |
465 | 465 | $("#semantic-frames-count").append(data.frames_count); |
466 | + updateSchemataConnections(); | |
466 | 467 | }); |
467 | 468 | frames_operations = []; |
468 | 469 | } |
469 | 470 | } |
470 | - | |
... | ... |
semantics/static/js/semantics_lexical_units.js
urls.py
... | ... | @@ -121,6 +121,8 @@ urlpatterns += patterns('dictionary.ajax_lemma_view', |
121 | 121 | url(r'^ajax/user_is_authenticated/$', 'user_is_authenticated'), |
122 | 122 | |
123 | 123 | url(r'^ajax/deselect_preview_tab/$', 'deselect_preview_tab'), |
124 | + url(r'^ajax/get_schemata/$', 'get_schemata'), | |
125 | + url(r'^ajax/get_examples/$', 'get_examples'), | |
124 | 126 | |
125 | 127 | # powiazywanie hasel (nieczasownikowe) |
126 | 128 | url(r'^ajax/relate_entries/$', 'relate_entries'), |
... | ... |