Add students emails to instructor sessions

This commit is contained in:
Tanner Collin 2020-02-21 00:09:24 +00:00
parent c57c782eb5
commit ca54c48d39

View File

@ -259,6 +259,7 @@ class TrainingSerializer(serializers.ModelSerializer):
]) ])
session = serializers.PrimaryKeyRelatedField(queryset=models.Session.objects.all()) session = serializers.PrimaryKeyRelatedField(queryset=models.Session.objects.all())
student_name = serializers.SerializerMethodField() student_name = serializers.SerializerMethodField()
student_email = serializers.SerializerMethodField()
class Meta: class Meta:
model = models.Training model = models.Training
@ -272,6 +273,13 @@ class TrainingSerializer(serializers.ModelSerializer):
member = models.Member.objects.get(id=obj.member_id) member = models.Member.objects.get(id=obj.member_id)
return member.preferred_name + ' ' + member.last_name return member.preferred_name + ' ' + member.last_name
def get_student_email(self, obj):
if obj.user:
return obj.user.email
else:
member = models.Member.objects.get(id=obj.member_id)
return member.old_email
class StudentTrainingSerializer(TrainingSerializer): class StudentTrainingSerializer(TrainingSerializer):
attendance_status = serializers.ChoiceField(['Waiting for payment', 'Withdrawn']) attendance_status = serializers.ChoiceField(['Waiting for payment', 'Withdrawn'])