Add tool view to perform OCR on all documents at once.

This commit is contained in:
Roberto Rosario
2015-07-17 13:04:51 -04:00
parent e7f626aba4
commit 653a145914
4 changed files with 22 additions and 3 deletions

View File

@@ -54,6 +54,22 @@ class DocumentSubmitView(ConfirmView):
return HttpResponseRedirect(self.get_success_url())
class DocumentAllSubmitView(ConfirmView):
extra_context = {
'title': _('Submit all documents for OCR?')
}
def post(self, request, *args, **kwargs):
count = 0
for document in Document.objects.all():
document.submit_for_ocr()
count += 1
messages.success(request, _('%d documents added to the OCR queue.') % count)
return HttpResponseRedirect(self.get_success_url())
class DocumentManySubmitView(DocumentSubmitView):
def get_context_data(self, **kwargs):
context = super(DocumentManySubmitView, self).get_context_data(**kwargs)