Skip to content

Commit

Permalink
[#166] Add change passord and add email
Browse files Browse the repository at this point in the history
Add redirect modification for password change allauth url
	modified:   django_string_rota/urls.py

Add links for Change assword and Add Email,
Make various validation corrections
	modified:   templates/base.html

Customise Allauth templates to unify site style
	modified:   templates/account/email.html
	modified:   templates/account/email/base_message.txt
	modified:   templates/account/email_confirm.html
	modified:   templates/account/logout.html
	modified:   templates/account/password_change.html
	modified:   templates/account/password_reset.html
	modified:   templates/account/password_reset_done.html
	modified:   templates/account/password_reset_from_key.html
	modified:   templates/account/password_reset_from_key_done.html

Make minor validation corrections to home.html
	modified:   string_rota/templates/string_rota/home.html

Add backend email server to settings.py
	modified:   django_string_rota/settings.py

Add testing of change passord and add email to readme
	modified:   README.md
    new file:   readme_assets/images/testing-issue166-1.png
	new file:   readme_assets/images/testing-issue166-2.png
  • Loading branch information
mikerae committed Oct 7, 2023
1 parent b33e4f1 commit 7ffe835
Show file tree
Hide file tree
Showing 16 changed files with 278 additions and 145 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ The following manual tests were made:
- [see issue #157 here](https://github.com/mikerae/string-rota/issues/157)
- [Display Draft/Published rota data #159 Testing](/readme_assets/images/testing-issue159.png)
- [see issue #159 here](https://github.com/mikerae/string-rota/issues/159)
- [Change Password #166 Testing](/readme_assets/images/testing-issue166-1.png)
- [see issue #166 here](https://github.com/mikerae/string-rota/issues/166)
- [Add Email #166 Testing](/readme_assets/images/testing-issue166-2.png)
- [see issue #166 here](https://github.com/mikerae/string-rota/issues/166)
#### Human Testing
No human testing was done for this MVP, but once office manager functionality, and the hiding of draft rotas is implemented, user feedback will be sort.

Expand Down
3 changes: 3 additions & 0 deletions django_string_rota/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@

ACCOUNT_EMAIL_VERIFICATION = "none"

# Email Server
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

Expand Down
16 changes: 15 additions & 1 deletion django_string_rota/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
"""django_string_rota URL Configuration
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import path, include, re_path
from allauth.account.views import PasswordChangeView

from string_rota.views import login


class CustomPasswordChangeView(PasswordChangeView):
"""Redirect url for successfull password change"""

success_url = "/string_rota"


urlpatterns = [
path("admin/", admin.site.urls, name="admin"),
path("summernote/", include("django_summernote.urls")),
path("string_rota/", include("string_rota.urls")),
path("", login, name="login"),
re_path(
r"^accounts/password/change/$",
CustomPasswordChangeView.as_view(),
name="account_password_change",
),
path("accounts/", include("allauth.urls")),
path("player_info/", include("player_info.urls")),
]
Binary file added readme_assets/images/testing-issue166-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme_assets/images/testing-issue166-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion string_rota/templates/string_rota/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2 class="card-title">
<div class="col-lg-7">
<div class="card">
<div class="card-body">
<h2 class="card-title">Select a Project<span></h2>
<h2 class="card-title">Select a Project</h2>

<div class="ps-3">
<p>Choose a project from the list of projects in the side menu to view a rota for that project.</p>
Expand Down
138 changes: 86 additions & 52 deletions templates/account/email.html
Original file line number Diff line number Diff line change
@@ -1,63 +1,97 @@
{% extends "account/base.html" %}
{% extends "string_rota/home.html" %}

{% load i18n %}

{% load crispy_forms_tags %}

{% block head_title %}{% trans "E-mail Addresses" %}{% endblock %}

{% block content %}
<h1>{% trans "E-mail Addresses" %}</h1>
{% if user.emailaddress_set.all %}
<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>

<form action="{% url 'account_email' %}" class="email_list" method="post">
{% csrf_token %}
<fieldset class="blockLabels">

{% for emailaddress in user.emailaddress_set.all %}
<div class="ctrlHolder">
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">

<input id="email_radio_{{forloop.counter}}" type="radio" name="email"
{% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked" {%endif %}
value="{{emailaddress.email}}">

{{ emailaddress.email }}
<main id="main" class="main">

<div class="pagetitle">
<h1>Add An Email to Your Account</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home' %}">Home</a></li>
<li class="breadcrumb-item active">Add Email</li>
</ol>
</nav>
</div>

<section class="section dashboard">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-body">

<!-- Add Email Form -->
<h2>{% trans "Add Email" %}</h2>

<h3>{% trans "E-mail Addresses" %}</h3>
{% if user.emailaddress_set.all %}
<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>

<form action="{% url 'account_email' %}" class="email_list" method="post">
{% csrf_token %}
<fieldset class="blockLabels">

{% for emailaddress in user.emailaddress_set.all %}
<div class="ctrlHolder">
<label for="email_radio_{{forloop.counter}}"
class="{% if emailaddress.primary %}primary_email{%endif%}">

<input id="email_radio_{{forloop.counter}}" type="radio" name="email"
{% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked" {%endif %}
value="{{emailaddress.email}}">

{{ emailaddress.email }}
{% if emailaddress.verified %}
<span class="verified">{% trans "Verified" %}</span>
{% else %}
<span class="unverified">{% trans "Unverified" %}</span>
{% endif %}
{% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
</label>
</div>
{% endfor %}

<div class="buttonHolder">
<button class="secondaryAction" type="submit" name="action_primary">{% trans 'Make Primary' %}</button>
<button class="secondaryAction" type="submit" name="action_send">{% trans 'Re-send Verification' %}</button>
<button class="primaryAction" type="submit" name="action_remove">{% trans 'Remove' %}</button>
<span class="verified">{% trans "Verified" %}</span>
{% else %}
<span class="unverified">{% trans "Unverified" %}</span>
{% endif %}
{% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
</label>
</div>
{% endfor %}

<div class="buttonHolder text-center my-3">
<button class="btn btn-success" name="action_primary">{% trans 'Make Primary' %}</button>
<button class="btn btn-primary secondaryAction" type="submit"
name="action_send">{% trans 'Re-send Verification' %}</button>
<button class="primaryAction btn btn-danger" type="submit"
name="action_remove">{% trans 'Remove' %}</button>
</div>

</fieldset>
</form>

{% else %}
<p class="text-warning"><strong>{% trans 'Warning:'%}</strong>
{% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
</p>

{% endif %}

{% if can_add_email %}
<h2>{% trans "Add E-mail Address" %}</h2>

<form method="post" action="{% url 'account_email' %}" class="add_email">
{% csrf_token %}
{{ form|crispy }}
<div class="text-center my-3">
<button class="btn btn-success" name="action_add" type="submit">{% trans "Add E-mail" %}</button>
<a href="{% url 'home' %}" class="btn btn-secondary">Cancel</a>
</div>
</form>
{% endif %}
</div>
</div>
</div>
</div>

</fieldset>
</form>

{% else %}
<p><strong>{% trans 'Warning:'%}</strong>
{% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
</p>

{% endif %}

{% if can_add_email %}
<h2>{% trans "Add E-mail Address" %}</h2>

<form method="post" action="{% url 'account_email' %}" class="add_email">
{% csrf_token %}
{{ form.as_p }}
<button name="action_add" type="submit">{% trans "Add E-mail" %}</button>
</form>
{% endif %}

</section>
</main>
{% endblock %}


Expand Down
5 changes: 2 additions & 3 deletions templates/account/email/base_message.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name %}Hello from {{ site_name }}!{% endblocktrans %}
{% load i18n %}{% autoescape off %}Hello from the RSNO String Rota Team!

{% block content %}{% endblock %}

{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}!
{{ site_domain }}{% endblocktrans %}
Thank you for using the RSNO String Rota!
{% endautoescape %}
47 changes: 33 additions & 14 deletions templates/account/email_confirm.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
{% extends "account/base.html" %}
{% extends "string_rota/index.html" %}

{% load i18n %}

{% load crispy_forms_tags %}

{% load account %}

{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %}


{% block content %}
<h1>{% trans "Confirm E-mail Address" %}</h1>
<div class="row"></div>
<div class="col 12">
<div class="card mb-3">
<div class="card-body">
{% if confirmation %}

{% user_display confirmation.email_address.user as user_display %}

{% if confirmation %}
<div class=" pt-4 pb-2">
<h1 class="card-title text-center pb-0 fs-4">{% trans "Confirm Email" %}</h1>
<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a
href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user
{{ user_display }}.{% endblocktrans %}</p>
</div>

{% user_display confirmation.email_address.user as user_display %}

<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}.{% endblocktrans %}</p>

<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
{% csrf_token %}
<button type="submit">{% trans 'Confirm' %}</button>
</form>
<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
{% csrf_token %}
<div class="text-center">
<button class="btn btn-success" type="submit">{% trans 'Confirm' %}</button>
</div>
</form>

{% else %}
{% else %}

{% url 'account_email' as email_url %}
{% url 'account_email' as email_url %}

<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>
<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a
href="{{ email_url }}">issue a
new e-mail confirmation request</a>.{% endblocktrans %}</p>

{% endif %}
{% endif %}

{% endblock %}
</div>
</div>
</div>
{% endblock %}
46 changes: 26 additions & 20 deletions templates/account/logout.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
{% extends "string_rota/index.html" %}
{% extends "string_rota/home.html" %}

{% load i18n %}

{% block head_title %}{% trans "Sign Out" %}{% endblock %}

{% block content %}

<div class="card mb-3">
<div class="card-body">

<div class="pt-4 pb-2">
<h5 class="card-title text-center pb-0 fs-4">{% trans "Sign Out" %}</h5>
<p class="text-center small">{% trans 'Are you sure you want to sign out?' %}</p>
</div>

<form method="post" action="{% url 'account_logout' %}">
{% csrf_token %}
{{ form.as_p }}
<main id="main" class="main">
<div class="row"></div>
<div class="col-lg-4">
<div class="card mb-3">
<div class="card-body">

<div class=" pt-4 pb-2">
<h1 class="card-title text-center pb-0 fs-4">{% trans "Sign Out" %}</h1>
<p class="text-center small">{% trans 'Are you sure you want to sign out?' %}</p>
</div>

<form method="post" action="{% url 'account_logout' %}">
{% csrf_token %}
{{ form.as_p }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}">
{% endif %}
<button class="btn btn-primary w-100" type="submit">{% trans 'Sign Out' %}</button>
</form>

<input type="hidden" name="redirect_field_name" value="{{ redirect_field_value }}">
{% endif %}
<div class="text-center">
<button class="btn btn-primary" type="submit">{% trans 'Sign Out' %}</button>
</div>
</form>

</div>
</div>
</div>
</div>

</div>
</main>
{% endblock %}
9 changes: 5 additions & 4 deletions templates/account/password_change.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<main id="main" class="main">

<div class="pagetitle">
<h1>Chamge Your Password</h1>
<h1>Change Your Password</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home' %}">Home</a></li>
Expand All @@ -24,13 +24,14 @@ <h1>Chamge Your Password</h1>
<div class="col-md-6">
<div class="card">
<div class="card-body">

<!-- Rota Form Section-->
<h1>{% trans "Change Password" %}</h1>
<h2>{% trans "Change Password" %}</h2>

<form method="POST" action="{% url 'account_change_password' %}" class="password_change">
{% csrf_token %}
{{ form|crispy }}

<input type="hidden" name="redirect_field_name" value="string_rota/home">

<div class="text-center my-3">
<button class="btn btn-success" type="submit"
name="action">{% trans "Change Password" %}</button>
Expand Down
10 changes: 4 additions & 6 deletions templates/account/password_reset.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ <h1>Reset Password</h1>
<div class="col-md-6">
<div class="card">
<div class="card-body">

<!-- Password Reset Section-->
<h1>{% trans "Password Reset" %}</h1>
<h2>{% trans "Password Reset" %}</h2>
{% if user.is_authenticated %}
{% include "account/snippets/already_logged_in.html" %}
{% endif %}
Expand All @@ -40,14 +38,14 @@ <h1>{% trans "Password Reset" %}</h1>
<form method="POST" action="{% url 'account_reset_password' %}" class="password_reset">
{% csrf_token %}
{{ form|crispy }}
<div class="my-3">
<div class="text-center my-3">
<input class="btn btn-success" type="submit" value="{% trans 'Reset My Password' %}">
<a href="{% url 'home' %}" class="btn btn-secondary">Cancel</a>
</div>
</form>

<p>{% blocktrans %}Please contact us if you have any trouble resetting your
password.{% endblocktrans %}</p>
<p>{% blocktrans %}Please contact an office member if you have any trouble resetting your
password.We will need to add your {% endblocktrans %}</p>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 7ffe835

Please sign in to comment.