From b2e824b9bef442fc15da66603556eea8baed9a0f Mon Sep 17 00:00:00 2001 From: Flavio Tarsetti <flavio.tarsetti@idiap.ch> Date: Tue, 5 Sep 2017 17:01:17 +0200 Subject: [PATCH] [accounts] removed godfather and changed with supervisor --- beat/web/accounts/api.py | 84 ++++----- beat/web/accounts/api_urls.py | 8 +- .../commands/clean_invalid_users.py | 2 +- .../commands/year_revalidation_users.py | 6 +- .../0011_rename_godfather_to_supervisor.py | 25 +++ beat/web/accounts/models.py | 8 +- beat/web/accounts/permissions.py | 8 +- beat/web/accounts/serializers.py | 8 +- .../accounts/static/accounts/css/dialogs.css | 4 +- .../accounts/static/accounts/js/dialogs.js | 20 +- .../accounts/dialogs/change_supervisor.html | 2 +- .../accounts/templates/accounts/settings.html | 12 +- beat/web/accounts/tests.py | 174 +++++++++--------- beat/web/accounts/views.py | 8 +- beat/web/navigation/admin.py | 20 +- beat/web/settings/settings.py | 2 +- beat/web/ui/registration/docs/forms.txt | 4 +- beat/web/ui/registration/forms.py | 26 +-- beat/web/ui/registration/models.py | 16 +- .../registration/blocked_user_reactivate.html | 8 +- ...t => mail.supervisor_rejected.message.txt} | 0 ...t => mail.supervisor_rejected.subject.txt} | 0 ...visor_rejected_delete_account.message.txt} | 0 ... => mail.supervisor_rejection.message.txt} | 0 ... => mail.supervisor_rejection.subject.txt} | 0 ... => mail.supervisor_validated.message.txt} | 0 ... => mail.supervisor_validated.subject.txt} | 0 ...=> mail.supervisor_validation.message.txt} | 0 ...=> mail.supervisor_validation.subject.txt} | 0 ...dation_supervisee_add_request.message.txt} | 0 .../registration/registration_form.html | 8 +- beat/web/ui/views.py | 20 +- 32 files changed, 249 insertions(+), 224 deletions(-) create mode 100644 beat/web/accounts/migrations/0011_rename_godfather_to_supervisor.py rename beat/web/ui/registration/templates/registration/{mail.godfather_rejected.message.txt => mail.supervisor_rejected.message.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_rejected.subject.txt => mail.supervisor_rejected.subject.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_rejected_delete_account.message.txt => mail.supervisor_rejected_delete_account.message.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_rejection.message.txt => mail.supervisor_rejection.message.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_rejection.subject.txt => mail.supervisor_rejection.subject.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_validated.message.txt => mail.supervisor_validated.message.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_validated.subject.txt => mail.supervisor_validated.subject.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_validation.message.txt => mail.supervisor_validation.message.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_validation.subject.txt => mail.supervisor_validation.subject.txt} (100%) rename beat/web/ui/registration/templates/registration/{mail.godfather_validation_supervisee_add_request.message.txt => mail.supervisor_validation_supervisee_add_request.message.txt} (100%) diff --git a/beat/web/accounts/api.py b/beat/web/accounts/api.py index a56b2e4d9..fcc34817a 100644 --- a/beat/web/accounts/api.py +++ b/beat/web/accounts/api.py @@ -58,7 +58,7 @@ from itertools import chain from datetime import datetime, timedelta -from .permissions import IsGodfatherAndAuthor, IsAuthorAndNotGodfather +from .permissions import IsSupervisorAndAuthor, IsAuthorAndNotSupervisor from ..common.responses import BadRequestResponse, ForbiddenResponse @@ -72,31 +72,31 @@ import simplejson as json #---------------------------------------------------------- -class GodfatherListView(generics.ListAPIView): +class SupervisorListView(generics.ListAPIView): model = SupervisionTrack serializer_class = FullSupervisionTrackSerializer def get_permissions(self): - permission_classes = [permissions.IsAuthenticated, IsGodfatherAndAuthor] + permission_classes = [permissions.IsAuthenticated, IsSupervisorAndAuthor] self.permission_classes = permission_classes - return super(GodfatherListView, self).get_permissions() + return super(SupervisorListView, self).get_permissions() def get_serializer(self, *args, **kwargs): - return super(GodfatherListView, self).get_serializer(*args, **kwargs) + return super(SupervisorListView, self).get_serializer(*args, **kwargs) def list(self, request): - #A godfather can validate an account of: + #A supervisor can validate an account of: #1) a new user requesting validation #2) an existing validated user rejected by a previous supervisor #3) an existing validated user requesting a change of supervisor #4) a blocked user requesting a supervision #On all cases check the current key in supervisee profile match the supervisiontrack key as this is the current supervision request/track from the supervisee - queryset = SupervisionTrack.objects.filter(godfather=request.user).filter(Q(supervisee__profile__status=Profile.WAITINGVALIDATION)|Q(supervisee__profile__status=Profile.REJECTED)|Q(supervisee__profile__status=Profile.YEARREVALIDATION)|Q(supervisee__profile__status=Profile.ACCEPTED)|Q(supervisee__profile__status=Profile.BLOCKED)).filter(Q(supervisee__profile__supervision_key=models.F('supervision_key'))) + queryset = SupervisionTrack.objects.filter(supervisor=request.user).filter(Q(supervisee__profile__status=Profile.WAITINGVALIDATION)|Q(supervisee__profile__status=Profile.REJECTED)|Q(supervisee__profile__status=Profile.YEARREVALIDATION)|Q(supervisee__profile__status=Profile.ACCEPTED)|Q(supervisee__profile__status=Profile.BLOCKED)).filter(Q(supervisee__profile__supervision_key=models.F('supervision_key'))) serializer = FullSupervisionTrackSerializer(queryset, many=True, context ={'request': request}) return Response(serializer.data) @@ -110,7 +110,7 @@ class BaseUpdateSupervisionTrackView(generics.UpdateAPIView): serializer_class = SupervisionTrackUpdateSerializer def get_permissions(self): - permission_classes = [permissions.IsAuthenticated, IsGodfatherAndAuthor] + permission_classes = [permissions.IsAuthenticated, IsSupervisorAndAuthor] self.permission_classes = permission_classes @@ -120,14 +120,14 @@ class BaseUpdateSupervisionTrackView(generics.UpdateAPIView): #---------------------------------------------------------- -class GodfatherAddSuperviseeView(BaseUpdateSupervisionTrackView): +class SupervisorAddSuperviseeView(BaseUpdateSupervisionTrackView): permission_classes = BaseUpdateSupervisionTrackView.permission_classes def put(self, request, supervisee_name): supervisee = User.objects.get(username=supervisee_name) profile_supervisee = Profile.objects.get(user=supervisee) if supervisee.profile.status != Profile.ACCEPTED: - supervisiontrack = SupervisionTrack.objects.get(godfather=request.user, supervisee=supervisee, supervisee__profile__supervision_key=models.F('supervision_key')) + supervisiontrack = SupervisionTrack.objects.get(supervisor=request.user, supervisee=supervisee, supervisee__profile__supervision_key=models.F('supervision_key')) supervisiontrack.is_valid = True @@ -150,19 +150,19 @@ class GodfatherAddSuperviseeView(BaseUpdateSupervisionTrackView): parsed_url = urlparse(settings.URL_PREFIX) server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname) - c = Context({ 'supervisor': supervisiontrack.godfather, + c = Context({ 'supervisor': supervisiontrack.supervisor, 'supervisee': supervisee, 'prefix': server_address, }) try: - t = loader.get_template('registration/mail.godfather_validated.subject.txt') + t = loader.get_template('registration/mail.supervisor_validated.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_validated.message.txt') + t = loader.get_template('registration/mail.supervisor_validated.message.txt') message = t.render(c) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisee.email]) @@ -182,19 +182,19 @@ class GodfatherAddSuperviseeView(BaseUpdateSupervisionTrackView): #---------------------------------------------------------- -class GodfatherRemoveSuperviseeView(BaseUpdateSupervisionTrackView): +class SupervisorRemoveSuperviseeView(BaseUpdateSupervisionTrackView): permission_classes = BaseUpdateSupervisionTrackView.permission_classes def put(self, request, supervisee_name): supervisee = User.objects.get(username=supervisee_name) - supervisiontrack = SupervisionTrack.objects.get(godfather=request.user, supervisee=supervisee, supervisee__profile__supervision_key=models.F('supervision_key')) + supervisiontrack = SupervisionTrack.objects.get(supervisor=request.user, supervisee=supervisee, supervisee__profile__supervision_key=models.F('supervision_key')) from django.core.mail import send_mail parsed_url = urlparse(settings.URL_PREFIX) server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname) - c = Context({ 'supervisor': supervisiontrack.godfather, + c = Context({ 'supervisor': supervisiontrack.supervisor, 'supervisee': supervisee, 'prefix': server_address, }) @@ -202,13 +202,13 @@ class GodfatherRemoveSuperviseeView(BaseUpdateSupervisionTrackView): if supervisee.profile.status == Profile.WAITINGVALIDATION: #New user account waiting validation, so delete this account and inform by email the user try: - t = loader.get_template('registration/mail.godfather_rejected.subject.txt') + t = loader.get_template('registration/mail.supervisor_rejected.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_rejected_delete_account.message.txt') + t = loader.get_template('registration/mail.supervisor_rejected_delete_account.message.txt') message = t.render(c) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisee.email]) @@ -242,13 +242,13 @@ class GodfatherRemoveSuperviseeView(BaseUpdateSupervisionTrackView): supervisee.save() try: - t = loader.get_template('registration/mail.godfather_rejected.subject.txt') + t = loader.get_template('registration/mail.supervisor_rejected.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_rejected.message.txt') + t = loader.get_template('registration/mail.supervisor_rejected.message.txt') message = t.render(c) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisee.email]) @@ -270,7 +270,7 @@ class BaseCreateSupervisionTrackViewSupervisee(generics.CreateAPIView): serializer_class = SupervisionTrackUpdateSerializer def get_permissions(self): - permission_classes = [permissions.IsAuthenticated, IsAuthorAndNotGodfather] + permission_classes = [permissions.IsAuthenticated, IsAuthorAndNotSupervisor] self.permission_classes = permission_classes @@ -280,23 +280,23 @@ class BaseCreateSupervisionTrackViewSupervisee(generics.CreateAPIView): #---------------------------------------------------------- -class SuperviseeAddGodfatherView(BaseCreateSupervisionTrackViewSupervisee): +class SuperviseeAddSupervisorView(BaseCreateSupervisionTrackViewSupervisee): permission_classes = BaseCreateSupervisionTrackViewSupervisee.permission_classes def post(self, request, supervisor_name): - #check if user exists and its validity and if it's a godfather account + #check if user exists and its validity and if it's a supervisor account try: - godfather = User.objects.get(username=supervisor_name) - if not godfather.profile.is_godfather: - #Not a valid godfather + supervisor = User.objects.get(username=supervisor_name) + if not supervisor.profile.is_supervisor: + #Not a valid supervisor reason = "Not a valid supervisor request" result = { 'error': reason, } return BadRequestResponse(result) else: - if godfather.profile.status == Profile.BLOCKED: - #Not a valid godfather + if supervisor.profile.status == Profile.BLOCKED: + #Not a valid supervisor reason = "Not a valid supervisor request" result = { 'error': reason, @@ -331,22 +331,22 @@ class SuperviseeAddGodfatherView(BaseCreateSupervisionTrackViewSupervisee): parsed_url = urlparse(settings.URL_PREFIX) server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname) - c = Context({ 'supervisor': supervisiontrack.godfather, + c = Context({ 'supervisor': supervisiontrack.supervisor, 'supervisee': supervisiontrack.supervisee, 'prefix': server_address, }) try: - t = loader.get_template('registration/mail.godfather_rejection.subject.txt') + t = loader.get_template('registration/mail.supervisor_rejection.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_rejection.message.txt') + t = loader.get_template('registration/mail.supervisor_rejection.message.txt') message = t.render(c) - send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisiontrack.godfather.email]) + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisiontrack.supervisor.email]) except: pass @@ -391,7 +391,7 @@ class SuperviseeAddGodfatherView(BaseCreateSupervisionTrackViewSupervisee): supervisee.profile.supervision_key = supervisee.profile._generate_current_supervision_key() supervisiontrack = SupervisionTrack.objects.create( supervisee = supervisee, - godfather = godfather, + supervisor = supervisor, is_valid = False, ) @@ -407,22 +407,22 @@ class SuperviseeAddGodfatherView(BaseCreateSupervisionTrackViewSupervisee): parsed_url = urlparse(settings.URL_PREFIX) server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname) - c = Context({ 'supervisor': godfather, + c = Context({ 'supervisor': supervisor, 'supervisee': supervisee, 'prefix': server_address, }) try: - t = loader.get_template('registration/mail.godfather_validation.subject.txt') + t = loader.get_template('registration/mail.supervisor_validation.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_validation_supervisee_add_request.message.txt') + t = loader.get_template('registration/mail.supervisor_validation_supervisee_add_request.message.txt') message = t.render(c) - send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [godfather.email]) + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisor.email]) except: pass @@ -437,7 +437,7 @@ class BaseUpdateSupervisionTrackFromSuperviseeView(generics.UpdateAPIView): serializer_class = SupervisionTrackUpdateSerializer def get_permissions(self): - permission_classes = [permissions.IsAuthenticated, IsAuthorAndNotGodfather] + permission_classes = [permissions.IsAuthenticated, IsAuthorAndNotSupervisor] self.permission_classes = permission_classes @@ -459,10 +459,10 @@ class SuperviseeReValidationView(BaseUpdateSupervisionTrackFromSuperviseeView): supervisiontrack = SupervisionTrack.objects.get(supervisee=supervisee, supervisee__profile__supervision_key=models.F('supervision_key')) if supervisiontrack.is_valid: if supervisee.profile.status == Profile.YEARREVALIDATION: - #Check Godfather validity - godfather = supervisiontrack.godfather - #If Godfather account is not valid. Reject the account (though this should already be done during godfather rejection) - if godfather.profile.status != Profile.BLOCKED: + #Check Supervisor validity + supervisor = supervisiontrack.supervisor + #If Supervisor account is not valid. Reject the account (though this should already be done during supervisor rejection) + if supervisor.profile.status != Profile.BLOCKED: #Change status supervisee.profile.status = Profile.ACCEPTED #Extend supervisiontrack validity for another 12 months diff --git a/beat/web/accounts/api_urls.py b/beat/web/accounts/api_urls.py index c6b3d1659..a1d7eb7cc 100644 --- a/beat/web/accounts/api_urls.py +++ b/beat/web/accounts/api_urls.py @@ -31,25 +31,25 @@ from . import api urlpatterns = [ url( r'^$', - api.GodfatherListView.as_view(), + api.SupervisorListView.as_view(), name='list_supervisee' ), url( r'^(?P<supervisee_name>[\w\W]+)/validate/$', - api.GodfatherAddSuperviseeView.as_view(), + api.SupervisorAddSuperviseeView.as_view(), name='validate_supervisee' ), url( r'^(?P<supervisee_name>[\w\W]+)/remove/$', - api.GodfatherRemoveSuperviseeView.as_view(), + api.SupervisorRemoveSuperviseeView.as_view(), name='remove_supervisee' ), url( r'^(?P<supervisor_name>[\w\W]+)/add/$', - api.SuperviseeAddGodfatherView.as_view(), + api.SuperviseeAddSupervisorView.as_view(), name='add_supervisor' ), diff --git a/beat/web/accounts/management/commands/clean_invalid_users.py b/beat/web/accounts/management/commands/clean_invalid_users.py index 36c3059e2..0d98d7d39 100644 --- a/beat/web/accounts/management/commands/clean_invalid_users.py +++ b/beat/web/accounts/management/commands/clean_invalid_users.py @@ -87,7 +87,7 @@ class Command(BaseCommand): supervisiontrack = SupervisionTrack.objects.get(supervision_key=invalid_profile.supervision_key) registration_profile = RegistrationProfile.objects.get(user=invalid_profile.user) - expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS_FROM_GODFATHER) + expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR) if user.profile.registration_date + expiration_date <= datetime.datetime.now(): count += 1 user.delete() diff --git a/beat/web/accounts/management/commands/year_revalidation_users.py b/beat/web/accounts/management/commands/year_revalidation_users.py index b00a3669c..9bf3fc62b 100644 --- a/beat/web/accounts/management/commands/year_revalidation_users.py +++ b/beat/web/accounts/management/commands/year_revalidation_users.py @@ -79,8 +79,8 @@ class Command(BaseCommand): for torevalidate_profile in torevalidate_profiles: user = torevalidate_profile.user - if user.profile.is_godfather == False: - #Not godfather + if user.profile.is_supervisor == False: + #Not supervisor if user.profile.supervision_key != None: supervisiontrack = SupervisionTrack.objects.get(supervision_key=torevalidate_profile.supervision_key) if supervisiontrack.is_valid: @@ -138,7 +138,7 @@ class Command(BaseCommand): else: - #Is godfather + #Is supervisor #TODO implement this procedure pass diff --git a/beat/web/accounts/migrations/0011_rename_godfather_to_supervisor.py b/beat/web/accounts/migrations/0011_rename_godfather_to_supervisor.py new file mode 100644 index 000000000..780473067 --- /dev/null +++ b/beat/web/accounts/migrations/0011_rename_godfather_to_supervisor.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2017-09-05 16:45 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0010_check_all_accounts'), + ] + + operations = [ + migrations.RenameField( + model_name='profile', + old_name='is_godfather', + new_name='is_supervisor', + ), + migrations.RenameField( + model_name='supervisiontrack', + old_name='godfather', + new_name='supervisor', + ), + ] diff --git a/beat/web/accounts/models.py b/beat/web/accounts/models.py index ae35b2a05..b39117eff 100644 --- a/beat/web/accounts/models.py +++ b/beat/web/accounts/models.py @@ -52,7 +52,7 @@ class SupervisionTrack(models.Model): supervisee = models.ForeignKey(User, on_delete=models.CASCADE, related_name='supervisors') - godfather = models.ForeignKey(User, on_delete=models.CASCADE, + supervisor = models.ForeignKey(User, on_delete=models.CASCADE, related_name='supervisees') is_valid = models.BooleanField(default=False) start_date = models.DateTimeField(null=True, blank=True) @@ -61,14 +61,14 @@ class SupervisionTrack(models.Model): supervision_key = models.CharField(max_length=40, null=True, blank=True) def __unicode__(self): - return u'Godfather: %s, Supervisee, %s, Validity: %s' % (self.godfather.username, self.supervisee.username, self.is_valid) + return u'Supervisor: %s, Supervisee, %s, Validity: %s' % (self.supervisor.username, self.supervisee.username, self.is_valid) class Profile(models.Model): #_____ Constants __________ #New account creation 'N'/'W' - #Godfather acceptance/rejection 'A'/'R' + #Supervisor acceptance/rejection 'A'/'R' #Yearly revalidation/blockage 'Y'/'B' NEWUSER = 'N' WAITINGVALIDATION = 'W' @@ -93,7 +93,7 @@ class Profile(models.Model): # Other fields here status = models.CharField(max_length=1, choices=PROFILE_STATUS, default=BLOCKED) - is_godfather = models.BooleanField(default=False) + is_supervisor = models.BooleanField(default=False) supervision = models.ManyToManyField(SupervisionTrack, related_name='profiles', blank=True) supervision_key = models.CharField(max_length=40, null=True, blank=True) registration_date = models.DateTimeField(null=True, blank=True) diff --git a/beat/web/accounts/permissions.py b/beat/web/accounts/permissions.py index 18f8c351a..3caca54a8 100644 --- a/beat/web/accounts/permissions.py +++ b/beat/web/accounts/permissions.py @@ -31,24 +31,24 @@ from rest_framework import permissions #---------------------------------------------------------- -class IsGodfatherAndAuthor(permissions.BasePermission): +class IsSupervisorAndAuthor(permissions.BasePermission): """ The logged in user should also be the author """ message = 'Not a supervisor account' def has_permission(self, request, view): - return request.user.profile.is_godfather + return request.user.profile.is_supervisor #---------------------------------------------------------- -class IsAuthorAndNotGodfather(permissions.BasePermission): +class IsAuthorAndNotSupervisor(permissions.BasePermission): """ The logged in user should also be the author """ message = 'Not a supervisee account' def has_permission(self, request, view): - return not request.user.profile.is_godfather + return not request.user.profile.is_supervisor diff --git a/beat/web/accounts/serializers.py b/beat/web/accounts/serializers.py index 491af9bda..5d3cd2820 100644 --- a/beat/web/accounts/serializers.py +++ b/beat/web/accounts/serializers.py @@ -61,7 +61,7 @@ class UserSerializer(serializers.ModelSerializer): class BasicSupervisionTrackSerializer(serializers.ModelSerializer): supervisee = UserSerializer() - godfather = UserSerializer() + supervisor = UserSerializer() is_valid = serializers.SerializerMethodField() start_date = serializers.SerializerMethodField() expiration_date = serializers.SerializerMethodField() @@ -75,8 +75,8 @@ class BasicSupervisionTrackSerializer(serializers.ModelSerializer): #def get_supervisee(self, obj): # return obj.supervisee - #def get_godfather(self, obj): - # return obj.godfather + #def get_supervisor(self, obj): + # return obj.supervisor def get_is_valid(self, obj): return obj.is_valid @@ -100,7 +100,7 @@ class BasicSupervisionTrackSerializer(serializers.ModelSerializer): class FullSupervisionTrackSerializer(BasicSupervisionTrackSerializer): class Meta(BasicSupervisionTrackSerializer.Meta): - fields = ['supervisee', 'godfather', 'is_valid', 'start_date', 'expiration_date','last_validation_date', 'supervision_key'] + fields = ['supervisee', 'supervisor', 'is_valid', 'start_date', 'expiration_date','last_validation_date', 'supervision_key'] #---------------------------------------------------------- diff --git a/beat/web/accounts/static/accounts/css/dialogs.css b/beat/web/accounts/static/accounts/css/dialogs.css index 004a329b9..aa0a68a5f 100644 --- a/beat/web/accounts/static/accounts/css/dialogs.css +++ b/beat/web/accounts/static/accounts/css/dialogs.css @@ -70,14 +70,14 @@ div.change_supervisor span.label } -div.change_supervisor input#new_godfather_username +div.change_supervisor input#new_supervisor_username { display: inline-block; width: 50%; } -div.change_supervisor input#new_godfather_username +div.change_supervisor input#new_supervisor_username { margin-top: 10px; } diff --git a/beat/web/accounts/static/accounts/js/dialogs.js b/beat/web/accounts/static/accounts/js/dialogs.js index 1d14883c8..872b5b8de 100644 --- a/beat/web/accounts/static/accounts/js/dialogs.js +++ b/beat/web/accounts/static/accounts/js/dialogs.js @@ -111,14 +111,14 @@ beat.accounts.dialogs.modal_renew_account = function(dialog_id, api_url, redirec * Parameters: * * dialog_id: ID of the DOM element to use - * old_godfather_username: previous supervisor username + * old_supervisor_username: previous supervisor username * api_url (str): The URL towards the API for changing the supervisor * redirect_url (str): The URL where to redirect the user if the operation is * successful */ -beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_godfather_username, api_url, redirect_url) { +beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_supervisor_username, api_url, redirect_url) { - var split_api_url = api_url.split(old_godfather_username); + var split_api_url = api_url.split(old_supervisor_username); // Create the dialog $('#' + dialog_id).dialog({ @@ -134,7 +134,7 @@ beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_godfathe text: 'Request', click: function() { - var new_godfather_username = $('#' + dialog_id + ' #new_godfather_username')[0].value; + var new_supervisor_username = $('#' + dialog_id + ' #new_supervisor_username')[0].value; var name = $('#' + dialog_id + ' input')[0].value.trim(); @@ -144,7 +144,7 @@ beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_godfathe return; } - if (new_godfather_username == old_godfather_username) + if (new_supervisor_username == old_supervisor_username) { alert("The new supervisor username is the same as the previous one!"); return; @@ -159,7 +159,7 @@ beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_godfathe $.ajax({ type: "POST", - url: split_api_url[0] + new_godfather_username + split_api_url[1], + url: split_api_url[0] + new_supervisor_username + split_api_url[1], data: JSON.stringify({ name: name, }), @@ -191,7 +191,7 @@ beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_godfathe }); // Initialise the dialog content - $('#' + dialog_id + ' input')[0].value = old_godfather_username; + $('#' + dialog_id + ' input')[0].value = old_supervisor_username; // Display the dialog $('#' + dialog_id).dialog("open"); @@ -212,7 +212,7 @@ beat.accounts.dialogs.modal_change_supervisor = function(dialog_id, old_godfathe */ beat.accounts.dialogs.modal_add_supervisor = function(dialog_id, api_url, redirect_url) { - var split_api_url = api_url.split("nogodfather"); + var split_api_url = api_url.split("nosupervisor"); // Create the dialog $('#' + dialog_id).dialog({ @@ -228,7 +228,7 @@ beat.accounts.dialogs.modal_add_supervisor = function(dialog_id, api_url, redire text: 'Request', click: function() { - var new_godfather_username = $('#' + dialog_id + ' #new_godfather_username')[0].value; + var new_supervisor_username = $('#' + dialog_id + ' #new_supervisor_username')[0].value; var name = $('#' + dialog_id + ' input')[0].value.trim(); @@ -247,7 +247,7 @@ beat.accounts.dialogs.modal_add_supervisor = function(dialog_id, api_url, redire $.ajax({ type: "POST", - url: split_api_url[0] + new_godfather_username + split_api_url[1], + url: split_api_url[0] + new_supervisor_username + split_api_url[1], data: JSON.stringify({ name: name, }), diff --git a/beat/web/accounts/templates/accounts/dialogs/change_supervisor.html b/beat/web/accounts/templates/accounts/dialogs/change_supervisor.html index b4156162b..eecd97244 100644 --- a/beat/web/accounts/templates/accounts/dialogs/change_supervisor.html +++ b/beat/web/accounts/templates/accounts/dialogs/change_supervisor.html @@ -26,7 +26,7 @@ Take into account that requesting a new supervision will temporarely set your account to an inactive state until the request is validated by your new supervisor.<br> If your new supervisor rejects your supervision request, you need to find another supervisor.<br> If no supervisor is found after a specific date, your account will be blocked and you will need to proceed with an account reactivation request<br> - <div><span class="label">New supervisor username: </span><input id="new_godfather_username" type="text" /></div> + <div><span class="label">New supervisor username: </span><input id="new_supervisor_username" type="text" /></div> <div><span class="documentation">A request for supervision will be sent to the new supervisor</span></div> </div> </div> diff --git a/beat/web/accounts/templates/accounts/settings.html b/beat/web/accounts/templates/accounts/settings.html index 1737f6f16..f18baca7f 100644 --- a/beat/web/accounts/templates/accounts/settings.html +++ b/beat/web/accounts/templates/accounts/settings.html @@ -196,7 +196,7 @@ </div> </div> -{% if not user.profile.is_godfather and not user.is_superuser %} +{% if not user.profile.is_supervisor and not user.is_superuser %} <div class="row"> @@ -225,14 +225,14 @@ <br> <h4>Supervision Information</h4> <ul class="list-group"> - <li class="list-group-item"><b>Supervisor:</b> <a href="{% url "activity-stream" supervisiontrack.godfather.username %}">{{ supervisiontrack.godfather.username }}</a></li> + <li class="list-group-item"><b>Supervisor:</b> <a href="{% url "activity-stream" supervisiontrack.supervisor.username %}">{{ supervisiontrack.supervisor.username }}</a></li> <li class="list-group-item"><b>Supervision start date:</b> {{ supervisiontrack.start_date }}</li> <li class="list-group-item"><b>Supervision last validation date:</b> {{ supervisiontrack.last_validation_date }}</li> <li class="list-group-item"><b>Supervision expiration date:</b> {{ supervisiontrack.expiration_date }}</li> </ul> <div class="form-group" style="text-align: center;"> <input type="hidden" name="token" value="true"> - <button type="button" class="btn btn-warning" onclick="beat.accounts.dialogs.modal_change_supervisor('change_supervisor', '{{ supervisiontrack.godfather.username }}', '{% url 'api_accounts:add_supervisor' supervisiontrack.godfather.username %}', '{% url 'accounts:settings' %}');"><i class="fa fa-refresh fa-fw fa-lg"></i> Change supervisor?</button> + <button type="button" class="btn btn-warning" onclick="beat.accounts.dialogs.modal_change_supervisor('change_supervisor', '{{ supervisiontrack.supervisor.username }}', '{% url 'api_accounts:add_supervisor' supervisiontrack.supervisor.username %}', '{% url 'accounts:settings' %}');"><i class="fa fa-refresh fa-fw fa-lg"></i> Change supervisor?</button> </div> {% elif user.profile.status == 'R' %} {% if user.profile.supervision_key == None %} @@ -246,14 +246,14 @@ </ul> <div class="form-group" style="text-align: center;"> <input type="hidden" name="token" value="true"> - <button type="button" class="btn btn-danger" onclick="beat.accounts.dialogs.modal_add_supervisor('change_supervisor', '{% url 'api_accounts:add_supervisor' 'nogodfather' %}', '{% url 'accounts:settings' %}');"><i class="fa fa-plus fa-fw fa-lg"></i> Add a supervisor</button> + <button type="button" class="btn btn-danger" onclick="beat.accounts.dialogs.modal_add_supervisor('change_supervisor', '{% url 'api_accounts:add_supervisor' 'nosupervisor' %}', '{% url 'accounts:settings' %}');"><i class="fa fa-plus fa-fw fa-lg"></i> Add a supervisor</button> </div> {% else %} <li class="list-group-item list-group-item-warning" style="text-align:center;">Status is pending: You need to wait approval from supervisor</li> <br> <h4>General Information about a pending request</h4> <ul class="list-group"> - <li class="list-group-item"><b>Pending request made to supervisor:</b> {{ supervisiontrack.godfather.username }}</li> + <li class="list-group-item"><b>Pending request made to supervisor:</b> {{ supervisiontrack.supervisor.username }}</li> <li class="list-group-item"><b>Deadline account blockage date (if no supervisor):</b> {{ user.profile.rejection_date }}</li> <li class="list-group-item"><i>You need to be patient until this supervisor accepts your request. An email was sent about your request, but in the meantime you can remind him/her to accept your supervision.<br> If this supervisor rejects your supervision request, you will be informed and you will get the opportunity to make a new one.<br> @@ -266,7 +266,7 @@ <br> <h4>General Information</h4> <ul class="list-group"> - <li class="list-group-item"><b>Supervisor:</b> {{ supervisiontrack.godfather.username }}</li> + <li class="list-group-item"><b>Supervisor:</b> {{ supervisiontrack.supervisor.username }}</li> <li class="list-group-item"><b>Supervision Track started on:</b> {{ supervisiontrack.start_date }}</li> <li class="list-group-item"><b>Supervision Track last validation date:</b> {{ supervisiontrack.last_validation_date }}</li> <li class="list-group-item"><b>Supervision Track expiration date:</b> {{ supervisiontrack.expiration_date }}</li> diff --git a/beat/web/accounts/tests.py b/beat/web/accounts/tests.py index 81a61ce82..995af2634 100644 --- a/beat/web/accounts/tests.py +++ b/beat/web/accounts/tests.py @@ -56,9 +56,9 @@ class AccountTestCase(APITestCase): # Create the users self.password = '1234' - self.firstgodfather = User.objects.create_user('firstgodfather', 'firstgodfather@test.org', self.password) - self.secondgodfather = User.objects.create_user('secondgodfather', 'secondgodfather@test.org', self.password) - self.invalidgodfather = User.objects.create_user('invalidgodfather', 'invalidgodfather@test.org', self.password) + self.firstsupervisor = User.objects.create_user('firstsupervisor', 'firstsupervisor@test.org', self.password) + self.secondsupervisor = User.objects.create_user('secondsupervisor', 'secondsupervisor@test.org', self.password) + self.invalidsupervisor = User.objects.create_user('invalidsupervisor', 'invalidsupervisor@test.org', self.password) self.accepteduser = User.objects.create_user('accepteduser', 'accepteduser@test.org', self.password) self.rejecteduser = User.objects.create_user('rejecteduser', 'rejecteduser@test.org', self.password) @@ -66,21 +66,21 @@ class AccountTestCase(APITestCase): self.blockeduser = User.objects.create_user('blockeduser', 'blockeduser@test.org', self.password) # Update the profiles - #godfathers - self.firstgodfather.profile.status = Profile.ACCEPTED - self.secondgodfather.profile.status = Profile.ACCEPTED - self.invalidgodfather.profile.status = Profile.BLOCKED - self.firstgodfather.profile.is_godfather = True - self.secondgodfather.profile.is_godfather = True - self.invalidgodfather.profile.is_godfather = True - self.invalidgodfather.is_active = False - - self.firstgodfather.save() - self.secondgodfather.save() - self.invalidgodfather.save() - self.firstgodfather.profile.save() - self.secondgodfather.profile.save() - self.invalidgodfather.profile.save() + #supervisors + self.firstsupervisor.profile.status = Profile.ACCEPTED + self.secondsupervisor.profile.status = Profile.ACCEPTED + self.invalidsupervisor.profile.status = Profile.BLOCKED + self.firstsupervisor.profile.is_supervisor = True + self.secondsupervisor.profile.is_supervisor = True + self.invalidsupervisor.profile.is_supervisor = True + self.invalidsupervisor.is_active = False + + self.firstsupervisor.save() + self.secondsupervisor.save() + self.invalidsupervisor.save() + self.firstsupervisor.profile.save() + self.secondsupervisor.profile.save() + self.invalidsupervisor.profile.save() #users self.accepteduser.profile.status = Profile.ACCEPTED @@ -94,7 +94,7 @@ class AccountTestCase(APITestCase): self.accepteduser.profile.supervision_key = self.accepteduser.profile._generate_current_supervision_key() supervisiontrack = SupervisionTrack.objects.create( supervisee = self.accepteduser, - godfather = self.firstgodfather, + supervisor = self.firstsupervisor, is_valid = True, start_date = now, expiration_date = now + expiration_date_delta, @@ -120,7 +120,7 @@ class AccountTestCase(APITestCase): self.yearrevalidationuser.profile.supervision_key = self.yearrevalidationuser.profile._generate_current_supervision_key() supervisiontrack = SupervisionTrack.objects.create( supervisee = self.yearrevalidationuser, - godfather = self.firstgodfather, + supervisor = self.firstsupervisor, is_valid = True, start_date = now, expiration_date = now + expiration_date_delta, @@ -148,23 +148,23 @@ class AccountTestCase(APITestCase): def test_check_access_and_setup(self): - #Godfathers - user = self.firstgodfather + #Supervisors + user = self.firstsupervisor logged_in = self.client.login(username=user.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(user.username, 'firstgodfather') + self.assertEqual(user.username, 'firstsupervisor') logged_out = self.client.logout() - user = self.secondgodfather + user = self.secondsupervisor logged_in = self.client.login(username=user.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(user.username, 'secondgodfather') + self.assertEqual(user.username, 'secondsupervisor') logged_out = self.client.logout() - user = self.invalidgodfather + user = self.invalidsupervisor logged_in = self.client.login(username=user.username, password=self.password) self.assertFalse(logged_in) - self.assertEqual(user.username, 'invalidgodfather') + self.assertEqual(user.username, 'invalidsupervisor') logged_out = self.client.logout() #Users @@ -211,7 +211,7 @@ class AccountListTestCase(AccountTestCase): errormsg = content['detail'] self.assertEqual(errormsg, 'Authentication credentials were not provided.') - def test_logged_in_user_not_godfather(self): + def test_logged_in_user_not_supervisor(self): client = self.accepteduser @@ -228,13 +228,13 @@ class AccountListTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_user_godfather(self): + def test_logged_in_user_supervisor(self): - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.get(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -346,13 +346,13 @@ class AccountRevalidationTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_user_godfather(self): + def test_logged_in_user_supervisor(self): - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -363,13 +363,13 @@ class AccountRevalidationTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_invalid_godfather(self): + def test_logged_in_invalid_supervisor(self): - client = self.invalidgodfather + client = self.invalidsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertFalse(logged_in) - self.assertEqual(client.username, 'invalidgodfather') + self.assertEqual(client.username, 'invalidsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -389,7 +389,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): def setUp(self): super(AccountAddSupervisorTestCase, self).setUp() - self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondgodfather.username}) + self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondsupervisor.username}) def test_anonymous_user(self): response = self.client.post(self.url, format='json') @@ -399,7 +399,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): errormsg = content['detail'] self.assertEqual(errormsg, 'Authentication credentials were not provided.') - def test_logged_in_accepted_user_supervision_request_to_invalid_godfather(self): + def test_logged_in_accepted_user_supervision_request_to_invalid_supervisor(self): client = self.accepteduser logged_in = self.client.login(username=client.username, password=self.password) @@ -411,7 +411,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): self.assertEqual(previous_supervision_track.is_valid, True) - self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.invalidgodfather.username}) + self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.invalidsupervisor.username}) #change supervisor response = self.client.post(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -457,7 +457,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): previous_supervision_track = SupervisionTrack.objects.get(supervision_key = previous_supervision_key) self.assertEqual(previous_supervision_track.is_valid, False) self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertNotEqual(previous_supervision_track.godfather, new_supervision_track.godfather) + self.assertNotEqual(previous_supervision_track.supervisor, new_supervision_track.supervisor) self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() @@ -482,7 +482,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): #check track change and supervisor self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertEqual(new_supervision_track.godfather.username, "secondgodfather") + self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor") self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() @@ -507,7 +507,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): #check track change and supervisor self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertEqual(new_supervision_track.godfather.username, "secondgodfather") + self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor") self.assertEqual(client.profile.status, Profile.REJECTED) #change supervisor second request response = self.client.post(self.url, format='json') @@ -523,7 +523,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): #check track change and supervisor self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertEqual(new_supervision_track.godfather.username, "secondgodfather") + self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor") self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() @@ -552,7 +552,7 @@ class AccountAddSupervisorTestCase(AccountTestCase): previous_supervision_track = SupervisionTrack.objects.get(supervision_key = previous_supervision_key) self.assertEqual(previous_supervision_track.is_valid, False) self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertNotEqual(previous_supervision_track.godfather, new_supervision_track.godfather) + self.assertNotEqual(previous_supervision_track.supervisor, new_supervision_track.supervisor) self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() @@ -576,13 +576,13 @@ class AccountAddSupervisorTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_user_godfather(self): + def test_logged_in_user_supervisor(self): - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.post(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -593,13 +593,13 @@ class AccountAddSupervisorTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_invalid_godfather(self): + def test_logged_in_invalid_supervisor(self): - client = self.invalidgodfather + client = self.invalidsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertFalse(logged_in) - self.assertEqual(client.username, 'invalidgodfather') + self.assertEqual(client.username, 'invalidsupervisor') response = self.client.post(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -703,13 +703,13 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_user_godfather_validate_already_accepted_user(self): + def test_logged_in_user_supervisor_validate_already_accepted_user(self): - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -720,9 +720,9 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_user_secondgodfather_validates_previously_accepted_user(self): + def test_logged_in_user_secondsupervisor_validates_previously_accepted_user(self): - self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondgodfather.username}) + self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondsupervisor.username}) client = self.accepteduser @@ -748,16 +748,16 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): self.assertEqual(previous_supervision_track.is_valid, False) self.assertEqual(new_supervision_track.is_valid, False) self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertNotEqual(previous_supervision_track.godfather, new_supervision_track.godfather) + self.assertNotEqual(previous_supervision_track.supervisor, new_supervision_track.supervisor) self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() self.url = reverse('api_accounts:validate_supervisee', kwargs={'supervisee_name': self.accepteduser.username}) - client = self.secondgodfather + client = self.secondsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'secondgodfather') + self.assertEqual(client.username, 'secondsupervisor') response = self.client.put(self.url, format='json') @@ -773,13 +773,13 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): self.assertEqual(previous_supervision_track.is_valid, False) self.assertEqual(new_supervision_track.is_valid, True) self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertNotEqual(previous_supervision_track.godfather, new_supervision_track.godfather) + self.assertNotEqual(previous_supervision_track.supervisor, new_supervision_track.supervisor) self.assertEqual(client.profile.status, Profile.ACCEPTED) - def test_logged_in_user_secondgodfather_validates_rejected_user(self): + def test_logged_in_user_secondsupervisor_validates_rejected_user(self): - self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondgodfather.username}) + self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondsupervisor.username}) client = self.rejecteduser @@ -800,16 +800,16 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): #check track change and supervisor self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertEqual(new_supervision_track.godfather.username, "secondgodfather") + self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor") self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() self.url = reverse('api_accounts:validate_supervisee', kwargs={'supervisee_name': self.rejecteduser.username}) - client = self.secondgodfather + client = self.secondsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'secondgodfather') + self.assertEqual(client.username, 'secondsupervisor') response = self.client.put(self.url, format='json') @@ -823,12 +823,12 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): #check track change and supervisor self.assertEqual(new_supervision_track.is_valid, True) - self.assertNotEqual(new_supervision_track.godfather, "secondgodfather") + self.assertNotEqual(new_supervision_track.supervisor, "secondsupervisor") self.assertEqual(client.profile.status, Profile.ACCEPTED) - def test_logged_in_user_secondgodfather_validates_yearrevalidation_user(self): + def test_logged_in_user_secondsupervisor_validates_yearrevalidation_user(self): - self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondgodfather.username}) + self.url = reverse('api_accounts:add_supervisor', kwargs={'supervisor_name': self.secondsupervisor.username}) client = self.yearrevalidationuser @@ -853,17 +853,17 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): previous_supervision_track = SupervisionTrack.objects.get(supervision_key = previous_supervision_key) self.assertEqual(previous_supervision_track.is_valid, False) self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertNotEqual(previous_supervision_track.godfather, new_supervision_track.godfather) + self.assertNotEqual(previous_supervision_track.supervisor, new_supervision_track.supervisor) self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() self.url = reverse('api_accounts:validate_supervisee', kwargs={'supervisee_name': self.yearrevalidationuser.username}) - client = self.secondgodfather + client = self.secondsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'secondgodfather') + self.assertEqual(client.username, 'secondsupervisor') response = self.client.put(self.url, format='json') @@ -879,16 +879,16 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): self.assertEqual(previous_supervision_track.is_valid, False) self.assertEqual(new_supervision_track.is_valid, True) self.assertNotEqual(previous_supervision_key, new_supervision_key) - self.assertNotEqual(previous_supervision_track.godfather, new_supervision_track.godfather) + self.assertNotEqual(previous_supervision_track.supervisor, new_supervision_track.supervisor) self.assertEqual(client.profile.status, Profile.ACCEPTED) - def test_logged_in_user_godfather_validation_try(self): + def test_logged_in_user_supervisor_validation_try(self): - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -899,13 +899,13 @@ class AccountValidateSuperviseeTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_invalid_godfather(self): + def test_logged_in_invalid_supervisor(self): - client = self.invalidgodfather + client = self.invalidsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertFalse(logged_in) - self.assertEqual(client.username, 'invalidgodfather') + self.assertEqual(client.username, 'invalidsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -1009,7 +1009,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase): logged_out = self.client.logout() - def test_logged_in_godfather_remove_accepted_user(self): + def test_logged_in_supervisor_remove_accepted_user(self): #accepted user before client = self.accepteduser @@ -1025,11 +1025,11 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase): logged_out = self.client.logout() #accepted user removed - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) @@ -1050,7 +1050,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase): self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() - def test_logged_in_godfather_remove_yearrevalidation_user(self): + def test_logged_in_supervisor_remove_yearrevalidation_user(self): self.url = reverse('api_accounts:remove_supervisee', kwargs={'supervisee_name': self.yearrevalidationuser.username}) #yearrevalidationuser user before @@ -1068,11 +1068,11 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase): logged_out = self.client.logout() #yearrevalidationuser user removed - client = self.firstgodfather + client = self.firstsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertTrue(logged_in) - self.assertEqual(client.username, 'firstgodfather') + self.assertEqual(client.username, 'firstsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) @@ -1093,13 +1093,13 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase): self.assertEqual(client.profile.status, Profile.REJECTED) logged_out = self.client.logout() - def test_logged_in_invalid_godfather(self): + def test_logged_in_invalid_supervisor(self): - client = self.invalidgodfather + client = self.invalidsupervisor logged_in = self.client.login(username=client.username, password=self.password) self.assertFalse(logged_in) - self.assertEqual(client.username, 'invalidgodfather') + self.assertEqual(client.username, 'invalidsupervisor') response = self.client.put(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) diff --git a/beat/web/accounts/views.py b/beat/web/accounts/views.py index 823516c60..73ed922ab 100644 --- a/beat/web/accounts/views.py +++ b/beat/web/accounts/views.py @@ -71,7 +71,7 @@ def account_settings(request): supervisiontrack = None supervisiontracks_valid = None supervisiontracks_pending = None - if user.profile.is_godfather == False: + if user.profile.is_supervisor == False: supervisee = user if supervisee.profile.supervision_key is not None: #There's a key check if there's a valid track @@ -79,10 +79,10 @@ def account_settings(request): else: supervisiontrack = None else: - godfather = user + supervisor = user #Filter and get all supervision tracks valid and - supervisiontracks_valid = SupervisionTrack.objects.filter(godfather=godfather, is_valid=True) - supervisiontracks_pending = SupervisionTrack.objects.filter(godfather=godfather, is_valid=False, start_date=None) + supervisiontracks_valid = SupervisionTrack.objects.filter(supervisor=supervisor, is_valid=True) + supervisiontracks_pending = SupervisionTrack.objects.filter(supervisor=supervisor, is_valid=False, start_date=None) return render(request, 'accounts/settings.html', diff --git a/beat/web/navigation/admin.py b/beat/web/navigation/admin.py index 85d82d7ca..484d3cb69 100644 --- a/beat/web/navigation/admin.py +++ b/beat/web/navigation/admin.py @@ -54,7 +54,7 @@ class AccountSettingsInline(admin.StackedInline): class SupervisionTrackInline(admin.StackedInline): model = SupervisionTrack - fk_name = 'godfather' + fk_name = 'supervisor' #---------------------------------------------------------- @@ -79,8 +79,8 @@ class UserAdmin(UserAdmin): int(obj.accountsettings.database_notifications_enabled) + \ int(obj.accountsettings.environment_notifications_enabled) - def godfather(self, obj): - return obj.profile.is_godfather + def supervisor(self, obj): + return obj.profile.is_supervisor def status(self, obj): return obj.profile.status @@ -88,13 +88,13 @@ class UserAdmin(UserAdmin): def supervision(self, obj): if obj.is_staff: return "Staff account" - if obj.profile.is_godfather: + if obj.profile.is_supervisor: return "Supervisor account" else: supervisiontrack = SupervisionTrack.objects.get(supervisee=obj, is_valid=True) - godfather = supervisiontrack.godfather - return godfather + supervisor = supervisiontrack.supervisor + return supervisor def supervision_key(self, obj): return obj.profile.supervision_key @@ -110,7 +110,7 @@ class UserAdmin(UserAdmin): 'notifications', 'agreement_number', 'last_login', - 'godfather', + 'supervisor', 'status', 'supervision', 'supervision_key', @@ -141,7 +141,7 @@ class SupervisionTrackAdmin(admin.ModelAdmin): list_display = ( - 'godfather', + 'supervisor', 'supervisee', 'is_valid', 'start_date', @@ -151,7 +151,7 @@ class SupervisionTrackAdmin(admin.ModelAdmin): ) ordering = ( - 'godfather', + 'supervisor', ) admin.site.register(SupervisionTrack, SupervisionTrackAdmin) @@ -167,7 +167,7 @@ class ProfileAdmin(admin.ModelAdmin): 'user', 'status', 'registration_date', - 'is_godfather', + 'is_supervisor', 'supervision_key', 'rejection_date', ) diff --git a/beat/web/settings/settings.py b/beat/web/settings/settings.py index 61ec9923e..90f0a82dd 100755 --- a/beat/web/settings/settings.py +++ b/beat/web/settings/settings.py @@ -216,7 +216,7 @@ DATASETS_ROOT_PATH = None ############################################################################## ACCOUNT_ACTIVATION_DAYS = 2 -ACCOUNT_ACTIVATION_DAYS_FROM_GODFATHER = 7 +ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR = 7 ACCOUNT_EXPIRATION_DAYS = 365 ACCOUNT_BLOCKAGE_AFTER_FIRST_REJECTION_DAYS = 56 diff --git a/beat/web/ui/registration/docs/forms.txt b/beat/web/ui/registration/docs/forms.txt index 5435413ae..ac56fdc53 100644 --- a/beat/web/ui/registration/docs/forms.txt +++ b/beat/web/ui/registration/docs/forms.txt @@ -40,8 +40,8 @@ Fields: ``password2`` The password, again, to catch typos. -``godfather`` - The godfather that will validate this account. +``supervisor`` + The supervisor that will validate this account. diff --git a/beat/web/ui/registration/forms.py b/beat/web/ui/registration/forms.py index 355dcc2d0..743ba4910 100644 --- a/beat/web/ui/registration/forms.py +++ b/beat/web/ui/registration/forms.py @@ -82,7 +82,7 @@ class RegistrationForm(forms.Form): label=_(u'Password')) password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False), label=_(u'Password (again)')) - godfather = forms.RegexField(regex=r'^\w+$', + supervisor = forms.RegexField(regex=r'^\w+$', max_length=30, widget=forms.TextInput(attrs=attrs_dict), label=_(u'Supervisor Username')) @@ -100,22 +100,22 @@ class RegistrationForm(forms.Form): return self.cleaned_data['username'] raise forms.ValidationError(_(u'This username is already taken. Please choose another.')) - def clean_godfather(self): + def clean_supervisor(self): """ Validate that the username is alphanumeric and exists. """ try: - user = User.objects.get(username__iexact=self.cleaned_data['godfather']) + user = User.objects.get(username__iexact=self.cleaned_data['supervisor']) if user.profile.status == Profile.BLOCKED: raise forms.ValidationError(_(u'This user is not a valid supervisor. Please choose another.')) except User.DoesNotExist: raise forms.ValidationError(_(u'This supervisor username does not exist. Please choose another.')) - if not user.profile.is_godfather: + if not user.profile.is_supervisor: raise forms.ValidationError(_(u'This user is not a recognized supervisor. Please choose another.')) - return self.cleaned_data['godfather'] + return self.cleaned_data['supervisor'] def clean(self): @@ -152,17 +152,17 @@ class RegistrationForm(forms.Form): #Create and assign key new_user.profile.supervision_key = new_user.profile._generate_current_supervision_key() - godfather = User.objects.get(username = self.cleaned_data['godfather']) + supervisor = User.objects.get(username = self.cleaned_data['supervisor']) supervisiontrack = SupervisionTrack.objects.create( supervisee = new_user, - godfather = godfather, + supervisor = supervisor, is_valid = False, ) #Assign key to supervision track supervisiontrack.supervision_key = new_user.profile.supervision_key supervisiontrack.save() - new_user.profile.is_godfather = False + new_user.profile.is_supervisor = False new_user.profile.status = Profile.NEWUSER new_user.profile.registration_date = datetime.datetime.now() new_user.profile.supervision.add(supervisiontrack) @@ -273,7 +273,7 @@ class BlockedUserRevalidationForm(forms.Form): label=_(u'Username')) password = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False), label=_(u'Password')) - godfather = forms.RegexField(regex=r'^\w+$', + supervisor = forms.RegexField(regex=r'^\w+$', max_length=30, widget=forms.TextInput(attrs=attrs_dict), label=_(u'Supervisor Username (Your account needs to be re-validated by a recognized person)')) @@ -290,20 +290,20 @@ class BlockedUserRevalidationForm(forms.Form): except User.DoesNotExist: raise forms.ValidationError(_(u'This username has not been recognized')) - def clean_godfather(self): + def clean_supervisor(self): """ Validate that the username is alphanumeric and exists. """ try: - user = User.objects.get(username__iexact=self.cleaned_data['godfather']) + user = User.objects.get(username__iexact=self.cleaned_data['supervisor']) except User.DoesNotExist: raise forms.ValidationError(_(u'This supervisor username does not exist. Please choose another.')) - if not user.profile.is_godfather: + if not user.profile.is_supervisor: raise forms.ValidationError(_(u'This user is not a recognized supervisor. Please choose another.')) - return self.cleaned_data['godfather'] + return self.cleaned_data['supervisor'] def clean(self): diff --git a/beat/web/ui/registration/models.py b/beat/web/ui/registration/models.py index 405c31daf..76d63095b 100644 --- a/beat/web/ui/registration/models.py +++ b/beat/web/ui/registration/models.py @@ -96,7 +96,7 @@ class RegistrationManager(models.Manager): profile.activation_key = self.model.ACTIVATED profile.save() user_activated.send(sender=self.model, user=user) - # The user activated via the link but activation from godfather or admin + # The user activated via the link but activation from supervisor or admin # is requested now to have access to the platform (so set it # inactive again) user.is_active = False @@ -104,32 +104,32 @@ class RegistrationManager(models.Manager): user.profile.registration_date = datetime.datetime.now() user.save() - # Send email to godfather - # Fetch Godfather user from supervision track + # Send email to supervisor + # Fetch Supervisor user from supervision track supervisiontrack = SupervisionTrack.objects.get(supervision_key=user.profile.supervision_key) - godfather_user = supervisiontrack.godfather + supervisor_user = supervisiontrack.supervisor from django.core.mail import send_mail parsed_url = urlparse(settings.URL_PREFIX) server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname) - c = Context({ 'supervisor': godfather_user, + c = Context({ 'supervisor': supervisor_user, 'supervisee': user, 'prefix': server_address, }) try: - t = loader.get_template('registration/mail.godfather_validation.subject.txt') + t = loader.get_template('registration/mail.supervisor_validation.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_validation.message.txt') + t = loader.get_template('registration/mail.supervisor_validation.message.txt') message = t.render(c) - send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [godfather_user.email]) + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisor_user.email]) except: pass diff --git a/beat/web/ui/registration/templates/registration/blocked_user_reactivate.html b/beat/web/ui/registration/templates/registration/blocked_user_reactivate.html index 91e7f88c4..c071fb713 100644 --- a/beat/web/ui/registration/templates/registration/blocked_user_reactivate.html +++ b/beat/web/ui/registration/templates/registration/blocked_user_reactivate.html @@ -57,10 +57,10 @@ {% endfor %} </div> - <div class="form-group{% if form.godfather.errors %} has-error{% endif %}"> - {{ form.godfather.label_tag }} - {{ form.godfather|tabindex:2|addclass:"form-control" }} - {% for error in form.godfather.errors %} + <div class="form-group{% if form.supervisor.errors %} has-error{% endif %}"> + {{ form.supervisor.label_tag }} + {{ form.supervisor|tabindex:2|addclass:"form-control" }} + {% for error in form.supervisor.errors %} <div class="alert alert-danger" role="alert">{{ error }}</div> {% endfor %} </div> diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_rejected.message.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_rejected.message.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_rejected.message.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_rejected.message.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_rejected.subject.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_rejected.subject.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_rejected.subject.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_rejected.subject.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_rejected_delete_account.message.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_rejected_delete_account.message.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_rejected_delete_account.message.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_rejected_delete_account.message.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_rejection.message.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_rejection.message.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_rejection.message.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_rejection.message.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_rejection.subject.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_rejection.subject.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_rejection.subject.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_rejection.subject.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_validated.message.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_validated.message.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_validated.message.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_validated.message.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_validated.subject.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_validated.subject.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_validated.subject.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_validated.subject.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_validation.message.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_validation.message.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_validation.message.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_validation.message.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_validation.subject.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_validation.subject.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_validation.subject.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_validation.subject.txt diff --git a/beat/web/ui/registration/templates/registration/mail.godfather_validation_supervisee_add_request.message.txt b/beat/web/ui/registration/templates/registration/mail.supervisor_validation_supervisee_add_request.message.txt similarity index 100% rename from beat/web/ui/registration/templates/registration/mail.godfather_validation_supervisee_add_request.message.txt rename to beat/web/ui/registration/templates/registration/mail.supervisor_validation_supervisee_add_request.message.txt diff --git a/beat/web/ui/registration/templates/registration/registration_form.html b/beat/web/ui/registration/templates/registration/registration_form.html index 559fd90b2..63c49030a 100644 --- a/beat/web/ui/registration/templates/registration/registration_form.html +++ b/beat/web/ui/registration/templates/registration/registration_form.html @@ -92,10 +92,10 @@ {% endfor %} </div> - <div class="form-group{% if form.godfather.errors %} has-error{% endif %}"> - {{ form.godfather.label_tag }} - {{ form.godfather|tabindex:7|addclass:"form-control" }} - {% for error in form.godfather.errors %} + <div class="form-group{% if form.supervisor.errors %} has-error{% endif %}"> + {{ form.supervisor.label_tag }} + {{ form.supervisor|tabindex:7|addclass:"form-control" }} + {% for error in form.supervisor.errors %} <div class="alert alert-danger" role="alert">{{ error }}</div> {% endfor %} <div class="alert alert-warning" role="alert">Your account needs to diff --git a/beat/web/ui/views.py b/beat/web/ui/views.py index b6183a915..f042bd0a0 100644 --- a/beat/web/ui/views.py +++ b/beat/web/ui/views.py @@ -89,9 +89,9 @@ def blocked_user_reactivation(request): if user.check_password(request.POST["password"]): # Check if user is a blocked user if user.profile.status == Profile.BLOCKED: - godfather = User.objects.get(username=request.POST["godfather"]) - # Check the godfather - if godfather.profile.status == Profile.ACCEPTED: + supervisor = User.objects.get(username=request.POST["supervisor"]) + # Check the supervisor + if supervisor.profile.status == Profile.ACCEPTED: # Check if supervision track already exists if user.profile.supervision_key is None: # Create and assign key @@ -99,7 +99,7 @@ def blocked_user_reactivation(request): supervisee.profile.supervision_key = supervisee.profile._generate_current_supervision_key() supervisiontrack = SupervisionTrack.objects.create( supervisee = supervisee, - godfather = godfather, + supervisor = supervisor, is_valid = False, ) @@ -109,7 +109,7 @@ def blocked_user_reactivation(request): supervisee.profile.supervision.add(supervisiontrack) # Add a rejection date to the supervisee profile now = datetime.datetime.now() - expiration_date_delta = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS_FROM_GODFATHER) + expiration_date_delta = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR) if supervisee.profile.rejection_date == None: supervisee.profile.rejection_date = now + expiration_date_delta @@ -122,27 +122,27 @@ def blocked_user_reactivation(request): parsed_url = urlparse(settings.URL_PREFIX) server_address = '%s://%s' % (parsed_url.scheme, parsed_url.hostname) - c = Context({ 'supervisor': godfather, + c = Context({ 'supervisor': supervisor, 'supervisee': supervisee, 'prefix': server_address, }) try: - t = loader.get_template('registration/mail.godfather_validation.subject.txt') + t = loader.get_template('registration/mail.supervisor_validation.subject.txt') subject = t.render(c) # Note: e-mail subject *must not* contain newlines subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines()) - t = loader.get_template('registration/mail.godfather_validation_supervisee_add_request.message.txt') + t = loader.get_template('registration/mail.supervisor_validation_supervisee_add_request.message.txt') message = t.render(c) - send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [godfather.email]) + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [supervisor.email]) except: pass # inform the supervisee of his request - c = Context({ 'supervisor': godfather, + c = Context({ 'supervisor': supervisor, 'supervisee': supervisee, 'prefix': server_address, }) -- GitLab