diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-24 01:10:45 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-24 01:10:45 +0000 |
commit | 072a04487d43be292e3eb9eded5394f2c266d0ba (patch) | |
tree | 0d2ae3ec7fa2db6fe93b33e7d4102301c4834f1e | |
parent | 2daad646e3e8e7039758d9e3524fcfd2b52c4920 (diff) | |
download | troggle-072a04487d43be292e3eb9eded5394f2c266d0ba.tar.gz troggle-072a04487d43be292e3eb9eded5394f2c266d0ba.tar.bz2 troggle-072a04487d43be292e3eb9eded5394f2c266d0ba.zip |
stitch together the login sequence better
-rw-r--r-- | core/views/auth.py | 2 | ||||
-rw-r--r-- | core/views/other.py | 4 | ||||
-rw-r--r-- | core/views/signup.py | 6 | ||||
-rw-r--r-- | templates/errors/frontpage.html (renamed from templates/frontpage.html) | 2 | ||||
-rw-r--r-- | templates/login/index.html | 34 | ||||
-rw-r--r-- | templates/login/tasks.html (renamed from templates/tasks.html) | 0 |
6 files changed, 34 insertions, 14 deletions
diff --git a/core/views/auth.py b/core/views/auth.py index 966a100..db17ae3 100644 --- a/core/views/auth.py +++ b/core/views/auth.py @@ -57,7 +57,7 @@ def expologin(request): else: # going to login page when you are already logged in from django.contrib.admin.templatetags import log - return render(request, "tasks.html", {}) + return render(request, "login/tasks.html", {}) # POST username = request.POST["username"] diff --git a/core/views/other.py b/core/views/other.py index f1a7bdf..4019e73 100644 --- a/core/views/other.py +++ b/core/views/other.py @@ -104,12 +104,12 @@ def frontpage(request): """never seen in common practice. Logon should redirect here when this is more useful""" if request.user.is_authenticated: - return render(request, "tasks.html") + return render(request, "login/tasks.html") expeditions = Expedition.objects.order_by("-year") logbookentry = LogbookEntry cave = Cave - return render(request, "frontpage.html", locals()) + return render(request, "login/frontpage.html", locals()) @login_required_if_public diff --git a/core/views/signup.py b/core/views/signup.py index 177b2b7..c0360f9 100644 --- a/core/views/signup.py +++ b/core/views/signup.py @@ -3,6 +3,7 @@ import re from pathlib import Path import django.forms as forms +from django.contrib.auth.decorators import login_required from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render from django.urls import reverse @@ -19,13 +20,16 @@ from troggle.core.utils import ( ) from troggle.core.views.editor_helpers import HTMLarea -from .auth import login_required_if_public """The new user signup form and expo user management system in 2025. """ @ensure_csrf_cookie +@login_required def signup(request): + if request.user.username in ["expo", "expoadmin"]: + return redirect("/accounts/newregister/") + # /accounts/login/?next=/signup if request.method == "POST": # If the form has been submitted... pageform = ExpoSignupForm(request.POST) # A form bound to the POST data if pageform.is_valid(): diff --git a/templates/frontpage.html b/templates/errors/frontpage.html index e2ff96b..461bce9 100644 --- a/templates/frontpage.html +++ b/templates/errors/frontpage.html @@ -22,7 +22,7 @@ Here you will find information about the {{expedition.objects.count}} expedition You are not logged-in, so a few of the unpublished cave survey pages will not be visible to you. And of course you will not be able to edit anything. </p> <!-- <img src="/expofiles/photos/2007/selected/eishoehle5nial.jpg">--> -<img src="/expofiles/photos/2007/selected/eishoehle4nial.jpg"> +<img src="/expofiles/photos/2007/selected/eishoehle4nial.jpg" width="350px"> <p>Nial in <a href="/expofiles/photos/2007/selected/">Eishohle in 2007</a>. {% endblock content %} diff --git a/templates/login/index.html b/templates/login/index.html index 889149d..62e3d51 100644 --- a/templates/login/index.html +++ b/templates/login/index.html @@ -4,11 +4,16 @@ <!-- To understand how this all works, with invisible default behaviour, see troggle/templates/login/logout.html -troggle/templates/registration/ +troggle/templates/login/register.html +troggle/templates/registration/* because magic This is because Django is Opinionated and does lots of Invisible Defaults --> +<style> +input, label {font-family: monospace; font-weight: bold; text-align:right; font-size: 130%; padding: 0.5em; } +</style> + <div class='middle'> <h2>Troggle user login</h2> </div> @@ -23,7 +28,7 @@ This is because Django is Opinionated and does lots of Invisible Defaults <p>{{message }}</p> </div> {% endif %} -<h3>Troggle ordinary user login - no access to Django control panel</h3> +<h3>Troggle login - no administrative access</h3> <p>(This is using template login/index.html) <div style='width: 250px;' class='middle3 login'> <div class='align-center'> @@ -31,14 +36,14 @@ This is because Django is Opinionated and does lots of Invisible Defaults <div class='space'></div> {% if invalid %} <p class='error'>The username and password you provided don't match. Please try again.</p> - <p>Have you <a href='/accounts/forgottenpassword/'>forgotten your password</a>?<br/> - Or perhaps <a href='/accounts/forgottenusername/'>your username</a>?</p> - - <p>Neither of those links work yet, by the way, I'm only trying to *appear* helpful. - + <p> + Have you <a href='/people_ids'>forgotten your username</a>?<br/> + Or have you <a href='/accounts/password_reset/'>forgotten your password</a>?<br/> + </p> + <div class='space'></div> {% endif %} -<div class='align-center'> +<div style='width: 250px; text-align: right; '> <form action="" method="post" accept-charset="utf-8">{% csrf_token %} <table class='form'> <tr><th><label for="id_username">Username:</label></th><td><input id="id_username" type="text" name="username" maxlength="30" /></td></tr> @@ -47,8 +52,19 @@ This is because Django is Opinionated and does lots of Invisible Defaults <div class='space'></div> <br/> - <p><input type="submit" value="Login →"></p> + + <button class="fancybutton" style="padding: 0.5em 25px; font-size: 100%;" type = "submit" > + Login → + </button> + </div> </form> + <p> + Do you want to <a href="/accounts/register/">register for a personal login</a> <b>having been on expo before</b>? + <p> + or + <p> + Is this your first time here and do you want to <a href="/accounts/newregister/">register as a new user</a>? + </p> </div> <hr><hr> {{form}} diff --git a/templates/tasks.html b/templates/login/tasks.html index f0be3ab..f0be3ab 100644 --- a/templates/tasks.html +++ b/templates/login/tasks.html |