On the Order endpoint to generate_certificate, we have decided to return the reason why the certificate is not allowed to be generated. This allows the frontend consumers to understand the reason why the order is not eligible at this specific time when requesting the generation of the certificate.
Proposal
[x] Refactor get_or_generate_certificate in Order Model by returning a ValidationError instead of None, False
[x] Refactor endpoint generate_certificate on the OrderViewSet injoanie.core.api.admin.py
[x] Refactor helpers method to generate_certificates_for_orders.
[x] New custom exception when the generation of a certificate fails (CertificateGenerationError)
[x] Adjust all tests linked to helpers, models.Order, and endpoint OrderViewSet to generate certificate from an order.
Purpose
On the
Order
endpoint togenerate_certificate,
we have decided to return the reason why the certificate is not allowed to be generated. This allows the frontend consumers to understand the reason why the order is not eligible at this specific time when requesting the generation of the certificate.Proposal
get_or_generate_certificate
inOrder
Model by returning aValidationError
instead ofNone, False
generate_certificate
on theOrderViewSet
injoanie.core.api.admin.py
generate_certificates_for_orders
.CertificateGenerationError
)