From 0c612581cdf8b2be388e3110c9b4866fe70a6f54 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 26 Aug 2024 07:50:24 -0700 Subject: [PATCH] finish up --- app/main/views/dashboard.py | 28 +++++++++++++------- app/templates/views/dashboard/dashboard.html | 5 +++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 519f46c62..8e603f86d 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -49,6 +49,7 @@ def old_service_dashboard(service_id): @main.route("/services/") @user_has_permissions() def service_dashboard(service_id): + if session.get("invited_user_id"): session.pop("invited_user_id", None) session["service_id"] = service_id @@ -412,21 +413,13 @@ def get_dashboard_partials(service_id): def get_dashboard_totals(statistics): - # This 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 RuntimeError as e: - current_app.logger.warning(f"Can't get timezone, running tests? {e}") for msg_type in statistics.values(): msg_type["failed_percentage"] = get_formatted_percentage( msg_type["failed"], msg_type["requested"] ) msg_type["show_warning"] = float(msg_type["failed_percentage"]) > 3 + return statistics @@ -485,6 +478,8 @@ def get_months_for_financial_year(year, time_format="%B"): def get_current_month_for_financial_year(year): + # Setting the timezone here because we need to set it somewhere. + set_timezone() current_month = datetime.now().month return current_month @@ -557,3 +552,18 @@ def get_tuples_of_financial_years( ) for year in reversed(range(start, end + 1)) ) + + +def set_timezone(): + # This is set in dashboard.html on page load + print(hilite("INVOKING set_timezone()!!!!")) + 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 RuntimeError as e: + current_app.logger.exception(hilite(f"Can't get timezone, running tests?")) + except Exception as e: + current_app.logger.exception(hilite(f"Can't get timezone, running tests?")) diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 87299de13..7126e7ca8 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -7,6 +7,10 @@ {% block service_page_title %} Dashboard + + + + {% endblock %} {% block maincolumn_content %} @@ -141,4 +145,3 @@ {% endblock %} -