diff --git a/helpdesk/lib.py b/helpdesk/lib.py index b94eaf50..67cc325b 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -173,11 +173,10 @@ def format_time_spent(time_spent): """Format time_spent attribute to "[H]HHh:MMm" text string to be allign in all graphical outputs """ - if time_spent: time_spent = "{0:02d}h:{1:02d}m".format( - time_spent.seconds // 3600, - time_spent.seconds // 60 + int(time_spent.total_seconds()) // 3600, + int(time_spent.total_seconds()) % 3600 // 60 ) else: time_spent = "" diff --git a/helpdesk/models.py b/helpdesk/models.py index d965e0b0..0ac55504 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -8,7 +8,7 @@ models.py - Model (and hence database) definitions. This is the core of the """ -from .lib import convert_value, daily_time_spent_calculation +from .lib import format_time_spent, convert_value, daily_time_spent_calculation from .templated_email import send_templated_mail from .validators import validate_file_extension from .webhooks import send_new_ticket_webhook @@ -33,17 +33,6 @@ from rest_framework import serializers import uuid -def format_time_spent(time_spent): - if time_spent: - time_spent = "{0:02d}h:{1:02d}m".format( - int(time_spent.total_seconds()) // 3600, - int(time_spent.total_seconds()) % 3600 // 60 - ) - else: - time_spent = "" - return time_spent - - class EscapeHtml(Extension): def extendMarkdown(self, md): md.preprocessors.deregister('html_block') @@ -1017,7 +1006,7 @@ class FollowUp(models.Model): def time_spent_calculation(self): "Returns timedelta according to rules settings." - + # extract earliest time from previous follow-up # or ticket creation time try: