Inscription d'utilisateurs
This commit is contained in:
parent
caef878ba9
commit
c8e0abb073
6 changed files with 84 additions and 5 deletions
|
@ -40,6 +40,9 @@
|
||||||
<li class="nav-item {% if active == 4 %}active{% endif %}">
|
<li class="nav-item {% if active == 4 %}active{% endif %}">
|
||||||
<a class="nav-link" href="{% url 'users:login' %}">Connexion<span class="sr-only">(current)</span></a>
|
<a class="nav-link" href="{% url 'users:login' %}">Connexion<span class="sr-only">(current)</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="nav-link" href="{% url "users:password-reset" %}">(Mot de passe oublié)</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
14
users/templates/users/password_reset_mail.html
Normal file
14
users/templates/users/password_reset_mail.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{% load i18n %}{% autoescape off %}
|
||||||
|
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
|
||||||
|
|
||||||
|
{% trans "Please go to the following page and choose a new password:" %}
|
||||||
|
{% block reset_link %}
|
||||||
|
{{ protocol }}://festart.rezometz.org{% url 'users:password-reset-confirm' uidb64=uid token=token %}
|
||||||
|
{% endblock %}
|
||||||
|
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
|
||||||
|
|
||||||
|
{% trans "Thanks for using our site!" %}
|
||||||
|
|
||||||
|
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||||
|
|
||||||
|
{% endautoescape %}
|
|
@ -11,6 +11,10 @@ Inscription validée
|
||||||
<h1>
|
<h1>
|
||||||
{{school.name}}
|
{{school.name}}
|
||||||
</h1>
|
</h1>
|
||||||
|
<a class="btn btn-primary btn-sm" href="{% url 'users:password-change' %}">
|
||||||
|
<i class="fa fa-edit"></i>
|
||||||
|
Changer mon mot de passe
|
||||||
|
</a>
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'users:edit-school-name' school.pk %}">
|
<a class="btn btn-primary btn-sm" href="{% url 'users:edit-school-name' school.pk %}">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
Éditer
|
Éditer
|
||||||
|
|
14
users/templates/users/welcome_user.txt
Normal file
14
users/templates/users/welcome_user.txt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Bienvenue sur le site d'Il était une fois dans l'Est.
|
||||||
|
|
||||||
|
Vous recevez cet email car vous avez été désigné responsable des productions
|
||||||
|
vidéos pour votre école.
|
||||||
|
|
||||||
|
Votre identifiant est : {{id}}
|
||||||
|
|
||||||
|
Rendez-vous ici : http://festart.rezometz.org/users/reset pour réinitialiser
|
||||||
|
votre mot de passe (en utilisant cette adresse email).
|
||||||
|
|
||||||
|
Vous pouvez retrouver l'ensemble des informations sur l'évènement ici :
|
||||||
|
http://festart.rezometz.org
|
||||||
|
|
||||||
|
L'équipe de Il était une fois dans l'Est.
|
|
@ -1,4 +1,5 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from django.urls import reverse_lazy
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -26,17 +27,22 @@ urlpatterns = [
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
'password_change/done',
|
'password_change/done',
|
||||||
auth_views.PasswordChangeDoneView.as_view(template_name="base.html"),
|
views.PasswordChangeDoneView.as_view(),
|
||||||
name='password-change-done'
|
name='password-change-done'
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
'reset',
|
||||||
|
views.PasswordResetView.as_view(),
|
||||||
|
name='password-reset'
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
'reset/<uidb64>/<token>/',
|
'reset/<uidb64>/<token>/',
|
||||||
auth_views.PasswordResetConfirmView.as_view(template_name="edit.html"),
|
auth_views.PasswordResetConfirmView.as_view(template_name="edit.html", success_url=reverse_lazy('users:password-reset-done')),
|
||||||
name='password-reset-confirm'
|
name='password-reset-confirm'
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
'reset/done/',
|
'reset/done/',
|
||||||
auth_views.PasswordResetCompleteView.as_view(template_name="base.html"),
|
views.PasswordResetCompleteView.as_view(),
|
||||||
name='password-reset-done'
|
name='password-reset-done'
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.urls import reverse
|
from django.urls import reverse, reverse_lazy
|
||||||
|
from django.core.mail import send_mail
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.contrib.admin.views.decorators import staff_member_required
|
from django.contrib.admin.views.decorators import staff_member_required
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
|
|
||||||
from settings.forms import SelectUserForm
|
from settings.forms import SelectUserForm
|
||||||
from content.models import Category
|
from content.models import Category
|
||||||
|
@ -15,7 +18,14 @@ def create_user(request):
|
||||||
user_form = forms.CreateUser(request.POST or None)
|
user_form = forms.CreateUser(request.POST or None)
|
||||||
if user_form.is_valid():
|
if user_form.is_valid():
|
||||||
u = user_form.save()
|
u = user_form.save()
|
||||||
messages.success(request, "L'utilisateur {} {} a bien été créé.".format(
|
send_mail(
|
||||||
|
"Bienvenue sur Il était une fois dans l'Est.",
|
||||||
|
render_to_string("users/welcome_user.txt", {'id':u.username}),
|
||||||
|
"noreply.festart@rezometz.org",
|
||||||
|
[u.email],
|
||||||
|
fail_silently=False
|
||||||
|
)
|
||||||
|
messages.success(request, "L'utilisateur {} {} a bien été créé un mail lui a été envoyé pour réinitialiser son mot de passe.".format(
|
||||||
u.first_name, u.last_name))
|
u.first_name, u.last_name))
|
||||||
return redirect(reverse('settings:index'))
|
return redirect(reverse('settings:index'))
|
||||||
return render(request, 'edit.html', {
|
return render(request, 'edit.html', {
|
||||||
|
@ -226,3 +236,31 @@ def validate(request, pk):
|
||||||
messages.success(request, 'Inscription validée.')
|
messages.success(request, 'Inscription validée.')
|
||||||
|
|
||||||
return redirect(school.get_absolute_url())
|
return redirect(school.get_absolute_url())
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordChangeDoneView(auth_views.PasswordChangeDoneView):
|
||||||
|
template_name = "home.html"
|
||||||
|
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
r = super().dispatch(*args, **kwargs)
|
||||||
|
messages.success(self.request, "Le mot de passe a été changé.")
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordResetView(auth_views.PasswordResetView):
|
||||||
|
template_name = "edit.html"
|
||||||
|
success_url = reverse_lazy('home')
|
||||||
|
email_template_name = "users/password_reset_mail.html"
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
messages.success(self.request, "Un mail pour le changement de mot de passe a été envoyé.")
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordResetCompleteView(auth_views.PasswordResetCompleteView):
|
||||||
|
template_name = "home.html"
|
||||||
|
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
r = super().dispatch(*args, **kwargs)
|
||||||
|
messages.success(self.request, "Votre mot de passe a été réinitialisé.")
|
||||||
|
return r
|
||||||
|
|
Loading…
Reference in a new issue