mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
jira-15 top junior API and default images field
This commit is contained in:
@ -8,7 +8,8 @@ import random
|
||||
from junior.models import Junior
|
||||
from guardian.utils import upload_image_to_alibaba
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from guardian.models import Guardian
|
||||
from guardian.models import Guardian, JuniorTask
|
||||
from base.constants import PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED
|
||||
|
||||
class ListCharField(serializers.ListField):
|
||||
"""Serializer for Array field"""
|
||||
@ -147,7 +148,13 @@ class JuniorDetailListSerializer(serializers.ModelSerializer):
|
||||
email = serializers.SerializerMethodField('get_auth')
|
||||
first_name = serializers.SerializerMethodField('get_first_name')
|
||||
last_name = serializers.SerializerMethodField('get_last_name')
|
||||
|
||||
assigned_task = serializers.SerializerMethodField('get_assigned_task')
|
||||
points = serializers.SerializerMethodField('get_points')
|
||||
in_progress_task = serializers.SerializerMethodField('get_in_progress_task')
|
||||
completed_task = serializers.SerializerMethodField('get_completed_task')
|
||||
requested_task = serializers.SerializerMethodField('get_requested_task')
|
||||
rejected_task = serializers.SerializerMethodField('get_rejected_task')
|
||||
pending_task = serializers.SerializerMethodField('get_pending_task')
|
||||
|
||||
|
||||
def get_auth(self, obj):
|
||||
@ -159,9 +166,39 @@ class JuniorDetailListSerializer(serializers.ModelSerializer):
|
||||
def get_last_name(self, obj):
|
||||
return obj.auth.last_name
|
||||
|
||||
def get_assigned_task(self, obj):
|
||||
print("obj===>",obj,'type==>',type(obj))
|
||||
data = JuniorTask.objects.filter(junior=obj).count()
|
||||
return data
|
||||
|
||||
def get_points(self, obj):
|
||||
data = sum(JuniorTask.objects.filter(junior=obj, task_status=COMPLETED).values_list('points', flat=True))
|
||||
return data
|
||||
|
||||
def get_in_progress_task(self, obj):
|
||||
data = JuniorTask.objects.filter(junior=obj, task_status=IN_PROGRESS).count()
|
||||
return data
|
||||
|
||||
def get_completed_task(self, obj):
|
||||
data = JuniorTask.objects.filter(junior=obj, task_status=COMPLETED).count()
|
||||
return data
|
||||
|
||||
|
||||
def get_requested_task(self, obj):
|
||||
data = JuniorTask.objects.filter(junior=obj, task_status=REQUESTED).count()
|
||||
return data
|
||||
|
||||
def get_rejected_task(self, obj):
|
||||
data = JuniorTask.objects.filter(junior=obj, task_status=REJECTED).count()
|
||||
return data
|
||||
|
||||
def get_pending_task(self, obj):
|
||||
data = JuniorTask.objects.filter(junior=obj, task_status=PENDING).count()
|
||||
return data
|
||||
class Meta(object):
|
||||
"""Meta info"""
|
||||
model = Junior
|
||||
fields = ['id', 'email', 'first_name', 'last_name', 'country_code', 'phone', 'gender', 'dob',
|
||||
'guardian_code', 'referral_code','is_active', 'is_complete_profile', 'created_at', 'image',
|
||||
'updated_at']
|
||||
'updated_at', 'assigned_task','points', 'pending_task', 'in_progress_task', 'completed_task',
|
||||
'requested_task', 'rejected_task']
|
||||
|
Reference in New Issue
Block a user