From b322cd1ffbf3e18e4a7bf192bbfe98d9953ff9de Mon Sep 17 00:00:00 2001 From: Alex Ottr Date: Sun, 7 Apr 2024 17:18:58 +0200 Subject: [PATCH] fix error messages on username field and missing i18n ref --- core/forms.py | 12 ++++++------ paw/__init__.py | 2 +- paw/templates/core/account_finish.html | 16 ++++++++++------ paw/templates/core/register.html | 8 ++++++-- .../partials/ticket_priority_badge.html | 1 + 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/core/forms.py b/core/forms.py index a920499..54724a2 100644 --- a/core/forms.py +++ b/core/forms.py @@ -28,8 +28,8 @@ USERNAME_REGEX_FIELD = forms.RegexField( max_length=50, regex=r'^[a-zA-Z0-9-_@]+$', error_messages={ - 'required': _('Please enter your name'), - 'invalid': _('Alphanumeric characters and underscores and dashes only (a-z, 0-9, _, -, @)') + 'required': _('Please enter a username'), + 'invalid': _('Username can only have alphanumeric characters and underscores and dashes (a-z, 0-9, _, -, @)') }, widget=forms.TextInput( attrs={'placeholder': _('Username'), 'class': 'input input-bordered w-full'}), @@ -55,20 +55,20 @@ class RegisterForm(forms.Form): if password != password_confirm: raise forms.ValidationError( - "password and password_confirm does not match" + "Password and Confirm Password do not match." ) if len(password) < 10: raise forms.ValidationError( - "password must be at least 10 characters long" + "Password must be at least 10 characters long." ) if PawUser.objects.filter(username=cleaned_data.get("username")).exists(): raise forms.ValidationError( - "An account with this username already exists" + "An account with this username already exists." ) if PawUser.objects.filter(email=cleaned_data.get("email")).exists(): raise forms.ValidationError( - "An account with this email already exists" + "An account with this email already exists." ) return cleaned_data diff --git a/paw/__init__.py b/paw/__init__.py index 71a898a..d635a5f 100644 --- a/paw/__init__.py +++ b/paw/__init__.py @@ -1,5 +1,5 @@ from django import get_version -VERSION = (0, 5, 8, "final", 0) +VERSION = (0, 5, 9, "final", 0) __version__ = get_version(VERSION) diff --git a/paw/templates/core/account_finish.html b/paw/templates/core/account_finish.html index b588893..f8f3b0f 100644 --- a/paw/templates/core/account_finish.html +++ b/paw/templates/core/account_finish.html @@ -10,17 +10,21 @@

{% trans 'Register a new account' %}

+
  • {% trans 'Authenticate' %}
  • +
  • {% trans 'Set up account' %}
  • +
  • {% trans 'Done' %}
  • +
    {% csrf_token %} - {% if form.non_field_errors %} + {% if form.errors %} {% endif %} diff --git a/paw/templates/core/register.html b/paw/templates/core/register.html index 557ab23..3df2012 100644 --- a/paw/templates/core/register.html +++ b/paw/templates/core/register.html @@ -8,10 +8,14 @@ {% csrf_token %} - {% if form.non_field_errors %} + {% if form.errors %} {% endif %} diff --git a/paw/templates/partials/ticket_priority_badge.html b/paw/templates/partials/ticket_priority_badge.html index c912d93..159c60c 100644 --- a/paw/templates/partials/ticket_priority_badge.html +++ b/paw/templates/partials/ticket_priority_badge.html @@ -1,4 +1,5 @@ {% block ticket_priority_badge %} +{% load i18n %} {% if ticket.priority == 3 %} {% trans 'Low' %} {% elif ticket.priority == 2 %} -- 2.51.2