mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 15:33:09 +01:00
Adding HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS setting
This commit is contained in:
parent
eb9d947dd6
commit
220f6d56a8
@ -299,11 +299,11 @@ Time Tracking Options
|
||||
**Default:** ``HELPDESK_FOLLOWUP_TIME_SPENT_AUTO = False``
|
||||
|
||||
- **HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS** If defined, calculates follow-up 'time_spent' according to open hours.
|
||||
|
||||
|
||||
**Default:** ``HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS = {}``
|
||||
|
||||
If HELPDESK_FOLLOWUP_TIME_SPENT_AUTO is ``True``, you may set open hours to remove off hours from 'time_spent'::
|
||||
|
||||
|
||||
HELPDESK_FOLLOWUP_TIME_SPENT_OPENING_HOURS = {
|
||||
"monday": (8.5, 19),
|
||||
"tuesday": (8.5, 19),
|
||||
@ -316,7 +316,16 @@ Time Tracking Options
|
||||
|
||||
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.
|
||||
|
||||
- **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
|
||||
------------------------------
|
||||
|
@ -1025,25 +1025,28 @@ class FollowUp(models.Model):
|
||||
|
||||
time_spent_seconds = 0
|
||||
open_hours = helpdesk_settings.FOLLOWUP_TIME_SPENT_OPENING_HOURS
|
||||
holidays = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS
|
||||
|
||||
# split time interval by days
|
||||
days = latest.toordinal() - earliest.toordinal()
|
||||
if days:
|
||||
for day in range(days + 1):
|
||||
if day == 0:
|
||||
start_day_time = earliest
|
||||
end_day_time = earliest.replace(hour=23, minute=59, second=59)
|
||||
elif day == days:
|
||||
start_day_time = latest.replace(hour=0, minute=0, second=0)
|
||||
for day in range(days + 1):
|
||||
if day == 0:
|
||||
start_day_time = earliest
|
||||
if days == 0:
|
||||
# close single day case
|
||||
end_day_time = latest
|
||||
else:
|
||||
middle_day_time = earliest + datetime.timedelta(days=day)
|
||||
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 = earliest.replace(hour=23, minute=59, second=59)
|
||||
elif day == days:
|
||||
start_day_time = latest.replace(hour=0, minute=0, second=0)
|
||||
end_day_time = latest
|
||||
else:
|
||||
middle_day_time = earliest + datetime.timedelta(days=day)
|
||||
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)
|
||||
|
||||
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)
|
||||
# handle same day
|
||||
else:
|
||||
time_spent_seconds += daily_time_spent_calculation(earliest, latest, open_hours)
|
||||
|
||||
return datetime.timedelta(seconds=time_spent_seconds)
|
||||
|
||||
|
@ -166,6 +166,11 @@ FOLLOWUP_TIME_SPENT_OPENING_HOURS = getattr(settings,
|
||||
'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 #
|
||||
############################
|
||||
|
Loading…
Reference in New Issue
Block a user