mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
jira-15 top leadership API
This commit is contained in:
@ -13,7 +13,7 @@ from account.serializers import JuniorSerializer
|
||||
from junior.serializers import JuniorDetailSerializer
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from .utils import upload_image_to_alibaba
|
||||
from junior.models import Junior
|
||||
from junior.models import Junior, JuniorPoints
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
"""User serializer"""
|
||||
auth_token = serializers.SerializerMethodField('get_auth_token')
|
||||
@ -181,37 +181,13 @@ class TaskDetailsSerializer(serializers.ModelSerializer):
|
||||
'junior', 'task_status', 'is_active', 'created_at','updated_at']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TopJuniorSerializer(serializers.ModelSerializer):
|
||||
total_points = serializers.SerializerMethodField()
|
||||
|
||||
email = serializers.SerializerMethodField('get_auth')
|
||||
first_name = serializers.SerializerMethodField('get_first_name')
|
||||
last_name = serializers.SerializerMethodField('get_last_name')
|
||||
|
||||
def get_auth(self, obj):
|
||||
return obj.auth.username
|
||||
|
||||
def get_first_name(self, obj):
|
||||
return obj.auth.first_name
|
||||
|
||||
def get_last_name(self, obj):
|
||||
return obj.auth.last_name
|
||||
junior = JuniorDetailSerializer()
|
||||
|
||||
class Meta:
|
||||
model = Junior
|
||||
fields = ['id', 'email', 'first_name', 'last_name', 'phone', 'country_code', 'country_name', 'gender', 'dob', 'image', 'junior_code', 'guardian_code', 'referral_code', 'referral_code_used', 'is_active', 'is_complete_profile', 'passcode', 'is_verified', 'created_at', 'updated_at', 'total_points']
|
||||
model = JuniorPoints
|
||||
fields = ['id', 'junior', 'total_task_points', 'created_at', 'updated_at']
|
||||
|
||||
def get_total_points(self, obj):
|
||||
junior_ids_with_total_points = self.context.get('junior_ids_with_total_points')
|
||||
if junior_ids_with_total_points:
|
||||
junior_id = obj.id
|
||||
for item in junior_ids_with_total_points:
|
||||
if item['junior'] == junior_id:
|
||||
return item['total_points']
|
||||
return 0
|
||||
|
||||
class GuardianProfileSerializer(serializers.ModelSerializer):
|
||||
"""junior serializer"""
|
||||
|
Reference in New Issue
Block a user