Skip to content

Commit

Permalink
add a call on the send page as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Kehl committed Aug 26, 2024
1 parent f78fe35 commit 7b6b363
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
13 changes: 1 addition & 12 deletions app/main/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)
from app.formatters import format_date_numeric, format_datetime_numeric, get_time_left
from app.main import main
from app.main.views.user_profile import set_timezone
from app.statistics_utils import get_formatted_percentage
from app.utils import (
DELIVERED_STATUSES,
Expand Down Expand Up @@ -552,15 +553,3 @@ def get_tuples_of_financial_years(
)
for year in reversed(range(start, end + 1))
)


def set_timezone():
# Cookie is set in dashboard.html on page load
try:
timezone = request.cookies.get("timezone", "US/Eastern")
current_app.logger.debug(hilite(f"User's timezone is {timezone}"))
serialized_user = current_user.serialize()
if serialized_user["preferred_timezone"] is not timezone:
current_user.update(preferred_timezone=timezone)
except Exception:
current_app.logger.exception(hilite("Can't get timezone"))
2 changes: 2 additions & 0 deletions app/main/views/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
SetSenderForm,
get_placeholder_form_instance,
)
from app.main.views.user_profile import set_timezone
from app.models.user import Users
from app.s3_client.s3_csv_client import (
get_csv_metadata,
Expand Down Expand Up @@ -1075,6 +1076,7 @@ def get_spreadsheet_column_headings_from_template(template):


def get_recipient():
set_timezone()
if {"recipient", "placeholders"} - set(session.keys()):
return None

Expand Down
12 changes: 12 additions & 0 deletions app/main/views/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,15 @@ def user_profile_disable_platform_admin_view():
return render_template(
"views/user-profile/disable-platform-admin-view.html", form=form
)


def set_timezone():
# Cookie is set in dashboard.html on page load
try:
timezone = request.cookies.get("timezone", "US/Eastern")
current_app.logger.debug(f"User's timezone is {timezone}")
serialized_user = current_user.serialize()
if serialized_user["preferred_timezone"] is not timezone:
current_user.update(preferred_timezone=timezone)
except Exception:
current_app.logger.exception(hilite("Can't get timezone"))
1 change: 1 addition & 0 deletions app/templates/views/send.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% from "components/file-upload.html" import file_upload %}
{% from "components/table.html" import list_table, text_field, index_field, index_field_heading %}
{% from "components/components/back-link/macro.njk" import usaBackLink %}
<script type="text/javascript" src="{{ asset_url('js/setTimezone.js') }}"></script>

{% block service_page_title %}
Upload a list of {{ 999|recipient_count_label(template.template_type) }}
Expand Down

0 comments on commit 7b6b363

Please sign in to comment.