From 3f620e83a20de7661584349b48e9d0614d042fdc Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Tue, 27 Sep 2016 17:29:59 -0400 Subject: [PATCH] Update style of Ticket FollowUp list to be a timeline --- helpdesk/templates/helpdesk/ticket.html | 98 ++++++++++++++----------- helpdesk/views/staff.py | 22 ++++++ 2 files changed, 77 insertions(+), 43 deletions(-) diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index f914d843..5b87d5e7 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -74,53 +74,59 @@ $(document).on('change', ':file', function() { {% include "helpdesk/ticket_desc_table.html" %} {% if ticket.followup_set.all %} -

{% trans "Follow-Ups" %}

{% load ticket_to_link %} -{% for followup in ticket.followup_set.all %} -{% if helpdesk_settings.HELPDESK_FOLLOWUP_MOD %} -
-
- {{ followup.title }} - {% if not followup.public %} ({% trans "Private" %}){% endif %} - {% if helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %} - {% if followup.user and request.user == followup.user and not followup.ticketchange_set.all %} - - {% endif %} - {% endif %} - {% if user.is_superuser and helpdesk_settings.HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP %} - - {% endif %} +
+
+

 {% trans "Follow-Ups" %}

-{% else %} -
-
- {{ followup.title }} - {% if helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %} - {% if followup.user and request.user == followup.user and not followup.ticketchange_set.all %} - - {% endif %} - {% endif %} - {% if user.is_superuser and helpdesk_settings.HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP %} - - {% endif %} + +
+
    + {% for followup in ticket.followup_set.all %} + +
    +
    +
    +

    {{ followup.title }}

    +

     

    +
    +
    +

    {% if followup.comment %}{{ followup.comment|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}{% endif %}

    + {% for change in followup.ticketchange_set.all %} + {% if forloop.first %}
      {% endif %} +
    • {% blocktrans with change.field as field and change.old_value as old_value and change.new_value as new_value %}Changed {{ field }} from {{ old_value }} to {{ new_value }}.{% endblocktrans %}
    • + {% if forloop.last %}
    {% endif %} + {% endfor %} + {% for attachment in followup.attachment_set.all %}{% if forloop.first %}
    {% endif %} + {% endfor %} +
    +
    + {% if helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %} + {% if followup.user and request.user == followup.user and not followup.ticketchange_set.all %} + + {% endif %} + {% endif %} + {% if user.is_superuser and helpdesk_settings.HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP %} + + {% endif %} +
    +
    +
    + + {% endfor %} + +
-{% endif %} -{% if followup.comment %}{{ followup.comment|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}{% endif %} -{% for change in followup.ticketchange_set.all %} -{% if forloop.first %}
    {% endif %} -
  • {% blocktrans with change.field as field and change.old_value as old_value and change.new_value as new_value %}Changed {{ field }} from {{ old_value }} to {{ new_value }}.{% endblocktrans %}
  • -{% if forloop.last %}
{% endif %} -{% endfor %} -{% for attachment in followup.attachment_set.all %}{% if forloop.first %}
{% endif %} -{% endfor %} +
-{% endfor %} + + {% endif %} {% if helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS %}
@@ -237,4 +243,10 @@ $(document).on('change', ':file', function() {
+ + {% endblock %} diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 7ea2f56e..85a5a06a 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -391,6 +391,7 @@ def update_ticket(request, ticket_id, public=False): reassigned = False + old_owner = ticket.assigned_to if owner is not -1: if owner != 0 and ((ticket.assigned_to and owner != ticket.assigned_to.id) or not ticket.assigned_to): new_user = User.objects.get(id=owner) @@ -404,10 +405,13 @@ def update_ticket(request, ticket_id, public=False): f.title = _('Unassigned') ticket.assigned_to = None + old_status_str = ticket.get_status_display() + old_status = ticket.status if new_status != ticket.status: ticket.status = new_status ticket.save() f.new_status = new_status + ticket_status_changed = True if f.title: f.title += ' and %s' % ticket.get_status_display() else: @@ -455,6 +459,24 @@ def update_ticket(request, ticket_id, public=False): c.save() ticket.title = title + if new_status != old_status: + c = TicketChange( + followup=f, + field=_('Status'), + old_value=old_status_str, + new_value=ticket.get_status_display(), + ) + c.save() + + if ticket.assigned_to != old_owner: + c = TicketChange( + followup=f, + field=_('Owner'), + old_value=old_owner, + new_value=ticket.assigned_to, + ) + c.save() + if priority != ticket.priority: c = TicketChange( followup=f,