Compare commits
2 Commits
2d4816e78f
...
5a10e033a2
Author | SHA1 | Date |
---|---|---|
Danhia | 5a10e033a2 | |
Starthur | 691c53e110 |
|
@ -10,13 +10,13 @@ from django.shortcuts import get_object_or_404
|
|||
def bot_discord_rank(request):
|
||||
if request.method != 'GET':
|
||||
return JsonResponse({'error':'bad request'})
|
||||
|
||||
|
||||
token = request.GET.get('token')
|
||||
auth_token = os.getenv('BOT_TOKEN')
|
||||
|
||||
if (token != auth_token or not auth_token):
|
||||
return JsonResponse({'error':'not authorized'})
|
||||
|
||||
|
||||
all_users = UserProfileInfo.objects.select_related().order_by('-score', 'last_submission_date', 'user__username')
|
||||
data = {}
|
||||
rank = 1
|
||||
|
@ -30,30 +30,30 @@ def bot_discord_rank(request):
|
|||
def bot_discord_campus(request):
|
||||
if request.method != 'GET':
|
||||
return JsonResponse({'error':'bad request'})
|
||||
|
||||
|
||||
token = request.GET.get('token')
|
||||
auth_token = os.getenv('BOT_TOKEN')
|
||||
|
||||
if (token != auth_token or not auth_token):
|
||||
return JsonResponse({'error':'not authorized'})
|
||||
|
||||
|
||||
all_users = UserProfileInfo.objects.select_related().order_by('-score', 'last_submission_date', 'user__username')
|
||||
data = {}
|
||||
for user in all_users:
|
||||
if user.discord_id:
|
||||
data[user.discord_id] = user.campus
|
||||
if user.campus and user.discord_id:
|
||||
data[user.discord_id] = user.campus.name
|
||||
|
||||
return JsonResponse(data)
|
||||
|
||||
def events_data(request, event_slug):
|
||||
if request.method != 'GET':
|
||||
return JsonResponse({'error':'bad request'})
|
||||
|
||||
|
||||
event_info = get_object_or_404(Event, slug=event_slug)
|
||||
|
||||
|
||||
if event_info.password and request.GET.get('password') != event_info.password:
|
||||
return JsonResponse({'error':'not authorized'})
|
||||
|
||||
|
||||
players = EventPlayer.objects.filter(event=event_info)
|
||||
|
||||
data = {}
|
||||
|
@ -67,7 +67,6 @@ def events_data(request, event_slug):
|
|||
else:
|
||||
for player in players:
|
||||
data[player.user.username] = player.score
|
||||
|
||||
|
||||
return JsonResponse(data)
|
||||
|
||||
|
Loading…
Reference in New Issue