Commit 8ba1501998d5e9bd85b2510e44e3fddbeb852f4f
1 parent
f381c866
Change order conditions while merging chunks, rename "sekcja" for "akapit"
Showing
6 changed files
with
35 additions
and
29 deletions
collector/storage/forms.py
... | ... | @@ -361,7 +361,7 @@ class ChunkMoveForm(ModelForm): |
361 | 361 | |
362 | 362 | |
363 | 363 | class ChunkMergeForm(ModelForm): |
364 | - target_chunk = ModelChoiceField(queryset=None, label="Połącz z sekcją:") | |
364 | + target_chunk = ModelChoiceField(queryset=None, label="Połącz z akapitem:") | |
365 | 365 | |
366 | 366 | def __init__(self, *args, **kwargs): |
367 | 367 | poss_target_chunks = kwargs.pop('poss_target_chunks') |
... | ... | @@ -386,5 +386,5 @@ class ChunkSplitForm(Form): |
386 | 386 | super(ChunkSplitForm, self).__init__(*args, **kwargs) |
387 | 387 | self.fields['text'].initial = initial_text |
388 | 388 | self.fields['text'].widget = Textarea(attrs={'class': 'formset-field', |
389 | - 'placeholder': 'Tekst sekcji', | |
389 | + 'placeholder': 'Tekst akapitu', | |
390 | 390 | 'rows': 5}) |
... | ... |
collector/storage/templates/storage/annotation.html
... | ... | @@ -69,7 +69,7 @@ |
69 | 69 | {% if messages %} |
70 | 70 | {% for message in messages %} |
71 | 71 | <div class="alert alert-danger center-alert text-center" role="alert"> |
72 | - {{ message }}Ano | |
72 | + {{ message }} | |
73 | 73 | </div> |
74 | 74 | {% endfor %} |
75 | 75 | {% endif %} |
... | ... | @@ -352,23 +352,23 @@ |
352 | 352 | <div class="text-align-center"> |
353 | 353 | {% if user.is_authenticated %} |
354 | 354 | <i class="add-chunk-between material-icons button add" data-id="{% url 'add_chunk_between' document.id %}" |
355 | - title="Dodaj sekcję tutaj">add</i> | |
355 | + title="Dodaj akapit tutaj">add</i> | |
356 | 356 | {% endif %} |
357 | 357 | </div> |
358 | 358 | {% for chunk in chunks %} |
359 | 359 | <table class="doc-table"> |
360 | 360 | <thead> |
361 | 361 | <tr id="chunk-{{ chunk.pk }}" > |
362 | - <th class="sequence">Sekcja {{ chunk.sequence }}</th> | |
362 | + <th class="sequence">Akapit {{ chunk.sequence }}</th> | |
363 | 363 | <th></th> |
364 | 364 | <th class="actions"> |
365 | 365 | {% if user.is_authenticated %} |
366 | 366 | <i class="merge-chunk material-icons button merge" |
367 | 367 | data-id="{% url 'merge_chunk' chunk.pk %}" |
368 | - title="Połącz z inną sekcją">merge_type</i> | |
368 | + title="Połącz z innym akapitem">merge_type</i> | |
369 | 369 | <i class="split-chunk material-icons button split" |
370 | 370 | data-id="{% url 'split_chunk' chunk.pk %}" |
371 | - title="Podziel sekcję">call_split</i> | |
371 | + title="Podziel akapit">call_split</i> | |
372 | 372 | <i class="move-chunk material-icons button redo" data-id="{% url 'move_chunk' chunk.pk %}" |
373 | 373 | title="Przenieś do innego dokumentu">redo</i> |
374 | 374 | {% if not chunk.utterances.exists %} |
... | ... | @@ -407,7 +407,7 @@ |
407 | 407 | <div class="text-align-center"> |
408 | 408 | {% if user.is_authenticated %} |
409 | 409 | <i class="add-chunk-between material-icons button add" data-id="{% url 'add_chunk_between' document.id chunk.pk %}" |
410 | - title="Dodaj sekcję tutaj">add</i> | |
410 | + title="Dodaj akapit tutaj">add</i> | |
411 | 411 | {% endif %} |
412 | 412 | </div> |
413 | 413 | {% endfor %} |
... | ... |
collector/storage/templates/storage/chunk-split.html
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | </td> |
44 | 44 | {% endfor %} |
45 | 45 | <td class="col-remove"> |
46 | - <i class="remove-form-row material-icons" id="{{ formset.prefix }}" title="Usuń sekcję">clear</i> | |
46 | + <i class="remove-form-row material-icons" id="{{ formset.prefix }}" title="Usuń akapit">clear</i> | |
47 | 47 | </td> |
48 | 48 | </tr> |
49 | 49 | {% endfor %} |
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | |
56 | 56 | <div class="modal-footer"> |
57 | 57 | <button type="button" class="btn btn-sm btn-success add-form-row mr-auto" id="{{ formset.prefix }}"> |
58 | - Dodaj sekcję <i class="material-icons def-col-button">add</i> | |
58 | + Dodaj akapit <i class="material-icons def-col-button">add</i> | |
59 | 59 | </button> |
60 | 60 | <button type="submit" class="submit-btn btn btn-primary">{{ submit_btn_text }}</button> |
61 | 61 | </div> |
... | ... |
collector/storage/templates/storage/document.html
... | ... | @@ -119,7 +119,7 @@ |
119 | 119 | <table class="doc-table"> |
120 | 120 | <thead> |
121 | 121 | <tr id="chunk-{{ chunk.pk }}" > |
122 | - <th class="sequence">Sekcja {{ chunk.sequence }}</th> | |
122 | + <th class="sequence">Akapit {{ chunk.sequence }}</th> | |
123 | 123 | <th></th> |
124 | 124 | <th class="actions"> |
125 | 125 | {% if user.is_authenticated %} |
... | ... |
collector/storage/templates/storage/review.html
... | ... | @@ -235,7 +235,7 @@ |
235 | 235 | <table class="doc-table"> |
236 | 236 | <thead> |
237 | 237 | <tr id="chunk-{{ chunk.pk }}" > |
238 | - <th class="sequence">Sekcja {{ chunk.sequence }}</th> | |
238 | + <th class="sequence">Akapit {{ chunk.sequence }}</th> | |
239 | 239 | </tr> |
240 | 240 | {% if chunk.text %} |
241 | 241 | <tr class="chunk-text"> |
... | ... |
collector/storage/views.py
... | ... | @@ -105,10 +105,10 @@ def split_chunk(request, pk): |
105 | 105 | return HttpResponseRedirect('%s#chunk-%d' % ( |
106 | 106 | reverse_lazy('annotation', kwargs={'doc_id': chunk_document_id}), old_chunk.pk)) |
107 | 107 | else: |
108 | - messages.error(request, 'Błąd: Nieprawidłowy podział sekcji') | |
108 | + messages.error(request, 'Błąd: Nieprawidłowy podział akapitu.') | |
109 | 109 | return HttpResponseRedirect(reverse('annotation', kwargs={'doc_id': chunk_document_id})) |
110 | 110 | context['formset'] = formset |
111 | - context['title'] = 'Dzielenie sekcji' | |
111 | + context['title'] = 'Dzielenie akapitu' | |
112 | 112 | context['submit_btn_text'] = 'Podziel' |
113 | 113 | formset.data['chunks-TOTAL_FORMS'] = 0 |
114 | 114 | return render(request, 'storage/chunk-split.html', context) |
... | ... | @@ -262,7 +262,7 @@ class ChunkAddView(CreateView): |
262 | 262 | |
263 | 263 | def get_context_data(self, **kwargs): |
264 | 264 | context = super().get_context_data(**kwargs) |
265 | - context['title'] = 'Dodawanie sekcji' | |
265 | + context['title'] = 'Dodawanie akapitu' | |
266 | 266 | context['submit_btn_text'] = 'Dodaj' |
267 | 267 | return context |
268 | 268 | |
... | ... | @@ -282,8 +282,8 @@ class ChunkDeleteView(DeleteView): |
282 | 282 | |
283 | 283 | def get_context_data(self, **kwargs): |
284 | 284 | context = super().get_context_data(**kwargs) |
285 | - context['title'] = 'Usuwanie sekcji' | |
286 | - context['msg'] = 'Czy jesteś pewien, że chcesz usunąć sekcję?' | |
285 | + context['title'] = 'Usuwanie akapitu' | |
286 | + context['msg'] = 'Czy jesteś pewien, że chcesz usunąć akapit?' | |
287 | 287 | context['submit_btn_text'] = 'Usuń' |
288 | 288 | return context |
289 | 289 | |
... | ... | @@ -315,7 +315,7 @@ class ChunkEditView(UpdateView): |
315 | 315 | |
316 | 316 | def get_context_data(self, **kwargs): |
317 | 317 | context = super().get_context_data(**kwargs) |
318 | - context['title'] = 'Edycja sekcji' | |
318 | + context['title'] = 'Edycja akapitu' | |
319 | 319 | context['submit_btn_text'] = 'Zapisz' |
320 | 320 | return context |
321 | 321 | |
... | ... | @@ -336,7 +336,7 @@ class ChunkAddBetweenView(CreateView): |
336 | 336 | |
337 | 337 | def get_context_data(self, **kwargs): |
338 | 338 | context = super().get_context_data(**kwargs) |
339 | - context['title'] = 'Dodawanie sekcji' | |
339 | + context['title'] = 'Dodawanie akapitu' | |
340 | 340 | context['submit_btn_text'] = 'Dodaj' |
341 | 341 | return context |
342 | 342 | |
... | ... | @@ -365,7 +365,7 @@ class ChunkMoveView(UpdateView): |
365 | 365 | |
366 | 366 | def get_context_data(self, **kwargs): |
367 | 367 | context = super().get_context_data(**kwargs) |
368 | - context['title'] = 'Przenoszenie sekcji' | |
368 | + context['title'] = 'Przenoszenie akapitu' | |
369 | 369 | context['submit_btn_text'] = 'Przenieś' |
370 | 370 | return context |
371 | 371 | |
... | ... | @@ -392,15 +392,21 @@ class ChunkMergeView(UpdateView): |
392 | 392 | def form_valid(self, form): |
393 | 393 | if not self.request.is_ajax(): |
394 | 394 | target_chunk = form.cleaned_data['target_chunk'] |
395 | - target_chunk.text += f' {self.object.text}' | |
396 | - target_chunk.save() | |
397 | - self.object.delete() | |
398 | - return HttpResponseRedirect(self.get_success_url(target_chunk)) | |
395 | + if target_chunk.sequence > self.object.sequence: | |
396 | + self.object.text += f' {target_chunk.text}' | |
397 | + self.object.save() | |
398 | + target_chunk.delete() | |
399 | + return HttpResponseRedirect(self.get_success_url(self.object)) | |
400 | + else: | |
401 | + target_chunk.text += f' {self.object.text}' | |
402 | + target_chunk.save() | |
403 | + self.object.delete() | |
404 | + return HttpResponseRedirect(self.get_success_url(target_chunk)) | |
399 | 405 | return render(self.request, self.template_name, {'form': form}) |
400 | 406 | |
401 | 407 | def get_context_data(self, **kwargs): |
402 | 408 | context = super().get_context_data(**kwargs) |
403 | - context['title'] = 'Łączenie sekcji' | |
409 | + context['title'] = 'Łączenie akapitu' | |
404 | 410 | context['submit_btn_text'] = 'Połącz' |
405 | 411 | return context |
406 | 412 | |
... | ... | @@ -884,7 +890,7 @@ class FinishAnnotationView(RedirectView): |
884 | 890 | return HttpResponseRedirect(reverse('annotation', kwargs={'doc_id': document.id})) |
885 | 891 | if len(subdoc.chunks.all()) == 0: |
886 | 892 | messages.error(request, |
887 | - f'Błąd: Poddokument o ID "{subdoc.id}" nie posiada żadnych sekcji. Usuń go przed ' | |
893 | + f'Błąd: Poddokument o ID "{subdoc.id}" nie posiada żadnych akapitów. Usuń go przed ' | |
888 | 894 | f'zakończeniem anotacji.') |
889 | 895 | return HttpResponseRedirect(reverse('annotation', kwargs={'doc_id': document.id})) |
890 | 896 | document.change_processing_status('correct') |
... | ... | @@ -911,7 +917,7 @@ class DocSplitView(UpdateView): |
911 | 917 | chunk_end = form.cleaned_data['chunk_end'].sequence |
912 | 918 | chunks = self.object.chunks.all().order_by('sequence') |
913 | 919 | if chunk_end < chunk_beg: |
914 | - messages.error(self.request, 'Błąd: Nieprawidłowy zakres sekcji.') | |
920 | + messages.error(self.request, 'Błąd: Nieprawidłowy zakres akapitów.') | |
915 | 921 | return HttpResponseRedirect(reverse('annotation', kwargs={'doc_id': self.object.id})) |
916 | 922 | max_seq_doc = Document.objects.filter(parent=self.object).order_by('-sequence').first() |
917 | 923 | if max_seq_doc is None: |
... | ... | @@ -979,8 +985,8 @@ class RevertSubdocDivisionView(DeleteView): |
979 | 985 | def get_context_data(self, **kwargs): |
980 | 986 | context = super().get_context_data(**kwargs) |
981 | 987 | context['title'] = 'Cofanie podziału dokumentu' |
982 | - context['msg'] = 'Czy jesteś pewien, że chcesz cofnąć podział dokumentu? Spowoduje to powrót wszystkich sekcji' \ | |
983 | - ' do dokumentu głównego i utratę wszystkich metadanych przypisanych do tego dokumentu.' | |
988 | + context['msg'] = 'Czy jesteś pewien, że chcesz cofnąć podział dokumentu? Spowoduje to powrót wszystkich ' \ | |
989 | + 'akapitów do dokumentu głównego i utratę wszystkich metadanych przypisanych do tego dokumentu.' | |
984 | 990 | context['submit_btn_text'] = 'Cofnij podział' |
985 | 991 | return context |
986 | 992 | |
... | ... |