mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-27 00:54:54 +00:00
jira-15 changes in profile API
This commit is contained in:
@ -219,6 +219,9 @@ class GuardianProfileSerializer(serializers.ModelSerializer):
|
|||||||
email = serializers.SerializerMethodField('get_auth')
|
email = serializers.SerializerMethodField('get_auth')
|
||||||
first_name = serializers.SerializerMethodField('get_first_name')
|
first_name = serializers.SerializerMethodField('get_first_name')
|
||||||
last_name = serializers.SerializerMethodField('get_last_name')
|
last_name = serializers.SerializerMethodField('get_last_name')
|
||||||
|
total_count = serializers.SerializerMethodField('get_total_count')
|
||||||
|
complete_field_count = serializers.SerializerMethodField('get_complete_field_count')
|
||||||
|
notification_count = serializers.SerializerMethodField('get_notification_count')
|
||||||
|
|
||||||
def get_auth(self, obj):
|
def get_auth(self, obj):
|
||||||
"""user email address"""
|
"""user email address"""
|
||||||
@ -231,9 +234,26 @@ class GuardianProfileSerializer(serializers.ModelSerializer):
|
|||||||
def get_last_name(self, obj):
|
def get_last_name(self, obj):
|
||||||
"""user last name"""
|
"""user last name"""
|
||||||
return obj.user.last_name
|
return obj.user.last_name
|
||||||
|
|
||||||
|
def get_total_count(self, obj):
|
||||||
|
"""total fields count"""
|
||||||
|
return 9
|
||||||
|
|
||||||
|
def get_complete_field_count(self, obj):
|
||||||
|
"""total filled fields count"""
|
||||||
|
total_field_list = [obj.user.first_name, obj.user.last_name, obj.user.email, obj.country_name, obj.country_code,
|
||||||
|
obj.phone, obj.gender, obj.dob, obj.image]
|
||||||
|
total_complete_field = [data for data in total_field_list if data != '' and data is not None]
|
||||||
|
return len(total_complete_field)
|
||||||
|
|
||||||
|
def get_notification_count(self, obj):
|
||||||
|
"""total notification count"""
|
||||||
|
return 0
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
"""Meta info"""
|
"""Meta info"""
|
||||||
model = Guardian
|
model = Guardian
|
||||||
fields = ['id', 'email', 'first_name', 'last_name', 'country_name','country_code', 'phone', 'gender', 'dob',
|
fields = ['id', 'email', 'first_name', 'last_name', 'country_name','country_code', 'phone', 'gender', 'dob',
|
||||||
'guardian_code', 'referral_code','is_active', 'is_complete_profile', 'created_at', 'image',
|
'guardian_code', 'notification_count', 'total_count', 'complete_field_count', 'referral_code',
|
||||||
|
'is_active', 'is_complete_profile', 'created_at', 'image',
|
||||||
'updated_at']
|
'updated_at']
|
||||||
@ -84,7 +84,8 @@ class TaskListAPIView(viewsets.ModelViewSet):
|
|||||||
def list(self, request, *args, **kwargs):
|
def list(self, request, *args, **kwargs):
|
||||||
"""Create guardian profile"""
|
"""Create guardian profile"""
|
||||||
status_value = self.request.GET.get('status')
|
status_value = self.request.GET.get('status')
|
||||||
if status_value == 0:
|
print("status_value==>",status_value,'===>',type(status_value))
|
||||||
|
if str(status_value) == '0':
|
||||||
queryset = JuniorTask.objects.filter(guardian__user=request.user).order_by('created_at')
|
queryset = JuniorTask.objects.filter(guardian__user=request.user).order_by('created_at')
|
||||||
else:
|
else:
|
||||||
queryset = JuniorTask.objects.filter(guardian__user=request.user,
|
queryset = JuniorTask.objects.filter(guardian__user=request.user,
|
||||||
|
|||||||
@ -199,6 +199,8 @@ class JuniorProfileSerializer(serializers.ModelSerializer):
|
|||||||
first_name = serializers.SerializerMethodField('get_first_name')
|
first_name = serializers.SerializerMethodField('get_first_name')
|
||||||
last_name = serializers.SerializerMethodField('get_last_name')
|
last_name = serializers.SerializerMethodField('get_last_name')
|
||||||
notification_count = serializers.SerializerMethodField('get_notification_count')
|
notification_count = serializers.SerializerMethodField('get_notification_count')
|
||||||
|
total_count = serializers.SerializerMethodField('get_total_count')
|
||||||
|
complete_field_count = serializers.SerializerMethodField('get_complete_field_count')
|
||||||
|
|
||||||
def get_auth(self, obj):
|
def get_auth(self, obj):
|
||||||
"""user email address"""
|
"""user email address"""
|
||||||
@ -213,12 +215,22 @@ class JuniorProfileSerializer(serializers.ModelSerializer):
|
|||||||
return obj.auth.last_name
|
return obj.auth.last_name
|
||||||
|
|
||||||
def get_notification_count(self, obj):
|
def get_notification_count(self, obj):
|
||||||
"""user email address"""
|
"""total notification count"""
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def get_total_count(self, obj):
|
||||||
|
"""total fields count"""
|
||||||
|
return 9
|
||||||
|
|
||||||
|
def get_complete_field_count(self, obj):
|
||||||
|
"""total filled fields count"""
|
||||||
|
field_list = [obj.auth.first_name, obj.auth.last_name, obj.auth.email, obj.country_name, obj.country_code,
|
||||||
|
obj.phone, obj.gender, obj.dob, obj.image]
|
||||||
|
complete_field = [data for data in field_list if data is not None and data != '']
|
||||||
|
return len(complete_field)
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
"""Meta info"""
|
"""Meta info"""
|
||||||
model = Junior
|
model = Junior
|
||||||
fields = ['id', 'email', 'first_name', 'last_name', 'country_name', 'country_code', 'phone', 'gender', 'dob',
|
fields = ['id', 'email', 'first_name', 'last_name', 'country_name', 'country_code', 'phone', 'gender', 'dob',
|
||||||
'guardian_code', 'referral_code','is_active', 'is_complete_profile', 'created_at', 'image',
|
'guardian_code', 'referral_code','is_active', 'is_complete_profile', 'created_at', 'image',
|
||||||
'updated_at', 'notification_count']
|
'updated_at', 'notification_count', 'total_count', 'complete_field_count']
|
||||||
|
|||||||
Reference in New Issue
Block a user