From 6eee6d196c1721badc5c0aaae54ac8282b3b8cd2 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Mon, 21 Oct 2019 19:21:22 +0200 Subject: [PATCH] Add timeline view for ticket queries --- helpdesk/templates/helpdesk/ticket_list.html | 132 +++++++++++++------ helpdesk/urls.py | 5 + helpdesk/views/staff.py | 40 ++++++ 3 files changed, 137 insertions(+), 40 deletions(-) diff --git a/helpdesk/templates/helpdesk/ticket_list.html b/helpdesk/templates/helpdesk/ticket_list.html index fdc395b0..f9818f99 100644 --- a/helpdesk/templates/helpdesk/ticket_list.html +++ b/helpdesk/templates/helpdesk/ticket_list.html @@ -30,58 +30,110 @@ {% block helpdesk_body %} {% load in_list %} -
+
- - {% trans "Query Results" %} +
{{ search_message|safe }} -
- - - - - - - - - - - - - - -
 {% trans "Ticket" %}{% trans "Prority" %}{% trans "Queue" %}{% trans "Status" %}{% trans "Created" %}{% trans "Due Date" %}{% trans "Owner" %}{% trans "Time Spent" %}
+
+
+ + + + + + + + + + + + + + + +
 {% trans "Ticket" %}{% trans "Prority" %}{% trans "Queue" %}{% trans "Status" %}{% trans "Created" %}{% trans "Due Date" %}{% trans "Owner" %}{% trans "Time Spent" %}
-

+

- -

+

-

- - - -

- {% csrf_token %} +

+ + + +

+ {% csrf_token %} + +
+
+
+ + + + + + + + + +
+
diff --git a/helpdesk/urls.py b/helpdesk/urls.py index d5acabd5..059b088d 100644 --- a/helpdesk/urls.py +++ b/helpdesk/urls.py @@ -151,6 +151,11 @@ urlpatterns = [ url(r'^datatables_ticket_list/(?P{})$'.format(base64_pattern), staff.datatables_ticket_list, name="datatables_ticket_list"), + + url(r'^timeline_ticket_list/(?P{})$'.format(base64_pattern), + staff.timeline_ticket_list, + name="timeline_ticket_list"), + ] urlpatterns += [ diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 2d96208d..87e1b68a 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -975,6 +975,46 @@ def datatables_ticket_list(request, query): return (JsonResponse(result, status=status.HTTP_200_OK)) +@helpdesk_staff_member_required +@api_view(['GET']) +def timeline_ticket_list(request, query): + """ + Datatable on ticket_list.html uses this view from to get objects to display + on the table. query_tickets_by_args is at lib.py, DatatablesTicketSerializer is in + serializers.py. The serializers and this view use django-rest_framework methods + """ + tickets = get_query(query, HelpdeskUser(request.user)) + events = [] + + def mk_timeline_date(date): + return { + 'year': date.year, + 'month': date.month, + 'day': date.day, + 'hour': date.hour, + 'minute': date.minute, + 'second': date.second, + 'second': date.second, + } + for ticket in tickets: + for followup in ticket.followup_set.all(): + event = { + 'start_date': mk_timeline_date(followup.date), + 'text': { + 'headline': ticket.title + '
' + followup.title, + 'text': (followup.comment if followup.comment else _('No text')) + '
%s' % + (reverse('helpdesk:view', kwargs={'ticket_id': ticket.pk}), _("View ticket")), + }, + 'group': _('Messages'), + } + events.append(event) + + result = { + 'events': events, + } + return (JsonResponse(result, status=status.HTTP_200_OK)) + + @helpdesk_staff_member_required def edit_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id)