mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 09:23:39 +01:00
Adding HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS setting
This commit is contained in:
parent
eb9d947dd6
commit
220f6d56a8
@ -317,6 +317,15 @@ Time Tracking Options
|
|||||||
Valid hour values must be set between 0 and 23.9999.
|
Valid hour values must be set between 0 and 23.9999.
|
||||||
In this example 8.5 is interpreted as 8:30AM, saturdays and sundays don't count.
|
In this example 8.5 is interpreted as 8:30AM, saturdays and sundays don't count.
|
||||||
|
|
||||||
|
- **HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS** List of days in format "%m-%d" to exclude from automatic follow-up 'time_spent' calculation.
|
||||||
|
|
||||||
|
**Default:** ``HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS = ()``
|
||||||
|
|
||||||
|
This example removes the first and last days of the year together with Christmas::
|
||||||
|
|
||||||
|
HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS = ("01-01",
|
||||||
|
"12-25",
|
||||||
|
"12-31",)
|
||||||
|
|
||||||
Staff Ticket Creation Settings
|
Staff Ticket Creation Settings
|
||||||
------------------------------
|
------------------------------
|
||||||
|
@ -1025,13 +1025,17 @@ class FollowUp(models.Model):
|
|||||||
|
|
||||||
time_spent_seconds = 0
|
time_spent_seconds = 0
|
||||||
open_hours = helpdesk_settings.FOLLOWUP_TIME_SPENT_OPENING_HOURS
|
open_hours = helpdesk_settings.FOLLOWUP_TIME_SPENT_OPENING_HOURS
|
||||||
|
holidays = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS
|
||||||
|
|
||||||
# split time interval by days
|
# split time interval by days
|
||||||
days = latest.toordinal() - earliest.toordinal()
|
days = latest.toordinal() - earliest.toordinal()
|
||||||
if days:
|
|
||||||
for day in range(days + 1):
|
for day in range(days + 1):
|
||||||
if day == 0:
|
if day == 0:
|
||||||
start_day_time = earliest
|
start_day_time = earliest
|
||||||
|
if days == 0:
|
||||||
|
# close single day case
|
||||||
|
end_day_time = latest
|
||||||
|
else:
|
||||||
end_day_time = earliest.replace(hour=23, minute=59, second=59)
|
end_day_time = earliest.replace(hour=23, minute=59, second=59)
|
||||||
elif day == days:
|
elif day == days:
|
||||||
start_day_time = latest.replace(hour=0, minute=0, second=0)
|
start_day_time = latest.replace(hour=0, minute=0, second=0)
|
||||||
@ -1040,10 +1044,9 @@ class FollowUp(models.Model):
|
|||||||
middle_day_time = earliest + datetime.timedelta(days=day)
|
middle_day_time = earliest + datetime.timedelta(days=day)
|
||||||
start_day_time = middle_day_time.replace(hour=0, minute=0, second=0)
|
start_day_time = middle_day_time.replace(hour=0, minute=0, second=0)
|
||||||
end_day_time = middle_day_time.replace(hour=23, minute=59, second=59)
|
end_day_time = middle_day_time.replace(hour=23, minute=59, second=59)
|
||||||
|
|
||||||
|
if start_day_time.strftime("%m-%d") not in holidays:
|
||||||
time_spent_seconds += daily_time_spent_calculation(start_day_time, end_day_time, open_hours)
|
time_spent_seconds += daily_time_spent_calculation(start_day_time, end_day_time, open_hours)
|
||||||
# handle same day
|
|
||||||
else:
|
|
||||||
time_spent_seconds += daily_time_spent_calculation(earliest, latest, open_hours)
|
|
||||||
|
|
||||||
return datetime.timedelta(seconds=time_spent_seconds)
|
return datetime.timedelta(seconds=time_spent_seconds)
|
||||||
|
|
||||||
|
@ -166,6 +166,11 @@ FOLLOWUP_TIME_SPENT_OPENING_HOURS = getattr(settings,
|
|||||||
'HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS',
|
'HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS',
|
||||||
{})
|
{})
|
||||||
|
|
||||||
|
# Holidays don't count for time_spent calculation
|
||||||
|
FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS= getattr(settings,
|
||||||
|
'HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS',
|
||||||
|
())
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# options for public pages #
|
# options for public pages #
|
||||||
############################
|
############################
|
||||||
|
Loading…
Reference in New Issue
Block a user