Skip to content

Commit

Permalink
handle edgecase of user alr in the specified team
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Dec 11, 2023
1 parent 518de98 commit b48e616
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/views/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b48e616

Please sign in to comment.