aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/resources/urls.py
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-10-17 13:41:51 +0100
committerGravatar GitHub <[email protected]>2021-10-17 13:41:51 +0100
commitf5ab651b1f8e2dc9f498198087750d4c38010320 (patch)
treed101820efaa59f066e37d3aa4d6908663498a1ba /pydis_site/apps/resources/urls.py
parentDirect appeals to the appeals server (diff)
parentMerge pull request #613 from python-discord/mbaruh-patch-1 (diff)
Merge branch 'main' into new-ban-appeals-process
Diffstat (limited to 'pydis_site/apps/resources/urls.py')
-rw-r--r--pydis_site/apps/resources/urls.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/pydis_site/apps/resources/urls.py b/pydis_site/apps/resources/urls.py
index 19142081..10eda132 100644
--- a/pydis_site/apps/resources/urls.py
+++ b/pydis_site/apps/resources/urls.py
@@ -1,9 +1,25 @@
-from django.urls import path
+import typing
+from pathlib import Path
+
+from django_distill import distill_path
from pydis_site.apps.resources import views
app_name = "resources"
+
+
+def get_all_resources() -> typing.Iterator[dict[str, str]]:
+ """Yield a dict of all resource categories."""
+ for category in Path("pydis_site", "apps", "resources", "resources").iterdir():
+ yield {"category": category.name}
+
+
urlpatterns = [
- path("", views.ResourcesView.as_view(), name="index"),
- path("<str:category>/", views.ResourcesListView.as_view(), name="resources")
+ distill_path("", views.ResourcesView.as_view(), name="index"),
+ distill_path(
+ "<str:category>/",
+ views.ResourcesListView.as_view(),
+ name="resources",
+ distill_func=get_all_resources
+ ),
]