Skip to content

Commit

Permalink
feat: Add option to disable order attachment PDF (#7139)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Jul 16, 2020
1 parent 3e42e7a commit 2ec5359
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 9 additions & 3 deletions app/api/helpers/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ def send_email_change_user_email(user, email):


def send_email_to_attendees(order, purchaser_id, attachments=None):
if not current_app.config['ATTACH_ORDER_PDF']:
attachments = None

frontend_url = get_settings()['frontend_url']
order_view_url = frontend_url + '/orders/' + order.identifier + '/view'
for holder in order.ticket_holders:
if holder.user and holder.user.id == purchaser_id:
# Ticket holder is the purchaser
Expand All @@ -333,11 +338,12 @@ def send_email_to_attendees(order, purchaser_id, attachments=None):
subject=MAILS[TICKET_PURCHASED]['subject'].format(
event_name=order.event.name,
invoice_id=order.invoice_number,
frontend_url=get_settings()['frontend_url'],
frontend_url=frontend_url,
),
html=MAILS[TICKET_PURCHASED]['message'].format(
event_name=order.event.name,
frontend_url=get_settings()['frontend_url'],
frontend_url=frontend_url,
order_view_url=order_view_url,
),
attachments=attachments,
)
Expand All @@ -350,7 +356,7 @@ def send_email_to_attendees(order, purchaser_id, attachments=None):
event_name=order.event.name, invoice_id=order.invoice_number
),
html=MAILS[TICKET_PURCHASED_ATTENDEE]['message'].format(
my_tickets_url=get_settings()['frontend_url'] + '/my-tickets',
my_tickets_url=frontend_url + '/my-tickets',
event_name=order.event.name,
),
attachments=attachments,
Expand Down
6 changes: 3 additions & 3 deletions app/api/helpers/system_mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
'message': (
u"Hi, this is a confirmation mail of your tickets for the event {event_name}"
u"<br/>Your order has been processed successfully."
+ u"<br/> You can find your Tickets and Order Invoice attached to this mail."
u"<br/> You can find your Tickets and Order Invoice at the link below."
u"<br/>{order_view_url}"
u"<br><br><em>Looking forward to seeing you at the event."
u"<br/>Login to manage your orders at {frontend_url} </em>"
),
Expand All @@ -188,8 +189,7 @@
'message': (
u"Hi, this is a confirmation mail of your tickets for the event {event_name}"
u"<br/>Your order has been processed successfully."
+ u"<br/> Your tickets & invoice have been enclosed."
u"<br><br>You can also download your tickets in <b>My Tickets</b> section."
u"<br><br>You can download your tickets in <b>My Tickets</b> section."
u"<br/>Login to manage the orders at <a href='{my_tickets_url}' target='_blank'>{my_tickets_url}</a> </em>"
u"<br><br><em>Looking forward to seeing you at the event."
),
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Config:
)
ETAG = True
SENTRY_TRACES_SAMPLE_RATE = env.float('SENTRY_TRACES_SAMPLE_RATE', default=0.01)
ATTACH_ORDER_PDF = env.bool('ATTACH_ORDER_PDF', default=True)

if not SQLALCHEMY_DATABASE_URI:
print('`DATABASE_URL` either not exported or empty')
Expand Down

0 comments on commit 2ec5359

Please sign in to comment.