Commit 0002a454 authored by Flavio TARSETTI's avatar Flavio TARSETTI Committed by Samuel GAIST

[accounts][management][commands] Fix yearly account revalidation url

prefix

Fixes # 570

Part of #558
parent cbfc8313
......@@ -29,11 +29,12 @@
import datetime
import sys
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.sites.models import Site
from django.db import models
from django.db.models import Q
from django.urls import reverse
from ....common.management.commands.base import InteractiveCommand
from ....ui.registration.models import RegistrationProfile
......@@ -76,9 +77,6 @@ class Command(InteractiveCommand):
blocked_count = 0
warned_count = 0
parsed_url = urlparse(settings.URL_PREFIX)
server_address = "%s://%s" % (parsed_url.scheme, parsed_url.hostname)
for torevalidate_profile in torevalidate_profiles:
user = torevalidate_profile.user
if user.profile.supervision_key is not None:
......@@ -96,9 +94,7 @@ class Command(InteractiveCommand):
# if supervisor account reject all supervisees and inform them
if user.profile.is_supervisor:
context = {
"supervisor": user,
"supervisee": user,
"prefix": server_address,
}
# Transform supervisor account to normal account and inform by email
......@@ -179,7 +175,6 @@ class Command(InteractiveCommand):
context = {
"supervisor": track_supervisor,
"supervisee": track_supervisee,
"prefix": server_address,
}
mail.send_email(
......@@ -212,7 +207,6 @@ class Command(InteractiveCommand):
context = {
"supervisor": track_supervisor,
"supervisee": track_supervisee,
"prefix": server_address,
}
# New user account waiting validation, so delete this account and inform by email the user
......@@ -268,11 +262,19 @@ class Command(InteractiveCommand):
TemporaryUrl.YEARREVALIDATION, supervisiontrack,
)
current_site = Site.objects.get_current()
revalidation_url = (
f"https://{current_site.domain}"
+ reverse(
"accounts:temp_url_validation",
kwargs={"hash_url": temp_url.url_hash},
)
)
context = {
"user": user,
"expiration_date": supervisiontrack.expiration_date.date(),
"prefix": server_address,
"temp_url": temp_url.url_hash,
"revalidation_url": revalidation_url,
}
mail.send_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