From 09b4821e0b29ece9fe550ec5af60ff31bda1af98 Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Tue, 1 Oct 2024 15:53:40 +0300 Subject: [PATCH] Improve error pages --- backend/donations/views/account_management.py | 2 +- backend/locale/en/LC_MESSAGES/django.po | 50 +++++++++++---- backend/locale/ro/LC_MESSAGES/django.po | 44 ++++++++++--- backend/redirectioneaza/urls.py | 6 +- backend/templates/v1/cont-nou.html | 6 +- .../v2/account/errors/app_missing.html | 11 ---- backend/templates/v2/account/errors/base.html | 20 +++--- .../v2/account/errors/login/app_missing.html | 10 +++ .../v2/account/errors/login/base_login.html | 8 +++ .../account/errors/login/multiple_ngos.html | 10 +++ .../v2/account/errors/login/unknown_role.html | 10 +++ .../v2/account/errors/multiple_ngos.html | 11 ---- .../v2/account/errors/unknown_role.html | 11 ---- backend/templates/v2/account/login.html | 34 +++++++--- .../v2/account/snippets/classic-login.html | 62 +++++++++---------- .../v2/account/snippets/third-party.html | 40 +++++------- 16 files changed, 200 insertions(+), 135 deletions(-) delete mode 100644 backend/templates/v2/account/errors/app_missing.html create mode 100644 backend/templates/v2/account/errors/login/app_missing.html create mode 100644 backend/templates/v2/account/errors/login/base_login.html create mode 100644 backend/templates/v2/account/errors/login/multiple_ngos.html create mode 100644 backend/templates/v2/account/errors/login/unknown_role.html delete mode 100644 backend/templates/v2/account/errors/multiple_ngos.html delete mode 100644 backend/templates/v2/account/errors/unknown_role.html diff --git a/backend/donations/views/account_management.py b/backend/donations/views/account_management.py index 01db07b9..80d97bb9 100644 --- a/backend/donations/views/account_management.py +++ b/backend/donations/views/account_management.py @@ -133,7 +133,7 @@ def post(self, request: HttpRequest): logger.warning("Invalid email or password: {0}".format(email)) context["email"] = email - context["errors"] = "Se pare că această combinație de email și parolă este incorectă." + context["errors"] = _("It seems that this email and password combination is incorrect.") return render(request, self.template_name, context) diff --git a/backend/locale/en/LC_MESSAGES/django.po b/backend/locale/en/LC_MESSAGES/django.po index 3c47dae9..9d7dd2af 100644 --- a/backend/locale/en/LC_MESSAGES/django.po +++ b/backend/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-01 11:24+0300\n" +"POT-Creation-Date: 2024-10-01 13:54+0300\n" "PO-Revision-Date: 2024-02-28 15:45+0000\n" "Last-Translator: Tudor Amariei \n" "Language-Team: English \n" "Language-Team: Romanian {{ csrf_input }}
- Cont nou +

+ Cont nou +

+
diff --git a/backend/templates/v2/account/errors/app_missing.html b/backend/templates/v2/account/errors/app_missing.html deleted file mode 100644 index 3085c40d..00000000 --- a/backend/templates/v2/account/errors/app_missing.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'account/errors/base.html' %} -{% load i18n %} - -{% block content %} -

- {% trans 'Application not activated' %} -

-

- {% trans 'The application is not activated for this user/organization.' %} -

-{% endblock %} diff --git a/backend/templates/v2/account/errors/base.html b/backend/templates/v2/account/errors/base.html index 8ffd2e1f..13dbd9ee 100644 --- a/backend/templates/v2/account/errors/base.html +++ b/backend/templates/v2/account/errors/base.html @@ -2,17 +2,17 @@ {% load static %} {% load i18n %} +{% block content %} +
-{% block title %}{% trans 'Sign In Error' %}{% endblock %} +

+ {% block title %}{% endblock %} +

+

+ {% block message %}{% endblock %} +

-{% block left-side-view %} -
-

- {% trans 'Sign In Error' %} -

+ {% block extra_content %}{% endblock %} - {% block error_message %} -

- {% endblock %} -
+
{% endblock %} diff --git a/backend/templates/v2/account/errors/login/app_missing.html b/backend/templates/v2/account/errors/login/app_missing.html new file mode 100644 index 00000000..38611cd3 --- /dev/null +++ b/backend/templates/v2/account/errors/login/app_missing.html @@ -0,0 +1,10 @@ +{% extends 'account/errors/login/base_login.html' %} +{% load i18n %} + +{% block title %} + {% trans 'Application not activated' %} +{% endblock %} + +{% block message %} + {% trans 'The application is not activated for this user/organization.' %} +{% endblock %} diff --git a/backend/templates/v2/account/errors/login/base_login.html b/backend/templates/v2/account/errors/login/base_login.html new file mode 100644 index 00000000..cff224cb --- /dev/null +++ b/backend/templates/v2/account/errors/login/base_login.html @@ -0,0 +1,8 @@ +{% extends 'account/errors/base.html' %} +{% load i18n %} + +{% block extra_content %} +

+ {% trans "Return to login" %} +

+{% endblock %} diff --git a/backend/templates/v2/account/errors/login/multiple_ngos.html b/backend/templates/v2/account/errors/login/multiple_ngos.html new file mode 100644 index 00000000..f9448d6a --- /dev/null +++ b/backend/templates/v2/account/errors/login/multiple_ngos.html @@ -0,0 +1,10 @@ +{% extends 'account/errors/login/base_login.html' %} +{% load i18n %} + +{% block title %} + {% trans 'Multiple NGOs for this CUI' %} +{% endblock %} + +{% block message %} + {% trans 'Multiple NGOs have been found during synchronization. Admins have been notified and will resolve the issue shortly.' %} +{% endblock %} diff --git a/backend/templates/v2/account/errors/login/unknown_role.html b/backend/templates/v2/account/errors/login/unknown_role.html new file mode 100644 index 00000000..46860bb2 --- /dev/null +++ b/backend/templates/v2/account/errors/login/unknown_role.html @@ -0,0 +1,10 @@ +{% extends 'account/errors/login/base_login.html' %} +{% load i18n %} + +{% block title %} + {% trans 'Unknown role' %} +{% endblock %} + +{% block message %} + {% trans "Your current role isn't supported." %} +{% endblock %} diff --git a/backend/templates/v2/account/errors/multiple_ngos.html b/backend/templates/v2/account/errors/multiple_ngos.html deleted file mode 100644 index eabbf48f..00000000 --- a/backend/templates/v2/account/errors/multiple_ngos.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'account/errors/base.html' %} -{% load i18n %} - -{% block content %} -

- {% trans 'Multiple NGOs for this CUI' %} -

-

- {% trans 'Multiple NGOs have been found during synchronization. Admins have been notified and will resolve the issue shortly.'%} -

-{% endblock %} diff --git a/backend/templates/v2/account/errors/unknown_role.html b/backend/templates/v2/account/errors/unknown_role.html deleted file mode 100644 index bc3662c6..00000000 --- a/backend/templates/v2/account/errors/unknown_role.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'account/errors/base.html' %} -{% load i18n %} - -{% block content %} -

- {% trans 'Unknown role' %} -

-

- {% trans "Your current role isn't supported." %} -

-{% endblock %} diff --git a/backend/templates/v2/account/login.html b/backend/templates/v2/account/login.html index 390d6fda..815445c2 100644 --- a/backend/templates/v2/account/login.html +++ b/backend/templates/v2/account/login.html @@ -11,18 +11,34 @@ {% endelement %}
-
+
- {% if not SOCIALACCOUNT_ONLY %} - {% include "account/snippets/classic-login.html" %} - {% endif %} +
+ {% if errors %} +
+
+ + + {% trans "Error!" %} + + {{ errors }} +
+
+ {% endif %} +
- {% if SOCIALACCOUNT_ONLY or SOCIALACCOUNT_ENABLED %} - {% include "account/snippets/third-party.html" %} - {% endif %} + {% if SOCIALACCOUNT_ONLY or SOCIALACCOUNT_ENABLED %} + {% include "account/snippets/third-party.html" %} + {% endif %} -
-
+ {% if not SOCIALACCOUNT_ONLY %} +
+ + {% include "account/snippets/classic-login.html" %} + {% endif %} + +
+
{% endblock content %} diff --git a/backend/templates/v2/account/snippets/classic-login.html b/backend/templates/v2/account/snippets/classic-login.html index f388d2d6..a3536d43 100644 --- a/backend/templates/v2/account/snippets/classic-login.html +++ b/backend/templates/v2/account/snippets/classic-login.html @@ -2,40 +2,36 @@ {% load allauth %} {% load socialaccount %} -
- {% if errors %} -
-
- - Oops! {{ errors }} -
-
- {% endif %} -
+
+ {% csrf_token %} - - {% csrf_token %} +
+

+ {% trans "Login with email & password" %} +

-
- Login -
-
- -
-
-
-
- -
-
-
-
- + + +
+
+ +
+
+
+
+ +
+
+
+ -
-
- + Am uitat parola + Vreau un cont nou +
+
+
+ diff --git a/backend/templates/v2/account/snippets/third-party.html b/backend/templates/v2/account/snippets/third-party.html index 0ca1f38b..f2453ee6 100644 --- a/backend/templates/v2/account/snippets/third-party.html +++ b/backend/templates/v2/account/snippets/third-party.html @@ -2,36 +2,30 @@ {% load allauth %} {% load socialaccount %} -{% get_providers as socialaccount_providers %} +
-{% if socialaccount_providers %} +

+ {% trans "Login through NGO Hub" %} +

- {% if not SOCIALACCOUNT_ONLY %} -
+ {% if SOCIALACCOUNT_ONLY %} +

+ {% trans "To access your account, you need to authenticate through NGO Hub." %} +

{% endif %} -
-
-

- {% translate "Login through NGO Hub" %} -

+ - {% if SOCIALACCOUNT_ONLY %} -

- {% trans "To access your account, you need to authenticate through NGO Hub." %} -

- {% endif %} + - -
- -
+
- +
-
-{% endif %} +