Commit 615f9267e24d284f5d6cfc2f32979ae33207582d
1 parent
139e39ee
Add drafts view and change the way of choosing new document for annotation for a…
…lways getting documents "to_correct"
Showing
7 changed files
with
117 additions
and
44 deletions
collector/storage/models.py
... | ... | @@ -234,4 +234,7 @@ class Annotation(models.Model): |
234 | 234 | finished = models.BooleanField(default=False) |
235 | 235 | |
236 | 236 | def __str__(self): |
237 | - return f'{self.user.username}-{str(self.document.pk)}' | |
237 | + return f'{self.user.username}-{self.document.name}-{str(self.document.pk)}' | |
238 | + | |
239 | + class Meta: | |
240 | + ordering = ['finish_time'] | |
... | ... |
collector/storage/static/storage/css/document.css
... | ... | @@ -402,4 +402,13 @@ ul.legend { |
402 | 402 | |
403 | 403 | .nav-anchor:hover { |
404 | 404 | text-decoration: none; |
405 | -} | |
406 | 405 | \ No newline at end of file |
406 | +} | |
407 | + | |
408 | +.unfinished-ann-username { | |
409 | + text-decoration: underline; | |
410 | +} | |
411 | + | |
412 | +#drafts-table { | |
413 | + width: 50%; | |
414 | + text-align: center; | |
415 | +} | |
... | ... |
collector/storage/templates/storage/annotation.html
... | ... | @@ -35,8 +35,15 @@ |
35 | 35 | |
36 | 36 | <div class="btn-group-vertical centered-buttons"> |
37 | 37 | {% if user.is_authenticated %} |
38 | - <a href="{% url 'start_annotation' %}" class="btn btn-primary btn-lg" role="button">Anotuj dokument</a> | |
39 | - <a href="{% url 'document_list' %}" class="btn btn-success btn-lg" role="button">Przeglądaj wszystkie dokumenty</a> | |
38 | + <a href="{% url 'start_annotation' %}" class="btn btn-primary btn-lg" role="button"> | |
39 | + Anotuj kolejny dokument <i class="fas fa-edit"></i> | |
40 | + </a> | |
41 | + <a href="{% url 'draft_list' user.id %}" class="btn btn-info btn-lg" role="button"> | |
42 | + Zobacz swoje wersje robocze <i class="far fa-clipboard"></i> | |
43 | + </a> | |
44 | + <a href="{% url 'document_list' %}" class="btn btn-success btn-lg" role="button"> | |
45 | + Przeglądaj wszystkie dokumenty <i class="fas fa-layer-group"></i> | |
46 | + </a> | |
40 | 47 | {% endif %} |
41 | 48 | </div> |
42 | 49 | |
... | ... | @@ -59,29 +66,35 @@ |
59 | 66 | </div> |
60 | 67 | |
61 | 68 | {% if user.is_authenticated %} |
62 | - {% if messages %} | |
63 | - {% for message in messages %} | |
64 | - <div class="alert alert-danger center-alert text-center" role="alert"> | |
65 | - {{ message }} | |
66 | - </div> | |
67 | - {% endfor %} | |
68 | - {% endif %} | |
69 | - <div class="main-actions text-align-center"> | |
70 | - <a class="btn btn-info" | |
71 | - href="{% url 'download_source' document.id 'annotation' %}"> | |
72 | - Pobierz źródło | |
73 | - <i class="material-icons def-col-button">file_download</i> | |
74 | - </a> | |
75 | - {% if document.parent %} | |
76 | - <button class="revert-subdoc-division btn btn-danger" type="button" | |
77 | - data-id="{% url 'revert_subdoc_division' document.id %}">Cofnij podział dokumentu</button> | |
78 | - {% else %} | |
79 | - <button class="split-doc btn btn-primary" type="button" data-id="{% url 'split_doc' document.id %}"> | |
80 | - Podziel dokument</button> | |
81 | - <button class="finish-annotation btn btn-success" type="button" data-id="{% url 'finish_annotation' document.id %}"> | |
82 | - Zakończ anotację</button> | |
83 | - {% endif %} | |
84 | - </div> | |
69 | + {% if messages %} | |
70 | + {% for message in messages %} | |
71 | + <div class="alert alert-danger center-alert text-center" role="alert"> | |
72 | + {{ message }}Ano | |
73 | + </div> | |
74 | + {% endfor %} | |
75 | + {% endif %} | |
76 | + <div class="main-actions text-align-center"> | |
77 | + <a class="btn btn-info" | |
78 | + href="{% url 'download_source' document.id 'annotation' %}"> | |
79 | + Pobierz źródło | |
80 | + <i class="material-icons def-col-button">file_download</i> | |
81 | + </a> | |
82 | + {% if document.parent %} | |
83 | + <button class="revert-subdoc-division btn btn-danger" type="button" | |
84 | + data-id="{% url 'revert_subdoc_division' document.id %}"> | |
85 | + Cofnij podział dokumentu <i class="material-icons def-col-button">backspace</i> | |
86 | + </button> | |
87 | + {% else %} | |
88 | + <button class="split-doc btn btn-primary" type="button" data-id="{% url 'split_doc' document.id %}"> | |
89 | + Podziel dokument <i class="material-icons def-col-button">splitscreen</i> | |
90 | + </button> | |
91 | + <br> | |
92 | + <br> | |
93 | + <button class="finish-annotation btn btn-success" type="button" data-id="{% url 'finish_annotation' document.id %}"> | |
94 | + Zakończ anotację <i class="material-icons def-col-button">done</i> | |
95 | + </button> | |
96 | + {% endif %} | |
97 | + </div> | |
85 | 98 | {% endif %} |
86 | 99 | |
87 | 100 | {% if document.image or document.broken_source %} |
... | ... |
collector/storage/templates/storage/document_list.html
... | ... | @@ -119,8 +119,12 @@ |
119 | 119 | >{{ document.name }} |
120 | 120 | </a></td> |
121 | 121 | <td> |
122 | - {% for annotation in document.annotations.all|dictsort:"finish_time" %} | |
123 | - {{ annotation.user.username }} | | |
122 | + {% for annotation in document.annotations.all %} | |
123 | + {% if annotation.finished == True %} | |
124 | + {{ annotation.user.username }} | | |
125 | + {% else %} | |
126 | + <span class="unfinished-ann-username">{{ annotation.user.username }}</span> | | |
127 | + {% endif %} | |
124 | 128 | {% endfor %} |
125 | 129 | </td> |
126 | 130 | </tr> |
... | ... |
collector/storage/templates/storage/draft_list.html
0 → 100755
1 | +{% extends "storage/base.html" %} | |
2 | +{% load static %} | |
3 | +{% block title %} Wersje robocze {% endblock %} | |
4 | + | |
5 | +{% block content %} | |
6 | + | |
7 | + {% if drafts %} | |
8 | + <div class="info"> | |
9 | + <p>Twoje wersje robocze:</p> | |
10 | + </div> | |
11 | + | |
12 | + <table class="data-table doc-table" id="drafts-table"> | |
13 | + <thead> | |
14 | + <tr> | |
15 | + <th>Nazwa-ID</th> | |
16 | + </tr> | |
17 | + </thead> | |
18 | + | |
19 | + <tbody> | |
20 | + {% for draft in drafts %} | |
21 | + <tr> | |
22 | + <td><a href="{% url 'annotation' draft.id %}">{{ draft }}</a></td> | |
23 | + </tr> | |
24 | + {% endfor %} | |
25 | + </tbody> | |
26 | + | |
27 | + </table> | |
28 | + | |
29 | + {% else %} | |
30 | + <div class="info"> | |
31 | + <p>Nie posiadasz żadnych wersji roboczych.</p> | |
32 | + </div> | |
33 | + | |
34 | + {% endif %} | |
35 | + | |
36 | +{% endblock %} | |
0 | 37 | \ No newline at end of file |
... | ... |
collector/storage/urls.py
... | ... | @@ -60,6 +60,7 @@ urlpatterns = [ |
60 | 60 | path('download-source/<str:doc_id>/<str:redirect_view>', login_required(views.download_source), |
61 | 61 | name='download_source'), |
62 | 62 | path('document-list/', login_required(views.DocumentListView.as_view()), name='document_list'), |
63 | + path('draft-list/<str:user_id>', login_required(views.DraftListView.as_view()), name='draft_list'), | |
63 | 64 | path('retake-doc-for-annotation/<str:doc_id>', login_required(views.RetakeDocForAnnotationView.as_view()), |
64 | 65 | name='retake_doc_for_annotation') |
65 | 66 | ] |
... | ... |
collector/storage/views.py
... | ... | @@ -824,21 +824,17 @@ class StartAnnotationView(UserPassesTestMixin, RedirectView): |
824 | 824 | return reverse('annotation', kwargs={'doc_id': kwargs['doc_id']}) |
825 | 825 | |
826 | 826 | def get(self, request, *args, **kwargs): |
827 | - try: | |
828 | - unfinished_ann = Annotation.objects.get(user=request.user, finished=False) | |
829 | - doc_id = unfinished_ann.document.id | |
830 | - except Annotation.DoesNotExist: | |
831 | - new_documents = Document.objects.filter(parent__isnull=True, | |
832 | - processing_status=ProcessingStatus.objects.get(key='to_correct')) | |
833 | - if len(new_documents) == 0: | |
834 | - messages.error(request, 'Brak dokumentów dostępnych do anotacji') | |
835 | - return HttpResponseRedirect(reverse('annotation')) | |
836 | - else: | |
837 | - doc_id = new_documents[0].id | |
838 | - document = Document.objects.get(id=doc_id) | |
839 | - Annotation.objects.create(document=document, user=request.user) | |
840 | - document.change_processing_status('in_correction') | |
841 | - document.save() | |
827 | + new_documents = Document.objects.filter(parent__isnull=True, | |
828 | + processing_status=ProcessingStatus.objects.get(key='to_correct')) | |
829 | + if len(new_documents) == 0: | |
830 | + messages.error(request, 'Brak dokumentów dostępnych do anotacji') | |
831 | + return HttpResponseRedirect(reverse('annotation')) | |
832 | + else: | |
833 | + doc_id = new_documents[0].id | |
834 | + document = Document.objects.get(id=doc_id) | |
835 | + Annotation.objects.create(document=document, user=request.user) | |
836 | + document.change_processing_status('in_correction') | |
837 | + document.save() | |
842 | 838 | kwargs['doc_id'] = doc_id |
843 | 839 | return super().get(request, *args, **kwargs) |
844 | 840 | |
... | ... | @@ -1067,6 +1063,17 @@ class RetakeDocForAnnotationView(UserPassesTestMixin, RedirectView): |
1067 | 1063 | return HttpResponse('Wymagana jest rola redaktora, aby uzyskać dostęp do tej strony.') |
1068 | 1064 | |
1069 | 1065 | |
1066 | +class DraftListView(ListView): | |
1067 | + model = Document | |
1068 | + template_name = 'storage/draft_list.html' | |
1069 | + | |
1070 | + def get_context_data(self, **kwargs): | |
1071 | + context = super(DraftListView, self).get_context_data(**kwargs) | |
1072 | + drafts = [ann.document for ann in Annotation.objects.filter(user=self.request.user, finished=False)] | |
1073 | + context['drafts'] = drafts | |
1074 | + return context | |
1075 | + | |
1076 | + | |
1070 | 1077 | # ****************************** autocomplete ****************************** |
1071 | 1078 | |
1072 | 1079 | |
... | ... |