Raise ImproperlyConfigured if HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS is out of (0, 23.9999) boundary values

This commit is contained in:
Sam Splunks 2024-02-15 15:24:55 +00:00
parent 02e333cf52
commit ae7c8c7aea

View File

@ -9,7 +9,7 @@ lib.py - Common functions (eg multipart e-mail)
from datetime import date, datetime, time from datetime import date, datetime, time
from django.conf import settings 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 django.utils.encoding import smart_str
from helpdesk.settings import CUSTOMFIELD_DATE_FORMAT, CUSTOMFIELD_DATETIME_FORMAT, CUSTOMFIELD_TIME_FORMAT from helpdesk.settings import CUSTOMFIELD_DATE_FORMAT, CUSTOMFIELD_DATETIME_FORMAT, CUSTOMFIELD_TIME_FORMAT
import logging import logging
@ -206,7 +206,8 @@ def daily_time_spent_calculation(earliest, latest, open_hours):
MIDNIGHT = 23.9999 MIDNIGHT = 23.9999
start, end = open_hours.get(weekday, (0, MIDNIGHT)) start, end = open_hours.get(weekday, (0, MIDNIGHT))
if not 0 <= start <= end <= 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 # transform decimals to minutes and seconds
start_hour, start_minute, start_second = int(start), int(start % 1 * 60), int(start * 60 % 1 * 60) start_hour, start_minute, start_second = int(start), int(start % 1 * 60), int(start * 60 % 1 * 60)