diff --git a/markup/email.py b/markup/email.py index 9c04b95..60a70f7 100644 --- a/markup/email.py +++ b/markup/email.py @@ -31,6 +31,16 @@ Thanks, ProCatalog Markup Bot """ +body_no_matches = """Hi, + +I couldn't find any products marked in your pdf. Make sure you're +using a ProCatalog pdf and that you've circled or otherwise scribbled +over some material images or SKUs before submitting. + +Thanks, +ProCatalog Markup Bot +""" + def reply(frm, subj, xls_path, pdf_path): msg = EmailMessage() @@ -57,6 +67,12 @@ def reply_missing(frm, subj): send(frm, subj, msg) +def reply_no_matches(frm, subj): + msg = EmailMessage() + msg.set_content(body_no_matches) + send(frm, subj, msg) + + def send(frm, subj, msg): msg['From'] = 'Keen ProCatalog Markup Bot ' msg['To'] = frm diff --git a/markup/tasks.py b/markup/tasks.py index a011257..bc0b6af 100644 --- a/markup/tasks.py +++ b/markup/tasks.py @@ -19,7 +19,7 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'procat2.settings') django.setup() from .utils import clean_path, ensure_dir, set_file_perms, WORKDIR -from .email import reply, reply_missing +from .email import reply, reply_missing, reply_no_matches from .matching import find_marked_products from .spreadsheet import write_spreadsheet @@ -62,6 +62,11 @@ def process_attachment(from_address, subject, attachment): # find matches matches = find_marked_products(pdf_path, workdir, debug=0) + if not matches: + print('no product matches') + reply_no_matches(from_address, subject) + return + print(f'{len(matches)} product matches') # write spreadsheet