diff --git a/bookwyrm/templates/invite.html b/bookwyrm/templates/invite.html index 1147673da..939281d86 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/layout.html b/bookwyrm/templates/layout.html index 829f781eb..3aacb0318 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -99,11 +99,8 @@ {% else %} diff --git a/bookwyrm/templates/login.html b/bookwyrm/templates/login.html index d9145d3db..00dcd431a 100644 --- a/bookwyrm/templates/login.html +++ b/bookwyrm/templates/login.html @@ -2,46 +2,51 @@ {% block content %}
-
-

About {{ site_settings.name }}

-

- {{ site_settings.instance_description }} -

- -

- More about this site -

- -

- Create an Account -

-
- -
-

Log in

- -
-
- {% csrf_token %} -
- -
{{ login_form.username }}
-
-
- -
{{ login_form.password }}
-
-
-
- -
- -
-
+
+
+ {% if site_settings.allow_registration %} +

Create an Account

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

This instance is closed

+

Contact an administrator to get an invite

+ {% endif %} +
+
+ +
+
+

Log in

+
+ {% csrf_token %} +
+ +
+ {{ login_form.username }} +
+
+
+ +
+ {{ login_form.password }} +
+
+
+
+ +
+ +
+
+
+
+ {% include 'snippets/about.html' with site_settings=site_settings %} +
-
{% endblock %} diff --git a/bookwyrm/templates/register.html b/bookwyrm/templates/register.html deleted file mode 100644 index 101918603..000000000 --- a/bookwyrm/templates/register.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends 'layout.html' %} -{% block content %} - -
-
-

About {{ site_settings.name }}

-

- {{ site_settings.instance_description }} -

- -

- More about this site -

- -

- Log In -

-
- -
-

Create an Account

- -
-
- {% csrf_token %} -
- -
{{ register_form.username }}
-
-
- -
{{ register_form.email }}
-
-
- -
{{ register_form.password }}
-
-
-
- -
-
-
-
-
- -
-{% endblock %} - diff --git a/bookwyrm/templates/snippets/about.html b/bookwyrm/templates/snippets/about.html new file mode 100644 index 000000000..cbd25678e --- /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 000000000..dfde08ab0 --- /dev/null +++ b/bookwyrm/templates/snippets/register_form.html @@ -0,0 +1,24 @@ +{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 626c1bb03..d35ed377f 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -38,7 +38,6 @@ urlpatterns = [ # ui views re_path(r'^login/?$', views.login_page), - re_path(r'^register/?$', views.register_page), re_path(r'^about/?$', views.about_page), re_path(r'^invite/?$', views.manage_invites), re_path(r'^invite/(?P[A-Za-z0-9]+)/?$', views.invite_page), diff --git a/bookwyrm/views.py b/bookwyrm/views.py index e619856d1..9c0513d10 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(), @@ -193,16 +196,6 @@ def login_page(request): return TemplateResponse(request, 'login.html', data) -def register_page(request): - ''' authentication ''' - # send user to the login page - data = { - 'site_settings': models.SiteSettings.get(), - 'register_form': forms.RegisterForm(), - } - return TemplateResponse(request, 'register.html', data) - - def about_page(request): ''' more information about the instance ''' data = { @@ -213,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():