Skip to content

Commit

Permalink
Merge pull request #169 from mikerae/166-user-story-change-password
Browse files Browse the repository at this point in the history
166 user story change password closes #166
  • Loading branch information
mikerae authored Oct 7, 2023
2 parents 4c3c081 + d6501bd commit c6aaa0d
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 158 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ 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)
- [Enable Email Server #166 Testing](/readme_assets/images/testing-issue166-3.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
14 changes: 14 additions & 0 deletions django_string_rota/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,17 @@
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

# Email Server

if "DEVELOPMENT" in os.environ:
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
DEFAULT_FROM_EMAIL = "[email protected]"
else:
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASS")
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_HOST_USER")
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.
Binary file added readme_assets/images/testing-issue166-3.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 %}
Loading

0 comments on commit c6aaa0d

Please sign in to comment.