Skip to content

Commit

Permalink
fix: Use event timezone in ticket PDF (#7437)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Nov 12, 2020
1 parent 7fcc8a6 commit ef592f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions app/templates/flask_ext/jinja/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def money_filter(string):
return '{:20,.2f}'.format(float(string))

@app.template_filter('datetime')
def simple_datetime_display(date):
return date.strftime('%B %d, %Y %I:%M %p')
def simple_datetime_display(date, timezone='UTC', format='%B %d, %Y %I:%M %p'):
if not date:
return ''
return date.astimezone(pytz.timezone(timezone)).strftime(format)

@app.template_filter('date')
def simple_date_display(date):
Expand Down
3 changes: 2 additions & 1 deletion app/templates/pdf/ticket_attendee.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
<span style="font-size: 15px;"> {{order.event.location_name }}</span><br><br>

<span class="label">Date and Time</span><br>
<span style="font-size: 15px;">{{ order.event.starts_at.strftime('%H:%M %Z') }} to {{ order.event.ends_at.strftime('%H:%M %Z') }}</span>
<span style="font-size: 15px;">From: {{ order.event.starts_at | datetime(order.event.timezone) }}</span><br>
<span style="font-size: 15px;">To: {{ order.event.ends_at | datetime(order.event.timezone) }}</span>
<br><br>

<span class="label">Type</span><br>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/pdf/ticket_purchaser.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<span style="font-size: 15px;">{{ order.event.location_name }}</span><br><br>

<span class="label">Date and Time</span><br>
<span style="font-size: 15px;">From: {{ order.event.starts_at.strftime("%H:%M %Z") }} on {{ order.event.starts_at.date() }}</span><br>
<span style="font-size: 15px;">To: {{ order.event.ends_at.strftime("%H:%M %Z") }} on {{ order.event.ends_at.date() }}</span>
<span style="font-size: 15px;">From: {{ order.event.starts_at | datetime(order.event.timezone) }}</span><br>
<span style="font-size: 15px;">To: {{ order.event.ends_at | datetime(order.event.timezone) }}</span>
<br><br>

<span class="label">Type</span><br>
Expand Down

0 comments on commit ef592f0

Please sign in to comment.