From 8fffae343ca6af8fb421fc1440bec3e1fea9107b Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 07:58:33 +0000 Subject: [PATCH 01/17] Update TicketChange creation code --- helpdesk/update_ticket.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py index deca0b40..f10a33d5 100644 --- a/helpdesk/update_ticket.py +++ b/helpdesk/update_ticket.py @@ -268,41 +268,33 @@ def update_ticket( files = process_attachments(f, files) if files else [] if ticket_title and ticket_title != ticket.title: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Title'), old_value=ticket.title, new_value=ticket_title, ) - c.save() ticket.title = ticket_title if new_status != old_status: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( 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, + c = f.ticketchange_set.create( field=_('Owner'), old_value=old_owner, new_value=ticket.assigned_to, ) - c.save() if priority != ticket.priority: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Priority'), old_value=ticket.priority, new_value=priority, ) - c.save() ticket.priority = priority if queue != ticket.queue.id: @@ -314,13 +306,11 @@ def update_ticket( ticket.queue_id = queue if due_date != ticket.due_date: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Due on'), old_value=ticket.due_date, new_value=due_date, ) - c.save() ticket.due_date = due_date for checklist in ticket.checklists.all(): From 2499f81d4dc964924deb6cadee9ff6c1e21ee836 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:04:01 +0000 Subject: [PATCH 02/17] Add a signal when the ticket upate is done (every related instance created and updated) --- helpdesk/update_ticket.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py index f10a33d5..ddd337ee 100644 --- a/helpdesk/update_ticket.py +++ b/helpdesk/update_ticket.py @@ -4,6 +4,7 @@ from django.core.exceptions import ValidationError from django.contrib.auth import get_user_model from django.utils import timezone from django.utils.translation import gettext as _ +import django.dispatch from helpdesk.lib import safe_template_context from helpdesk import settings as helpdesk_settings @@ -20,6 +21,8 @@ from helpdesk.models import ( User = get_user_model() +update_ticket_done = django.dispatch.Signal() + def add_staff_subscription( user: User, ticket: Ticket @@ -387,6 +390,9 @@ def update_ticket( )) ticket.save() + # emit signal with followup when the ticket update is done + update_ticket_done.send(sender="update_ticket", followup=f) + from helpdesk.webhooks import notify_followup_webhooks notify_followup_webhooks(f) From ebb9a4d50d59cf85cd359dda7a114653f1ddbc9e Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:23:06 +0000 Subject: [PATCH 03/17] Make update_ticket_done signal trigger notify_followup_webhooks --- helpdesk/signals.py | 4 ++++ helpdesk/update_ticket.py | 8 ++------ helpdesk/webhooks.py | 43 ++++++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 helpdesk/signals.py diff --git a/helpdesk/signals.py b/helpdesk/signals.py new file mode 100644 index 00000000..0f3ed823 --- /dev/null +++ b/helpdesk/signals.py @@ -0,0 +1,4 @@ +import django.dispatch + +# create a signal for ticket updates +update_ticket_done = django.dispatch.Signal() \ No newline at end of file diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py index ddd337ee..017b5b4f 100644 --- a/helpdesk/update_ticket.py +++ b/helpdesk/update_ticket.py @@ -4,7 +4,6 @@ from django.core.exceptions import ValidationError from django.contrib.auth import get_user_model from django.utils import timezone from django.utils.translation import gettext as _ -import django.dispatch from helpdesk.lib import safe_template_context from helpdesk import settings as helpdesk_settings @@ -18,11 +17,10 @@ from helpdesk.models import ( TicketCC, TicketChange, ) +from helpdesk.signals import update_ticket_done User = get_user_model() -update_ticket_done = django.dispatch.Signal() - def add_staff_subscription( user: User, ticket: Ticket @@ -391,11 +389,9 @@ def update_ticket( ticket.save() # emit signal with followup when the ticket update is done + # internally used for webhooks update_ticket_done.send(sender="update_ticket", followup=f) - from helpdesk.webhooks import notify_followup_webhooks - notify_followup_webhooks(f) - # auto subscribe user if enabled add_staff_subscription(user, ticket) return f diff --git a/helpdesk/webhooks.py b/helpdesk/webhooks.py index 3133a3fa..39ab2359 100644 --- a/helpdesk/webhooks.py +++ b/helpdesk/webhooks.py @@ -1,33 +1,38 @@ -from . import settings - import requests import requests.exceptions import logging +from . import settings +from .signals import update_ticket_done + logger = logging.getLogger(__name__) -def notify_followup_webhooks(followup): +# listener is loaded via app.py HelpdeskConfig.ready() +@receiver(update_ticket_done) +def notify_followup_webhooks(sender, followup, **kwargs): urls = settings.HELPDESK_GET_FOLLOWUP_WEBHOOK_URLS() if not urls: return - # Serialize the ticket associated with the followup - from .serializers import TicketSerializer - ticket = followup.ticket - ticket.set_custom_field_values() - serialized_ticket = TicketSerializer(ticket).data - # Prepare the data to send - data = { - 'ticket': serialized_ticket, - 'queue_slug': ticket.queue.slug, - 'followup_id': followup.id - } + if sender == "update_ticket": + # Serialize the ticket associated with the followup + from .serializers import TicketSerializer + ticket = followup.ticket + ticket.set_custom_field_values() + serialized_ticket = TicketSerializer(ticket).data - for url in urls: - try: - requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT) - except requests.exceptions.Timeout: - logger.error('Timeout while sending followup webhook to %s', url) + # Prepare the data to send + data = { + 'ticket': serialized_ticket, + 'queue_slug': ticket.queue.slug, + 'followup_id': followup.id + } + + for url in urls: + try: + requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT) + except requests.exceptions.Timeout: + logger.error('Timeout while sending followup webhook to %s', url) def send_new_ticket_webhook(ticket): From 08ed2a50352ac73736ec065828365ddcee6322bf Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:34:03 +0000 Subject: [PATCH 04/17] Adding receiver import --- helpdesk/webhooks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/helpdesk/webhooks.py b/helpdesk/webhooks.py index 39ab2359..cee26ad4 100644 --- a/helpdesk/webhooks.py +++ b/helpdesk/webhooks.py @@ -1,6 +1,7 @@ import requests import requests.exceptions import logging +from django.dispatch import receiver from . import settings from .signals import update_ticket_done From 0e96909f438036cb456301ec1e3f59d19d709e49 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:36:29 +0000 Subject: [PATCH 05/17] Removed unused TichetChange import --- helpdesk/update_ticket.py | 1 - 1 file changed, 1 deletion(-) diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py index 017b5b4f..989e04e4 100644 --- a/helpdesk/update_ticket.py +++ b/helpdesk/update_ticket.py @@ -15,7 +15,6 @@ from helpdesk.models import ( FollowUp, Ticket, TicketCC, - TicketChange, ) from helpdesk.signals import update_ticket_done From 79b7ce9650ad13fc4ae73276f08b237fef47ba08 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:42:03 +0000 Subject: [PATCH 06/17] notify_followup_webhooks used in email, so moving signal triggering code --- helpdesk/webhooks.py | 46 ++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/helpdesk/webhooks.py b/helpdesk/webhooks.py index cee26ad4..0eb33133 100644 --- a/helpdesk/webhooks.py +++ b/helpdesk/webhooks.py @@ -8,32 +8,36 @@ from .signals import update_ticket_done logger = logging.getLogger(__name__) -# listener is loaded via app.py HelpdeskConfig.ready() -@receiver(update_ticket_done) -def notify_followup_webhooks(sender, followup, **kwargs): +def notify_followup_webhooks(followup): urls = settings.HELPDESK_GET_FOLLOWUP_WEBHOOK_URLS() if not urls: return + # Serialize the ticket associated with the followup + from .serializers import TicketSerializer + ticket = followup.ticket + ticket.set_custom_field_values() + serialized_ticket = TicketSerializer(ticket).data + + # Prepare the data to send + data = { + 'ticket': serialized_ticket, + 'queue_slug': ticket.queue.slug, + 'followup_id': followup.id + } + + for url in urls: + try: + requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT) + except requests.exceptions.Timeout: + logger.error('Timeout while sending followup webhook to %s', url) + + +# listener is loaded via app.py HelpdeskConfig.ready() +@receiver(update_ticket_done) +def notify_followup_webhooks_receiver(sender, followup, **kwargs): if sender == "update_ticket": - # Serialize the ticket associated with the followup - from .serializers import TicketSerializer - ticket = followup.ticket - ticket.set_custom_field_values() - serialized_ticket = TicketSerializer(ticket).data - - # Prepare the data to send - data = { - 'ticket': serialized_ticket, - 'queue_slug': ticket.queue.slug, - 'followup_id': followup.id - } - - for url in urls: - try: - requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT) - except requests.exceptions.Timeout: - logger.error('Timeout while sending followup webhook to %s', url) + notify_followup_webhooks(followup) def send_new_ticket_webhook(ticket): From c0ee8e0847df5b5741300852488c6e399124bdf4 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:49:11 +0000 Subject: [PATCH 07/17] Use update_ticket mechanism in email.py --- helpdesk/email.py | 4 +++- helpdesk/webhooks.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index c454d5a2..d9a89325 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -25,6 +25,7 @@ from helpdesk import webhooks from helpdesk.exceptions import DeleteIgnoredTicketException, IgnoreTicketException from helpdesk.lib import process_attachments, safe_template_context from helpdesk.models import FollowUp, IgnoreEmail, Queue, Ticket +from helpdesk.signals import update_ticket_done import imaplib import logging import mimetypes @@ -618,7 +619,8 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger) else: send_info_email(message_id, f, ticket, context, queue, new) if not new: - webhooks.notify_followup_webhooks(f) + # emit signal with followup when the ticket is updated + update_ticket_done.send(sender="create_object_from_email_message", followup=f) return ticket diff --git a/helpdesk/webhooks.py b/helpdesk/webhooks.py index 0eb33133..c1050581 100644 --- a/helpdesk/webhooks.py +++ b/helpdesk/webhooks.py @@ -36,8 +36,7 @@ def notify_followup_webhooks(followup): # listener is loaded via app.py HelpdeskConfig.ready() @receiver(update_ticket_done) def notify_followup_webhooks_receiver(sender, followup, **kwargs): - if sender == "update_ticket": - notify_followup_webhooks(followup) + notify_followup_webhooks(followup) def send_new_ticket_webhook(ticket): From c6cad5f70221229a2cc6e0129256c8a598bcc96f Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:52:22 +0000 Subject: [PATCH 08/17] Removed unused webhooks import --- helpdesk/email.py | 1 - 1 file changed, 1 deletion(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index d9a89325..ea90ce65 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -21,7 +21,6 @@ from email.message import EmailMessage, MIMEPart from email.utils import getaddresses from email_reply_parser import EmailReplyParser from helpdesk import settings -from helpdesk import webhooks from helpdesk.exceptions import DeleteIgnoredTicketException, IgnoreTicketException from helpdesk.lib import process_attachments, safe_template_context from helpdesk.models import FollowUp, IgnoreEmail, Queue, Ticket From 9a6939b5642ea446230152fe0a046d69363a058e Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:02:44 +0000 Subject: [PATCH 09/17] Attach send_new_ticket_webhook to the new_ticket_done signal --- helpdesk/forms.py | 9 +++++++++ helpdesk/models.py | 2 -- helpdesk/signals.py | 5 ++++- helpdesk/webhooks.py | 8 ++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index e63072cd..eb77c2e6 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -36,6 +36,7 @@ from helpdesk.settings import ( CUSTOMFIELD_TO_FIELD_DICT ) from helpdesk.validators import validate_file_extension +from helpdesk.signals import new_ticket_done import logging @@ -418,6 +419,10 @@ class TicketForm(AbstractTicketForm): followup.save() files = self._attach_files_to_follow_up(followup) + + # emit signal when the TicketForm.save is done + new_ticket_done.send(sender="TicketForm", ticket=ticket) + self._send_messages(ticket=ticket, queue=queue, followup=followup, @@ -507,6 +512,10 @@ class PublicTicketForm(AbstractTicketForm): followup.save() files = self._attach_files_to_follow_up(followup) + + # emit signal when the PublicTicketForm.save is done + new_ticket_done.send(sender="PublicTicketForm", ticket=ticket) + self._send_messages(ticket=ticket, queue=queue, followup=followup, diff --git a/helpdesk/models.py b/helpdesk/models.py index a9ce9a1b..c95f100c 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -644,8 +644,6 @@ class Ticket(models.Model): if self.queue.enable_notifications_on_email_events: for cc in self.ticketcc_set.all(): send('ticket_cc', cc.email_address) - if "new_ticket_cc" in roles: - send_new_ticket_webhook(self) return recipients def _get_assigned_to(self): diff --git a/helpdesk/signals.py b/helpdesk/signals.py index 0f3ed823..0f72ef20 100644 --- a/helpdesk/signals.py +++ b/helpdesk/signals.py @@ -1,4 +1,7 @@ import django.dispatch -# create a signal for ticket updates +# create a signal for *TicketForm +new_ticket_done = django.dispatch.Signal() + +# create a signal for ticket_update view update_ticket_done = django.dispatch.Signal() \ No newline at end of file diff --git a/helpdesk/webhooks.py b/helpdesk/webhooks.py index c1050581..1770e753 100644 --- a/helpdesk/webhooks.py +++ b/helpdesk/webhooks.py @@ -4,7 +4,7 @@ import logging from django.dispatch import receiver from . import settings -from .signals import update_ticket_done +from .signals import new_ticket_done, update_ticket_done logger = logging.getLogger(__name__) @@ -32,7 +32,6 @@ def notify_followup_webhooks(followup): except requests.exceptions.Timeout: logger.error('Timeout while sending followup webhook to %s', url) - # listener is loaded via app.py HelpdeskConfig.ready() @receiver(update_ticket_done) def notify_followup_webhooks_receiver(sender, followup, **kwargs): @@ -59,3 +58,8 @@ def send_new_ticket_webhook(ticket): requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT) except requests.exceptions.Timeout: logger.error('Timeout while sending new ticket webhook to %s', url) + +# listener is loaded via app.py HelpdeskConfig.ready() +@receiver(new_ticket_done) +def send_new_ticket_webhook_receiver(sender, ticket, **kwargs): + send_new_ticket_webhook(ticket) \ No newline at end of file From 81f9226f7c4014841ae9df8b3fc69337b134afef Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:09:15 +0000 Subject: [PATCH 10/17] Removed unused webhooks import --- helpdesk/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index c95f100c..eacdfe6e 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -11,7 +11,6 @@ models.py - Model (and hence database) definitions. This is the core of the 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 import datetime from django.conf import settings from django.contrib.auth import get_user_model From 2fc95d165a9a5089dcef1fc592f764f5fa91d68f Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:19:50 +0000 Subject: [PATCH 11/17] new_ticket_done signal emitted through email --- helpdesk/email.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index ea90ce65..c87e485c 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -24,7 +24,7 @@ from helpdesk import settings from helpdesk.exceptions import DeleteIgnoredTicketException, IgnoreTicketException from helpdesk.lib import process_attachments, safe_template_context from helpdesk.models import FollowUp, IgnoreEmail, Queue, Ticket -from helpdesk.signals import update_ticket_done +from helpdesk.signals import new_ticket_done, update_ticket_done import imaplib import logging import mimetypes @@ -617,7 +617,10 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger) "Message seems to be auto-reply, not sending any emails back to the sender") else: send_info_email(message_id, f, ticket, context, queue, new) - if not new: + if new: + # emit signal when the PublicTicketForm.save is done + new_ticket_done.send(sender="create_object_from_email_message", ticket=ticket) + else: # emit signal with followup when the ticket is updated update_ticket_done.send(sender="create_object_from_email_message", followup=f) return ticket From 8541acd49d0dd7df3ae34e8373ae3e144eea787c Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:21:02 +0000 Subject: [PATCH 12/17] Updated comment --- helpdesk/email.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index c87e485c..f0d3a70f 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -618,7 +618,7 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger) else: send_info_email(message_id, f, ticket, context, queue, new) if new: - # emit signal when the PublicTicketForm.save is done + # emit signal when a new ticket is created new_ticket_done.send(sender="create_object_from_email_message", ticket=ticket) else: # emit signal with followup when the ticket is updated From 2f26180451c149ccd1fc2963e30820376d448a89 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:20:27 +0000 Subject: [PATCH 13/17] Update webhooks documentation with signals info --- docs/webhooks.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/webhooks.rst b/docs/webhooks.rst index 257dbe3f..19c56187 100644 --- a/docs/webhooks.rst +++ b/docs/webhooks.rst @@ -10,3 +10,29 @@ You can register webhooks to allow third party apps to be notified of helpdesk e 3. You can optionally set ``HELPDESK_WEBHOOK_TIMEOUT`` which defaults to 3 seconds. Warning, however, webhook requests are sent out sychronously on ticket update. If your webhook handling server is too slow, you should fix this rather than causing helpdesk freezes by messing with this variable. Once these URLs are configured, a serialized copy of the ticket object will be posted to each of these URLs each time a ticket is created or followed up on respectively. + + +Django signals +-------------- + +Webhooks are triggered through signals emitted for new tickets creation and ticket follow-up updates. + +The two existing signals are: + - new_ticket_done + - update_ticket_done + +You have the opportunity to listen to those in your project if you have post processing workflows outside of webhooks. + +``` +from helpdesk.signals import new_ticket_done, update_ticket_done + +@receiver(new_ticket_done) +def process_new_ticket(sender, ticket, **kwargs): + "Triggers this code when a ticket is created." + pass + +@receiver(update_ticket_done) +def process_followup_update(sender, followup, **kwargs): + "Triggers this code when a follow-up is created." + pass +``` \ No newline at end of file From 16bb4d46f17f89e4a2eb5ce952ce8c82c841d2fe Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:24:15 +0200 Subject: [PATCH 14/17] Update webhooks documentation --- docs/webhooks.rst | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/webhooks.rst b/docs/webhooks.rst index 19c56187..ef4abebb 100644 --- a/docs/webhooks.rst +++ b/docs/webhooks.rst @@ -12,27 +12,26 @@ You can register webhooks to allow third party apps to be notified of helpdesk e Once these URLs are configured, a serialized copy of the ticket object will be posted to each of these URLs each time a ticket is created or followed up on respectively. -Django signals +Signals -------------- -Webhooks are triggered through signals emitted for new tickets creation and ticket follow-up updates. +Webhooks are triggered through django signals. The two existing signals are: - new_ticket_done - update_ticket_done -You have the opportunity to listen to those in your project if you have post processing workflows outside of webhooks. +You have the opportunity to listen to those in your project if you have post processing workflows outside of webhooks:: -``` -from helpdesk.signals import new_ticket_done, update_ticket_done -@receiver(new_ticket_done) -def process_new_ticket(sender, ticket, **kwargs): - "Triggers this code when a ticket is created." - pass - -@receiver(update_ticket_done) -def process_followup_update(sender, followup, **kwargs): - "Triggers this code when a follow-up is created." - pass -``` \ No newline at end of file + from helpdesk.signals import new_ticket_done, update_ticket_done + + @receiver(new_ticket_done) + def process_new_ticket(sender, ticket, **kwargs): + "Triggers this code when a ticket is created." + pass + + @receiver(update_ticket_done) + def process_followup_update(sender, followup, **kwargs): + "Triggers this code when a follow-up is created." + pass From 361ba84295ca29180356ee772e37b0a80d1dc46c Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:31:57 +0200 Subject: [PATCH 15/17] Updated signals code --- docs/webhooks.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/webhooks.rst b/docs/webhooks.rst index ef4abebb..e25c8faa 100644 --- a/docs/webhooks.rst +++ b/docs/webhooks.rst @@ -17,13 +17,14 @@ Signals Webhooks are triggered through django signals. -The two existing signals are: +The two available signals are: - new_ticket_done - update_ticket_done You have the opportunity to listen to those in your project if you have post processing workflows outside of webhooks:: - + + from django.dispatch import receiver from helpdesk.signals import new_ticket_done, update_ticket_done @receiver(new_ticket_done) From 750b216d66f77558d77b5ad90b06b5a561a7e3a1 Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:34:47 +0200 Subject: [PATCH 16/17] Update docs/webhooks.rst with django signals link Co-authored-by: Benbb96 --- docs/webhooks.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/webhooks.rst b/docs/webhooks.rst index e25c8faa..967fd8fa 100644 --- a/docs/webhooks.rst +++ b/docs/webhooks.rst @@ -15,7 +15,7 @@ Once these URLs are configured, a serialized copy of the ticket object will be p Signals -------------- -Webhooks are triggered through django signals. +Webhooks are triggered through `Django Signals _`. The two available signals are: - new_ticket_done From c723873d83e20dd42f103427c59763b3bbe11379 Mon Sep 17 00:00:00 2001 From: Georg Lehner Date: Wed, 17 Apr 2024 21:17:41 +0200 Subject: [PATCH 17/17] FIX: replace hardcoded urls with Django generated ones. The My Tickets view generated ticket urls with a '/view' string prefix. This is replaced by proper Django URL resolution. The public and staff ticket view used a '../../' string prefix which brakes in the public ticket view. They are both replaced with proper Django URL resolution. --- helpdesk/templates/helpdesk/my_tickets.html | 4 +++- helpdesk/templates/helpdesk/public_view_ticket.html | 5 ++++- helpdesk/templates/helpdesk/ticket.html | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/helpdesk/templates/helpdesk/my_tickets.html b/helpdesk/templates/helpdesk/my_tickets.html index cde160a1..ab25a840 100644 --- a/helpdesk/templates/helpdesk/my_tickets.html +++ b/helpdesk/templates/helpdesk/my_tickets.html @@ -37,7 +37,9 @@ window.addEventListener('load', function() data.results.forEach(function(ticket) { $('#ticketsTable tbody').append(` - ${ticket.title} + + ${ticket.title} + ${ticket.queue.title} ${ticket.status} ${ticket.created} diff --git a/helpdesk/templates/helpdesk/public_view_ticket.html b/helpdesk/templates/helpdesk/public_view_ticket.html index 62f37a43..77de5af1 100644 --- a/helpdesk/templates/helpdesk/public_view_ticket.html +++ b/helpdesk/templates/helpdesk/public_view_ticket.html @@ -103,7 +103,10 @@
-
{% trans "You can insert ticket and queue details in your message. For more information, see the context help page." %}
+ {% url "helpdesk:help_context" as context_help_url %} + {% blocktrans %} +
You can insert ticket and queue details in your message. For more information, see the context help page.
+ {% endblocktrans %} {% if not ticket.can_be_resolved %}
{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}
{% endif %} {% if ticket.status == 1 %} diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index 8f0ede76..b61743f7 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -105,7 +105,10 @@
-
{% trans "You can insert ticket and queue details in your message. For more information, see the context help page." %}
+ {% url "helpdesk:help_context" as context_help_url %} + {% blocktrans %} +
You can insert ticket and queue details in your message. For more information, see the context help page.
+ {% endblocktrans %}
{% if not ticket.can_be_resolved %}
{% trans "This ticket cannot be resolved or closed until the tickets it depends on are resolved." %}
{% endif %}