Repository: fossasia/open-event-server

Issue:
Canceled orders with invoice links to 404 page
If an organizer cancels a ticket the user receives an email with "Click here to view/download the invoice." and a wrong link. The entire message is:

> Hi,Your order for TechSummit 2020 has been cancelled has been cancelled by the organizer
Please contact the organizer for more info
Message from the organizer: None
Click here to view/download the invoice.
Login to manage the orders at https://eventyay.com

![Screenshot from 2019-12-06 18-44-40](https://user-images.githubusercontent.com/1583873/70344054-144d7d00-1859-11ea-9424-8a866c999a68.png)


Please change the email as follows. Include punctuation and line breaks as follows.


Hello,

your order for [name of event] has been cancelled by the organizer. 

Please contact the organizer for more info. 

To manage orders please login to https://eventyay.com and visit "My Tickets".

Best regards,

Eventyay Team


Discussion:
@iamareebjamal Please shift this to open-event-server
Taking this up!

Resolving patch:
diff --git a/app/api/helpers/mail.py b/app/api/helpers/mail.py
--- a/app/api/helpers/mail.py
+++ b/app/api/helpers/mail.py
@@ -363,18 +363,21 @@ def send_email_to_attendees(order, purchaser_id, attachments=None):
 
 
 def send_order_cancel_email(order):
+    cancel_msg = ''
+    if order.cancel_note:
+        cancel_msg = u"<br/>Message from the organizer: {cancel_note}".format(cancel_note=order.cancel_note)
+
     send_email(
         to=order.user.email,
         action=TICKET_CANCELLED,
         subject=MAILS[TICKET_CANCELLED]['subject'].format(
             event_name=order.event.name,
             invoice_id=order.invoice_number,
-            frontend_url=get_settings()['frontend_url']
         ),
         html=MAILS[TICKET_CANCELLED]['message'].format(
             event_name=order.event.name,
-            order_url=make_frontend_url('/orders/{identifier}'.format(identifier=order.identifier)),
-            cancel_note=order.cancel_note,
-            frontend_url=get_settings()['frontend_url']
+            frontend_url=get_settings()['frontend_url'],
+            cancel_msg=cancel_msg,
+            app_name=get_settings()['app_name']
         )
     )
diff --git a/app/api/helpers/system_mails.py b/app/api/helpers/system_mails.py
--- a/app/api/helpers/system_mails.py
+++ b/app/api/helpers/system_mails.py
@@ -186,11 +186,13 @@
         'recipient': 'User',
         'subject': u'Your order for {event_name} has been cancelled ({invoice_id})',
         'message': (
-            u"Hi,Your order for {event_name} has been cancelled has been cancelled by the organizer"
-            u"<br/>Please contact the organizer for more info" +
-            u"<br/>Message from the organizer: {cancel_note}"
-            u"<br/> <a href='{order_url}'>Click here</a> to view/download the invoice."
-            u"<br/>Login to manage the orders at {frontend_url} </em>"
+            u"Hello,"
+            u"<br/>your order for {event_name} has been cancelled by the organizer."
+            u"<br/>Please contact the organizer for more info." +
+            u"{cancel_msg}"
+            u"<br/>To manage orders please login to {frontend_url} and visit \"My Tickets\"."
+            u"<br/>Best regards,"
+            u"<br/>{app_name} Team"
         )
     },
     EVENT_EXPORTED: {


Test patch: