Skip to content

Commit

Permalink
fixed multiple return statements with one error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutvikrj26 committed Nov 8, 2023
1 parent a236062 commit 109a4ee
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions physionet-django/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ def manage_co_hosts(request):
event = get_object_or_404(Event, slug=event_slug)

if not event.host == user:
return JsonResponse({'error': 'You are not the host of this event'}, status=403)

error_response = JsonResponse({'error': 'You are not the host of this event'}, status=403)
if event.end_date < datetime.now().date():
return JsonResponse({'error': 'You cannot manage co-hosts of an event that has ended'}, status=403)

error_response JsonResponse({'error': 'You cannot manage co-hosts of an event that has ended'}, status=403)
if not event.participants.filter(id=participant_id).exists():
return JsonResponse({'error': 'User is not a participant of this event'}, status=403)
error_response JsonResponse({'error': 'User is not a participant of this event'}, status=403)
if error_response:
return error_response

participant = event.participants.get(id=participant_id)

Expand Down

0 comments on commit 109a4ee

Please sign in to comment.