Commit 698d2490 authored by Julien Palard's avatar Julien Palard
Browse files

Still todo: A user can change its email after validation.

parent bb7fef93
......@@ -28,6 +28,7 @@ DEBUG = True
ALLOWED_HOSTS = ["*"]
SERVER_EMAIL = "team@example.com"
DEFAULT_FROM_EMAIL = "julien@seraph.palard.fr"
# Application definition
......@@ -174,7 +175,7 @@ USE_TZ = True
STATIC_URL = "/static/"
# Django registration
ACCOUNT_ACTIVATION_DAYS = 7
ACCOUNT_ACTIVATION_DAYS = 999999
REGISTRATION_FORM = "website.forms.HkisRegistrationForm"
LOGIN_REDIRECT_URL = "/exercises/"
LOGOUT_REDIRECT_URL = "/"
......
......@@ -17,6 +17,7 @@ from django.contrib import admin
from django.shortcuts import redirect
from django.conf import settings
from django.urls import path, include
from website.api import router
from website.views import (
ExerciseListView,
......@@ -32,6 +33,7 @@ from website.views import (
index,
privacy,
team,
ResendActivationView,
)
......@@ -56,6 +58,8 @@ urlpatterns = [
path("stats/<int:pk>", StatsDetailView.as_view(), name="stats"),
path("lessons/", LessonListView.as_view(), name="lesson"),
path("lessons/<slug:slug>", LessonView.as_view(), name="lesson"),
path("activate/resend/", ResendActivationView.as_view(), name="resend_activation",),
path("", include("registration.backends.default.urls")),
]
if settings.DEBUG:
......
......@@ -13,6 +13,16 @@
{% endfor %}
</ul>
{% endif %}
{% if not user.registrationprofile.activated %}
<div class="alert alert-warning" role="alert">
Your email address has not been validated yet. It's usefull if you loose your password.<br/>
<form action="{% url 'resend_activation' %}" method="post">
{% csrf_token %}
<button type="submit" class="btn btn-primary">Resend confirmation email</button>
</form>
</div>
{% endif %}
<form action="" method="post" class="form">
{% csrf_token %}
{{ form|crispy }}
......
{% extends "hkis/layout.html" %}
{% block title %}Activation email{% endblock %}
{% block container %}
Activation mail sent, check your inbox.
{% endblock %}
......@@ -9,8 +9,7 @@
<p>
{% url 'auth_login' as auth_login_url %}
{% blocktrans %}
Thanks, activation complete! You may now <a href="{{ auth_login_url }}">login</a>
using the username and password you set at registration.
Thanks, email verification complete!
{% endblocktrans %}
</p>
{% endblock %}
{% load i18n %}
{% blocktrans %}
You have asked to register an account at {{ site.name }}.
If this wasn't you, please ignore this email
and your address will be removed from our records.
You have asked to validate your HackInScience email.
To activate this account, please click the following link within the next
{{ expiration_days }} days:
If this wasn't you, please ignore this email.
To validate your email, please click the following link:
{% endblocktrans %}
http://{{ site.domain }}{% url 'registration_activate' activation_key %}
......
{% load i18n %}{% trans "Account activation for" %} {{ site.name }}
{% load i18n %}{% trans "Email verification for" %} {{ site.name }}
......@@ -3,6 +3,7 @@ from collections import OrderedDict
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Group
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.contrib.sites.shortcuts import get_current_site
from django.contrib import messages
from django.urls import reverse
from django.http import HttpResponseRedirect
......@@ -10,9 +11,13 @@ from django.db.models import Count, Q, Max
from django.shortcuts import render
from django.utils.translation import gettext
from django.contrib.auth.models import User
from django.views.generic import View
from django.views.generic.detail import DetailView
from django.views.generic.edit import UpdateView
from django.views.generic.list import ListView
from registration.models import RegistrationProfile
from website.models import Exercise, Answer, Lesson
from website.forms import AnswerForm
......@@ -220,3 +225,11 @@ class StatsDetailView(UserPassesTestMixin, DetailView):
]
)
return context
class ResendActivationView(LoginRequiredMixin, View):
def post(self, request):
RegistrationProfile.objects.resend_activation_mail(
request.user.email, get_current_site(request), request
)
return render(request, "hkis/resent.html", {"email": request.user.email})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment