From e9b5f8f3efdf8b2ea18db335b7dd63a02be40b6d Mon Sep 17 00:00:00 2001 From: Dani Hodovic Date: Mon, 20 May 2024 23:28:24 -0300 Subject: [PATCH] ci: run manage.py validate_templates and djlint --- .github/workflows/ci-cd.yml | 5 ++ allauth_ui/templates/account/_button.html | 23 +++-- allauth_ui/templates/account/_links.html | 7 +- .../templates/account/_non_field_errors.html | 12 ++- .../templates/account/_render_form.html | 32 +++---- allauth_ui/templates/account/base.html | 55 ++++++------ .../templates/account/email_confirm.html | 37 ++++---- allauth_ui/templates/account/login.html | 87 +++++++++---------- allauth_ui/templates/account/logout.html | 19 ++-- .../templates/account/password_reset.html | 29 ++++--- .../account/password_reset_done.html | 33 ++++--- .../account/password_reset_from_key.html | 53 ++++++----- .../account/password_reset_from_key_done.html | 22 +++-- allauth_ui/templates/account/signup.html | 25 +++--- .../templates/account/signup_closed.html | 22 ++--- .../templates/account/verification_sent.html | 25 +++--- .../socialaccount/authentication_error.html | 28 +++--- allauth_ui/templates/socialaccount/base.html | 2 +- .../templates/socialaccount/connections.html | 84 +++++++++--------- allauth_ui/templates/socialaccount/login.html | 38 ++++---- .../templates/socialaccount/signup.html | 30 +++---- .../socialaccount/snippets/provider_list.html | 19 ++-- .../socialaccount/snippets/social_login.html | 18 ++-- 23 files changed, 356 insertions(+), 349 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 76112e1..344f3a6 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -62,6 +62,11 @@ jobs: source .venv/bin/activate ./manage.py validate_templates + - name: Django Template/Html Lint (djlint) + run: | + source .venv/bin/activate + djlint . --check + test: name: Test runs-on: ubuntu-latest diff --git a/allauth_ui/templates/account/_button.html b/allauth_ui/templates/account/_button.html index cdba0dd..6bfd087 100644 --- a/allauth_ui/templates/account/_button.html +++ b/allauth_ui/templates/account/_button.html @@ -1,15 +1,12 @@ {% with base_color=base_color|default:"bg-blue" %} - + + {% endwith %} diff --git a/allauth_ui/templates/account/_links.html b/allauth_ui/templates/account/_links.html index 6fe1d9f..f43b790 100644 --- a/allauth_ui/templates/account/_links.html +++ b/allauth_ui/templates/account/_links.html @@ -1,5 +1,6 @@
- Home - / - Log In + Home + / + Log In
diff --git a/allauth_ui/templates/account/_non_field_errors.html b/allauth_ui/templates/account/_non_field_errors.html index f3d7cf3..1998af7 100644 --- a/allauth_ui/templates/account/_non_field_errors.html +++ b/allauth_ui/templates/account/_non_field_errors.html @@ -1,9 +1,7 @@ {% if form.non_field_errors %} - + {% endif %} diff --git a/allauth_ui/templates/account/_render_form.html b/allauth_ui/templates/account/_render_form.html index 35158cd..c9f8194 100644 --- a/allauth_ui/templates/account/_render_form.html +++ b/allauth_ui/templates/account/_render_form.html @@ -1,25 +1,21 @@ {% load widget_tweaks %} - {% csrf_token %} - {% if redirect_field_value %} - + {% endif %} - {% include "account/_non_field_errors.html" %} - {% for field in form.visible_fields %} -
- {{ field|add_label_class:"font-semibold text-xs" }} - {% if field.errors %} - {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 border-red-500 rounded focus:outline-none focus:ring-2" %} - {% else %} - {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 rounded focus:outline-none focus:ring-2" %} - {% endif %} - {% for error in field.errors %} - - {{ error }} - - {% endfor %} -
+
+ {{ field|add_label_class:"font-semibold text-xs" }} + {% if field.errors %} + {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 border-red-500 rounded focus:outline-none focus:ring-2" %} + {% else %} + {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 rounded focus:outline-none focus:ring-2" %} + {% endif %} + {% for error in field.errors %} + {{ error }} + {% endfor %} +
{% endfor %} diff --git a/allauth_ui/templates/account/base.html b/allauth_ui/templates/account/base.html index 23b8008..e406ce0 100644 --- a/allauth_ui/templates/account/base.html +++ b/allauth_ui/templates/account/base.html @@ -1,32 +1,33 @@ {% load static %} - - - - - {% block head_title %}{% endblock %} - - {% block extra_head %} - {% endblock %} - - - {% if messages %} -
- {% for message in messages %} - - {% endfor %} -
- {% endif %} - {% block content %} -
-
- {% block whitebox %} + + + + + + {% block head_title %}{% endblock %} + + + {% block extra_head %}{% endblock %} + + + {% if messages %} +
+ {% for message in messages %} + + {% endfor %} +
+ {% endif %} + {% block content %} +
+
+ {% block whitebox %}{% endblock %} +
+
{% endblock %} -
-
- {% endblock %} - + diff --git a/allauth_ui/templates/account/email_confirm.html b/allauth_ui/templates/account/email_confirm.html index 0734fb9..2da8a4d 100644 --- a/allauth_ui/templates/account/email_confirm.html +++ b/allauth_ui/templates/account/email_confirm.html @@ -1,27 +1,28 @@ {% extends "account/base.html" %} - {% load i18n %} {% load account %} - -{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %} - +{% block head_title %} + {% trans "Confirm E-mail Address" %} +{% endblock %} {% block whitebox %} -

{% trans "Confirm E-mail Address" %}

-{% if confirmation %} -

- {% blocktrans with confirmation.email_address.email as email %} +

{% trans "Confirm E-mail Address" %}

+ {% if confirmation %} +

+ {% blocktrans with confirmation.email_address.email as email %} Please confirm that {{ email }} is an e-mail address for user {{ user_display }}. {% endblocktrans %} -

-
- {% include "account/_render_form.html" %} - {% include "account/_button.html" with text="Confirm" %} -
-{% else %} -{% url 'account_email' as email_url %} - {% blocktrans %} +

+
+ {% include "account/_render_form.html" %} + {% include "account/_button.html" with text="Confirm" %} +
+ {% else %} + {% url 'account_email' as email_url %} + {% blocktrans %} This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request. {% endblocktrans %} -{% endif %} -{% include "account/_links.html" %} + {% endif %} + {% include "account/_links.html" %} {% endblock %} diff --git a/allauth_ui/templates/account/login.html b/allauth_ui/templates/account/login.html index 5b2f497..a0eac01 100644 --- a/allauth_ui/templates/account/login.html +++ b/allauth_ui/templates/account/login.html @@ -1,54 +1,47 @@ {% extends "account/base.html" %} {% load i18n account allauth_ui widget_tweaks %} - {% block head_title %} - {% translate "Sign in" %} + {% translate "Sign in" %} {% endblock %} - {% block whitebox %} -

Sign in

-
- {% csrf_token %} - - {% include "account/_non_field_errors.html" %} - - {% for field in form.visible_fields %} - {% if field.name != "remember" %} -
- {{ field|add_label_class:"font-semibold text-xs" }} - {% if field.errors %} - {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 border-red-500 rounded focus:outline-none focus:ring-2" %} - {% else %} - {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 rounded focus:outline-none focus:ring-2" %} +

Sign in

+ + {% csrf_token %} + {% include "account/_non_field_errors.html" %} + {% for field in form.visible_fields %} + {% if field.name != "remember" %} +
+ {{ field|add_label_class:"font-semibold text-xs" }} + {% if field.errors %} + {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 border-red-500 rounded focus:outline-none focus:ring-2" %} + {% else %} + {% render_field field class="flex items-center w-64 h-12 px-4 pb-2 mt-2 rounded focus:outline-none focus:ring-2" %} + {% endif %} + {% for error in field.errors %} + {{ error }} + {% endfor %} +
+ {% endif %} + {% endfor %} + {% translate "Login" as login_text %} + {% include "account/_button.html" with text=login_text %} + + {% if redirect_field_value %} + + {% endif %} + + {% check_allauth_socialaccount_installed as is_allauth_socialaccount_installed %} + {% if is_allauth_socialaccount_installed %} + {% include "socialaccount/snippets/social_login.html" %} {% endif %} - {% for error in field.errors %} - - {{ error }} - - {% endfor %} -
- {% endif %} - {% endfor %} - - {% translate "Login" as login_text %} - {% include "account/_button.html" with text=login_text %} - -
- {% translate "Forgot Password" %} - - / - {% translate "Sign Up" %} -
- - {% if redirect_field_value %} - - {% endif %} - - - -{% check_allauth_socialaccount_installed as is_allauth_socialaccount_installed %} -{% if is_allauth_socialaccount_installed %} -{% include "socialaccount/snippets/social_login.html" %} -{% endif %} - {% endblock %} diff --git a/allauth_ui/templates/account/logout.html b/allauth_ui/templates/account/logout.html index e518728..4d77aec 100644 --- a/allauth_ui/templates/account/logout.html +++ b/allauth_ui/templates/account/logout.html @@ -1,12 +1,13 @@ {% extends "account/base.html" %} - -{% block head_title %}{% translate "Sign out" %}{% endblock %} - +{% load i18n %} +{% block head_title %} + {% translate "Sign out" %} +{% endblock %} {% block whitebox %} -
- {% csrf_token %} -

{% translate "Are you sure you want to sign out? %}

- {% translate "Sign out" as signout_message } - {% include "account/_button.html" with text=signout_message %} -
+
+ {% csrf_token %} +

{% translate "Are you sure you want to sign out?" %}

+ {% translate "Sign out" as signout_message } + {% include "account/_button.html" with text=signout_message %} +
{% endblock %} diff --git a/allauth_ui/templates/account/password_reset.html b/allauth_ui/templates/account/password_reset.html index f211f00..097309a 100644 --- a/allauth_ui/templates/account/password_reset.html +++ b/allauth_ui/templates/account/password_reset.html @@ -1,16 +1,19 @@ {% extends "account/base.html" %} - -{% block head_title %}{% translate "Password Reset" %}{% endblock %} - +{% load i18n %} +{% block head_title %} + {% translate "Password Reset" %} +{% endblock %} {% block whitebox %} -

{% translate "Password Reset" %}

-

- {% translate "Enter your user account's verified email address and we will send you a password reset link." %} -

-
- {% include "account/_render_form.html" %} - {% translate "Reset my password" as reset_text %} - {% include "account/_button.html" with text=reset_text %} -
-{% include "account/_links.html" %} +

{% translate "Password Reset" %}

+

+ {% translate "Enter your user account's verified email address and we will send you a password reset link." %} +

+
+ {% include "account/_render_form.html" %} + {% translate "Reset my password" as reset_text %} + {% include "account/_button.html" with text=reset_text %} +
+ {% include "account/_links.html" %} {% endblock %} diff --git a/allauth_ui/templates/account/password_reset_done.html b/allauth_ui/templates/account/password_reset_done.html index ac8e374..a319ced 100644 --- a/allauth_ui/templates/account/password_reset_done.html +++ b/allauth_ui/templates/account/password_reset_done.html @@ -1,17 +1,22 @@ {% extends "account/base.html" %} - -{% block head_title %}{% translate "Password Reset" %}{% endblock %} - +{% load i18n %} +{% block head_title %} + {% translate "Password Reset" %} +{% endblock %} {% block content %} -
-
-

{% translate "Reset email sent" %}

- - - {% include "account/_links.html" %} -
-
+
+
+

{% translate "Reset email sent" %}

+ + {% include "account/_links.html" %} +
+
{% endblock %} diff --git a/allauth_ui/templates/account/password_reset_from_key.html b/allauth_ui/templates/account/password_reset_from_key.html index 042dc08..6711a83 100644 --- a/allauth_ui/templates/account/password_reset_from_key.html +++ b/allauth_ui/templates/account/password_reset_from_key.html @@ -1,30 +1,35 @@ {% extends "account/base.html" %} - {% load i18n %} - -{% block head_title %}{% translate "Change Password" %}{% endblock %} - +{% block head_title %} + {% translate "Change Password" %} +{% endblock %} {% block whitebox %} -

{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}

-{% if token_fail %} - + {% else %} + {% if form %} +
+ {% include "account/_render_form.html" %} + {% translate "Change password" as change_text %} + {% include "account/_button.html" with text=change_text %} +
+ {% else %} +

{% trans 'Your password is now changed.' %}

+ {% endif %} + {% endif %} {% endblock %} diff --git a/allauth_ui/templates/account/password_reset_from_key_done.html b/allauth_ui/templates/account/password_reset_from_key_done.html index c8dccc3..9611168 100644 --- a/allauth_ui/templates/account/password_reset_from_key_done.html +++ b/allauth_ui/templates/account/password_reset_from_key_done.html @@ -1,16 +1,14 @@ {% extends "account/base.html" %} - {% load i18n %} - -{% block head_title %}{% trans "Changed Password" %}{% endblock %} - +{% block head_title %} + {% trans "Changed Password" %} +{% endblock %} {% block content %} -
-
-

{% trans "Changed Password" %}

-

{% trans 'Your password is now changed.' %}

- - {% include "account/_links.html" %} -
-
+
+
+

{% trans "Changed Password" %}

+

{% trans 'Your password is now changed.' %}

+ {% include "account/_links.html" %} +
+
{% endblock %} diff --git a/allauth_ui/templates/account/signup.html b/allauth_ui/templates/account/signup.html index d793a0c..c2dafff 100644 --- a/allauth_ui/templates/account/signup.html +++ b/allauth_ui/templates/account/signup.html @@ -1,13 +1,18 @@ {% extends "account/base.html" %} - -{% block head_title %}{% translate "Sign up" %}{% endblock %} - +{% load i18n %} +{% block head_title %} + {% translate "Sign up" %} +{% endblock %} {% block whitebox %} -

Sign up

-
- {% include "account/_render_form.html" %} - {% translate "Sign up" as signup_text %} - {% include "account/_button.html" with text=signup_text %} -
-{% translate "Already have an account? Sign in." %} +

Sign up

+
+ {% include "account/_render_form.html" %} + {% translate "Sign up" as signup_text %} + {% include "account/_button.html" with text=signup_text %} +
+ {% translate "Already have an account? Sign in." %} {% endblock %} diff --git a/allauth_ui/templates/account/signup_closed.html b/allauth_ui/templates/account/signup_closed.html index 2858386..0a04cc4 100644 --- a/allauth_ui/templates/account/signup_closed.html +++ b/allauth_ui/templates/account/signup_closed.html @@ -1,14 +1,14 @@ {% extends "account/base.html" %} -{% load i18n %} -{% load allauth %} - -{% block head_title %}{% trans "Sign Up Closed" %}{% endblock head_title %} +{% load i18n account %} +{% block head_title %} + {% trans "Sign Up Closed" %} +{% endblock head_title %} {% block content %} -
-
-

{% trans "Sign Up Closed" %}

-

{% trans "We are sorry, but the sign up is currently closed." %}

- {% include "account/_links.html" %} -
-
+
+
+

{% trans "Sign Up Closed" %}

+

{% trans "We are sorry, but the sign up is currently closed." %}

+ {% include "account/_links.html" %} +
+
{% endblock content %} diff --git a/allauth_ui/templates/account/verification_sent.html b/allauth_ui/templates/account/verification_sent.html index 9fc4fce..0ff1960 100644 --- a/allauth_ui/templates/account/verification_sent.html +++ b/allauth_ui/templates/account/verification_sent.html @@ -1,20 +1,19 @@ {% extends "account/base.html" %} - {% load i18n %} - -{% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %} - +{% block head_title %} + {% trans "Verify Your E-mail Address" %} +{% endblock %} {% block content %} -
-
-

{% trans "Verify Your E-mail Address" %}

-

- {% blocktrans %} +

+
+

{% trans "Verify Your E-mail Address" %}

+

+ {% blocktrans %} We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes. {% endblocktrans %} -

- {% include "account/_links.html" %} -
-
+

+ {% include "account/_links.html" %} +
+
{% endblock %} diff --git a/allauth_ui/templates/socialaccount/authentication_error.html b/allauth_ui/templates/socialaccount/authentication_error.html index 5f1b2f8..f07ab31 100644 --- a/allauth_ui/templates/socialaccount/authentication_error.html +++ b/allauth_ui/templates/socialaccount/authentication_error.html @@ -1,19 +1,17 @@ {% extends "socialaccount/base.html" %} - {% load i18n %} - -{% block head_title %}{% trans "Social Network Login Failure" %}{% endblock %} - +{% block head_title %} + {% trans "Social Network Login Failure" %} +{% endblock %} {% block content %} -
-
-

{% trans "Social Network Login Failure" %}

- -

- {% trans "An error occurred while attempting to login via your social network account." %} -

-

Code: {{ auth_error.code }}

-

Error: {{ auth_error.exception }}

-
-
+
+
+

{% trans "Social Network Login Failure" %}

+

{% trans "An error occurred while attempting to login via your social network account." %}

+

+ Code: {{ auth_error.code }} +

+

Error: {{ auth_error.exception }}

+
+
{% endblock %} diff --git a/allauth_ui/templates/socialaccount/base.html b/allauth_ui/templates/socialaccount/base.html index 8a64a55..b64fd56 100644 --- a/allauth_ui/templates/socialaccount/base.html +++ b/allauth_ui/templates/socialaccount/base.html @@ -1 +1 @@ -{% extends "account/base.html" %} \ No newline at end of file +{% extends "account/base.html" %} diff --git a/allauth_ui/templates/socialaccount/connections.html b/allauth_ui/templates/socialaccount/connections.html index 9f3f42f..5f8549e 100644 --- a/allauth_ui/templates/socialaccount/connections.html +++ b/allauth_ui/templates/socialaccount/connections.html @@ -1,46 +1,46 @@ {% extends "socialaccount/base.html" %} {% load i18n %} - -{% block head_title %}{% trans "Account Connections" %}{% endblock %} - +{% block head_title %} + {% trans "Account Connections" %} +{% endblock %} {% block whitebox %} -

{% trans "Account Connections" %}

- -{% if form.accounts %} -

{% blocktrans %}You have the following social accounts connected:{% endblocktrans %}

- -
- {% csrf_token %} - - {% include "account/_non_field_errors.html" %} - - {% for base_account in form.accounts %} - {% with base_account.get_provider_account as account %} -
- -
- {% endwith %} - {% endfor %} - - {% include "account/_button.html" with text="Remove" base_color="bg-red" %} -
- -{% else %} -

{% trans 'You currently have no social network accounts connected to this account.' %}

-{% endif %} -
-
- OR -
-
-{% trans 'Add a third party account' %} -
-{% include "socialaccount/snippets/provider_list.html" with process="connect" %} -{% include "socialaccount/snippets/login_extra.html" %} -
+

{% trans "Account Connections" %}

+ {% if form.accounts %} +

+ {% blocktrans %}You have the following social accounts connected:{% endblocktrans %} +

+
+ {% csrf_token %} + {% include "account/_non_field_errors.html" %} + {% for base_account in form.accounts %} + {% with base_account.get_provider_account as account %} +
+ +
+ {% endwith %} + {% endfor %} + {% include "account/_button.html" with text="Remove" base_color="bg-red" %} +
+ {% else %} +

{% trans 'You currently have no social network accounts connected to this account.' %}

+ {% endif %} +
+
+ OR +
+
+ {% trans 'Add a third party account' %} +
+ {% include "socialaccount/snippets/provider_list.html" with process="connect" %} + {% include "socialaccount/snippets/login_extra.html" %} +
{% endblock %} diff --git a/allauth_ui/templates/socialaccount/login.html b/allauth_ui/templates/socialaccount/login.html index 219d036..a99278a 100644 --- a/allauth_ui/templates/socialaccount/login.html +++ b/allauth_ui/templates/socialaccount/login.html @@ -1,19 +1,25 @@ {% extends "socialaccount/base.html" %} - +{% load i18n %} {% block whitebox %} - -
- {% csrf_token %} - {% translate "Continue" as continue_text %} - {% include "account/_button.html" with text=continue_text %} -
+ +
+ {% csrf_token %} + {% translate "Continue" as continue_text %} + {% include "account/_button.html" with text=continue_text %} +
{% endblock %} diff --git a/allauth_ui/templates/socialaccount/signup.html b/allauth_ui/templates/socialaccount/signup.html index 9d6da5e..63665ee 100644 --- a/allauth_ui/templates/socialaccount/signup.html +++ b/allauth_ui/templates/socialaccount/signup.html @@ -1,22 +1,22 @@ {% extends "socialaccount/base.html" %} - {% load i18n %} - -{% block head_title %}{% trans "Sign Up" %}{% endblock %} - +{% block head_title %} + {% trans "Sign Up" %} +{% endblock %} {% block whitebox %} -

{% trans "Sign Up" %}

- -

-{% blocktrans with provider_name=account.get_provider.name site_name=site.name %} +

{% trans "Sign Up" %}

+

+ {% blocktrans with provider_name=account.get_provider.name site_name=site.name %} You are about to use your {{provider_name}} account to login to {{site_name}}. As a final step, please complete the following form: {% endblocktrans %} -

- -
- {% include "account/_render_form.html" %} - {% translate "Sign up" as signup_text %} - {% include "account/_button.html" with text=signup_text %} -
+

+
+ {% include "account/_render_form.html" %} + {% translate "Sign up" as signup_text %} + {% include "account/_button.html" with text=signup_text %} +
{% endblock %} diff --git a/allauth_ui/templates/socialaccount/snippets/provider_list.html b/allauth_ui/templates/socialaccount/snippets/provider_list.html index 4bf9131..6933bfb 100644 --- a/allauth_ui/templates/socialaccount/snippets/provider_list.html +++ b/allauth_ui/templates/socialaccount/snippets/provider_list.html @@ -1,16 +1,13 @@ {% load socialaccount %} {% load allauth_ui %} - {% get_providers as socialaccount_providers %} - {% for provider in socialaccount_providers %} - {% if provider.id == "openid" %} - {% for brand in provider.get_brands %} - {{brand.name}} - {% endfor %} - {% endif %} - {{provider.name}} - + {% if provider.id == "openid" %} + {% for brand in provider.get_brands %} + {{ brand.name }} + {% endfor %} + {% endif %} + {{ provider.name }} {% endfor %} diff --git a/allauth_ui/templates/socialaccount/snippets/social_login.html b/allauth_ui/templates/socialaccount/snippets/social_login.html index 4d0c96d..fab412c 100644 --- a/allauth_ui/templates/socialaccount/snippets/social_login.html +++ b/allauth_ui/templates/socialaccount/snippets/social_login.html @@ -1,14 +1,12 @@ {% load socialaccount i18n %} {% get_providers as socialaccount_providers %} {% if socialaccount_providers %} -
-
- OR -
-
- -

{% translate "Sign in with a third party" %}

- -{% include "socialaccount/snippets/provider_list.html" with process="login" %} -{% include "socialaccount/snippets/login_extra.html" %} +
+
+ OR +
+
+

{% translate "Sign in with a third party" %}

+ {% include "socialaccount/snippets/provider_list.html" with process="login" %} + {% include "socialaccount/snippets/login_extra.html" %} {% endif %}