From ae7c8c7aeaf6634450ebcbc29fd9f5718b6de368 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:24:55 +0000 Subject: [PATCH] Raise ImproperlyConfigured if HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS is out of (0, 23.9999) boundary values --- helpdesk/lib.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 67cc325b..481d4cbb 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -9,7 +9,7 @@ lib.py - Common functions (eg multipart e-mail) from datetime import date, datetime, time from django.conf import settings -from django.core.exceptions import ValidationError +from django.core.exceptions import ValidationError, ImproperlyConfigured from django.utils.encoding import smart_str from helpdesk.settings import CUSTOMFIELD_DATE_FORMAT, CUSTOMFIELD_DATETIME_FORMAT, CUSTOMFIELD_TIME_FORMAT import logging @@ -206,7 +206,8 @@ def daily_time_spent_calculation(earliest, latest, open_hours): MIDNIGHT = 23.9999 start, end = open_hours.get(weekday, (0, MIDNIGHT)) if not 0 <= start <= end <= MIDNIGHT: - start, end = 0, MIDNIGHT + raise ImproperlyConfigured("HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS" + f" setting for {weekday} out of (0, 23.9999) boundary") # transform decimals to minutes and seconds start_hour, start_minute, start_second = int(start), int(start % 1 * 60), int(start * 60 % 1 * 60)