From 77d49754c638d786944503df4037c1b9de02cd12 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 23 Aug 2024 11:03:32 -0700 Subject: [PATCH] initial --- app/main/views/dashboard.py | 19 ++++++++++++++++++- app/templates/views/dashboard/dashboard.html | 3 +++ poetry.lock | 1 - 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 0913dcfdd..5310c4b22 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -3,7 +3,7 @@ from datetime import datetime from functools import partial from itertools import groupby -from flask import Response, abort, jsonify, render_template, request, session, url_for +from flask import Response, abort, app, jsonify, render_template, request, session, url_for from flask_login import current_user from werkzeug.utils import redirect @@ -21,6 +21,7 @@ from app.utils import ( DELIVERED_STATUSES, FAILURE_STATUSES, REQUESTED_STATUSES, + hilite, service_has_permission, ) from app.utils.csv import Spreadsheet @@ -281,6 +282,17 @@ def inbox_download(service_id): }, ) +@main.route('/get-timezone', methods=['POST', 'GET']) +def get_timezone(): + print(hilite("ENTER GET-TIMEZONE")) + timezone = request.cookies.get('timezone', 'UTC') + print(hilite(f"TIMEZONE {timezone}")) + #data = request.get_json() + #print(f"HEY DATA WAS {data}") + #timezone = data.get('timezone') + #print(hilite(f"TIMEZONE = {timezone}")) + #session['timezone'] = timezone + return jsonify({'message': f'Timezone get successfully {timezone}'}), 200 def get_inbox_partials(service_id): page = int(request.args.get("page", 1)) @@ -402,6 +414,11 @@ def get_dashboard_partials(service_id): def get_dashboard_totals(statistics): + + timezone = request.cookies.get('timezone', 'UTC') + if current_user.preferred_timezone is not timezone: + current_user.update(preferred_timezone=timezone) + for msg_type in statistics.values(): msg_type["failed_percentage"] = get_formatted_percentage( msg_type["failed"], msg_type["requested"] diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 2254c3c78..6bfce7bd0 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -1,3 +1,6 @@ + +

{{ session['timezone'] }}

+ {% extends "withnav_template.html" %} {% from "components/table.html" import list_table, field, text_field, link_field, right_aligned_field_heading, hidden_field_heading, row_heading, notification_status_field, notification_carrier_field, notification_carrier_message_field %} diff --git a/poetry.lock b/poetry.lock index ae6ab5bb7..716e54132 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2430,7 +2430,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},