diff --git a/procat2/settings.py b/procat2/settings.py index 31981ab..4a201cf 100644 --- a/procat2/settings.py +++ b/procat2/settings.py @@ -69,6 +69,8 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.sites', + 'account', 'lazysignup', 'dashboard', ] @@ -82,6 +84,8 @@ MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware', + "account.middleware.LocaleMiddleware", + "account.middleware.TimezoneMiddleware", 'procat2.middleware.SetApplicationName', ] @@ -98,6 +102,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + "account.context_processors.account", ], }, }, @@ -144,5 +149,10 @@ STATIC_URL = '/static/' LOGIN_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 from .settings_ansible import * diff --git a/procat2/urls.py b/procat2/urls.py index 01fed41..fc33aaa 100644 --- a/procat2/urls.py +++ b/procat2/urls.py @@ -27,7 +27,7 @@ urlpatterns = [ path('', dashboard, name='home'), path('dashboard', dashboard, name='dashboard'), 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/done/', lazy_convert_done, name='lazysignup_convert_done'), ] diff --git a/requirements.txt b/requirements.txt index d675f7e..ca2e5ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ Django==2.1.7 django-lazysignup==2.0.0 +django-user-accounts==2.1.0 psycopg2-binary==2.7.7 pytz==2018.9 six==1.12.0 diff --git a/templates/account/_login_sidebar.html b/templates/account/_login_sidebar.html new file mode 100644 index 0000000..dcf7d21 --- /dev/null +++ b/templates/account/_login_sidebar.html @@ -0,0 +1 @@ +{# provide log in sidebar here #} \ No newline at end of file diff --git a/templates/account/_signup_sidebar.html b/templates/account/_signup_sidebar.html new file mode 100644 index 0000000..660aca1 --- /dev/null +++ b/templates/account/_signup_sidebar.html @@ -0,0 +1 @@ +{# provide sign up in sidebar here #} \ No newline at end of file diff --git a/templates/account/base.html b/templates/account/base.html new file mode 100644 index 0000000..8d151cf --- /dev/null +++ b/templates/account/base.html @@ -0,0 +1,22 @@ +{% extends "theme_bootstrap/subnav_base.html" %} + +{% load i18n %} + +{% block content_class %}account{% endblock %} + +{% block subnav %} +
+
{% trans "Settings" %}
+
+ + + +
+
+{% endblock %} diff --git a/templates/account/delete.html b/templates/account/delete.html new file mode 100644 index 0000000..3bdc33f --- /dev/null +++ b/templates/account/delete.html @@ -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 %} +

{% trans "Delete Account" %}

+ +

{% blocktrans %}If you go ahead and delete your account, your information will be expunged within {{ ACCOUNT_DELETION_EXPUNGE_HOURS }} hours.{% endblocktrans %}

+ +
+ {% csrf_token %} + +
+ +{% endblock %} diff --git a/templates/account/email/email_confirmation_message.txt b/templates/account/email/email_confirmation_message.txt new file mode 100644 index 0000000..c3b4244 --- /dev/null +++ b/templates/account/email/email_confirmation_message.txt @@ -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 %} \ No newline at end of file diff --git a/templates/account/email/email_confirmation_subject.txt b/templates/account/email/email_confirmation_subject.txt new file mode 100644 index 0000000..ad4cf94 --- /dev/null +++ b/templates/account/email/email_confirmation_subject.txt @@ -0,0 +1 @@ +{% load i18n %}{% blocktrans with site_name=current_site.name %}Confirm email address for {{ site_name }}{% endblocktrans %} \ No newline at end of file diff --git a/templates/account/email/invite_user.txt b/templates/account/email/invite_user.txt new file mode 100644 index 0000000..a817337 --- /dev/null +++ b/templates/account/email/invite_user.txt @@ -0,0 +1,4 @@ +{% load i18n %}{% blocktrans with name=current_site.name %}You have been invited to sign up at {{ name }}. + +{{ signup_url }} +{% endblocktrans %} \ No newline at end of file diff --git a/templates/account/email/invite_user_subject.txt b/templates/account/email/invite_user_subject.txt new file mode 100644 index 0000000..86a4b06 --- /dev/null +++ b/templates/account/email/invite_user_subject.txt @@ -0,0 +1 @@ +{% load i18n %}{% blocktrans with name=current_site.name %}Create an account on {{ name }}{% endblocktrans %} \ No newline at end of file diff --git a/templates/account/email/password_change.txt b/templates/account/email/password_change.txt new file mode 100644 index 0000000..66f40e9 --- /dev/null +++ b/templates/account/email/password_change.txt @@ -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 %} \ No newline at end of file diff --git a/templates/account/email/password_change_subject.txt b/templates/account/email/password_change_subject.txt new file mode 100644 index 0000000..e722a8a --- /dev/null +++ b/templates/account/email/password_change_subject.txt @@ -0,0 +1 @@ +{% load i18n %}{% trans "Change password email notification" %} \ No newline at end of file diff --git a/templates/account/email/password_reset.txt b/templates/account/email/password_reset.txt new file mode 100644 index 0000000..55170c7 --- /dev/null +++ b/templates/account/email/password_reset.txt @@ -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 %} \ No newline at end of file diff --git a/templates/account/email/password_reset_subject.txt b/templates/account/email/password_reset_subject.txt new file mode 100644 index 0000000..94020c9 --- /dev/null +++ b/templates/account/email/password_reset_subject.txt @@ -0,0 +1 @@ +{% load i18n %}{% blocktrans with site_name=current_site.name %}[{{ site_name }}] Password reset{% endblocktrans %} \ No newline at end of file diff --git a/templates/account/email_confirm.html b/templates/account/email_confirm.html new file mode 100644 index 0000000..5cb5c3c --- /dev/null +++ b/templates/account/email_confirm.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block title %}{% trans "Confirm Email" %}{% endblock %} + +{% block content %} +
+
+
+ {% trans "Confirm Email" %} +
+ {% csrf_token %} +

{% blocktrans with email=confirmation.email_address.email %}Confirm email address {{ email }}?{% endblocktrans %}

+ +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/account/email_confirmation_sent.html b/templates/account/email_confirmation_sent.html new file mode 100644 index 0000000..5b4dd9e --- /dev/null +++ b/templates/account/email_confirmation_sent.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block title %}{% trans "Confirm your email address" %}{% endblock %} + +{% block content %} +

{% trans "Confirm your email address" %}

+ +

{% blocktrans %}We have sent you an email to {{ email }} for verification. Follow the link provided to finalize the signup process. If you do not receive it within a few minutes, contact us at {{ THEME_CONTACT_EMAIL }}.{% endblocktrans %}

+

{% trans "Go back" %}

+{% endblock %} diff --git a/templates/account/email_confirmed.html b/templates/account/email_confirmed.html new file mode 100644 index 0000000..0d2fa4b --- /dev/null +++ b/templates/account/email_confirmed.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block title %}{% trans "Email confirmed" %}{% endblock %} + +{% block content %} +

{% trans "Email confirmed" %}

+

{% blocktrans with email=confirmation.email_address.email %}You have confirmed {{ email }}{% endblocktrans %}

+{% endblock %} \ No newline at end of file diff --git a/templates/account/login.html b/templates/account/login.html new file mode 100644 index 0000000..328ea24 --- /dev/null +++ b/templates/account/login.html @@ -0,0 +1,42 @@ +{% extends "base.html" %} + +{% load account_tags %} +{% load i18n %} + +{% block title %}{% trans "Log in" %}{% endblock %} + +{% block content %} +
+
+
+ {% trans "Log in to an existing account" %} + {% csrf_token %} + {{ form }} + {% if redirect_field_value %} + + {% endif %} + + {% trans "Forgot your password?" %} +
+ {% if ACCOUNT_OPEN_SIGNUP %} + + {% endif %} +
+
+ {% include "account/_login_sidebar.html" %} +
+
+{% endblock %} + +{% block scripts %} + {{ block.super }} + +{% endblock %} diff --git a/templates/account/logout.html b/templates/account/logout.html new file mode 100644 index 0000000..eac4c98 --- /dev/null +++ b/templates/account/logout.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% load i18n %} + +{% block title %}{% trans "Log out" %}{% endblock %} + +{% block content %} +
+
+
+ {% trans "Log out" %} +
+ {% csrf_token %} +

{% trans "Are you sure you want to log out?" %}

+ +
+
+
+
+{% endblock %} diff --git a/templates/account/password_change.html b/templates/account/password_change.html new file mode 100644 index 0000000..b218fe9 --- /dev/null +++ b/templates/account/password_change.html @@ -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 %} +
+
+
+ {% trans "Change password" %} +
+ {% csrf_token %} + {{ form|bootstrap }} + +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/account/password_reset.html b/templates/account/password_reset.html new file mode 100644 index 0000000..33bd795 --- /dev/null +++ b/templates/account/password_reset.html @@ -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 %} +
+
+
+ {% trans "Password reset" %} +

{% trans "Forgotten your password? Enter your email address below, and we'll send you an email allowing you to reset it." %}

+
+
+ {% csrf_token %} + {{ form|bootstrap }} + +
+
+
+
+
+

{% blocktrans %}If you have any trouble resetting your password, contact us at {{ THEME_CONTACT_EMAIL }}.{% endblocktrans %}

+{% endblock %} + +{% block extra_body %} + +{% endblock %} \ No newline at end of file diff --git a/templates/account/password_reset_sent.html b/templates/account/password_reset_sent.html new file mode 100644 index 0000000..f6c75d4 --- /dev/null +++ b/templates/account/password_reset_sent.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} + +{% load i18n %} +{% load account_tags %} + +{% block title %}{% trans "Password reset sent" %}{% endblock %} + +{% block content %} +

{% trans "Password reset sent" %}

+ {% if not resend %} +

{% blocktrans %}We have sent you an email. If you do not receive it within a few minutes, try resending or contact us at {{ THEME_CONTACT_EMAIL }}.{% endblocktrans %}

+ +
+
+
+ {% csrf_token %} + {% for field in form %} + {{ field.as_hidden }} + {% endfor %} + +
+
+
+ {% else %} +

{% blocktrans %}We have resent the password email. If you do not receive it within a few minutes, contact us at {{ THEME_CONTACT_EMAIL }}.{% endblocktrans %}

+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/account/password_reset_token.html b/templates/account/password_reset_token.html new file mode 100644 index 0000000..13dfc79 --- /dev/null +++ b/templates/account/password_reset_token.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% load i18n %} +{% load bootstrap %} + +{% block title %}{% trans "Set your new password" %}{% endblock %} + +{% block content %} +
+
+
+ {% trans "Set your new password" %} +
+ {% csrf_token %} + {{ form|bootstrap }} + +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/account/password_reset_token_fail.html b/templates/account/password_reset_token_fail.html new file mode 100644 index 0000000..942a08d --- /dev/null +++ b/templates/account/password_reset_token_fail.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block title %}{% trans "Bad token" %}{% endblock %} + +{% block content %} +

{% trans "Bad token" %}

+ {% url "account_password_reset" as url %} +

{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %}

+{% endblock %} \ No newline at end of file diff --git a/templates/account/settings.html b/templates/account/settings.html new file mode 100644 index 0000000..455b076 --- /dev/null +++ b/templates/account/settings.html @@ -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 %} +
+
+
+ {% trans "Account" %} + {% csrf_token %} + {{ form|bootstrap }} + +
+
+
+{% endblock %} diff --git a/templates/account/signup.html b/templates/account/signup.html new file mode 100644 index 0000000..0f96c8a --- /dev/null +++ b/templates/account/signup.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + +{% load account_tags %} +{% load i18n %} + +{% block title %}{% trans "Sign up" %}{% endblock %} + +{% block content %} +
+
+
+ {% trans "Sign up" %} + {% csrf_token %} + {{ form }} + {% if redirect_field_value %} + + {% endif %} + +
+ +
+
+ {% include "account/_signup_sidebar.html" %} +
+
+{% endblock %} + +{% block scripts %} + {{ block.super }} + +{% endblock %} diff --git a/templates/account/signup_closed.html b/templates/account/signup_closed.html new file mode 100644 index 0000000..20aa9a5 --- /dev/null +++ b/templates/account/signup_closed.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block title %}{% trans "Sign up" %}{% endblock %} + +{% block content %} +

{% trans "This site is in private beta" %}

+

{% blocktrans %}If you have signup code you can enter it below.{% endblocktrans %}

+
+
+
+
+{% endblock %}