From d56efb8f8290f2e88e5a584b8ae6806023035003 Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Thu, 4 Sep 2014 15:26:00 +0200 Subject: [PATCH 1/7] Display validation errors on login form --- .../templates/rest_framework/login_base.html | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index 43860e53ea..75e6d47276 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -18,17 +18,32 @@
+ {% if form.non_field_errors %} + {% for error in form.non_field_errors %} +

{{ error }}

+ {% endfor %} + {% endif %} {% csrf_token %}
+ {% if form.username.errors %} +

+ {{ form.username.errors|striptags }} +

+ {% endif %} - +
-
+
+ {% if form.password.errors %} +

+ {{ form.password.errors|striptags }} +

+ {% endif %} - +
From ea259e8bde2d4ea6b018f28900288a71ab2db05a Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Thu, 4 Sep 2014 16:01:27 +0200 Subject: [PATCH 2/7] Error messages are displayed below the input fields --- .../templates/rest_framework/login_base.html | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index 75e6d47276..3a75e8b35f 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -18,38 +18,38 @@
- {% if form.non_field_errors %} - {% for error in form.non_field_errors %} -

{{ error }}

- {% endfor %} - {% endif %} {% csrf_token %}
+ + {% if form.username.errors %} -

+

{{ form.username.errors|striptags }}

{% endif %} - -
+ + {% if form.password.errors %} -

+

{{ form.password.errors|striptags }}

{% endif %} - -
+ {% if form.non_field_errors %} + {% for error in form.non_field_errors %} +
{{ error }}
+ {% endfor %} + {% endif %}
From 3bc858c30b04a1c042d1b0d5196994a2e1e3fe64 Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Thu, 4 Sep 2014 17:51:45 +0200 Subject: [PATCH 3/7] General message error goes above submit button --- rest_framework/templates/rest_framework/login_base.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index 3a75e8b35f..49dad3aeb3 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -42,14 +42,14 @@
-
- -
{% if form.non_field_errors %} {% for error in form.non_field_errors %}
{{ error }}
{% endfor %} {% endif %} +
+ +
From 6106701c063ea2efab7dbe82bbdfc02f9eb40421 Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Fri, 5 Sep 2014 09:38:54 +0200 Subject: [PATCH 4/7] Input fields get hightlighted if login fails and username is persisted --- .../templates/rest_framework/login_base.html | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index 49dad3aeb3..7569c77ad6 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -17,25 +17,32 @@
-
+ {% csrf_token %} -
+
- + {% if form.username.errors %} -

+

{{ form.username.errors|striptags }}

{% endif %}
-
+
- + {% if form.password.errors %} -

+

{{ form.password.errors|striptags }}

{% endif %} @@ -44,7 +51,7 @@ {% if form.non_field_errors %} {% for error in form.non_field_errors %} -
{{ error }}
+
{{ error }}
{% endfor %} {% endif %}
From d3ee26ba9972619bdbe191b7d90d4dd60fb65983 Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Fri, 5 Sep 2014 10:55:49 +0200 Subject: [PATCH 5/7] Change bootstrap class warning to error --- .../templates/rest_framework/login_base.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index 7569c77ad6..fb355d5281 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -20,7 +20,7 @@ {% csrf_token %}
+ class="clearfix control-group {% if form.username.errors %}error{% endif %}">
{% if form.username.errors %} -

+

{{ form.username.errors|striptags }}

{% endif %}
+ class="clearfix control-group {% if form.password.errors %}error{% endif %}">
{% if form.password.errors %} -

+

{{ form.password.errors|striptags }}

{% endif %} @@ -51,7 +51,7 @@ {% if form.non_field_errors %} {% for error in form.non_field_errors %} -
{{ error }}
+
{{ error }}
{% endfor %} {% endif %}
From 34b3ee9ea1d9c6f389424186c446dbfa8b9a58c6 Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Fri, 5 Sep 2014 11:06:30 +0200 Subject: [PATCH 6/7] Place general error message in well --- .../templates/rest_framework/login_base.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index fb355d5281..582a7f273d 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -24,8 +24,9 @@
{% if form.username.errors %}

@@ -39,8 +40,8 @@

+ autocapitalize="off" autocorrect="off" class="span12 textinput textInput" + id="id_password" required> {% if form.password.errors %}

{{ form.password.errors|striptags }} @@ -51,7 +52,7 @@ {% if form.non_field_errors %} {% for error in form.non_field_errors %} -

{{ error }}
+
{{ error }}
{% endfor %} {% endif %}
From 2531b5cd864bd5138fe9456d069400363337f206 Mon Sep 17 00:00:00 2001 From: Cezar Pendarovski Date: Fri, 5 Sep 2014 13:28:47 +0200 Subject: [PATCH 7/7] Remove light gray bordering from the well with general message error --- rest_framework/templates/rest_framework/login_base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/templates/rest_framework/login_base.html b/rest_framework/templates/rest_framework/login_base.html index 582a7f273d..8ab682ac8b 100644 --- a/rest_framework/templates/rest_framework/login_base.html +++ b/rest_framework/templates/rest_framework/login_base.html @@ -52,7 +52,7 @@ {% if form.non_field_errors %} {% for error in form.non_field_errors %} -
{{ error }}
+
{{ error }}
{% endfor %} {% endif %}