From f733620475e821b22cad488538fad68ac0833a97 Mon Sep 17 00:00:00 2001
From: paul
Date: Sat, 21 Aug 2021 11:17:47 -0600
Subject: [PATCH 1/2] change app name in celery broker
---
droppdf/droppdf/celery.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/droppdf/droppdf/celery.py b/droppdf/droppdf/celery.py
index 6fa17fe..852804a 100644
--- a/droppdf/droppdf/celery.py
+++ b/droppdf/droppdf/celery.py
@@ -5,7 +5,7 @@
from django.conf import settings
-app = Celery('financial_planning_app', broker=settings.BROKER_URL)
+app = Celery('droppdf_app', broker=settings.BROKER_URL)
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
From 805ca0562b667ab11cd10dbb0cb0577ec82b7b0c Mon Sep 17 00:00:00 2001
From: paul
Date: Sat, 21 Aug 2021 12:43:08 -0600
Subject: [PATCH 2/2] change ocr upload page to only show "redo" option if
document has text. other minor changes
---
.../apps/_static/apps/js/ocr_pdf_upload.js | 14 +++++++-
droppdf/apps/_templates/ocr_pdf.html | 35 ++++++++++++++-----
droppdf/apps/_templates/ocr_pdf_result.html | 2 +-
droppdf/apps/apps/ocr/views.py | 7 ++--
4 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/droppdf/apps/_static/apps/js/ocr_pdf_upload.js b/droppdf/apps/_static/apps/js/ocr_pdf_upload.js
index d8d55e1..e02427c 100644
--- a/droppdf/apps/_static/apps/js/ocr_pdf_upload.js
+++ b/droppdf/apps/_static/apps/js/ocr_pdf_upload.js
@@ -79,10 +79,17 @@
$('#run-button')
.addClass('disabled')
.attr('disabled', true)
+
+ } else if (response.file_info.has_text) {
+
+ $('#run-button').hide();
+ $('#upload-has-text').show();
+
} else {
$('#run-button')
.removeClass('disabled')
.attr('disabled', false)
+ .show()
}
};
},
@@ -164,8 +171,13 @@
$(document).ready(function() {
upload_in_progress = false;
$('.button-box').hide();
+ $('#upload-has-text').hide();
$('#in-progress').hide();
- $('#pdf-file').attr('disabled', false);
+
+ $('#pdf-file')
+ .attr('disabled', false)
+ .val('')
+
$('#progress-bar-inner').css('width', '0%');
$('#pdf-file')
.attr('disabled', false)
diff --git a/droppdf/apps/_templates/ocr_pdf.html b/droppdf/apps/_templates/ocr_pdf.html
index 1be39e2..7060bd7 100644
--- a/droppdf/apps/_templates/ocr_pdf.html
+++ b/droppdf/apps/_templates/ocr_pdf.html
@@ -80,6 +80,15 @@
color: red;
}
+ .success-msg {
+ padding-top: 1em;
+ color: green;
+ }
+
+ .black-text {
+ color: #000;
+ }
+
.button-box {
display: flex;
flex: 1;
@@ -245,7 +254,7 @@
Add text to an image PDF.
-
diff --git a/droppdf/apps/_templates/ocr_pdf_result.html b/droppdf/apps/_templates/ocr_pdf_result.html
index f20f5e4..a076ca7 100644
--- a/droppdf/apps/_templates/ocr_pdf_result.html
+++ b/droppdf/apps/_templates/ocr_pdf_result.html
@@ -162,7 +162,7 @@
OCR in progress. Started at
- Large files can sometimes take several minutes, or up to five or ten if the Force OCR option is used.
+ Large files can sometimes take several minutes, or up to five or ten if the OCR is a redo with existing text.
A clickable download link will appear when processing is complete.
diff --git a/droppdf/apps/apps/ocr/views.py b/droppdf/apps/apps/ocr/views.py
index 38ba7d3..66ad1eb 100644
--- a/droppdf/apps/apps/ocr/views.py
+++ b/droppdf/apps/apps/ocr/views.py
@@ -70,7 +70,10 @@ def upload(request):
#already_has_text?
if check_pdf_has_text(new_filename):
- processing_error = 'This PDF already has text. Use the "Force OCR" button to overwrite text with a fresh OCR if desired. If file was OCRd on previous upload those results will be provided'
+ #processing_error = 'This PDF already has text. Use the "Force OCR" button to overwrite text with a fresh OCR if desired. If file was OCRd on previous upload those results will be provided'
+ has_text = True
+ else:
+ has_text = False
if not existing_name:
@@ -114,7 +117,7 @@ def upload(request):
data = {'file_info': {'filename': filename, 'size': file_.size,
'new_filename': new_filename, 'processing_error': processing_error,
'tempfile_path': tempfile_path, 'already_exists': already_exists,
- 'md5_hash': md5_hash}}
+ 'md5_hash': md5_hash, 'has_text': has_text}}
return JsonResponse(data)