Commit d642e93d authored by Samuel GAIST's avatar Samuel GAIST
Browse files

Merge branch '570_fix_url_prefix_usage_yearly_account_revalidation' into 'django3_migration'

Fix url prefix usage yearly account revalidation

See merge request !392
parents cbfc8313 5bac3de6
Pipeline #43205 passed with stage
in 16 minutes and 3 seconds
......@@ -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(
......
......@@ -10,6 +10,8 @@ If you haven't done this by this expiration date: {{ expiration_date }}, your ac
will be blocked and you will then need to go trough an account revalidation
procedure to re-activate it.
You can also click on the following direct link to accomplish this action and re-validate your account at {{ prefix }}/accounts/validation/{{ temp_url }}
You can also click on the following direct link to accomplish this action and re-validate your account at:
{{ revalidation_url }}
BEAT Administrators at the Idiap Research Institute
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