mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Merge pull request #929 from GSA/notify-admin-861
Change timezone displays to Eastern time
This commit is contained in:
@@ -64,15 +64,18 @@ from app.main.validators import (
|
||||
from app.models.feedback import PROBLEM_TICKET_TYPE, QUESTION_TICKET_TYPE
|
||||
from app.models.organization import Organization
|
||||
from app.utils import branding, merge_jsonlike
|
||||
from app.utils.csv import get_user_preferred_timezone
|
||||
from app.utils.user_permissions import all_ui_permissions, permission_options
|
||||
|
||||
|
||||
def get_time_value_and_label(future_time):
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
return (
|
||||
future_time.astimezone(pytz.utc).replace(tzinfo=None).isoformat(),
|
||||
"{} at {} UTC".format(
|
||||
get_human_day(future_time.astimezone(pytz.utc)),
|
||||
get_human_time(future_time.astimezone(pytz.utc)),
|
||||
future_time.astimezone(preferred_tz).replace(tzinfo=None).isoformat(),
|
||||
"{} at {} {}".format(
|
||||
get_human_day(future_time.astimezone(preferred_tz)),
|
||||
get_human_time(future_time.astimezone(preferred_tz)),
|
||||
get_user_preferred_timezone(),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -85,21 +88,25 @@ def get_human_time(time):
|
||||
|
||||
def get_human_day(time, prefix_today_with="T"):
|
||||
# Add 1 hour to get ‘midnight today’ instead of ‘midnight tomorrow’
|
||||
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
time = (time - timedelta(hours=1)).strftime("%A")
|
||||
if time == datetime.now(pytz.utc).strftime("%A"):
|
||||
if time == datetime.now(preferred_tz).strftime("%A"):
|
||||
return "{}oday".format(prefix_today_with)
|
||||
if time == (datetime.now(pytz.utc) + timedelta(days=1)).strftime("%A"):
|
||||
if time == (datetime.now(preferred_tz) + timedelta(days=1)).strftime("%A"):
|
||||
return "Tomorrow"
|
||||
return time
|
||||
|
||||
|
||||
def get_furthest_possible_scheduled_time():
|
||||
# We want local time to find date boundaries
|
||||
return (datetime.now(pytz.utc) + timedelta(days=4)).replace(hour=0)
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
return (datetime.now(preferred_tz) + timedelta(days=4)).replace(hour=0)
|
||||
|
||||
|
||||
def get_next_hours_until(until):
|
||||
now = datetime.now(pytz.utc)
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
now = datetime.now(preferred_tz)
|
||||
hours = int((until - now).total_seconds() / (60 * 60))
|
||||
return [
|
||||
(now + timedelta(hours=i)).replace(minute=0, second=0, microsecond=0)
|
||||
@@ -108,7 +115,8 @@ def get_next_hours_until(until):
|
||||
|
||||
|
||||
def get_next_days_until(until):
|
||||
now = datetime.now(pytz.utc)
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
now = datetime.now(preferred_tz)
|
||||
days = int((until - now).total_seconds() / (60 * 60 * 24))
|
||||
return [
|
||||
get_human_day((now + timedelta(days=i)), prefix_today_with="Later t")
|
||||
|
||||
@@ -8,13 +8,15 @@ from flask import render_template
|
||||
|
||||
from app import performance_dashboard_api_client, status_api_client
|
||||
from app.main import main
|
||||
from app.utils.csv import get_user_preferred_timezone
|
||||
|
||||
|
||||
@main.route("/performance")
|
||||
def performance():
|
||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||
stats = performance_dashboard_api_client.get_performance_dashboard_stats(
|
||||
start_date=(datetime.now(pytz.utc) - timedelta(days=7)).date(),
|
||||
end_date=datetime.now(pytz.utc).date(),
|
||||
start_date=(datetime.now(preferred_tz) - timedelta(days=7)).date(),
|
||||
end_date=datetime.now(preferred_tz).date(),
|
||||
)
|
||||
stats["organizations_using_notify"] = sorted(
|
||||
[
|
||||
@@ -35,4 +37,5 @@ def performance():
|
||||
stats[
|
||||
"count_of_live_services_and_organizations"
|
||||
] = status_api_client.get_count_of_live_services_and_organizations()
|
||||
|
||||
return render_template("views/performance.html", **stats)
|
||||
|
||||
Reference in New Issue
Block a user