|
|
|
|
@ -647,6 +647,42 @@ def resend_payment_email(request, team_registration_id): |
|
|
|
|
except Exception as e: |
|
|
|
|
return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) |
|
|
|
|
|
|
|
|
|
@api_view(['GET']) |
|
|
|
|
@permission_classes([IsAuthenticated]) |
|
|
|
|
def get_payment_link(request, team_registration_id): |
|
|
|
|
""" |
|
|
|
|
Get payment link for a team registration. |
|
|
|
|
Only accessible by the umpire (tournament creator). |
|
|
|
|
""" |
|
|
|
|
try: |
|
|
|
|
team_registration = get_object_or_404(TeamRegistration, id=team_registration_id) |
|
|
|
|
|
|
|
|
|
# Check if the user is the umpire (creator) of the tournament |
|
|
|
|
if request.user != team_registration.tournament.event.creator: |
|
|
|
|
return Response({ |
|
|
|
|
'success': False, |
|
|
|
|
'message': "Vous n'êtes pas autorisé à accéder à ce lien de paiement" |
|
|
|
|
}, status=403) |
|
|
|
|
|
|
|
|
|
# Create payment link |
|
|
|
|
payment_link = PaymentService.create_payment_link(team_registration.id) |
|
|
|
|
|
|
|
|
|
if payment_link: |
|
|
|
|
return Response({ |
|
|
|
|
'success': True, |
|
|
|
|
'payment_link': payment_link |
|
|
|
|
}) |
|
|
|
|
else: |
|
|
|
|
return Response({ |
|
|
|
|
'success': False, |
|
|
|
|
'message': 'Impossible de créer le lien de paiement' |
|
|
|
|
}, status=500) |
|
|
|
|
|
|
|
|
|
except TeamRegistration.DoesNotExist: |
|
|
|
|
return Response({'error': 'Team not found'}, status=status.HTTP_404_NOT_FOUND) |
|
|
|
|
except Exception as e: |
|
|
|
|
return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) |
|
|
|
|
|
|
|
|
|
@api_view(['GET']) |
|
|
|
|
@permission_classes([IsAuthenticated]) |
|
|
|
|
def is_granted_unlimited_access(request): |
|
|
|
|
|