diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-20 21:57:11 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-20 21:57:11 +0000 |
commit | ba5987b67417ef6af563dbe7c8405f4c6182eaee (patch) | |
tree | 7fbecca514f01e2e4cd7d04e8629ba95159d198e /core | |
parent | d79ffd8354413f4f295e13ecdea31d90d7722af5 (diff) | |
download | troggle-ba5987b67417ef6af563dbe7c8405f4c6182eaee.tar.gz troggle-ba5987b67417ef6af563dbe7c8405f4c6182eaee.tar.bz2 troggle-ba5987b67417ef6af563dbe7c8405f4c6182eaee.zip |
form now working with basic validation
Diffstat (limited to 'core')
-rw-r--r-- | core/views/user_registration.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/views/user_registration.py b/core/views/user_registration.py index df00ed9..d4ce58e 100644 --- a/core/views/user_registration.py +++ b/core/views/user_registration.py @@ -1,6 +1,7 @@ from django import forms
from django.http import HttpResponseRedirect
from django.shortcuts import render
+from django.core.exceptions import ValidationError
"""
This is the new individual user login registration, instead of everyone signing
@@ -13,7 +14,10 @@ def register(request): form = register_form(request.POST)
if form.is_valid():
# <process form cleaned data>
- return HttpResponseRedirect("/success/")
+ un = form.cleaned_data["username"]
+ pw= form.cleaned_data["password1"]
+
+ return HttpResponseRedirect("/accounts/login/")
else:
form = register_form(initial={"visible": "True"})
@@ -26,17 +30,31 @@ class register_form(forms.Form): # not a model-form, just a form-form attrs={"size": 35, "placeholder": "e.g. anathema-device",
"style": "vertical-align: text-top;"}
))
+ email = forms.CharField(strip=True, required=True,
+ label="email",
+ widget=forms.TextInput(
+ attrs={"size": 35, "placeholder": "e.g. anathema@potatohut.exp",
+ "style": "vertical-align: text-top;"}
+ ))
password1 = forms.CharField(strip=True, required=True,
- label="Password",
+ label="Troggle password",
widget=forms.TextInput(
attrs={"size": 30, "placeholder": "your new login password",
"style": "vertical-align: text-top;"}
))
password2 = forms.CharField(strip=True, required=True,
- label="Re-type your password",
+ label="Re-type your troggle password",
widget=forms.TextInput(
attrs={"size": 30, "placeholder": "same as the password above",
"style": "vertical-align: text-top;"}
) )
- # )
\ No newline at end of file + def clean(self):
+ cleaned_data = super().clean()
+ pw1 = cleaned_data.get("password1")
+ pw2 = cleaned_data.get("password2")
+
+ if pw1 != pw2:
+ raise ValidationError(
+ "Retyped password does not match initial password: please fix this."
+ )
\ No newline at end of file |