Merge pull request 'fix(api): Check if user has campus before add to response' (#85) from Starthur/website:main into main

Reviewed-on: #85
Reviewed-by: Danhia <danhia@protonmail.com>
This commit is contained in:
Danhia 2023-09-01 11:09:53 +02:00
commit 5a10e033a2
1 changed files with 10 additions and 11 deletions

View File

@ -40,8 +40,8 @@ def bot_discord_campus(request):
all_users = UserProfileInfo.objects.select_related().order_by('-score', 'last_submission_date', 'user__username') all_users = UserProfileInfo.objects.select_related().order_by('-score', 'last_submission_date', 'user__username')
data = {} data = {}
for user in all_users: for user in all_users:
if user.discord_id: if user.campus and user.discord_id:
data[user.discord_id] = user.campus data[user.discord_id] = user.campus.name
return JsonResponse(data) return JsonResponse(data)
@ -70,4 +70,3 @@ def events_data(request, event_slug):
return JsonResponse(data) return JsonResponse(data)