From 48256a6d62a78fbfc52eff302823f70cc268907e Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Tue, 13 Sep 2022 19:11:23 +0200 Subject: account creation use default error text --- accounts/views.py | 19 +++---------------- version.txt | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/accounts/views.py b/accounts/views.py index 4a0be18..22e287e 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -354,22 +354,9 @@ def signup(request): else: # get errors from form and add toasts errors = form.errors.as_data() - for field in errors.keys(): - if field == "username": - out_errors.append("Il nome utente può contenere solo lettere e numeri") - else: - password_errors = errors["password2"] - for err in password_errors: - if err.code == "password_mismatch": - out_errors.append("Le due password non sono uguali") - elif err.code == "password_too_similar": - out_errors.append("La password è troppo simile all'username") - elif err.code == "password_too_short": - out_errors.append("La password è troppo corta") - elif err.code == "password_too_common": - out_errors.append("La password è troppo comune") - elif err.code == "password_entirely_numeric": - out_errors.append("La password deve contenere lettere") + errors_list = [x for xs in errors.values() for x in xs] + errors_text = list(map(lambda x: x.message, errors_list)) + out_errors += errors_text else: # create empty form to be filled diff --git a/version.txt b/version.txt index b8dce7b..6239158 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.6 -rev=2 +rev=3 -- cgit v1.2.1