Compare commits
No commits in common. "5a10e033a214896f00c010f59d8d1be606f03d1a" and "2d4816e78ff8fbf5e43556e9738baca53edb247f" have entirely different histories.
5a10e033a2
...
2d4816e78f
|
@ -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.campus and user.discord_id:
|
||||
data[user.discord_id] = user.campus.name
|
||||
if user.discord_id:
|
||||
data[user.discord_id] = user.campus
|
||||
|
||||
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,6 +67,7 @@ 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