fix(api): Check if user has campus before add to response

This commit is contained in:
Starthur 2023-02-07 10:15:30 +01:00
parent 2d4816e78f
commit 691c53e110
Signed by: Starthur
GPG Key ID: 68AD34A2CF658E32
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')
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)
@ -70,4 +70,3 @@ def events_data(request, event_slug):
return JsonResponse(data)