diff --git a/helpdesk/admin.py b/helpdesk/admin.py index d2e4914f..32bcfd9b 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -8,9 +8,17 @@ from helpdesk.models import CustomField @admin.register(Queue) class QueueAdmin(admin.ModelAdmin): - list_display = ('title', 'slug', 'email_address', 'locale') + list_display = ('title', 'slug', 'email_address', 'locale', 'time_spent') prepopulated_fields = {"slug": ("title",)} + def time_spent(self, q): + if q.dedicated_time: + return "{} / {}".format(q.time_spent, q.dedicated_time) + elif q.time_spent: + return q.time_spent + else: + return "-" + @admin.register(Ticket) class TicketAdmin(admin.ModelAdmin): diff --git a/helpdesk/migrations/0025_queue_dedicated_time.py b/helpdesk/migrations/0025_queue_dedicated_time.py new file mode 100644 index 00000000..d3dfd8d3 --- /dev/null +++ b/helpdesk/migrations/0025_queue_dedicated_time.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.5 on 2019-02-19 21:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('helpdesk', '0024_time_spent'), + ] + + operations = [ + migrations.AddField( + model_name='queue', + name='dedicated_time', + field=models.DurationField(blank=True, help_text='Time to be spent on this Queue in total', null=True), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index c772ade0..9096f75d 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -276,6 +276,11 @@ class Queue(models.Model): verbose_name=_('Default owner'), ) + dedicated_time = models.DurationField( + help_text=_("Time to be spent on this Queue in total"), + blank=True, null=True + ) + def __str__(self): return "%s" % self.title diff --git a/helpdesk/serializers.py b/helpdesk/serializers.py index 046509c4..abd95581 100644 --- a/helpdesk/serializers.py +++ b/helpdesk/serializers.py @@ -18,6 +18,7 @@ class TicketSerializer(serializers.ModelSerializer): due_date = serializers.SerializerMethodField() status = serializers.SerializerMethodField() row_class = serializers.SerializerMethodField() + time_spent = serializers.SerializerMethodField() class Meta: model = Ticket @@ -47,5 +48,8 @@ class TicketSerializer(serializers.ModelSerializer): else: return ("None") + def get_time_spent(self, obj): + return str(obj.time_spent) + def get_row_class(self, obj): return (obj.get_priority_css_class) diff --git a/helpdesk/templates/helpdesk/report_index.html b/helpdesk/templates/helpdesk/report_index.html index b570e071..4d82f40c 100644 --- a/helpdesk/templates/helpdesk/report_index.html +++ b/helpdesk/templates/helpdesk/report_index.html @@ -55,7 +55,7 @@