[PATCH 1/2] templates: Use form.as_table in registration template.
Christopher Baines
mail at cbaines.net
Sat Feb 27 20:59:10 AEDT 2021
This should make changes to the registration form easier. I'm
particularly thinking about adding in the Django simple math captcha.
---
htdocs/css/style.css | 4 +-
patchwork/forms.py | 9 ++-
.../templates/patchwork/registration.html | 81 +------------------
3 files changed, 11 insertions(+), 83 deletions(-)
diff --git a/htdocs/css/style.css b/htdocs/css/style.css
index 243caa0..e417c69 100644
--- a/htdocs/css/style.css
+++ b/htdocs/css/style.css
@@ -398,10 +398,10 @@ table.form th {
padding-top: 0.6em;
}
-table.form td.form-help {
+span.helptext {
font-size: smaller;
padding-bottom: 1em;
- padding-top: 0em;
+ padding-top: 1em;
}
table.form tr td.submitrow {
diff --git a/patchwork/forms.py b/patchwork/forms.py
index 24322c7..e06cfc1 100644
--- a/patchwork/forms.py
+++ b/patchwork/forms.py
@@ -16,10 +16,15 @@ from patchwork.models import UserProfile
class RegistrationForm(forms.Form):
first_name = forms.CharField(max_length=30, required=False)
- last_name = forms.CharField(max_length=30, required=False)
+ last_name = forms.CharField(max_length=30,
+ required=False,
+ help_text='Your name is used to identify you on '
+ 'the site')
+ email = forms.EmailField(max_length=100, label=u'Email address',
+ help_text='Patchwork will send a confirmation email '
+ 'to this address')
username = forms.RegexField(regex=r'^\w+$', max_length=30,
label=u'Username')
- email = forms.EmailField(max_length=100, label=u'Email address')
password = forms.CharField(widget=forms.PasswordInput(),
label='Password')
diff --git a/patchwork/templates/patchwork/registration.html b/patchwork/templates/patchwork/registration.html
index 5280b66..6cdbc5a 100644
--- a/patchwork/templates/patchwork/registration.html
+++ b/patchwork/templates/patchwork/registration.html
@@ -27,86 +27,9 @@
<tr>
<td colspan="2">{{ error }}</td>
</tr>
- {% endif %}
+ {% endif %}
- <tr>
- <td>{{ form.first_name.label_tag }}</td>
- <td>
-{% if form.first_name.errors %}
- {{ form.first_name.errors }}
-{% endif %}
- {{ form.first_name }}
-{% if form.first_name.help_text %}
- <div class="help_text"/>{{ form.first_name.help_text }}</div>
-{% endif %}
- </td>
- </tr>
-
- <tr>
- <td>{{ form.last_name.label_tag }}</td>
- <td>
-{% if form.last_name.errors %}
- {{ form.last_name.errors }}
-{% endif %}
- {{ form.last_name }}
-{% if form.last_name.help_text %}
- <div class="help_text"/>{{ form.last_name.help_text }}</div>
-{% endif %}
- </td>
- </tr>
-
- <tr>
- <td></td>
- <td class="form-help">
- Your name is used to identify you on the site
- </td>
- </tr>
-
- <tr>
- <td>{{ form.email.label_tag }}</td>
- <td>
-{% if form.email.errors %}
- {{ form.email.errors }}
-{% endif %}
- {{ form.email }}
-{% if form.email.help_text %}
- <div class="help_text"/>{{ form.email.help_text }}</div>
-{% endif %}
- </td>
- </tr>
-
- <tr>
- <td></td>
- <td class="form-help">
- Patchwork will send a confirmation email to this address
- </td>
- </tr>
-
- <tr>
- <td>{{ form.username.label_tag }}</td>
- <td>
-{% if form.username.errors %}
- {{ form.username.errors }}
-{% endif %}
- {{ form.username }}
-{% if form.username.help_text %}
- <div class="help_text"/>{{ form.username.help_text }}</div>
-{% endif %}
- </td>
- </tr>
-
- <tr>
- <td>{{ form.password.label_tag }}</td>
- <td>
-{% if form.password.errors %}
- {{ form.password.errors }}
-{% endif %}
- {{ form.password }}
-{% if form.password.help_text %}
- <div class="help_text"/>{{ form.password.help_text }}</div>
-{% endif %}
- </td>
- </tr>
+ {{ form.as_table }}
<tr>
<td colspan="2" class="submitrow">
--
2.30.0
More information about the Patchwork
mailing list