jira-15 leader board API and profile API

This commit is contained in:
jain
2023-07-10 14:53:43 +05:30
parent 026bfb6da7
commit c8925aad8e
6 changed files with 45 additions and 13 deletions

View File

@ -120,7 +120,7 @@ class CreateGuardianSerializer(serializers.ModelSerializer):
image_url = upload_image_to_alibaba(image, filename)
guardian.image = image_url
"""Complete profile of the junior if below all data are filled"""
complete_profile_field = all([guardian.phone, guardian.gender, guardian.family_name, guardian.country_name,
complete_profile_field = all([guardian.phone, guardian.gender, guardian.country_name,
guardian.dob, guardian.country_code, user.first_name, user.last_name,
user.email, guardian.image])
guardian.is_complete_profile = False
@ -188,18 +188,18 @@ class TaskDetailsSerializer(serializers.ModelSerializer):
class TopJuniorSerializer(serializers.ModelSerializer):
"""Top junior serializer"""
junior = JuniorDetailSerializer()
position = serializers.SerializerMethodField()
position = serializers.IntegerField()
class Meta(object):
class Meta:
"""Meta info"""
model = JuniorPoints
fields = ['id', 'junior', 'total_task_points', 'position', 'created_at', 'updated_at']
def get_position(self, obj):
"""get position of junior"""
queryset = self.context['view'].get_queryset()
position = list(queryset).index(obj) + 1
return position
def to_representation(self, instance):
"""Convert instance to representation"""
representation = super().to_representation(instance)
representation['position'] = instance.position
return representation
class GuardianProfileSerializer(serializers.ModelSerializer):