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

View file

@ -6,32 +6,8 @@
<div class="block"> <div class="block">
{% if site_settings.allow_registration %} {% if site_settings.allow_registration %}
<h2 class="title">Create an Account</h2> <h2 class="title">Create an Account</h2>
<form name="register" method="post" action="/user-register"> <form name="register" method="post" action="/user-register">
{% csrf_token %} {% include 'snippets/register_form.html' %}
<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>
</form> </form>
{% else %} {% else %}
<h2 class="title">This instance is closed</h2> <h2 class="title">This instance is closed</h2>
@ -68,18 +44,7 @@
</form> </form>
</div> </div>
<div class="block"> <div class="block">
<h2 class="title">About {{ site_settings.name }}</h2> {% include 'snippets/about.html' with site_settings=site_settings %}
<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>
</div> </div>
</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,\ from django.http import HttpResponseBadRequest, HttpResponseNotFound,\
JsonResponse JsonResponse
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.shortcuts import redirect
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
@ -184,6 +185,8 @@ def import_status(request, job_id):
def login_page(request): def login_page(request):
''' authentication ''' ''' authentication '''
if request.user.is_authenticated:
return redirect('/')
# send user to the login page # send user to the login page
data = { data = {
'site_settings': models.SiteSettings.get(), 'site_settings': models.SiteSettings.get(),
@ -203,6 +206,8 @@ def about_page(request):
def invite_page(request, code): def invite_page(request, code):
''' endpoint for sending invites ''' ''' endpoint for sending invites '''
if request.user.is_authenticated:
return redirect('/')
try: try:
invite = models.SiteInvite.objects.get(code=code) invite = models.SiteInvite.objects.get(code=code)
if not invite.valid(): if not invite.valid():