mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
update position of the junior
This commit is contained in:
@ -3,7 +3,8 @@
|
||||
from django.conf import settings
|
||||
"""Third party Django app"""
|
||||
from templated_email import send_templated_mail
|
||||
|
||||
from .models import JuniorPoints
|
||||
from django.db.models import F
|
||||
# junior notification
|
||||
# email for sending email
|
||||
# when guardian create junior profile
|
||||
@ -45,3 +46,14 @@ def junior_approval_mail(guardian, full_name):
|
||||
}
|
||||
)
|
||||
return full_name
|
||||
|
||||
def update_positions_based_on_points():
|
||||
# First, retrieve all the JuniorPoints instances ordered by total_points in descending order.
|
||||
juniors_points = JuniorPoints.objects.order_by('-total_points')
|
||||
|
||||
# Now, iterate through the queryset and update the position field based on the order.
|
||||
position = 1
|
||||
for junior_point in juniors_points:
|
||||
junior_point.position = position
|
||||
junior_point.save()
|
||||
position += 1
|
||||
|
Reference in New Issue
Block a user