diff --git a/competition/views.py b/competition/views.py index 81e0b662..676d8d41 100644 --- a/competition/views.py +++ b/competition/views.py @@ -32,7 +32,7 @@ SeriesWithProblemsSerializer, SolutionSerializer) from personal.models import Profile, School -from personal.serializers import ProfileMailSerializer, SchoolSerializer +from personal.serializers import ProfileExportSerializer, SchoolSerializer from webstrom.settings import EMAIL_ALERT, EMAIL_NO_REPLY # pylint: disable=unused-argument @@ -687,7 +687,7 @@ def participants(self, request, pk=None): solution.semester_registration.profile.pk) profiles = Profile.objects.only("user").filter(pk__in=participants_id) - serializer = ProfileMailSerializer(profiles, many=True) + serializer = ProfileExportSerializer(profiles, many=True) return Response(serializer.data) def post(self, request, format_post): diff --git a/personal/serializers.py b/personal/serializers.py index 398f0671..f0c7b0fd 100644 --- a/personal/serializers.py +++ b/personal/serializers.py @@ -157,9 +157,17 @@ class Meta: @ts_interface(context='personal') -class ProfileMailSerializer(serializers.ModelSerializer): - class Meta: - model = Profile - fields = ['first_name', 'last_name', 'nickname', 'email'] +class ProfileExportSerializer(serializers.ModelSerializer): + school_name = serializers.CharField(source='school.name') + school_abbreviation = serializers.CharField(source='school.abbreviation') + school_street = serializers.CharField(source='school.street') + school_city = serializers.CharField(source='school.city') + school_zip_code = serializers.CharField(source='school.zip_code') email = serializers.EmailField(source='user.email') + + class Meta: + model = Profile + fields = ['school_name', 'school_abbreviation', + 'school_street', 'school_city', 'school_zip_code', + 'first_name', 'last_name', 'nickname', 'email']