Skip to content

Commit

Permalink
Added school info to participants
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamín Mravec committed Nov 10, 2023
1 parent 2b7da9a commit 1f13567
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
22 changes: 18 additions & 4 deletions personal/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,25 @@ class Meta:
model = Profile
fields = ['first_name', 'last_name', 'nickname']


@ts_interface(context='personal')
class ProfileMailSerializer(serializers.ModelSerializer):
class ProfileExportSerializer(serializers.ModelSerializer):
school_code = serializers.CharField(source='school.code')
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')
school_email = serializers.CharField(source='school.email')

school_district = serializers.CharField(source='school.district')

email = serializers.EmailField(source='user.email')

class Meta:
model = Profile
fields = ['first_name', 'last_name', 'nickname', 'email']
fields = ['school_code', 'school_name', 'school_abbreviation',
'school_street', 'school_city', 'school_zip_code', 'school_email',
'school_district', 'first_name', 'last_name', 'nickname', 'email']


email = serializers.EmailField(source='user.email')

0 comments on commit 1f13567

Please sign in to comment.