You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/05/10 15:18:52 UTC
[airavata-django-portal] 04/04: AIRAVATA-2925 Factored out common
form code
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit c5ce80142af305dd05b35afdd68c69cc1651747b
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri May 10 11:03:23 2019 -0400
AIRAVATA-2925 Factored out common form code
---
.../django_airavata_auth/create_account.html | 52 +++-------------------
.../django_airavata_auth/forgot_password.html | 50 ++-------------------
.../django_airavata_auth/partials/form.html | 13 ++++++
.../django_airavata_auth/partials/form_field.html | 25 +++++++++++
.../partials/non_field_errors.html | 6 +++
.../django_airavata_auth/reset_password.html | 49 ++------------------
.../django_airavata_auth/verify_email.html | 44 ++----------------
7 files changed, 58 insertions(+), 181 deletions(-)
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/create_account.html b/django_airavata/apps/auth/templates/django_airavata_auth/create_account.html
index ba415ee..e7bdf2c 100644
--- a/django_airavata/apps/auth/templates/django_airavata_auth/create_account.html
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/create_account.html
@@ -2,6 +2,7 @@
{% block content %}
+<div class="main-content-wrapper">
<main class="main-content">
<div class="container">
{% if options.external %}
@@ -32,53 +33,9 @@
{% else %}
<h5 class="card-title">Create a {{ options.password.name }} account</h5>
{% endif %}
- {% if messages %}
- {% for message in messages %}
- <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger{% elif message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}alert-success{% else %}alert-secondary{% endif %}" role="alert">
- {{ message }}
- </div>
- {% endfor %}
- {% endif %}
- <form action="{% url 'django_airavata_auth:create_account' %}" method="post">
- {% for error in form.non_field_errors %}
- <div class="alert alert-danger" role="alert">
- {{ error }}
- </div>
- {% endfor %}
- {% csrf_token %}
-
- {% for field in form %}
- <div class="form-group">
- <label for="{{ field.id_for_label }}">{{ field.label }}</label>
- <input id="{{ field.id_for_label }}" type="{{ field.field.widget.input_type }}"
- class="form-control{% if field.errors %} is-invalid{% endif %}" name="{{ field.name }}"
- placeholder="{{ field.field.widget.attrs.placeholder }}"
- aria-describedby="{{ field.id_for_label }}-help"
- {% if field.value %} value="{{ field.value }}" {% endif %}
- {% if field.field.required %} required {% endif %} />
- {% if field.help_text %}
- <small id="{{ field.id_for_label }}-help" class="form-text text-muted">
- {{ field.help_text | escape }}
- </small>
- {% endif %}
- <div class="invalid-feedback">
- {% if field.errors|length == 1 %}
- {{ field.errors|first| escape }}
- {% else %}
- <ul>
- {% for error in field.errors %}
- <li>{{ error | escape }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- </div>
- </div>
- {% endfor %}
-
- <button type="submit" class="btn btn-primary btn-block">
- Create
- </button>
- </form>
+ {% include "./partials/messages.html" %}
+ {% url 'django_airavata_auth:create_account' as form_url %}
+ {% include "./partials/form.html" with form=form url=form_url submit_text="Create" %}
</div>
</div>
</div>
@@ -86,5 +43,6 @@
{% endif %}
</div>
</main>
+</div>
{% endblock %}
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/forgot_password.html b/django_airavata/apps/auth/templates/django_airavata_auth/forgot_password.html
index 573c13d..30524ab 100644
--- a/django_airavata/apps/auth/templates/django_airavata_auth/forgot_password.html
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/forgot_password.html
@@ -11,53 +11,9 @@
<div class="card-body">
<h5 class="card-title">Forgot Password?</h5>
<p class="card-text">If you forgot your password you can reset it. Just enter the username for your account and click Email Reset Link.</p>
- {% if messages %}
- {% for message in messages %}
- <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger{% elif message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}alert-success{% else %}alert-secondary{% endif %}" role="alert">
- {{ message }}
- </div>
- {% endfor %}
- {% endif %}
- <form action="{% url 'django_airavata_auth:forgot_password' %}" method="post">
- {% for error in form.non_field_errors %}
- <div class="alert alert-danger" role="alert">
- {{ error }}
- </div>
- {% endfor %}
- {% csrf_token %}
-
- {% for field in form %}
- <div class="form-group">
- <label for="{{ field.id_for_label }}">{{ field.label }}</label>
- <input id="{{ field.id_for_label }}" type="{{ field.field.widget.input_type }}"
- class="form-control{% if field.errors %} is-invalid{% endif %}" name="{{ field.name }}"
- placeholder="{{ field.field.widget.attrs.placeholder }}"
- aria-describedby="{{ field.id_for_label }}-help"
- {% if field.value %} value="{{ field.value }}" {% endif %}
- {% if field.field.required %} required {% endif %} />
- {% if field.help_text %}
- <small id="{{ field.id_for_label }}-help" class="form-text text-muted">
- {{ field.help_text | escape }}
- </small>
- {% endif %}
- <div class="invalid-feedback">
- {% if field.errors|length == 1 %}
- {{ field.errors|first| escape }}
- {% else %}
- <ul>
- {% for error in field.errors %}
- <li>{{ error | escape }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- </div>
- </div>
- {% endfor %}
-
- <button type="submit" class="btn btn-primary btn-block">
- Email Reset Link
- </button>
- </form>
+ {% include "./partials/messages.html" %}
+ {% url 'django_airavata_auth:forgot_password' as form_url %}
+ {% include "./partials/form.html" with form=form url=form_url submit_text="Email Reset Link" %}
</div>
</div>
</div>
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/partials/form.html b/django_airavata/apps/auth/templates/django_airavata_auth/partials/form.html
new file mode 100644
index 0000000..ce558f7
--- /dev/null
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/partials/form.html
@@ -0,0 +1,13 @@
+
+<form action="{{ url }}" method="post">
+ {% include "./non_field_errors.html" %}
+ {% csrf_token %}
+
+ {% for field in form %}
+ {% include './form_field.html' %}
+ {% endfor %}
+
+ <button type="submit" class="btn btn-primary btn-block">
+ {{ submit_text }}
+ </button>
+</form>
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/partials/form_field.html b/django_airavata/apps/auth/templates/django_airavata_auth/partials/form_field.html
new file mode 100644
index 0000000..e7ab8d4
--- /dev/null
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/partials/form_field.html
@@ -0,0 +1,25 @@
+<div class="form-group">
+ <label for="{{ field.id_for_label }}">{{ field.label }}</label>
+ <input id="{{ field.id_for_label }}" type="{{ field.field.widget.input_type }}"
+ class="form-control{% if field.errors %} is-invalid{% endif %}" name="{{ field.name }}"
+ placeholder="{{ field.field.widget.attrs.placeholder }}"
+ aria-describedby="{{ field.id_for_label }}-help"
+ {% if field.value %} value="{{ field.value }}" {% endif %}
+ {% if field.field.required %} required {% endif %} />
+ {% if field.help_text %}
+ <small id="{{ field.id_for_label }}-help" class="form-text text-muted">
+ {{ field.help_text | escape }}
+ </small>
+ {% endif %}
+ <div class="invalid-feedback">
+ {% if field.errors|length == 1 %}
+ {{ field.errors|first| escape }}
+ {% else %}
+ <ul>
+ {% for error in field.errors %}
+ <li>{{ error | escape }}</li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </div>
+</div>
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/partials/non_field_errors.html b/django_airavata/apps/auth/templates/django_airavata_auth/partials/non_field_errors.html
new file mode 100644
index 0000000..0788c94
--- /dev/null
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/partials/non_field_errors.html
@@ -0,0 +1,6 @@
+
+{% for error in form.non_field_errors %}
+<div class="alert alert-danger" role="alert">
+ {{ error }}
+</div>
+{% endfor %}
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/reset_password.html b/django_airavata/apps/auth/templates/django_airavata_auth/reset_password.html
index 0d367f8..4227153 100644
--- a/django_airavata/apps/auth/templates/django_airavata_auth/reset_password.html
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/reset_password.html
@@ -10,52 +10,9 @@
<div class="card">
<div class="card-body">
<h5 class="card-title">Reset Password</h5>
- {% if messages %}
- {% for message in messages %}
- <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger{% elif message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}alert-success{% else %}alert-secondary{% endif %}" role="alert">
- {{ message }}
- </div>
- {% endfor %}
- {% endif %}
- <form action="{% url 'django_airavata_auth:reset_password' code %}" method="post">
- {% for error in form.non_field_errors %}
- <div class="alert alert-danger" role="alert">
- {{ error }}
- </div>
- {% endfor %}
- {% csrf_token %}
- {% for field in form %}
- <div class="form-group">
- <label for="{{ field.id_for_label }}">{{ field.label }}</label>
- <input id="{{ field.id_for_label }}" type="{{ field.field.widget.input_type }}"
- class="form-control{% if field.errors %} is-invalid{% endif %}" name="{{ field.name }}"
- placeholder="{{ field.field.widget.attrs.placeholder }}"
- aria-describedby="{{ field.id_for_label }}-help"
- {% if field.value %} value="{{ field.value }}" {% endif %}
- {% if field.field.required %} required {% endif %} />
- {% if field.help_text %}
- <small id="{{ field.id_for_label }}-help" class="form-text text-muted">
- {{ field.help_text | escape }}
- </small>
- {% endif %}
- <div class="invalid-feedback">
- {% if field.errors|length == 1 %}
- {{ field.errors|first| escape }}
- {% else %}
- <ul>
- {% for error in field.errors %}
- <li>{{ error | escape }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- </div>
- </div>
- {% endfor %}
-
- <button type="submit" class="btn btn-primary btn-block">
- Reset
- </button>
- </form>
+ {% include "./partials/messages.html" %}
+ {% url 'django_airavata_auth:reset_password' code as form_url %}
+ {% include "./partials/form.html" with form=form url=form_url submit_text="Reset Password" %}
</div>
</div>
</div>
diff --git a/django_airavata/apps/auth/templates/django_airavata_auth/verify_email.html b/django_airavata/apps/auth/templates/django_airavata_auth/verify_email.html
index c54a2c8..537d970 100644
--- a/django_airavata/apps/auth/templates/django_airavata_auth/verify_email.html
+++ b/django_airavata/apps/auth/templates/django_airavata_auth/verify_email.html
@@ -9,47 +9,9 @@
<div class="card">
<div class="card-body">
<h5 class="card-title">Resend Email Verification Link</h5>
- {% if messages %}
- {% for message in messages %}
- <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger{% elif message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}alert-success{% else %}alert-secondary{% endif %}" role="alert">
- {{ message }}
- </div>
- {% endfor %}
- {% endif %}
- <form action="{% url 'django_airavata_auth:resend_email_link' %}" method="post">
- {% for error in form.non_field_errors %}
- <div class="alert alert-danger" role="alert">
- {{ error }}
- </div>
- {% endfor %}
- {% csrf_token %}
-
- {% for field in form %}
- <div class="form-group">
- <label for="{{ field.id_for_label }}">{{ field.label }}</label>
- <input id="{{ field.id_for_label }}" type="{{ field.field.widget.input_type }}"
- class="form-control{% if field.errors %} is-invalid{% endif %}" name="{{ field.name }}"
- placeholder="{{ field.field.widget.attrs.placeholder }}"
- {% if field.value %} value="{{ field.value }}" {% endif %}
- {% if field.field.required %} required {% endif %} />
- <div class="invalid-feedback">
- {% if field.errors|length == 1 %}
- {{ field.errors|first| escape }}
- {% else %}
- <ul>
- {% for error in field.errors %}
- <li>{{ error | escape }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- </div>
- </div>
- {% endfor %}
-
- <button type="submit" class="btn btn-primary btn-block">
- Resend
- </button>
- </form>
+ {% include "./partials/messages.html" %}
+ {% url 'django_airavata_auth:resend_email_link' code as form_url %}
+ {% include "./partials/form.html" with form=form url=form_url submit_text="Resend" %}
</div>
</div>
</div>