From 2e58798fe15005e07fd899b54bb78d1e3b6afc36 Mon Sep 17 00:00:00 2001 From: Jachym Cepicky Date: Wed, 22 May 2019 22:36:46 +0200 Subject: [PATCH] fixes #758 : enables adding comments to public tickets --- .../helpdesk/public_view_ticket.html | 75 +++++++++++++++++++ helpdesk/views/public.py | 2 + helpdesk/views/staff.py | 23 +++++- 3 files changed, 97 insertions(+), 3 deletions(-) diff --git a/helpdesk/templates/helpdesk/public_view_ticket.html b/helpdesk/templates/helpdesk/public_view_ticket.html index c3ebcce5..84c31617 100644 --- a/helpdesk/templates/helpdesk/public_view_ticket.html +++ b/helpdesk/templates/helpdesk/public_view_ticket.html @@ -74,4 +74,79 @@ {% endfor %} {% endif %} +
+ + + +
+
+ {% if preset_replies %} +
{% trans "(Optional)" %}
+
+
{% trans "Selecting a pre-set reply will over-write your comment below. You can then modify the pre-set reply to your liking before saving this update." %}
+ {% endif %} + +
+
+
{% trans "You can insert ticket and queue details in your message. For more information, see the context help page." %}
+ + {% if not ticket.can_be_resolved %}
{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}
{% endif %} + {% ifequal ticket.status 1 %} + + {% endifequal %} + {% ifequal ticket.status 2 %} +
+ + + + +
+ {% endifequal %} + {% ifequal ticket.status 3 %} +
+ + + +
+ {% endifequal %} + {% ifequal ticket.status 4 %} +
+
+ {% endifequal %} + {% ifequal ticket.status 5 %} +
+ + +
+ {% endifequal %} + + + +
+ +

+ + + +
+ + + +{% csrf_token %}
+ + {% endblock %} diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index 1e94cd82..94960e58 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -181,6 +181,8 @@ def view_ticket(request): redirect_url = reverse('helpdesk:view', args=[ticket_id]) return render(request, 'helpdesk/public_view_ticket.html', { + 'key': key, + 'mail': email, 'ticket': ticket, 'helpdesk_settings': helpdesk_settings, 'next': redirect_url, diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index e8afc01e..0534c84b 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -451,15 +451,32 @@ def subscribe_staff_member_to_ticket(ticket, user, email=''): def update_ticket(request, ticket_id, public=False): + + ticket = None + if not (public or ( request.user.is_authenticated and request.user.is_active and ( is_helpdesk_staff(request.user) or helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE))): - return HttpResponseRedirect('%s?next=%s' % - (reverse('helpdesk:login'), request.path)) - ticket = get_object_or_404(Ticket, id=ticket_id) + key = request.POST.get('key') + email = request.POST.get('mail') + + if key and email: + ticket = Ticket.objects.get( + id=ticket_id, + submitter_email__iexact=email, + secret_key__iexact=key + ) + + if not ticket: + return HttpResponseRedirect( + '%s?next=%s' % (reverse('helpdesk:login'), request.path) + ) + + if not ticket: + ticket = get_object_or_404(Ticket, id=ticket_id) date_re = re.compile( r'(?P\d{1,2})/(?P\d{1,2})/(?P\d{4})$'