Repository: fossasia/open-event-server

Issue:
Enhance Ticket info email for organizers
Organizers get an automatic email when a ticket was bought or a registration was made.  Please:

*  enhance this email and the email subject as in the below example.
* only show fields if they have been filled in, e.g. if there is no organisation info then do not show the empty field in the email.
* ensure all fields are translatable.

![Screenshot from 2021-09-03 16-26-37](https://user-images.githubusercontent.com/1583873/132024764-a34d52cf-1e8e-41bd-9b2a-4234a378c56b.png)


---

Subject: New order for [event name] on [event date] by [buyer name], [buyer email] ([Order number])

---

Congratulations!

You have a new order for your event [event name with public page link] starting at [time of event] on [date of event].

The order has been processed successfully on [app name with link to app website]. Click [here to view/download] the invoice.

The details of the order are:

Order Number: [order number with link to order page]
Name: [Name of buyer]
Email: [Email of buyer]

Purchase Time and Date: [Time and Date of purchase]
Payment Mode: [Payment mode, e.g. Paypal]
Payment Status: [Payment status here, e.g. completed, placed etc.]
Tickets/Registration: [Ticket/Registration info here, e.g. 1 x Community Ticket, 2 x Corporate Tickets)
Total Payment: [Grand total here, e.g. EUR 150.00]

Organisation: [Name of org or company of buyer]
Address: [Address of buyer here]
Tax ID: [Tax ID of buyer here]

--

Login to manage your event at [app URL].


Discussion:

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
@@ -19,6 +19,7 @@
 from app.models.ticket_holder import TicketHolder
 from app.models.user import User
 from app.settings import get_settings
+from app.models.order import OrderTicket
 
 logger = logging.getLogger(__name__)
 # pytype: disable=attribute-error
@@ -581,12 +582,31 @@ def send_email_to_attendees(order):
 
 
 def send_order_purchase_organizer_email(order, recipients):
+
+    order_tickets = OrderTicket.query.filter_by(order_id=order.id).all()
+
     context = dict(
         buyer_email=order.user.email,
+        buyer_name=order.user.full_name,
         event_name=order.event.name,
         invoice_id=order.invoice_number,
         frontend_url=get_settings()['frontend_url'],
+        site_link=order.event.site_link,
         order_url=order.site_view_link,
+        event_date=order.event.starts_at.strftime('%d %B %Y'),
+        event_time=order.event.starts_at.strftime("%H:%M %Z"),
+        purchase_time=order.completed_at,
+        timezone=order.event.timezone,
+        payment_mode=order.payment_mode,
+        payment_status=order.status,
+        order_amount=order.amount,
+        payment_currency=order.event.payment_currency,
+        tickets_count=order.tickets_count,
+        order_tickets=order_tickets,
+        buyer_org=order.company,
+        buyer_address=order.address,
+        buyer_tax_id=order.tax_business_info,
+        app_name=get_settings()['app_name'],
     )
     emails = list({organizer.email for organizer in recipients})
     if emails:
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
@@ -200,7 +200,7 @@ def entries():
     },
     MailType.TICKET_PURCHASED_ORGANIZER: {
         'recipient': 'Owner, Organizer, Coorganizer',
-        'subject': 'New ticket purchase for {event_name} by {buyer_email} ({invoice_id}) ',
+        'subject': 'New order for {event_name} on {event_date} by {buyer_name}, {buyer_email} ({invoice_id}) ',
         'template': 'email/ticket_purchased_organizer.html',
     },
     MailType.TICKET_CANCELLED: {


Test patch: