registration and passwd reset
authorCezary Czaplewski <czarek@chem.univ.gda.pl>
Fri, 8 Sep 2017 21:07:56 +0000 (23:07 +0200)
committerCezary Czaplewski <czarek@chem.univ.gda.pl>
Fri, 8 Sep 2017 21:07:56 +0000 (23:07 +0200)
20 files changed:
django_simple/authentication/templates/registration/activate.html [new file with mode: 0644]
django_simple/authentication/templates/registration/activation_complete.html [new file with mode: 0644]
django_simple/authentication/templates/registration/activation_email.txt [new file with mode: 0644]
django_simple/authentication/templates/registration/activation_email_subject.txt [new file with mode: 0644]
django_simple/authentication/templates/registration/login.html
django_simple/authentication/templates/registration/logout.html
django_simple/authentication/templates/registration/password_change_done.html [new file with mode: 0644]
django_simple/authentication/templates/registration/password_change_form.html [new file with mode: 0644]
django_simple/authentication/templates/registration/password_reset_complete.html [new file with mode: 0644]
django_simple/authentication/templates/registration/password_reset_confirm.html [new file with mode: 0644]
django_simple/authentication/templates/registration/password_reset_done.html [new file with mode: 0644]
django_simple/authentication/templates/registration/password_reset_email.html [new file with mode: 0644]
django_simple/authentication/templates/registration/password_reset_email.txt [new file with mode: 0644]
django_simple/authentication/templates/registration/password_reset_form.html [new file with mode: 0644]
django_simple/authentication/templates/registration/registration_closed.html [new file with mode: 0644]
django_simple/authentication/templates/registration/registration_complete.html [new file with mode: 0644]
django_simple/authentication/templates/registration/registration_form.html [new file with mode: 0644]
django_simple/settings.py
django_simple/todo/templates/base.html
django_simple/urls.py

diff --git a/django_simple/authentication/templates/registration/activate.html b/django_simple/authentication/templates/registration/activate.html
new file mode 100644 (file)
index 0000000..8deb01c
--- /dev/null
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+<p>{% trans "Account activation failed" %}</p>
+
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/activation_complete.html b/django_simple/authentication/templates/registration/activation_complete.html
new file mode 100644 (file)
index 0000000..aa93bcc
--- /dev/null
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<p>{% trans "Your account is now activated." %}</p>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/activation_email.txt b/django_simple/authentication/templates/registration/activation_email.txt
new file mode 100644 (file)
index 0000000..911df01
--- /dev/null
@@ -0,0 +1,6 @@
+{% load i18n %}
+{% trans "Activate account at" %} {{ site.name }}:
+
+http://{{ site.domain }}{% url 'registration_activate' activation_key %}
+
+{% blocktrans %}Link is valid for {{ expiration_days }} days.{% endblocktrans %}
diff --git a/django_simple/authentication/templates/registration/activation_email_subject.txt b/django_simple/authentication/templates/registration/activation_email_subject.txt
new file mode 100644 (file)
index 0000000..24f477c
--- /dev/null
@@ -0,0 +1 @@
+{% load i18n %}{% trans "Account activation on" %} {{ site.name }}
index b240eea..9b24598 100644 (file)
@@ -1,26 +1,15 @@
 {% extends "base.html" %}
+{% load i18n %}
 
 {% block content %}
+<form method="post" action=".">
+  {% csrf_token %} 
+  {{ form.as_p }}
 
-{% if form.errors %}
-       <p>Invalid credentials</p>
-{% endif %}
-
-<form method="post" action="{% url 'login' %}">
-{% csrf_token %}
-<table>
-<tr>
-    <td>{{ form.username.label_tag }}</td>
-    <td>{{ form.username }}</td>
-</tr>
-<tr>
-    <td>{{ form.password.label_tag }}</td>
-    <td>{{ form.password }}</td>
-</tr>
-</table>
-
-<input type="submit" value="login" />
-<input type="hidden" name="next" value="{{ next }}" />
+  <input type="submit" value="{% trans 'Log in' %}" />
+  <input type="hidden" name="next" value="{{ next }}" />
 </form>
 
-{% endblock %}
\ No newline at end of file
+<p>{% trans "Forgot password" %}? <a href="{% url 'auth_password_reset' %}">{% trans "Reset it" %}</a>!</p>
+<p>{% trans "Not member" %}? <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>!</p>
+{% endblock %}
index 67eb911..f8da51f 100644 (file)
@@ -1,9 +1,6 @@
-<!DOCTYPE html>
-<html>
-<head>
-       <title></title>
-</head>
-<body>
-hejeczka
-</body>
-</html>
\ No newline at end of file
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<p>{% trans "Logged out" %}</p>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_change_done.html b/django_simple/authentication/templates/registration/password_change_done.html
new file mode 100644 (file)
index 0000000..659be0a
--- /dev/null
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<p>{% trans "Password changed" %}</p>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_change_form.html b/django_simple/authentication/templates/registration/password_change_form.html
new file mode 100644 (file)
index 0000000..10b1fc1
--- /dev/null
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<form method="post" action=".">
+  {% csrf_token %} 
+  {{ form.as_p }}
+
+  <input type="submit" value="{% trans 'Submit' %}" />
+</form>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_reset_complete.html b/django_simple/authentication/templates/registration/password_reset_complete.html
new file mode 100644 (file)
index 0000000..55993e8
--- /dev/null
@@ -0,0 +1,10 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+<p>{% trans "Password reset successfully" %}</p>
+
+<p><a href="{% url 'auth_login' %}">{% trans "Log in" %}</a></p>
+
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_reset_confirm.html b/django_simple/authentication/templates/registration/password_reset_confirm.html
new file mode 100644 (file)
index 0000000..33bd276
--- /dev/null
@@ -0,0 +1,21 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+{% if validlink %}
+
+<form method="post" action=".">
+  {% csrf_token %} 
+  {{ form.as_p }}
+
+  <input type="submit" value="{% trans 'Submit' %}" />
+</form>
+
+{% else %}
+
+<p>{% trans "Password reset failed" %}</p>
+
+{% endif %}
+
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_reset_done.html b/django_simple/authentication/templates/registration/password_reset_done.html
new file mode 100644 (file)
index 0000000..6057ccb
--- /dev/null
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<p>{% trans "Email with password reset instructions has been sent." %}</p>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_reset_email.html b/django_simple/authentication/templates/registration/password_reset_email.html
new file mode 100644 (file)
index 0000000..c78893e
--- /dev/null
@@ -0,0 +1,5 @@
+{% load i18n %}
+{% blocktrans %}Reset password at {{ site_name }}{% endblocktrans %}:
+{% block reset_link %}
+{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uid token %}
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/password_reset_email.txt b/django_simple/authentication/templates/registration/password_reset_email.txt
new file mode 100644 (file)
index 0000000..e7c2831
--- /dev/null
@@ -0,0 +1,6 @@
+{% load i18n %}
+{% blocktrans %}Reset password at {{ site_name }}{% endblocktrans %}:
+{% block reset_link %}
+{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uid token %}
+{% endblock %}
+
diff --git a/django_simple/authentication/templates/registration/password_reset_form.html b/django_simple/authentication/templates/registration/password_reset_form.html
new file mode 100644 (file)
index 0000000..10b1fc1
--- /dev/null
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<form method="post" action=".">
+  {% csrf_token %} 
+  {{ form.as_p }}
+
+  <input type="submit" value="{% trans 'Submit' %}" />
+</form>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/registration_closed.html b/django_simple/authentication/templates/registration/registration_closed.html
new file mode 100644 (file)
index 0000000..c73cfac
--- /dev/null
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+       <p>{% trans "Registration is currently closed." %}</p>
+{% endblock %}
diff --git a/django_simple/authentication/templates/registration/registration_complete.html b/django_simple/authentication/templates/registration/registration_complete.html
new file mode 100644 (file)
index 0000000..96a22ac
--- /dev/null
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<p>{% trans "You are now registered. Activation email sent." %}</p>
+{% endblock %}
\ No newline at end of file
diff --git a/django_simple/authentication/templates/registration/registration_form.html b/django_simple/authentication/templates/registration/registration_form.html
new file mode 100644 (file)
index 0000000..6d0854d
--- /dev/null
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<form method="post" action=".">
+  {% csrf_token %}
+  {{ form.as_p }}
+
+  <input type="submit" value="{% trans 'Submit' %}" />
+</form>
+{% endblock %}
index fddea6d..1d17fda 100644 (file)
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.10/ref/settings/
 """
 
 import os
+from django.core.mail import send_mail
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -27,6 +28,7 @@ DEBUG = True
 
 ALLOWED_HOSTS = ["ha1.chem.univ.gda.pl"]
 
+ACCOUNT_ACTIVATION_DAYS = 2 # two days
 
 # Application definition
 
@@ -40,6 +42,7 @@ INSTALLED_APPS = [
     'django_simple.authentication',
     'django_simple.todo',
     'django_simple.directory',
+    'registration',
 ]
 
 MIDDLEWARE_CLASSES = [
@@ -130,3 +133,13 @@ STATICFILES_DIRS = (
 LOGIN_URL = '/login/'
 MEDIA_ROOT = './'
 
+EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
+#EMAIL_USE_TLS = True
+#EMAIL_PORTS = 587
+#EMAIL_HOST = 'smtp.localhost'
+#EMAIL_HOST_USER = 'admin@localhost'
+#EMAIL_HOST_PASSWORD = 'yourPassword'
+SERVER_EMAIL = 'admin@ha1.chem.univ.gda.pl'
+DEFAULT_FROM_EMAIL = 'UNRES server Admin <admin@ha1.chem.univ.gda.pl>'
+
+LOGIN_REDIRECT_URL = '/'
\ No newline at end of file
index 8aabba7..43dc57d 100644 (file)
@@ -22,7 +22,7 @@
 
               Lab. of Simul. of Polym. & Lab. of Mol. Model, Faculty of Chemistry, University of Gdansk
               <br>
-              Ver.24.08.2017 <span class="fa fa-envelope-o"></span> 
+              Ver.08.09.2017 <span class="fa fa-envelope-o"></span> 
               cezary.czaplewski<span class="fa fa-at"></span>ug.edu.pl
 
                <div class="user-name">
index 1b16e39..c0c5f34 100644 (file)
@@ -11,4 +11,5 @@ urlpatterns = [
        url(r'^', include(authentication_urls)),
        url(r'^myfiles/', include(directory_urls)),
         url(r'^admin/', include(admin.site.urls)),
+        url(r'^accounts/', include('registration.backends.hmac.urls')),
 ]