markup: special email for no matched products
This commit is contained in:
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user