Commit 955b82f9 authored by Flavio TARSETTI's avatar Flavio TARSETTI

[accounts][api] fix url prefix usage in api

Part of #558
parent 9526c024
Pipeline #43136 passed with stage
in 15 minutes and 35 seconds
......@@ -26,7 +26,6 @@
###############################################################################
import datetime
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.auth.models import User
......@@ -42,7 +41,6 @@ from ..ui.registration.models import RegistrationProfile
from ..utils import mail
from .models import Profile
from .models import SupervisionTrack
from .models import TemporaryUrl
from .permissions import IsAuthorAndNotSupervisor
from .permissions import IsAuthorAndPossiblySupervisor
from .permissions import IsSuperUser
......@@ -204,20 +202,15 @@ class SupervisorRemoveSuperviseeView(BaseUpdateSupervisionTrackView):
}
return BadRequestResponse(result)
parsed_url = urlparse(settings.URL_PREFIX)
server_address = "%s://%s" % (parsed_url.scheme, parsed_url.hostname)
if not supervisee.profile.is_supervisor:
context = {
"supervisor": supervisiontrack.supervisor,
"supervisee": supervisee,
"prefix": server_address,
}
else:
context = {
"supervisor": request.user,
"supervisee": supervisee,
"prefix": server_address,
}
if supervisee.profile.status == Profile.WAITINGVALIDATION:
......@@ -315,7 +308,6 @@ class SupervisorRemoveSuperviseeView(BaseUpdateSupervisionTrackView):
context = {
"supervisor": supervisee,
"supervisee": track_supervisee,
"prefix": server_address,
}
mail.send_email(
......@@ -345,7 +337,6 @@ class SupervisorRemoveSuperviseeView(BaseUpdateSupervisionTrackView):
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
......@@ -422,9 +413,6 @@ class SuperviseeAddSupervisorView(BaseCreateSupervisionTrackViewSupervisee):
}
return BadRequestResponse(result)
parsed_url = urlparse(settings.URL_PREFIX)
server_address = "%s://%s" % (parsed_url.scheme, parsed_url.hostname)
supervisee = request.user
if supervisee.profile.supervision_key is not None:
# There's a key check if there's a valid track
......@@ -452,7 +440,6 @@ class SuperviseeAddSupervisorView(BaseCreateSupervisionTrackViewSupervisee):
context = {
"supervisor": supervisiontrack.supervisor,
"supervisee": supervisiontrack.supervisee,
"prefix": server_address,
}
mail.send_email(
......@@ -519,7 +506,7 @@ class SuperviseeAddSupervisorView(BaseCreateSupervisionTrackViewSupervisee):
supervisee.save()
# Inform by email the supervisor that he has a new supervisee request
_ = inform_supervisor_new_supervisee_request(
inform_supervisor_new_supervisee_request(
request, supervisiontrack, supervisor, supervisee
)
......@@ -661,9 +648,6 @@ class RemoveSupervisorModeView(BaseUpdateSupervisorModeView):
| Q(supervisee__profile__status=Profile.WAITINGVALIDATION)
)
parsed_url = urlparse(settings.URL_PREFIX)
server_address = "%s://%s" % (parsed_url.scheme, parsed_url.hostname)
if supervisiontracks.count() > 0:
for track in supervisiontracks:
track.expiration_date = now
......@@ -688,7 +672,6 @@ class RemoveSupervisorModeView(BaseUpdateSupervisorModeView):
context = {
"supervisor": user,
"supervisee": track_supervisee,
"prefix": server_address,
}
mail.send_email(
......@@ -718,7 +701,6 @@ class RemoveSupervisorModeView(BaseUpdateSupervisorModeView):
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
......@@ -883,14 +865,9 @@ class UpdateSupervisorCandidateView(BaseUpdateSupervisorCandidateView):
supervisee.is_active = True
supervisee.save()
parsed_url = urlparse(settings.URL_PREFIX)
server_address = "%s://%s" % (parsed_url.scheme, parsed_url.hostname)
# Inform by email the new supervisor
context = {
"supervisor": request.user,
"supervisee": supervisee,
"prefix": server_address,
}
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