mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-15 18:42:35 +02:00
basic support for time spend of tikets and follow-ups
This commit is contained in:
@ -17,6 +17,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||
from io import StringIO
|
||||
import re
|
||||
import datetime
|
||||
|
||||
import uuid
|
||||
|
||||
@ -301,6 +302,17 @@ class Queue(models.Model):
|
||||
return u'%s <%s>' % (self.title, self.email_address)
|
||||
from_address = property(_from_address)
|
||||
|
||||
@property
|
||||
def time_spent(self):
|
||||
"""Return back total time spent on the ticket. This is calculated value
|
||||
based on total sum from all FollowUps
|
||||
"""
|
||||
total = datetime.timedelta(0)
|
||||
for val in self.ticket_set.all():
|
||||
if val.time_spent:
|
||||
total = total + val.time_spent
|
||||
return total
|
||||
|
||||
def prepare_permission_name(self):
|
||||
"""Prepare internally the codename for the permission and store it in permission_name.
|
||||
:return: The codename that can be used to create a new Permission object.
|
||||
@ -497,6 +509,17 @@ class Ticket(models.Model):
|
||||
default=mk_secret,
|
||||
)
|
||||
|
||||
@property
|
||||
def time_spent(self):
|
||||
"""Return back total time spent on the ticket. This is calculated value
|
||||
based on total sum from all FollowUps
|
||||
"""
|
||||
total = datetime.timedelta(0)
|
||||
for val in self.followup_set.all():
|
||||
if val.time_spent:
|
||||
total = total + val.time_spent
|
||||
return total
|
||||
|
||||
def send(self, roles, dont_send_to=None, **kwargs):
|
||||
"""
|
||||
Send notifications to everyone interested in this ticket.
|
||||
@ -771,6 +794,11 @@ class FollowUp(models.Model):
|
||||
|
||||
objects = FollowUpManager()
|
||||
|
||||
time_spent = models.DurationField(
|
||||
help_text=_("Time spent on this follow up"),
|
||||
blank=True, null=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ('date',)
|
||||
verbose_name = _('Follow-up')
|
||||
|
Reference in New Issue
Block a user