Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added school info to participants #226

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 12 additions & 4 deletions personal/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Loading