Skip to content

Commit

Permalink
feat: Changed pdf datetime to event timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
Suneet Srivastava committed Nov 18, 2020
1 parent aaacb23 commit ac50b5f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
7 changes: 6 additions & 1 deletion app/models/event_invoice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from datetime import datetime, timedelta

import pytz
from flask.templating import render_template
from sqlalchemy.sql import func

Expand Down Expand Up @@ -166,7 +167,11 @@ def generate_pdf(self, force=False):
return self.invoice_pdf_url

def send_notification(self, follow_up=False):
prev_month = self.previous_month_date.strftime("%b %Y") # Displayed as Aug 2016
prev_month = self.previous_month_date.astimezone(
pytz.timezone(self.event.timezone)
).strftime(
"%b %Y"
) # Displayed as Aug 2016
app_name = get_settings()['app_name']
frontend_url = get_settings()['frontend_url']
link = f'{frontend_url}/event-invoice/{self.identifier}/review'
Expand Down
6 changes: 2 additions & 4 deletions app/templates/flask_ext/jinja/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ def simple_datetime_display(date, timezone='UTC', format='%B %d, %Y %I:%M %p'):
return date.astimezone(pytz.timezone(timezone)).strftime(format)

@app.template_filter('date')
def simple_date_display(date):
if not date:
return ''
return date.strftime('%B %d, %Y')
def simple_date_display(date, timezone='UTC'):
return simple_datetime_display(date, timezone, '%B %d, %Y')

@app.template_filter('humanize')
def humanize_filter(time):
Expand Down
4 changes: 2 additions & 2 deletions app/templates/pdf/attendees_pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ <h3 style="text-align:center;">{{ holders[0].event.name }} - {{ ("Attendees List

{% if holder.order and holder.order.status == 'completed' %}
<span
class="datetime">{{ holder.order.completed_at | datetime }} - {{ holder.order.completed_at | humanize }}</span>
class="datetime">{{ holder.order.completed_at | datetime(holder.order.event.timezone) }} - {{ holder.order.completed_at | humanize }}</span>
{% elif holder.order %}
<span
class="datetime">{{ holder.order.created_at | datetime }} - {{ holder.order.created_at | humanize }}</span>
class="datetime">{{ holder.order.created_at | datetime(holder.order.event.timezone) }} - {{ holder.order.created_at | humanize }}</span>
{% else %}
{{ "-" }}
{% endif %}<br>
Expand Down
18 changes: 9 additions & 9 deletions app/templates/pdf/event_invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

body {
position: relative;
margin: 0 auto;
margin: 0 auto;
color: #001028;
background: #FFFFFF;
font-family: Arial, sans-serif;
font-size: 12px;
background: #FFFFFF;
font-family: Arial, sans-serif;
font-size: 12px;
font-family: Arial;
}

Expand Down Expand Up @@ -74,7 +74,7 @@

#project div,
#company div {
white-space: nowrap;
white-space: nowrap;
}

table {
Expand All @@ -98,7 +98,7 @@
padding: 5px 20px;
color: #5D6975;
border-bottom: 1px solid #C1CED9;
white-space: nowrap;
white-space: nowrap;
font-weight: normal;
}

Expand Down Expand Up @@ -167,8 +167,8 @@ <h1>INVOICE {{ invoice.identifier }}</h1>
{% if user.billing_tax_info %}
<div><span>TAX ID</span> {{user.billing_tax_info or ''}}</div>
{% endif %}
<div><span>DATE</span> {{ invoice.issued_at | date }}</div>
<div><span>DUE DATE</span> {{ invoice.due_at | date }}</div>
<div><span>DATE</span> {{ invoice.issued_at | date(event.timezone) }}</div>
<div><span>DUE DATE</span> {{ invoice.due_at | date(event.timezone) }}</div>
</div>
</header>
<main>
Expand Down Expand Up @@ -210,4 +210,4 @@ <h1>INVOICE {{ invoice.identifier }}</h1>
</div>
</main>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions app/templates/pdf/orders.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ <h3 style="text-align:center;">{{ event.name }} - {{ ("Order List") }}</h3>
{{ ('NA') }}
{% endif %}<br>
{% if order.status == 'completed' %}
<span class="datetime">{{ order.completed_at | datetime }}</span>
<span class="datetime">{{ order.completed_at | datetime(event.timezone) }}</span>
{% else %}
<span class="datetime">{{ order.created_at | datetime }}</span>
<span class="datetime">{{ order.created_at | datetime(event.timezone) }}</span>
{% endif %}<br>
</td>
<td style="text-align:center;"><br>
Expand Down

0 comments on commit ac50b5f

Please sign in to comment.