From 2fd192d6cced9a4d656e147a5e7c1a274d60bcd3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 30 Sep 2020 20:47:26 -0700 Subject: [PATCH] Updates ui and redirects for invites --- bookwyrm/templates/invite.html | 44 +++++++------------ bookwyrm/templates/login.html | 39 +--------------- bookwyrm/templates/snippets/about.html | 8 ++++ .../templates/snippets/register_form.html | 24 ++++++++++ bookwyrm/views.py | 5 +++ 5 files changed, 56 insertions(+), 64 deletions(-) create mode 100644 bookwyrm/templates/snippets/about.html create mode 100644 bookwyrm/templates/snippets/register_form.html diff --git a/bookwyrm/templates/invite.html b/bookwyrm/templates/invite.html index 1147673d..939281d8 100644 --- a/bookwyrm/templates/invite.html +++ b/bookwyrm/templates/invite.html @@ -1,33 +1,23 @@ {% extends 'layout.html' %} {% block content %} -
-

About {{ site_settings.name }}

-

- {{ site_settings.instance_description }} -

- -

- - More about this site - -

-
- -
-

Create an Account

-

- With a BookWyrm account, you can track and share your reading activity with - friends here and on any other federated server, like Mastodon and PixelFed. -

- -
-
- {% csrf_token %} - {{ register_form.as_p }} - - -
+
+
+ +
+
+
+ {% include 'snippets/about.html' with site_settings=site_settings %} +
+ {% endblock %} diff --git a/bookwyrm/templates/login.html b/bookwyrm/templates/login.html index 4c61495a..00dcd431 100644 --- a/bookwyrm/templates/login.html +++ b/bookwyrm/templates/login.html @@ -6,32 +6,8 @@
{% if site_settings.allow_registration %}

Create an Account

-
- {% csrf_token %} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
+ {% include 'snippets/register_form.html' %}
{% else %}

This instance is closed

@@ -68,18 +44,7 @@
-

About {{ site_settings.name }}

-

- {{ site_settings.instance_description }} -

- -

- More about this site -

- -

- Create an Account -

+ {% include 'snippets/about.html' with site_settings=site_settings %}
diff --git a/bookwyrm/templates/snippets/about.html b/bookwyrm/templates/snippets/about.html new file mode 100644 index 00000000..cbd25678 --- /dev/null +++ b/bookwyrm/templates/snippets/about.html @@ -0,0 +1,8 @@ +

About {{ site_settings.name }}

+

+ {{ site_settings.instance_description }} +

+ +

+ More about this site +

diff --git a/bookwyrm/templates/snippets/register_form.html b/bookwyrm/templates/snippets/register_form.html new file mode 100644 index 00000000..dfde08ab --- /dev/null +++ b/bookwyrm/templates/snippets/register_form.html @@ -0,0 +1,24 @@ +{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
diff --git a/bookwyrm/views.py b/bookwyrm/views.py index 129274fc..9c0513d1 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -6,6 +6,7 @@ from django.db.models import Avg, Count, Q from django.http import HttpResponseBadRequest, HttpResponseNotFound,\ JsonResponse from django.core.exceptions import PermissionDenied +from django.shortcuts import redirect from django.template.response import TemplateResponse from django.views.decorators.csrf import csrf_exempt @@ -184,6 +185,8 @@ def import_status(request, job_id): def login_page(request): ''' authentication ''' + if request.user.is_authenticated: + return redirect('/') # send user to the login page data = { 'site_settings': models.SiteSettings.get(), @@ -203,6 +206,8 @@ def about_page(request): 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():