jira-15 changes in profile API

This commit is contained in:
jain
2023-07-09 17:56:47 +05:30
parent 413434496c
commit 3723e46be1
3 changed files with 37 additions and 4 deletions

View File

@ -219,6 +219,9 @@ class GuardianProfileSerializer(serializers.ModelSerializer):
email = serializers.SerializerMethodField('get_auth')
first_name = serializers.SerializerMethodField('get_first_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):
"""user email address"""
@ -231,9 +234,26 @@ class GuardianProfileSerializer(serializers.ModelSerializer):
def get_last_name(self, 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):
"""Meta info"""
model = Guardian
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']

View File

@ -84,7 +84,8 @@ class TaskListAPIView(viewsets.ModelViewSet):
def list(self, request, *args, **kwargs):
"""Create guardian profile"""
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')
else:
queryset = JuniorTask.objects.filter(guardian__user=request.user,

View File

@ -199,6 +199,8 @@ class JuniorProfileSerializer(serializers.ModelSerializer):
first_name = serializers.SerializerMethodField('get_first_name')
last_name = serializers.SerializerMethodField('get_last_name')
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):
"""user email address"""
@ -213,12 +215,22 @@ class JuniorProfileSerializer(serializers.ModelSerializer):
return obj.auth.last_name
def get_notification_count(self, obj):
"""user email address"""
"""total notification count"""
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):
"""Meta info"""
model = Junior
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',
'updated_at', 'notification_count']
'updated_at', 'notification_count', 'total_count', 'complete_field_count']