Commit 680b9a38 authored by Flavio TARSETTI's avatar Flavio TARSETTI

[accounts][api] notify supervisor of supervisee yearly revalidation

parent ac029442
......@@ -47,7 +47,9 @@ from ..common.utils import validate_restructuredtext
from ..ui.templatetags.markup import restructuredtext
from .models import SupervisionTrack, Profile
from .models import Profile
from .models import SupervisionTrack
from .models import TemporaryUrl
from ..common.models import Shareable
from ..common.exceptions import ShareError
from ..common.mixins import CommonContextMixin
......@@ -490,10 +492,12 @@ class SuperviseeAddSupervisorView(BaseCreateSupervisionTrackViewSupervisee):
supervisee.save()
#Inform by email the supervisor that he has a new supervisee request
temp_url = TemporaryUrl.objects.create_temporary_url(TemporaryUrl.VALIDATION, supervisiontrack)
context = {
'supervisor': supervisor,
'supervisee': supervisee,
'prefix': server_address,
"temp_url": temp_url.url_hash,
}
mail.send_email('registration/mail.supervisor_validation.subject.txt',
......@@ -559,6 +563,27 @@ class SuperviseeReValidationView(BaseUpdateSupervisionTrackFromSuperviseeView):
supervisiontrack.save()
supervisee.profile.save()
supervisee.save()
# Inform supervisor about supervisee revalidation
# Possible supervisor rejection available
parsed_url = urlparse(settings.URL_PREFIX)
server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname)
temp_url_rejection = TemporaryUrl.objects.create_temporary_url(TemporaryUrl.REJECTION, supervisiontrack)
context = {
"supervisor": supervisiontrack.supervisor,
"supervisee": supervisee,
"prefix": server_address,
"temp_url": temp_url_rejection.url_hash,
}
mail.send_email(
"registration/mail.account_revalidation_supervisor.subject.txt",
"registration/mail.supervisor_possible_supervisee_rejection.message.txt",
context,
[supervisiontrack.supervisor.email],
)
else:
#Track already valid
reason = "You don't need to revalidate at the moment, your supervision is still valid"
......
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