changes in complete profile field

This commit is contained in:
jain
2023-07-13 12:28:35 +05:30
parent 1fc02d17e6
commit 324a023d83
3 changed files with 62 additions and 13 deletions

View File

@ -12,6 +12,7 @@ from account.models import UserProfile, UserEmailOtp, UserNotification
from account.serializers import JuniorSerializer
from junior.serializers import JuniorDetailSerializer
from base.messages import ERROR_CODE, SUCCESS_CODE
from base.constants import NUMBER
from .utils import upload_image_to_alibaba
from junior.models import Junior, JuniorPoints
class UserSerializer(serializers.ModelSerializer):
@ -117,9 +118,9 @@ class CreateGuardianSerializer(serializers.ModelSerializer):
guardian.referral_code_used = validated_data.get('referral_code_used', guardian.referral_code_used)
guardian.image = validated_data.get('image', guardian.image)
"""Complete profile of the junior if below all data are filled"""
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])
complete_profile_field = all([guardian.gender, guardian.country_name,
guardian.dob, user.first_name,
guardian.image])
guardian.is_complete_profile = False
if complete_profile_field:
guardian.is_complete_profile = True
@ -224,12 +225,12 @@ class GuardianProfileSerializer(serializers.ModelSerializer):
def get_total_count(self, obj):
"""total fields count"""
return 9
return NUMBER['five']
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_field_list = [obj.user.first_name, obj.country_name,
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)