mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 10:05:21 +00:00
jira-34 referral code validation API
This commit is contained in:
@ -11,6 +11,8 @@ from datetime import datetime, time
|
||||
import ntplib
|
||||
# import Number constant
|
||||
from base.constants import NUMBER
|
||||
# Import Junior's model
|
||||
from junior.models import Junior, JuniorPoints
|
||||
|
||||
# Define upload image on
|
||||
# ali baba cloud
|
||||
@ -21,6 +23,10 @@ from base.constants import NUMBER
|
||||
# bucket and reform the image url"""
|
||||
# fetch real time data without depend on system time
|
||||
# convert time delta into date time object
|
||||
# update junior total points
|
||||
# update referral points
|
||||
# if any one use referral code of the junior
|
||||
# junior earn 5 points
|
||||
|
||||
def upload_image_to_alibaba(image, filename):
|
||||
"""upload image on oss alibaba bucket"""
|
||||
@ -59,3 +65,15 @@ def convert_timedelta_into_datetime(time_difference):
|
||||
# Create a new time object with the extracted time components
|
||||
time_only = time(hours, minutes, seconds, microseconds)
|
||||
return time_only
|
||||
|
||||
def update_referral_points(referral_code, referral_code_used):
|
||||
"""Update benefit of referral points"""
|
||||
junior_queryset = Junior.objects.filter(referral_code=referral_code_used).last()
|
||||
if junior_queryset and junior_queryset.referral_code != referral_code:
|
||||
# create data if junior points is not exist
|
||||
junior_query, created = JuniorPoints.objects.get_or_create(junior=junior_queryset)
|
||||
if junior_query:
|
||||
# update junior total points and referral points
|
||||
junior_query.total_points = junior_query.total_points + NUMBER['five']
|
||||
junior_query.referral_points = junior_query.referral_points + NUMBER['five']
|
||||
junior_query.save()
|
||||
|
Reference in New Issue
Block a user