excluded the API from the i18n patterns
This commit is contained in:
parent
a0b76903a7
commit
8f32ef9a6e
|
@ -14,5 +14,4 @@ urlpatterns = [
|
||||||
path('connections/connect/discord/authorize', views.connection.authorize, name='connections-connect-discord-authorize'),
|
path('connections/connect/discord/authorize', views.connection.authorize, name='connections-connect-discord-authorize'),
|
||||||
path('connections/disconnect/discord', views.connection.disconnect, name='connections-disconnect-discord'),
|
path('connections/disconnect/discord', views.connection.disconnect, name='connections-disconnect-discord'),
|
||||||
path('delete_account/', views.delete_account, name='delete_account'),
|
path('delete_account/', views.delete_account, name='delete_account'),
|
||||||
path('api/bot/', views.api_bot, name='api_bot'),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -182,24 +182,4 @@ def rank(request, token):
|
||||||
break
|
break
|
||||||
rank += 1
|
rank += 1
|
||||||
data = {"rank": rank}
|
data = {"rank": rank}
|
||||||
return JsonResponse(data)
|
|
||||||
|
|
||||||
def api_bot(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
|
|
||||||
for user in all_users:
|
|
||||||
if user.discord_id:
|
|
||||||
data[user.discord_id] = rank
|
|
||||||
rank += 1
|
|
||||||
|
|
||||||
return JsonResponse(data)
|
return JsonResponse(data)
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ApiConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'api'
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('bot/discord', views.discord_bot, name='discord_bot'),
|
||||||
|
]
|
|
@ -0,0 +1,27 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from accounts.models import UserProfileInfo
|
||||||
|
from django.http import JsonResponse
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
|
def discord_bot(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
|
||||||
|
for user in all_users:
|
||||||
|
if user.discord_id:
|
||||||
|
data[user.discord_id] = rank
|
||||||
|
rank += 1
|
||||||
|
|
||||||
|
return JsonResponse(data)
|
|
@ -38,6 +38,7 @@ INSTALLED_APPS = [
|
||||||
'scoreboard.apps.ScoreboardConfig',
|
'scoreboard.apps.ScoreboardConfig',
|
||||||
'resources.apps.ResourcesConfig',
|
'resources.apps.ResourcesConfig',
|
||||||
'django.contrib.sites',
|
'django.contrib.sites',
|
||||||
|
'api.apps.ApiConfig',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -24,6 +24,7 @@ urlpatterns = [
|
||||||
path('', include('home.urls')),
|
path('', include('home.urls')),
|
||||||
path('set_lang/<str:lang_code>', home.views.set_language, name="set_language"),
|
path('set_lang/<str:lang_code>', home.views.set_language, name="set_language"),
|
||||||
path('dashboard/secret/admin', admin.site.urls),
|
path('dashboard/secret/admin', admin.site.urls),
|
||||||
|
path('api/', include('api.urls'))
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += i18n_patterns(
|
urlpatterns += i18n_patterns(
|
||||||
|
|
Loading…
Reference in New Issue