Add device_changed signal (#4412)

This provides both the original and updated version of the Device so
subscribers can see the changes.
This commit is contained in:
George Hickman
2024-10-11 10:08:23 +01:00
committed by GitHub
parent bfd88d1496
commit 9dc38e42d8
3 changed files with 15 additions and 1 deletions

View File

@@ -200,6 +200,11 @@ class UpdateView(APIView):
device.save()
device.log_action('pretix.device.updated', data=serializer.validated_data, auth=device)
from ...base.signals import device_info_updated
device_info_updated.send(
sender=Device, old_device=request.auth, new_device=device
)
serializer = DeviceSerializer(device)
return Response(serializer.data)

View File

@@ -838,3 +838,12 @@ is given as the first argument.
The ``sender`` keyword argument will contain the organizer.
"""
device_info_updated = django.dispatch.Signal()
"""
Arguments: ``old_device``, ``new_device``
This signal is sent out each time the information for a Device is modified.
Both the original and updated versions of the Device are included to allow
receivers to see what has been updated.
"""