diff --git a/entries/views.py b/entries/views.py index 27714635c7c61ef55cae1c3819c2b0bbea727526..f6f1f0255ceeb412799e5555cc7dac0f6dab144e 100644 --- a/entries/views.py +++ b/entries/views.py @@ -970,7 +970,8 @@ def get_entry(request): if local_frame_filter_form: frame_objects = get_filtered_objects(local_frame_filter_form, frame_objects) - free_lexical_unit = LexicalUnit.objects.filter(Q(base=entry.name) | Q(base__startswith=entry.name+' ')) + free_lexical_unit = LexicalUnit.objects.filter(Q(Q(base=entry.name) | Q(base__startswith=entry.name+' ')) + & Q(frames__isnull=True)) all_examples = Example.objects.filter(Q(example_connections__lexical_unit__in=entry.lexical_units.all()) | Q(example_connections__lexical_unit__in=free_lexical_unit) | diff --git a/financial_settlement/forms.py b/financial_settlement/forms.py index 62de4b10ad7a75704585a9f0c5f87b6e0ab2b900..4ffc966d0fd73ed01aad24a15dd119998236be8f 100644 --- a/financial_settlement/forms.py +++ b/financial_settlement/forms.py @@ -13,9 +13,9 @@ from users.models import Note class FinStatementForm(forms.ModelForm): - start_date = forms.DateTimeField(input_formats=['%d-%m-%Y'], + start_date = forms.DateTimeField(label='Data rozpoczęcia', input_formats=['%d-%m-%Y'], widget=forms.DateTimeInput(format='%d-%m-%Y', attrs={'class': 'form-control'})) - end_date = forms.DateTimeField(input_formats=['%d-%m-%Y'], + end_date = forms.DateTimeField(label='Data zakończenia', input_formats=['%d-%m-%Y'], widget=forms.DateTimeInput( format='%d-%m-%Y', attrs={'class': 'form-control'})) @@ -37,6 +37,16 @@ class FinStatementForm(forms.ModelForm): 'is_active' ] + labels = { + 'statement_id': 'Numer umowy', + 'title': 'Tytuł', + 'payment': 'Budżet', + 'last_statement_payment': 'Kwota z ostatniej umowy', + 'price_per_unified_frame': 'Stawka za remę zunifikowaną', + 'user': 'Nazwa użytkownika', + 'is_active': "Czy umowa jest aktywna?" + } + def __init__(self, *args, instance, **kwargs): super().__init__(*args, instance=instance, **kwargs) self.helper = FormHelper() diff --git a/freelus/urls.py b/freelus/urls.py index 8bb15489421a8c8edf54b3377797e635ad831774..a036effa4a7cac9a4e305c7af5c6dff152966b2e 100644 --- a/freelus/urls.py +++ b/freelus/urls.py @@ -17,6 +17,7 @@ urlpatterns = [ path('change_lus_in_slowal_frame/', views.change_lus_in_slowal_frame, name='change_lus_in_slowal_frame'), path('change_frame_opinion/', views.change_frame_opinion, name='change_frame_opinion'), path('change_frame_status_to_building/', views.change_frame_status_to_building, name='change_frame_status_to_building'), + path('remove_frame_in_progress/', views.remove_frame_in_progress, name='remove_frame_in_progress'), ] diff --git a/freelus/views.py b/freelus/views.py index fcefd6f217d2231996457df69d018f2129fee96e..e6e0d1a09c03682d86656d2cd907c317af90d665 100644 --- a/freelus/views.py +++ b/freelus/views.py @@ -9,6 +9,7 @@ from meanings.models import LexicalUnit from semantics.models import Frame, FrameOpinion, Argument, ArgumentRole, SemanticRole, \ RoleAttribute, RoleSubAttribute, RoleType from syntax.models import Position +from users.models import Assignment @ajax_required @@ -220,7 +221,9 @@ def attach_schema_to_argument(request): argument = Argument.objects.get(id=argument_id) - if not ArgumentConnection.objects.filter(argument=argument, schema_connections__schema_id=schema_id).exists(): + if not ArgumentConnection.objects.filter(argument=argument, schema_connections__schema_id=schema_id).exists() and \ + not SchemaHook.objects.filter(subentry_id=subentry_id, schema_id=schema_id, position_id=schema_position_id, alternation=schema_alternation_id, + argument_connections__argument__frame_id=frame_id).exists(): position = Position.objects.get(id=schema_position_id) for phrase_type in position.phrase_types.all(): schema_hooks = [SchemaHook.objects.create(subentry_id=subentry_id, schema_id=schema_id, @@ -300,6 +303,35 @@ def finish_frame_processing(request): return JsonResponse({}) +@ajax_required +@transaction.atomic +def remove_frame_in_progress(request): + """ + Remove frame in buliding process. + The request has to contain 'frame_id'. + :param request: http request + :return: Empty json response + """ + if request.method == 'POST': + frame_id = request.POST['frame_id'] + frame = Frame.objects.get(id=frame_id) + if frame.in_building: + + Assignment.assign(user=request.user, subject=frame) + for argument in frame.arguments.all(): + argument.argument_connections.all().delete() + # ArgumentConnection.objects.filter(argument=argument).delete() + argument.example_connections.all().delete() + argument.delete() + frame.alternation_meanings.all().delete() + frame.delete() + else: + return JsonResponse({}) + return JsonResponse({}) + + return JsonResponse({}) + + @ajax_required @transaction.atomic def change_frame_status_to_building(request): diff --git a/frontend/src/components/unification/free_lu/FreeLuEdit.vue b/frontend/src/components/unification/free_lu/FreeLuEdit.vue index df5d8ad5f0b6cb49b1a5a7e692fca329a5cba080..2f5f89a0f5bc2e13cd8d0f1865675ecf41120df3 100644 --- a/frontend/src/components/unification/free_lu/FreeLuEdit.vue +++ b/frontend/src/components/unification/free_lu/FreeLuEdit.vue @@ -452,7 +452,7 @@ }, (response) => { if(response['succ'] == true) { - show_info('Argument ramy został powiązany z wybranym argumentem schematu.'); + show_info('Argument ramy został powiązany z wybraną pozycją schematu.'); this.loadEntry(); } else { alert(gettext(response['error'])); @@ -481,7 +481,7 @@ 'schema_alternation_id': (parseInt(this.selected_schemata_position_alternation_id)+1) }, (response) => { - show_info('Powiązanie pomiędzy argumentem ramy a argumentem schematu zostało usunięte.'); + show_info('Powiązanie pomiędzy argumentem ramy a pozycją schematu zostało usunięte.'); this.loadEntry(); $.prompt.close(); }, @@ -491,7 +491,7 @@ $.prompt.close(); }) } else { - alert(gettext("W celu usunięcia powiązania schamatu oraz ramy zaznacz argument ramy oraz argument schematu.")); + alert(gettext("W celu usunięcia powiązania schamatu oraz ramy zaznacz argument ramy oraz pozycję schematu.")); } }, finish_frame_building() { @@ -512,7 +512,28 @@ $.prompt.close(); }) } else { - alert(gettext("W celu usunięcia powiązania schamatu oraz ramy zaznacz argument ramy oraz argument schematu.")); + alert(gettext("W celu usunięcia powiązania schamatu oraz ramy zaznacz argument ramy oraz pozycję schematu.")); + } + }, + remove_frame_in_progress() { + if (this.frame_in_progress) { + send_post_request('/freelus/remove_frame_in_progress/', + { + 'frame_id': this.frame_in_progress.id, + }, + (response) => { + alert(gettext("Rama została usunięta.")); + show_info('Rama została usunięta.'); + this.loadEntry(); + $.prompt.close(); + }, + (request, errorType, errorMessage) => { + alert(errorType + ' (' + errorMessage + ')'); + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + }) + } else { + alert(gettext("Nie ma ramyw budowie, która mogłaby być usunięta.")); } }, reload_view() { @@ -557,7 +578,7 @@ </td> <td id="assign-schema" class="table-button-menu-td" @click="assign_schema()" - style="padding: 10px 15px 10px 15px; color: #000000;">Podłącz argument + style="padding: 10px 15px 10px 15px; color: #000000;">Podłącz pozycję </td> <td id="assign-examples" class="table-button-menu-td" @click="attach_examples()" style="padding: 10px 15px 10px 15px; color: #000000;">Podłącz przykłady @@ -565,6 +586,9 @@ <td id="finish-frame-building" class="table-button-menu-td" @click="finish_frame_building()" style="padding: 10px 15px 10px 15px; color: #000000;">Gotowe </td> + <td v-if="frame_in_progress" id="remove-frame" class="table-button-menu-td" @click="remove_frame_in_progress()" + style="padding: 10px 15px 10px 15px; color: #000000;">Usuń ramę + </td> </tr> <tr style="background-color: white;"> <td id="modify-frame" class="table-button-menu-td" @click="change_frame_status_to_building()" @@ -575,7 +599,7 @@ style="padding: 10px 15px 10px 15px; color: #000000;">Zmień rolę </td> <td id="delete-schema" class="table-button-menu-td" @click="delete_schema_connections()" - style="padding: 10px 15px 10px 15px; color: #000000;">Odłącz argument + style="padding: 10px 15px 10px 15px; color: #000000;">Odłącz pozycję </td> <td id="remove-argument" class="table-button-menu-td" @click="remove_argument()" style="padding: 10px 15px 10px 15px; color: #000000;">Usuń argument @@ -705,6 +729,26 @@ </td> </template> </tr> + <tr> + <th scope="row" class="py-0 px-1 text-secondary">Preferencje selekcyjne</th> + <template v-for="argument in frame_in_progress.arguments"> + + <td class="preferences py-0 px-0 border-top border-left border-secondary" + :class="argument.selected ? 'active' : argument.hover ? 'bg-highlight' : ''" + > + <template v-if="argument.preferences.length > 0" v-for='preference in argument.preferences'> + <div + v-if="preference.url != null" + class="preference py-2 px-1" + > + <a class="synset-plwn" v-bind:href="preference.url" target="_blank">{{ preference.str }}</a> + <info-tooltip v-if="preference.info" :text="'definicja: <i>'+ preference.info +'</i>'"/> + </div> + <div v-else class="preference py-2 px-1">{{ preference.str }}</div> + </template> + </td> + </template> + </tr> </tbody> </table> </div>