diff --git a/bookwyrm/templates/invite.html b/bookwyrm/templates/invite.html index 42f564d6b..458ce3df7 100644 --- a/bookwyrm/templates/invite.html +++ b/bookwyrm/templates/invite.html @@ -3,7 +3,8 @@
-
diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index d27701b2c..16f537021 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -81,8 +81,12 @@ def register(request): if errors: data = { 'login_form': forms.LoginForm(), - 'register_form': form + 'register_form': form, + 'invite': invite, + 'valid': invite.valid() if invite else True, } + if invite: + return TemplateResponse(request, 'invite.html', data) return TemplateResponse(request, 'login.html', data) username = '%s@%s' % (localname, DOMAIN) diff --git a/bookwyrm/views.py b/bookwyrm/views.py index 413039b4f..f1851da84 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -377,17 +377,13 @@ def invite_page(request, code): ''' endpoint for sending invites ''' if request.user.is_authenticated: return redirect('/') - try: - invite = models.SiteInvite.objects.get(code=code) - if not invite.valid(): - raise PermissionDenied - except models.SiteInvite.DoesNotExist: - raise PermissionDenied + invite = get_object_or_404(models.SiteInvite, code=code) data = { 'title': 'Join', 'register_form': forms.RegisterForm(), 'invite': invite, + 'valid': invite.valid() if invite else True, } return TemplateResponse(request, 'invite.html', data)