From b48e6161e417528b3e57c42ca81f6130b10aa332 Mon Sep 17 00:00:00 2001 From: Jason Cameron Date: Sun, 10 Dec 2023 23:30:57 -0500 Subject: [PATCH] handle edgecase of user alr in the specified team --- core/views/team.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/views/team.py b/core/views/team.py index e785d89..e9fc691 100644 --- a/core/views/team.py +++ b/core/views/team.py @@ -28,7 +28,14 @@ def join(request): return HttpResponseBadRequest( "Invalid team invite code" + form.cleaned_data["code"] ) - if not team.is_full: + elif team.members.filter(id=request.user.id).exists(): + messages.error( + request, + _("You are already in team %(team_name)s") + % dict(team_name=team.name), + ) + return redirect(reverse("team")) + elif not team.is_full: team.join(request.user) invite_code.invites += 1 invite_code.save()