mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 18:36:18 +00:00
jira-34 referral code validation API
This commit is contained in:
@ -16,7 +16,7 @@ from base.constants import PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED,
|
||||
from guardian.models import Guardian, JuniorTask
|
||||
from account.models import UserEmailOtp
|
||||
from junior.utils import junior_notification_email, junior_approval_mail
|
||||
from guardian.utils import real_time
|
||||
from guardian.utils import real_time, update_referral_points
|
||||
|
||||
|
||||
class ListCharField(serializers.ListField):
|
||||
@ -92,7 +92,6 @@ class CreateJuniorSerializer(serializers.ModelSerializer):
|
||||
"""Update country code and phone number"""
|
||||
junior.phone = validated_data.get('phone', junior.phone)
|
||||
junior.country_code = validated_data.get('country_code', junior.country_code)
|
||||
junior.referral_code_used = validated_data.get('referral_code_used', junior.referral_code_used)
|
||||
junior.image = validated_data.get('image', junior.image)
|
||||
"""Complete profile of the junior if below all data are filled"""
|
||||
complete_profile_field = all([junior.gender, junior.country_name, junior.image,
|
||||
@ -100,6 +99,9 @@ class CreateJuniorSerializer(serializers.ModelSerializer):
|
||||
junior.is_complete_profile = False
|
||||
if complete_profile_field:
|
||||
junior.is_complete_profile = True
|
||||
referral_code_used = validated_data.get('referral_code_used')
|
||||
update_referral_points(junior.referral_code, referral_code_used)
|
||||
junior.referral_code_used = validated_data.get('referral_code_used', junior.referral_code_used)
|
||||
junior.save()
|
||||
return junior
|
||||
|
||||
@ -346,7 +348,7 @@ class JuniorPointsSerializer(serializers.ModelSerializer):
|
||||
"""total points"""
|
||||
points = JuniorPoints.objects.filter(junior=obj.junior).last()
|
||||
if points:
|
||||
return points.total_task_points
|
||||
return points.total_points
|
||||
|
||||
def get_in_progress_task(self, obj):
|
||||
return JuniorTask.objects.filter(junior=obj.junior, task_status=IN_PROGRESS).count()
|
||||
|
Reference in New Issue
Block a user