Updates ui and redirects for invites

This commit is contained in:
Mouse Reeve 2020-09-30 20:47:26 -07:00
parent 9e2ab147fb
commit 2fd192d6cc
5 changed files with 56 additions and 64 deletions

View file

@ -1,33 +1,23 @@
{% extends 'layout.html' %}
{% block content %}
<div class="content-container">
<h2>About {{ site_settings.name }}</h2>
<p>
{{ site_settings.instance_description }}
</p>
<p>
<small>
<a href="/about/">More about this site</a>
</small>
</p>
</div>
<div class="content-container login">
<h2>Create an Account</h2>
<p><small>
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.
</small></p>
<div>
<form name="register" method="post" action="/register">
{% csrf_token %}
{{ register_form.as_p }}
<input type=hidden name="invite_code" value="{{ invite.code }}">
<button type="submit">Create account</button>
</form>
<div class="columns">
<div class="column">
<div class="block login">
<h2 class="title">Create an Account</h2>
<div>
<form name="register" method="post" action="/user-register">
<input type=hidden name="invite_code" value="{{ invite.code }}">
{% include 'snippets/register_form.html' %}
</form>
</div>
</div>
</div>
<div class="column">
<div class="block">
{% include 'snippets/about.html' with site_settings=site_settings %}
</div>
</div>
</div>
{% endblock %}

View file

@ -6,32 +6,8 @@
<div class="block">
{% if site_settings.allow_registration %}
<h2 class="title">Create an Account</h2>
<form name="register" method="post" action="/user-register">
{% csrf_token %}
<div class="field">
<label class="label" for="id_username_register">Username:</label>
<div class="control">
<input type="text" name="username" maxlength="150" class="input" required="" id="id_username_register">
</div>
</div>
<div class="field">
<label class="label" for="id_email_register">Email address:</label>
<div class="control">
<input type="email" name="email" maxlength="254" class="input" id="id_email_register">
</div>
</div>
<div class="field">
<label class="label" for="id_password_register">Password:</label>
<div class="control">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password_register">
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button class="button is-primary" type="submit">Sign Up</button>
</div>
</div>
{% include 'snippets/register_form.html' %}
</form>
{% else %}
<h2 class="title">This instance is closed</h2>
@ -68,18 +44,7 @@
</form>
</div>
<div class="block">
<h2 class="title">About {{ site_settings.name }}</h2>
<p class="block">
{{ site_settings.instance_description }}
</p>
<p class="block">
<a href="/about/">More about this site</a>
</p>
<p class="block">
<a href="/register" class="button is-link">Create an Account</a>
</p>
{% include 'snippets/about.html' with site_settings=site_settings %}
</div>
</div>

View file

@ -0,0 +1,8 @@
<h2 class="title">About {{ site_settings.name }}</h2>
<p class="block">
{{ site_settings.instance_description }}
</p>
<p class="block">
<a href="/about/">More about this site</a>
</p>

View file

@ -0,0 +1,24 @@
{% csrf_token %}
<div class="field">
<label class="label" for="id_username_register">Username:</label>
<div class="control">
<input type="text" name="username" maxlength="150" class="input" required="" id="id_username_register">
</div>
</div>
<div class="field">
<label class="label" for="id_email_register">Email address:</label>
<div class="control">
<input type="email" name="email" maxlength="254" class="input" id="id_email_register">
</div>
</div>
<div class="field">
<label class="label" for="id_password_register">Password:</label>
<div class="control">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password_register">
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button class="button is-primary" type="submit">Sign Up</button>
</div>
</div>

View file

@ -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():