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

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

prefix

Fixes # 570

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