Repository: fossasia/open-event-server

Issue:
Attendee Ticket Emails: Add Date and Time to Subject
Please change the subjects of attendee tickets emails from "See you at [Conference Name] ([Order Number])" to "See you at [Conference Name] on [Event Date] at [Event Time] [Timezone] ([Order Number])"

![Screenshot from 2021-10-04 19-45-22](https://user-images.githubusercontent.com/1583873/135899241-dd597fde-17f9-4be7-a1d3-562e6f12a0cd.png)



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
@@ -546,6 +546,13 @@ def send_email_to_attendees(order):
         order_view_url=order.site_view_link,
     )
 
+    event_date = convert_to_event_timezone(
+        order.event.starts_at, order.event.timezone, format='%d %B %Y'
+    )
+    event_time = convert_to_event_timezone(
+        order.event.starts_at, order.event.timezone, format='%H:%M (%Z%z)'
+    )
+
     buyer_email = order.user.email
     action = MailType.TICKET_PURCHASED
     mail = MAILS[action]
@@ -555,6 +562,8 @@ def send_email_to_attendees(order):
         subject=mail['subject'].format(
             event_name=event.name,
             invoice_id=order.invoice_number,
+            event_date=event_date,
+            event_time=event_time,
         ),
         html=render_template(mail['template'], attendees=attendees, **context),
         attachments=attachments,
@@ -596,10 +605,12 @@ def send_order_purchase_organizer_email(order, recipients):
         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.replace(tzinfo=pytz.timezone('UTC'))
-        .astimezone(pytz.timezone(order.event.timezone))
-        .strftime('%H:%M (%Z%z)'),
+        event_date=convert_to_event_timezone(
+            order.event.starts_at, order.event.timezone, format='%d %B %Y'
+        ),
+        event_time=convert_to_event_timezone(
+            order.event.starts_at, order.event.timezone, format='%H:%M (%Z%z)'
+        ),
         timezone=order.event.timezone,
         purchase_time=order.completed_at,
         payment_mode=order.payment_mode,
@@ -610,6 +621,10 @@ def send_order_purchase_organizer_email(order, recipients):
         order_tickets=order_tickets,
         buyer_org=order.company,
         buyer_address=order.address,
+        buyer_zipcode=order.zipcode,
+        buyer_city=order.city,
+        buyer_state=order.state,
+        buyer_country=order.country,
         buyer_tax_id=order.tax_business_info,
         app_name=get_settings()['app_name'],
     )
@@ -762,3 +777,13 @@ def send_email_after_event_speaker(email, event_name):
             email=email,
         ),
     )
+
+
+def convert_to_event_timezone(date, timezone=None, format='%B %d, %Y %H:%M (%Z%z)'):
+    if not date:
+        return None
+    if timezone:
+        date = date.replace(tzinfo=pytz.timezone('UTC')).astimezone(
+            pytz.timezone(timezone)
+        )
+    return date.strftime(format)
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
@@ -192,7 +192,7 @@ def entries():
     },
     MailType.TICKET_PURCHASED: {
         'recipient': 'User',
-        'subject': 'See you at {event_name} ({invoice_id}) ',
+        'subject': 'See you at {event_name} on {event_date} at {event_time} ({invoice_id}) ',
         'template': 'email/ticket_purchased.html',
     },
     MailType.TICKET_PURCHASED_ATTENDEE: {


Test patch: