From 84dfa696955398971df40e88e6f0439eddb9d4c1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 29 Mar 2021 13:28:30 -0700 Subject: [PATCH] Fixes invite flow --- bookwyrm/views/invite.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bookwyrm/views/invite.py b/bookwyrm/views/invite.py index 106afe65f..49b5c91b1 100644 --- a/bookwyrm/views/invite.py +++ b/bookwyrm/views/invite.py @@ -111,13 +111,13 @@ class ManageInviteRequests(View): invite_request = get_object_or_404( models.InviteRequest, id=request.POST.get("invite-request") ) - # allows re-sending invites - invite_request.invite, _ = models.SiteInvite.objects.get_or_create( - use_limit=1, - user=request.user, - ) - - invite_request.save() + # only create a new invite if one doesn't exist already (resending) + if not invite_request.invite: + invite_request.invite = models.SiteInvite.objects.create( + use_limit=1, + user=request.user, + ) + invite_request.save() emailing.invite_email(invite_request) return redirect("settings-invite-requests")