53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""
|
|
URL configuration for opus_submitter project.
|
|
|
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
https://docs.djangoproject.com/en/5.2/topics/http/urls/
|
|
Examples:
|
|
Function views
|
|
1. Add an import: from my_app import views
|
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
Class-based views
|
|
1. Add an import: from other_app.views import Home
|
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
Including another URLconf
|
|
1. Import the include() function: from django.urls import include, path
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
"""
|
|
|
|
from django.contrib import admin
|
|
from django.http import HttpRequest
|
|
from django.shortcuts import render
|
|
from django.urls import path
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from simple_cas_views import SimpleCASLoginView, SimpleCASLogoutView
|
|
from .api import api
|
|
|
|
|
|
@login_required
|
|
def home(request: HttpRequest):
|
|
from submissions.models import SteamCollection
|
|
|
|
return render(
|
|
request,
|
|
"index.html",
|
|
{
|
|
"collection": SteamCollection.objects.filter(is_active=True).last(),
|
|
},
|
|
)
|
|
|
|
|
|
urlpatterns = [
|
|
path("admin/", admin.site.urls),
|
|
path("cas/login/", SimpleCASLoginView.as_view(), name="cas_ng_login"),
|
|
path("cas/logout/", SimpleCASLogoutView.as_view(), name="cas_ng_logout"),
|
|
path("api/", api.urls),
|
|
path("", home, name="home"),
|
|
]
|
|
|
|
# Serve media files in development
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|