Compare commits
No commits in common. "2d4816e78ff8fbf5e43556e9738baca53edb247f" and "9ad64e72bcb478b77751eefc3840ac0d88ec6505" have entirely different histories.
2d4816e78f
...
9ad64e72bc
|
@ -2,8 +2,6 @@ from django.urls import path
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('bot/discord', views.bot_discord_rank, name='bot_discord_rank'), # legacy, to remove when new bot is deployed
|
||||
path('bot/discord/rank', views.bot_discord_rank, name='bot_discord_rank'), # use this
|
||||
path('bot/discord/campus', views.bot_discord_campus, name='bot_discord_campus'),
|
||||
path('bot/discord', views.discord_bot, name='discord_bot'),
|
||||
path('events/<str:event_slug>', views.events_data, name='events_data'),
|
||||
]
|
||||
|
|
|
@ -7,7 +7,8 @@ from django.shortcuts import get_object_or_404
|
|||
|
||||
# Create your views here.
|
||||
|
||||
def bot_discord_rank(request):
|
||||
|
||||
def discord_bot(request):
|
||||
if request.method != 'GET':
|
||||
return JsonResponse({'error':'bad request'})
|
||||
|
||||
|
@ -27,24 +28,6 @@ def bot_discord_rank(request):
|
|||
|
||||
return JsonResponse(data)
|
||||
|
||||
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
|
||||
|
||||
return JsonResponse(data)
|
||||
|
||||
def events_data(request, event_slug):
|
||||
if request.method != 'GET':
|
||||
return JsonResponse({'error':'bad request'})
|
||||
|
|
Loading…
Reference in New Issue