add django-user-accounts

This commit is contained in:
Seth Ladygo
2019-03-13 19:12:06 -07:00
parent 6e21f5b91a
commit 0db088d8f9
28 changed files with 371 additions and 1 deletions

View File

@ -69,6 +69,8 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.sites',
'account',
'lazysignup', 'lazysignup',
'dashboard', 'dashboard',
] ]
@ -82,6 +84,8 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware', 'django.middleware.locale.LocaleMiddleware',
"account.middleware.LocaleMiddleware",
"account.middleware.TimezoneMiddleware",
'procat2.middleware.SetApplicationName', 'procat2.middleware.SetApplicationName',
] ]
@ -98,6 +102,7 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
"account.context_processors.account",
], ],
}, },
}, },
@ -144,5 +149,10 @@ STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = reverse_lazy('home') LOGIN_REDIRECT_URL = reverse_lazy('home')
LOGOUT_REDIRECT_URL = reverse_lazy('home') LOGOUT_REDIRECT_URL = reverse_lazy('home')
# django-user-accounts
SITE_ID = 1
ACCOUNT_EMAIL_UNIQUE = True
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = True
# bring in ansible-defined settings # bring in ansible-defined settings
from .settings_ansible import * from .settings_ansible import *

View File

@ -27,7 +27,7 @@ urlpatterns = [
path('', dashboard, name='home'), path('', dashboard, name='home'),
path('dashboard', dashboard, name='dashboard'), path('dashboard', dashboard, name='dashboard'),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')), path("account/", include("account.urls")),
path('convert/', convert, { 'form_class': UserCreationForm }, name='lazysignup_convert'), path('convert/', convert, { 'form_class': UserCreationForm }, name='lazysignup_convert'),
path('convert/done/', lazy_convert_done, name='lazysignup_convert_done'), path('convert/done/', lazy_convert_done, name='lazysignup_convert_done'),
] ]

View File

@ -1,5 +1,6 @@
Django==2.1.7 Django==2.1.7
django-lazysignup==2.0.0 django-lazysignup==2.0.0
django-user-accounts==2.1.0
psycopg2-binary==2.7.7 psycopg2-binary==2.7.7
pytz==2018.9 pytz==2018.9
six==1.12.0 six==1.12.0

View File

@ -0,0 +1 @@
{# provide log in sidebar here #}

View File

@ -0,0 +1 @@
{# provide sign up in sidebar here #}

View File

@ -0,0 +1,22 @@
{% extends "theme_bootstrap/subnav_base.html" %}
{% load i18n %}
{% block content_class %}account{% endblock %}
{% block subnav %}
<div class="panel panel-default">
<div class="panel-heading"><strong>{% trans "Settings" %}</strong></div>
<div class="list-group">
<a class="list-group-item account-settings" href="{% url "account_settings" %}">
{% trans "Account" %}
</a>
<a class="list-group-item account-password" href="{% url "account_password" %}">
{% trans "Change password" %}
</a>
<a class="list-group-item account-delete" href="{% url "account_delete" %}">
{% trans "Delete account" %}
</a>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,19 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block content_class %}account account-delete{% endblock %}
{% block title %}{% trans "Delete Account" %}{% endblock %}
{% block content %}
<h1>{% trans "Delete Account" %}</h1>
<p>{% blocktrans %}If you go ahead and delete your account, your information will be <b>expunged within {{ ACCOUNT_DELETION_EXPUNGE_HOURS }} hours</b>.{% endblocktrans %}</p>
<form method="post" action="{% url "account_delete" %}" autocapitalize="off">
{% csrf_token %}
<button type="submit" class="btn btn-danger">{% trans "Delete My Account" %}</button>
</form>
{% endblock %}

View File

@ -0,0 +1,6 @@
{% load i18n account_tags %}{% blocktrans with site_name=current_site.name %}A user on {{ site_name }} has created an account using this email address.
To confirm this email address, go to {{ activate_url }}
If you did not sign up for this site, you can ignore this message.
{% endblocktrans %}

View File

@ -0,0 +1 @@
{% load i18n %}{% blocktrans with site_name=current_site.name %}Confirm email address for {{ site_name }}{% endblocktrans %}

View File

@ -0,0 +1,4 @@
{% load i18n %}{% blocktrans with name=current_site.name %}You have been invited to sign up at {{ name }}.
{{ signup_url }}
{% endblocktrans %}

View File

@ -0,0 +1 @@
{% load i18n %}{% blocktrans with name=current_site.name %}Create an account on {{ name }}{% endblocktrans %}

View File

@ -0,0 +1 @@
{% load i18n %}{% blocktrans with now=user.account.now %}This is the email notification to confirm your password has been changed on {{ now }}.{% endblocktrans %}

View File

@ -0,0 +1 @@
{% load i18n %}{% trans "Change password email notification" %}

View File

@ -0,0 +1,5 @@
{% load i18n %}{% blocktrans with site_name=current_site.name %}You're receiving this email because you or someone else has requested a password for your user account at {{ site_name }}.
It can be safely ignored if you did not request a password reset. Click the link below to reset your password.
{{ password_reset_url }}
{% endblocktrans %}

View File

@ -0,0 +1 @@
{% load i18n %}{% blocktrans with site_name=current_site.name %}[{{ site_name }}] Password reset{% endblocktrans %}

View File

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Confirm Email" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<form method="post" action="{% url "account_confirm_email" key=confirmation.key %}">
<legend>{% trans "Confirm Email" %}</legend>
<fieldset>
{% csrf_token %}
<p>{% blocktrans with email=confirmation.email_address.email %}Confirm email address <b>{{ email }}</b>?{% endblocktrans %}</p>
<button type="submit" class="btn btn-primary">{% trans "Confirm" %}</button>
</fieldset>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Confirm your email address" %}{% endblock %}
{% block content %}
<h2>{% trans "Confirm your email address" %}</h2>
<p>{% blocktrans %}We have sent you an email to <b>{{ email }}</b> for verification. Follow the link provided to finalize the signup process. If you do not receive it within a few minutes, contact us at <a href="mailto:{{ THEME_CONTACT_EMAIL }}">{{ THEME_CONTACT_EMAIL }}</a>.{% endblocktrans %}</p>
<p><a href="{{ success_url }}">{% trans "Go back" %}</a></p>
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Email confirmed" %}{% endblock %}
{% block content %}
<h1>{% trans "Email confirmed" %}</h1>
<p>{% blocktrans with email=confirmation.email_address.email %}You have confirmed <b>{{ email }}</b>{% endblocktrans %}</p>
{% endblock %}

View File

@ -0,0 +1,42 @@
{% extends "base.html" %}
{% load account_tags %}
{% load i18n %}
{% block title %}{% trans "Log in" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-4">
<form method="POST" action="{% url "account_login" %}" autocapitalize="off" {% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
<legend>{% trans "Log in to an existing account" %}</legend>
{% csrf_token %}
{{ form }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<button type="submit" class="btn btn-primary">{% trans "Log in" %}</button>
<a href="{% url "account_password_reset" %}" class="btn btn-link">{% trans "Forgot your password?" %}</a>
</form>
{% if ACCOUNT_OPEN_SIGNUP %}
<p class="login-signup">
<small>
{% trans "Don't have an account?" %} <strong><a href="{% urlnext 'account_signup' %}">{% trans "Sign up" %}</a></strong>
</small>
</p>
{% endif %}
</div>
<div class="col-md-4">
{% include "account/_login_sidebar.html" %}
</div>
</div>
{% endblock %}
{% block scripts %}
{{ block.super }}
<script type="text/javascript">
$(document).ready(function() {
$('#id_username').focus();
});
</script>
{% endblock %}

View File

@ -0,0 +1,20 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Log out" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<form method="POST" action="{% url "account_logout" %}">
<legend>{% trans "Log out" %}</legend>
<fieldset>
{% csrf_token %}
<p>{% trans "Are you sure you want to log out?" %}</p>
<button type="submit" class="btn btn-primary">{% trans "Log out" %}</button>
</fieldset>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,23 @@
{% extends "account/base.html" %}
{% load i18n %}
{% load bootstrap %}
{% block content_class %}account account-password{% endblock %}
{% block title %}{% trans "Change password" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<form method="POST" action="">
<legend>{% trans "Change password" %}</legend>
<fieldset>
{% csrf_token %}
{{ form|bootstrap }}
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
</fieldset>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,36 @@
{% extends "base.html" %}
{% load i18n %}
{% load bootstrap %}
{% load account_tags %}
{% block title %}{% trans "Password reset" %}{% endblock %}
{% user_display request.user as user_display %}
{% block content %}
<div class="row">
<div class="col-md-8">
<form method="POST" action="">
<legend>{% trans "Password reset" %}</legend>
<p class="lead">{% trans "Forgotten your password? Enter your email address below, and we'll send you an email allowing you to reset it." %}</p>
<fieldset class="row">
<div class="col-md-5">
{% csrf_token %}
{{ form|bootstrap }}
<button type="submit" class="btn btn-primary">
{% trans "Reset my password" %}
</button>
</div>
</fieldset>
</form>
</div>
</div>
<p>{% blocktrans %}If you have any trouble resetting your password, contact us at <a href="mailto:{{ THEME_CONTACT_EMAIL }}">{{ THEME_CONTACT_EMAIL }}</a>.{% endblocktrans %}</p>
{% endblock %}
{% block extra_body %}
<script>
$("#id_email").focus();
</script>
{% endblock %}

View File

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% load i18n %}
{% load account_tags %}
{% block title %}{% trans "Password reset sent" %}{% endblock %}
{% block content %}
<h1>{% trans "Password reset sent" %}</h1>
{% if not resend %}
<p>{% blocktrans %}We have sent you an email. If you do not receive it within a few minutes, try resending or contact us at <a href="mailto:{{ THEME_CONTACT_EMAIL }}">{{ THEME_CONTACT_EMAIL }}</a>.{% endblocktrans %}</p>
<div class="row">
<div class="col-md-5">
<form method="POST" action="{% url "account_password_reset" %}">
{% csrf_token %}
{% for field in form %}
{{ field.as_hidden }}
{% endfor %}
<button type="submit" name="resend" class="btn btn-primary">{% trans "Resend" %}</button>
</form>
</div>
</div>
{% else %}
<p>{% blocktrans %}We have resent the password email. If you do not receive it within a few minutes, contact us at <a href="mailto:{{ THEME_CONTACT_EMAIL }}">{{ THEME_CONTACT_EMAIL }}</a>.{% endblocktrans %}</p>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% load i18n %}
{% load bootstrap %}
{% block title %}{% trans "Set your new password" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<form method="POST" action="{% url "account_password_reset_token" uidb36=uidb36 token=token %}">
<legend>{% trans "Set your new password" %}</legend>
<fieldset>
{% csrf_token %}
{{ form|bootstrap }}
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
</fieldset>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Bad token" %}{% endblock %}
{% block content %}
<h1>{% trans "Bad token" %}</h1>
{% url "account_password_reset" as url %}
<p>{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a <a href="{{ url }}">new password reset</a>.{% endblocktrans %}</p>
{% endblock %}

View File

@ -0,0 +1,21 @@
{% extends "account/base.html" %}
{% load i18n %}
{% load bootstrap %}
{% block content_class %}account account-settings{% endblock %}
{% block title %}{% trans "Account" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<form method="POST" action="{% url "account_settings" %}">
<legend>{% trans "Account" %}</legend>
{% csrf_token %}
{{ form|bootstrap }}
<button class="btn btn-primary" type="submit">{% trans "Save" %}</button>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,39 @@
{% extends "base.html" %}
{% load account_tags %}
{% load i18n %}
{% block title %}{% trans "Sign up" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-4">
<form id="signup_form" method="post" action="{% url "account_signup" %}" autocapitalize="off" {% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
<legend>{% trans "Sign up" %}</legend>
{% csrf_token %}
{{ form }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<button type="submit" class="btn btn-primary">{% trans "Sign up" %}</button>
</form>
<p class="login-signup">
<small>
{% trans "Already have an account?" %} <strong><a href="{% urlnext 'account_login' %}">{% trans "Log in" %}</a></strong>
</small>
</p>
</div>
<div class="col-md-4">
{% include "account/_signup_sidebar.html" %}
</div>
</div>
{% endblock %}
{% block scripts %}
{{ block.super }}
<script type="text/javascript">
$(document).ready(function() {
$('#id_username').focus();
});
</script>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Sign up" %}{% endblock %}
{% block content %}
<h1>{% trans "This site is in private beta" %}</h1>
<p>{% blocktrans %}If you have signup code you can enter it below.{% endblocktrans %}</p>
<form method="get" action="">
<div><input type="text" name="code" placeholder="{% trans 'Your signup code...' %}" /></div>
<div><input type="submit" class="btn btn-primary"></div>
</form>
{% endblock %}