sonar issues

This commit is contained in:
jain
2023-07-24 15:28:54 +05:30
parent ed28117a7f
commit 096961976d
4 changed files with 9 additions and 3 deletions

View File

@ -103,3 +103,6 @@ MAX_ARTICLE_CARD = 6
# min and max survey # min and max survey
MIN_ARTICLE_SURVEY = 5 MIN_ARTICLE_SURVEY = 5
MAX_ARTICLE_SURVEY = 10 MAX_ARTICLE_SURVEY = 10
# real time url
time_url = "http://worldtimeapi.org/api/timezone/Asia/Riyadh"

View File

@ -77,6 +77,7 @@ ERROR_CODE = {
"2044": "Task does not exist", "2044": "Task does not exist",
"2045": "Invalid guardian", "2045": "Invalid guardian",
"2046": "Due date must be future date", "2046": "Due date must be future date",
# invalid junior id msg
"2047": "Invalid Junior ID ", "2047": "Invalid Junior ID ",
"2048": "Choose right file for image", "2048": "Choose right file for image",
"2049": "This task is already requested " "2049": "This task is already requested "

View File

@ -10,7 +10,7 @@ import tempfile
# Import date time module's function # Import date time module's function
from datetime import datetime, time from datetime import datetime, time
# import Number constant # import Number constant
from base.constants import NUMBER from base.constants import NUMBER, time_url
# Import Junior's model # Import Junior's model
from junior.models import Junior, JuniorPoints from junior.models import Junior, JuniorPoints
@ -45,8 +45,9 @@ def upload_image_to_alibaba(image, filename):
return f"https://{settings.ALIYUN_OSS_BUCKET_NAME}.{settings.ALIYUN_OSS_ENDPOINT}/{new_filename}" return f"https://{settings.ALIYUN_OSS_BUCKET_NAME}.{settings.ALIYUN_OSS_ENDPOINT}/{new_filename}"
def real_time(timezone='Asia/Riyadh'): def real_time():
url = f'http://worldtimeapi.org/api/timezone/{timezone}' """fetch real time from world time api"""
url = time_url
response = requests.get(url) response = requests.get(url)
if response.status_code == 200: if response.status_code == 200:
data = response.json() data = response.json()

View File

@ -48,6 +48,7 @@ def junior_approval_mail(guardian, full_name):
return full_name return full_name
def update_positions_based_on_points(): def update_positions_based_on_points():
"""Update position of the junior"""
# First, retrieve all the JuniorPoints instances ordered by total_points in descending order. # First, retrieve all the JuniorPoints instances ordered by total_points in descending order.
juniors_points = JuniorPoints.objects.order_by('-total_points') juniors_points = JuniorPoints.objects.order_by('-total_points')