diff options
author | 2022-01-21 21:55:19 +0000 | |
---|---|---|
committer | 2022-01-21 21:55:19 +0000 | |
commit | 721d313e9170661bd969fe8e737866b2560dae4a (patch) | |
tree | 44aa19b25573ada3bf2ef3cf16c9c279d7b05603 /pydis_site/apps/resources/urls.py | |
parent | Implement voice mute + migration from voice mute -> voice ban (diff) | |
parent | Merge pull request #640 from Krish-bhardwaj/main (diff) |
Merge branch 'main' into voicemute
Diffstat (limited to 'pydis_site/apps/resources/urls.py')
-rw-r--r-- | pydis_site/apps/resources/urls.py | 22 |
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 + ), ] |