Fix sending of duplicate emails
The save
method on the LTARequest model was overridden and used to send e-mails, but the change detection (which queried the database) was not good enough:
- now,
update_fields
in theLTARequest.save
method is inspected to make sure that the status code is being changed (previously, it was also reacting to therequest_token
field being updated) - in the
LTARequestStatus.save
method (which callsLTARequest.save
), change detection is also added to prevent duplicate save calls - a bit of useful logging has been left in place
Unit tests were added to check if a celery task is being sent (or not) and whether an LTARequestStatus correctly saves an LTARequest.