Abhishek Thakur
commited on
Commit
·
5bafe72
1
Parent(s):
99c5748
update
Browse files- competitions/app.py +4 -3
competitions/app.py
CHANGED
|
@@ -178,9 +178,10 @@ async def fetch_leaderboard(request: Request, user_lb: UserLB):
|
|
| 178 |
if request.session.get("oauth_info") is not None:
|
| 179 |
user_lb.user_token = request.session.get("oauth_info")["access_token"]
|
| 180 |
|
| 181 |
-
|
|
|
|
| 182 |
|
| 183 |
-
if DISABLE_PUBLIC_LB == 1 and user_lb.lb == "public" and not
|
| 184 |
return {"response": "Public leaderboard is disabled by the competition host."}
|
| 185 |
|
| 186 |
leaderboard = Leaderboard(
|
|
@@ -193,7 +194,7 @@ async def fetch_leaderboard(request: Request, user_lb: UserLB):
|
|
| 193 |
)
|
| 194 |
if user_lb.lb == "private":
|
| 195 |
current_utc_time = datetime.datetime.now()
|
| 196 |
-
if current_utc_time < COMP_INFO.end_date and not
|
| 197 |
return {"response": "Private leaderboard will be available after the competition ends."}
|
| 198 |
df = leaderboard.fetch(private=user_lb.lb == "private")
|
| 199 |
|
|
|
|
| 178 |
if request.session.get("oauth_info") is not None:
|
| 179 |
user_lb.user_token = request.session.get("oauth_info")["access_token"]
|
| 180 |
|
| 181 |
+
is_user_admin = utils.is_user_admin(user_lb.user_token, COMPETITION_ID)
|
| 182 |
+
logger.info(f"User is admin: {is_user_admin}")
|
| 183 |
|
| 184 |
+
if DISABLE_PUBLIC_LB == 1 and user_lb.lb == "public" and not is_user_admin:
|
| 185 |
return {"response": "Public leaderboard is disabled by the competition host."}
|
| 186 |
|
| 187 |
leaderboard = Leaderboard(
|
|
|
|
| 194 |
)
|
| 195 |
if user_lb.lb == "private":
|
| 196 |
current_utc_time = datetime.datetime.now()
|
| 197 |
+
if current_utc_time < COMP_INFO.end_date and not is_user_admin:
|
| 198 |
return {"response": "Private leaderboard will be available after the competition ends."}
|
| 199 |
df = leaderboard.fetch(private=user_lb.lb == "private")
|
| 200 |
|