mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Ajout d'une view pour renvoyer le mail et du template du mail
This commit is contained in:
parent
faf6e4fc93
commit
0c75b6b555
4 changed files with 49 additions and 4 deletions
|
@ -415,8 +415,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
|
|
||||||
def has_access(self):
|
def has_access(self):
|
||||||
""" Renvoie si un utilisateur a accès à internet """
|
""" Renvoie si un utilisateur a accès à internet """
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
if(OptionalUser.get_cached_value('mail_verification') and not self.verified and self.verification_deadline is not None and timezone.now() > self.verification_deadline):
|
||||||
if(OptionalUser.get_cached_value('mail_verification') and not self.verified and self.verification_deadline is not None and now > self.verification_deadline):
|
|
||||||
verified = False
|
verified = False
|
||||||
else:
|
else:
|
||||||
verified = True
|
verified = True
|
||||||
|
@ -655,6 +654,9 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
def verification_message(self):
|
def verification_message(self):
|
||||||
if(OptionalUser.get_cached_value('mail_verification') and not self.verified):
|
if(OptionalUser.get_cached_value('mail_verification') and not self.verified):
|
||||||
if(self.verification_deadline is not None):
|
if(self.verification_deadline is not None):
|
||||||
|
if(timezone.now() > self.verification_deadline):
|
||||||
|
message = 'Votre adresse mail n\'est pas vérifiée et votre connexion a été interrompue'
|
||||||
|
else:
|
||||||
message = 'Votre adresse mail n\'est pas vérifiée. Si vous ne vérifiez pas votre adresse mail, toute connexion sera intérrompu le ' + str(self.verification_deadline)
|
message = 'Votre adresse mail n\'est pas vérifiée. Si vous ne vérifiez pas votre adresse mail, toute connexion sera intérrompu le ' + str(self.verification_deadline)
|
||||||
else:
|
else:
|
||||||
message = 'Votre adresse mail n\'est pas vérifiée.'
|
message = 'Votre adresse mail n\'est pas vérifiée.'
|
||||||
|
|
33
users/templates/users/email_verification_request
Normal file
33
users/templates/users/email_verification_request
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
Bonjour {{ name }},
|
||||||
|
|
||||||
|
Vous trouverez ci-dessous une url permetant dé vérifier compte votre
|
||||||
|
compte {{ site_name }}. Celui-ci vous permet de gérer l'ensemble de vos équipements
|
||||||
|
connectés, votre compte, vos factures, et tous les services proposés sur le réseau.
|
||||||
|
|
||||||
|
{{ url }}
|
||||||
|
|
||||||
|
Contactez les administrateurs si vous n'êtes pas à l'origine de cette requête.
|
||||||
|
|
||||||
|
Ce lien expirera dans {{ expire_in }}.
|
||||||
|
|
||||||
|
Cordialement,
|
||||||
|
|
||||||
|
L'équipe de {{ asso }} (contact : {{ asso_mail }}).
|
||||||
|
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Hi {{ name }},
|
||||||
|
|
||||||
|
You will find a link allowing you to validate your account on {{ site_name }}.
|
||||||
|
On this website you will then be able to manage your devices on the {{ asso }}.
|
||||||
|
|
||||||
|
{{ url }}
|
||||||
|
|
||||||
|
This link will expire in {{ expire_in }}.
|
||||||
|
|
||||||
|
Send an email at {{ asso_mail }} if you didn't request this or if you have
|
||||||
|
any other question.
|
||||||
|
|
||||||
|
Thanks
|
||||||
|
|
||||||
|
The team of {{ asso }} (contact : {{ asso_mail }}).
|
|
@ -116,4 +116,5 @@ urlpatterns = [
|
||||||
url(r'^rest/ml/club/member/(?P<ml_name>\w+)/$',
|
url(r'^rest/ml/club/member/(?P<ml_name>\w+)/$',
|
||||||
views.ml_club_members,
|
views.ml_club_members,
|
||||||
name='ml-club-members'),
|
name='ml-club-members'),
|
||||||
|
url(r'^resend_verification_mail$', views.resend_verification_mail, name="resend_verification_mail'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -46,6 +46,7 @@ from django.db import transaction
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from rest_framework.renderers import JSONRenderer
|
from rest_framework.renderers import JSONRenderer
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
@ -119,7 +120,7 @@ def new_user(request):
|
||||||
user.send_verification_mail(request)
|
user.send_verification_mail(request)
|
||||||
messages.warning(request, "Un mail pour vérifier l'adresse a été envoyé")
|
messages.warning(request, "Un mail pour vérifier l'adresse a été envoyé")
|
||||||
if(OptionalUser.get_cached_value('verification_time')>0):
|
if(OptionalUser.get_cached_value('verification_time')>0):
|
||||||
user.verification_deadline = datetime.datetime.now() + datetime.timedelta(hours=OptionalUser.get_cached_value('verification_time'))
|
user.verification_deadline = timezone.now() + datetime.timedelta(hours=OptionalUser.get_cached_value('verification_time'))
|
||||||
user.save()
|
user.save()
|
||||||
if(password != ""):
|
if(password != ""):
|
||||||
user.set_password(password)
|
user.set_password(password)
|
||||||
|
@ -1070,3 +1071,11 @@ def ml_club_members(request, ml_name):
|
||||||
)
|
)
|
||||||
seria = MailingMemberSerializer(members, many=True)
|
seria = MailingMemberSerializer(members, many=True)
|
||||||
return JSONResponse(seria.data)
|
return JSONResponse(seria.data)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def resend_verification_mail(request):
|
||||||
|
if(OptionalUser.get_cached_value('mail_verification')):
|
||||||
|
request.user.send_verification_mail(request)
|
||||||
|
messages.success(request, "Un nouveau mail a été envoyé")
|
||||||
|
return redirect(reverse('users:profil', kwargs={'userid': str(request.user.id)}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue