Commit ebf6cd358cbea490f9d46535e1be54d8b9674bb7
1 parent
7c50fbb1
Add feature to retake document for annotation for previous annotator
Showing
3 changed files
with
44 additions
and
6 deletions
collector/storage/templates/storage/review.html
... | ... | @@ -57,23 +57,34 @@ |
57 | 57 | </a> |
58 | 58 | |
59 | 59 | {% if document.processing_status.key == "correct" %} |
60 | + <br><br> | |
60 | 61 | {% if request.user|belongs_to_group:"Editors" %} |
61 | 62 | <a class="retake-doc-for-annotation btn btn-danger" |
62 | - href="{% url 'retake_doc_for_annotation' document.id %}"> | |
63 | + href="{% url 'retake_doc_for_anno' document.id %}"> | |
63 | 64 | Zwróć dokument do anotacji <i class="material-icons def-col-button">undo</i> |
64 | 65 | </a> |
66 | + <br><br> | |
67 | + <a class="retake-doc-for-annotation btn btn-danger" | |
68 | + href="{% url 'retake_doc_for_anno_for_prev_annot' document.id %}"> | |
69 | + Zwróć dokument do anotacji do poprzedniego anotatora<i class="material-icons def-col-button">undo</i> | |
70 | + </a> | |
65 | 71 | {% else %} |
66 | 72 | <span title="Opcja dostępna tylko dla grupy Redaktorzy"> |
67 | 73 | <a class="retake-doc-for-annotation btn btn-danger disable-click" |
68 | - href="{% url 'retake_doc_for_annotation' document.id %}"> | |
74 | + href="{% url 'retake_doc_for_anno' document.id %}"> | |
69 | 75 | Zwróć dokument do anotacji <i class="material-icons def-col-button">undo</i> |
70 | 76 | </a> |
77 | + <br><br> | |
78 | + <a class="retake-doc-for-annotation btn btn-danger disable-click" | |
79 | + href="{% url 'retake_doc_for_anno_for_prev_annot' document.id %}"> | |
80 | + Zwróć dokument do anotacji do poprzedniego anotatora <i class="material-icons def-col-button">undo</i> | |
81 | + </a> | |
71 | 82 | </span> |
72 | 83 | {% endif %} |
73 | 84 | {% endif %} |
74 | 85 | |
75 | 86 | <!-- <button class="retake-doc-for-annotation btn btn-danger" type="button"--> |
76 | -<!-- data-id="{% url 'retake_doc_for_annotation' document.id %}">--> | |
87 | +<!-- data-id="{% url 'retake_doc_for_anno' document.id %}">--> | |
77 | 88 | <!-- Zwróć dokument do anotacji <i class="material-icons def-col-button">undo</i>--> |
78 | 89 | <!-- </button>--> |
79 | 90 | |
... | ... |
collector/storage/urls.py
... | ... | @@ -61,6 +61,8 @@ urlpatterns = [ |
61 | 61 | name='download_source'), |
62 | 62 | path('document-list/', login_required(views.DocumentListView.as_view()), name='document_list'), |
63 | 63 | path('draft-list/<str:user_id>', login_required(views.DraftListView.as_view()), name='draft_list'), |
64 | - path('retake-doc-for-annotation/<str:doc_id>', login_required(views.RetakeDocForAnnotationView.as_view()), | |
65 | - name='retake_doc_for_annotation') | |
64 | + path('retake-doc-for-annotation/<str:doc_id>', login_required(views.RetakeDocForAnnoView.as_view()), | |
65 | + name='retake_doc_for_anno'), | |
66 | + path('retake-doc-for-anno-for-prev-annot/<str:doc_id>', | |
67 | + login_required(views.RetakeDocForAnnoForPrevAnnotView.as_view()), name='retake_doc_for_anno_for_prev_annot') | |
66 | 68 | ] |
... | ... |
collector/storage/views.py
... | ... | @@ -1056,7 +1056,7 @@ class DocumentListView(ListView): |
1056 | 1056 | return docs |
1057 | 1057 | |
1058 | 1058 | |
1059 | -class RetakeDocForAnnotationView(UserPassesTestMixin, RedirectView): | |
1059 | +class RetakeDocForAnnoView(UserPassesTestMixin, RedirectView): | |
1060 | 1060 | |
1061 | 1061 | def get_redirect_url(self, *args, **kwargs): |
1062 | 1062 | return reverse('document_list') |
... | ... | @@ -1079,6 +1079,31 @@ class RetakeDocForAnnotationView(UserPassesTestMixin, RedirectView): |
1079 | 1079 | return HttpResponse('Wymagana jest rola redaktora, aby uzyskać dostęp do tej strony.') |
1080 | 1080 | |
1081 | 1081 | |
1082 | +class RetakeDocForAnnoForPrevAnnotView(UserPassesTestMixin, RedirectView): | |
1083 | + | |
1084 | + def get_redirect_url(self, *args, **kwargs): | |
1085 | + return reverse('document_list') | |
1086 | + | |
1087 | + def get(self, request, *args, **kwargs): | |
1088 | + return render(self.request, 'storage/delete.html', {'msg': 'Czy na pewno chcesz zwrócić dokument do ponownej ' | |
1089 | + 'anotacji dla poprzedniego anotatora?', | |
1090 | + 'submit_btn_text': 'Zwróć'}) | |
1091 | + | |
1092 | + def post(self, request, *args, **kwargs): | |
1093 | + document = Document.objects.get(id=kwargs['doc_id']) | |
1094 | + document.change_processing_status('to_correct') | |
1095 | + last_annotator = document.annotations.order_by('-finish_time')[0].user | |
1096 | + Annotation.objects.create(user=last_annotator, document=document) | |
1097 | + document.save() | |
1098 | + return super().get(request, *args, **kwargs) | |
1099 | + | |
1100 | + def test_func(self): | |
1101 | + return self.request.user.groups.filter(name='Editors').exists() | |
1102 | + | |
1103 | + def handle_no_permission(self): | |
1104 | + return HttpResponse('Wymagana jest rola redaktora, aby uzyskać dostęp do tej strony.') | |
1105 | + | |
1106 | + | |
1082 | 1107 | class DraftListView(ListView): |
1083 | 1108 | model = Document |
1084 | 1109 | template_name = 'storage/draft_list.html' |
... | ... |