mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-20 15:17:06 +00:00
commit
7138cd4811
8 changed files with 100 additions and 131 deletions
|
@ -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 %}
|
||||
|
|
|
@ -99,11 +99,8 @@
|
|||
{% else %}
|
||||
<div class="navbar-item">
|
||||
<div class="buttons">
|
||||
<a href="/register" class="button is-primary">
|
||||
<strong>Sign up</strong>
|
||||
</a>
|
||||
<a href="/login" class="button is-light">
|
||||
Log in
|
||||
<a href="/login" class="button is-primary">
|
||||
Join
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,46 +2,51 @@
|
|||
{% block content %}
|
||||
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<h2 class="title">Log in</h2>
|
||||
|
||||
<div class="block">
|
||||
<form name="login" method="post" action="/user-login">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label class="label" for="id_username">Username:</label>
|
||||
<div class="control">{{ login_form.username }}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="id_password">Password:</label>
|
||||
<div class="control">{{ login_form.password }}</div>
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">Log in</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<small><a href="/reset-password">Forgot your password?</a></small>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="column">
|
||||
<div class="block">
|
||||
{% if site_settings.allow_registration %}
|
||||
<h2 class="title">Create an Account</h2>
|
||||
<form name="register" method="post" action="/user-register">
|
||||
{% include 'snippets/register_form.html' %}
|
||||
</form>
|
||||
{% else %}
|
||||
<h2 class="title">This instance is closed</h2>
|
||||
<p>Contact an administrator to get an invite</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="block">
|
||||
<h2 class="title">Log in</h2>
|
||||
<form name="login" method="post" action="/user-login">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label class="label" for="id_username">Username:</label>
|
||||
<div class="control">
|
||||
{{ login_form.username }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="id_password">Password:</label>
|
||||
<div class="control">
|
||||
{{ login_form.password }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">Log in</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<small><a href="/reset-password">Forgot your password?</a></small>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="block">
|
||||
{% include 'snippets/about.html' with site_settings=site_settings %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<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="/login" class="button is-link">Log In</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<h2 class="title">Create an Account</h2>
|
||||
|
||||
<div class="block">
|
||||
<form name="register" method="post" action="/user-register">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label class="label" for="id_username">Username:</label>
|
||||
<div class="control">{{ register_form.username }}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="id_email">Email address:</label>
|
||||
<div class="control">{{ register_form.email }}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="id_password">Password:</label>
|
||||
<div class="control">{{ register_form.password }}</div>
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">Sign Up</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
8
bookwyrm/templates/snippets/about.html
Normal file
8
bookwyrm/templates/snippets/about.html
Normal 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>
|
24
bookwyrm/templates/snippets/register_form.html
Normal file
24
bookwyrm/templates/snippets/register_form.html
Normal 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>
|
|
@ -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<code>[A-Za-z0-9]+)/?$', views.invite_page),
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue