From patchwork Sat Feb 27 09:59:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 1445154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dnhng41NJz9sBJ for ; Sat, 27 Feb 2021 20:59:19 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Dnhng1CjBz3cSp for ; Sat, 27 Feb 2021 20:59:19 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=cbaines.net (client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27; helo=mira.cbaines.net; envelope-from=mail@cbaines.net; receiver=) Received: from mira.cbaines.net (mira.cbaines.net [IPv6:2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]) by lists.ozlabs.org (Postfix) with ESMTP id 4DnhnZ2bnSz3cLK for ; Sat, 27 Feb 2021 20:59:14 +1100 (AEDT) Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:8ac0:b4c7:f5c8:7caa]) by mira.cbaines.net (Postfix) with ESMTPSA id 8C62527BC75 for ; Sat, 27 Feb 2021 09:59:12 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 0bd3dcbb for ; Sat, 27 Feb 2021 09:59:12 +0000 (UTC) From: Christopher Baines To: patchwork@lists.ozlabs.org Subject: [PATCH 1/2] templates: Use form.as_table in registration template. Date: Sat, 27 Feb 2021 09:59:10 +0000 Message-Id: <20210227095911.6290-1-mail@cbaines.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <87eeh1kg05.fsf@cbaines.net> References: <87eeh1kg05.fsf@cbaines.net> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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 @@ {{ error }} - {% endif %} + {% endif %} - - {{ form.first_name.label_tag }} - -{% if form.first_name.errors %} - {{ form.first_name.errors }} -{% endif %} - {{ form.first_name }} -{% if form.first_name.help_text %} -
{{ form.first_name.help_text }}
-{% endif %} - - - - - {{ form.last_name.label_tag }} - -{% if form.last_name.errors %} - {{ form.last_name.errors }} -{% endif %} - {{ form.last_name }} -{% if form.last_name.help_text %} -
{{ form.last_name.help_text }}
-{% endif %} - - - - - - - Your name is used to identify you on the site - - - - - {{ form.email.label_tag }} - -{% if form.email.errors %} - {{ form.email.errors }} -{% endif %} - {{ form.email }} -{% if form.email.help_text %} -
{{ form.email.help_text }}
-{% endif %} - - - - - - - Patchwork will send a confirmation email to this address - - - - - {{ form.username.label_tag }} - -{% if form.username.errors %} - {{ form.username.errors }} -{% endif %} - {{ form.username }} -{% if form.username.help_text %} -
{{ form.username.help_text }}
-{% endif %} - - - - - {{ form.password.label_tag }} - -{% if form.password.errors %} - {{ form.password.errors }} -{% endif %} - {{ form.password }} -{% if form.password.help_text %} -
{{ form.password.help_text }}
-{% endif %} - - + {{ form.as_table }} From patchwork Sat Feb 27 09:59:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 1445153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dnhnc1DKLz9sBJ for ; Sat, 27 Feb 2021 20:59:16 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Dnhnb6ZZfz3cVb for ; Sat, 27 Feb 2021 20:59:15 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=cbaines.net (client-ip=212.71.252.8; helo=mira.cbaines.net; envelope-from=mail@cbaines.net; receiver=) X-Greylist: delayed 1258 seconds by postgrey-1.36 at boromir; Sat, 27 Feb 2021 20:59:14 AEDT Received: from mira.cbaines.net (mira.cbaines.net [212.71.252.8]) by lists.ozlabs.org (Postfix) with ESMTP id 4DnhnZ21Gtz3cJf for ; Sat, 27 Feb 2021 20:59:14 +1100 (AEDT) Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:8ac0:b4c7:f5c8:7caa]) by mira.cbaines.net (Postfix) with ESMTPSA id A70A627BC76 for ; Sat, 27 Feb 2021 09:59:12 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id ace50260 for ; Sat, 27 Feb 2021 09:59:12 +0000 (UTC) From: Christopher Baines To: patchwork@lists.ozlabs.org Subject: [PATCH 2/2] forms: Use a captcha on the registration form. Date: Sat, 27 Feb 2021 09:59:11 +0000 Message-Id: <20210227095911.6290-2-mail@cbaines.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210227095911.6290-1-mail@cbaines.net> References: <87eeh1kg05.fsf@cbaines.net> <20210227095911.6290-1-mail@cbaines.net> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This should help avoid spam registration requests. --- patchwork/forms.py | 3 +++ patchwork/settings/base.py | 1 + 2 files changed, 4 insertions(+) diff --git a/patchwork/forms.py b/patchwork/forms.py index e06cfc1..f02bd29 100644 --- a/patchwork/forms.py +++ b/patchwork/forms.py @@ -8,6 +8,8 @@ from django import forms from django.db.models import Q from django.db.utils import ProgrammingError +from simplemathcaptcha.fields import MathCaptchaField + from patchwork.models import Bundle from patchwork.models import Patch from patchwork.models import State @@ -27,6 +29,7 @@ class RegistrationForm(forms.Form): label=u'Username') password = forms.CharField(widget=forms.PasswordInput(), label='Password') + captcha = MathCaptchaField() def clean_username(self): value = self.cleaned_data['username'] diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py index c1bb9b2..e18ee60 100644 --- a/patchwork/settings/base.py +++ b/patchwork/settings/base.py @@ -21,6 +21,7 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.staticfiles', + 'simplemathcaptcha', 'patchwork', ]