diff --git a/helpdesk/models.py b/helpdesk/models.py index b585f9ea..00a92aa3 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1000,8 +1000,11 @@ class FollowUp(models.Model): return u"%s#followup%s" % (self.ticket.get_absolute_url(), self.id) def save(self, *args, **kwargs): + now = timezone.now() t = self.ticket - t.modified = timezone.now() + if helpdesk_settings.FOLLOWUP_TIME_SPENT_AUTO and not self.time_spent: + self.time_spent = now - t.modified + t.modified = now t.save() super(FollowUp, self).save(*args, **kwargs) diff --git a/helpdesk/settings.py b/helpdesk/settings.py index cf5ca644..511109d7 100644 --- a/helpdesk/settings.py +++ b/helpdesk/settings.py @@ -151,6 +151,11 @@ TICKET_PRIORITY_CHOICES = getattr(settings, 'HELPDESK_TICKET_PRIORITY_CHOICES', DEFAULT_TICKET_PRIORITY_CHOICES) +# Follow-ups automatic time_spent calculation +FOLLOWUP_TIME_SPENT_AUTO = getattr(settings, + 'HELPDESK_FOLLOWUP_TIME_SPENT_AUTO', + False) + ############################ # options for public pages # ############################