markup: special email for no matched products

This commit is contained in:
2019-10-30 15:51:14 -07:00
parent ee6794cf2b
commit 0a2412f645
2 changed files with 22 additions and 1 deletions

View File

@ -31,6 +31,16 @@ Thanks,
ProCatalog Markup Bot 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): def reply(frm, subj, xls_path, pdf_path):
msg = EmailMessage() msg = EmailMessage()
@ -57,6 +67,12 @@ def reply_missing(frm, subj):
send(frm, subj, msg) 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): def send(frm, subj, msg):
msg['From'] = 'Keen ProCatalog Markup Bot <support@procatalog.io>' msg['From'] = 'Keen ProCatalog Markup Bot <support@procatalog.io>'
msg['To'] = frm msg['To'] = frm

View File

@ -19,7 +19,7 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'procat2.settings')
django.setup() django.setup()
from .utils import clean_path, ensure_dir, set_file_perms, WORKDIR 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 .matching import find_marked_products
from .spreadsheet import write_spreadsheet from .spreadsheet import write_spreadsheet
@ -62,6 +62,11 @@ def process_attachment(from_address, subject, attachment):
# find matches # find matches
matches = find_marked_products(pdf_path, workdir, debug=0) 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') print(f'{len(matches)} product matches')
# write spreadsheet # write spreadsheet