Refs #654 -- REST API: Allow to resend order link

This commit is contained in:
Raphael Michel
2019-03-23 13:33:57 +01:00
parent 0d02e2fe8c
commit 420649e10a
5 changed files with 100 additions and 28 deletions

View File

@@ -342,6 +342,20 @@ class OrderViewSet(viewsets.ModelViewSet):
status=status.HTTP_201_CREATED
)
@detail_route(methods=['POST'])
def resend_link(self, request, **kwargs):
order = self.get_object()
if not order.email:
return Response({'detail': 'There is no email address associated with this order.'}, status=status.HTTP_400_BAD_REQUEST)
try:
order.resend_link(user=self.request.user, auth=self.request.auth)
except SendMailException:
return Response({'detail': _('There was an error sending the mail. Please try again later.')}, status=status.HTTP_503_SERVICE_UNAVAILABLE)
return Response(
status=status.HTTP_204_NO_CONTENT
)
@detail_route(methods=['POST'])
@transaction.atomic
def regenerate_secrets(self, request, **kwargs):