diff options
| author | 2021-05-19 09:02:21 +0200 | |
|---|---|---|
| committer | 2021-05-19 09:02:21 +0200 | |
| commit | 5c37aee79c04d9199dc47b9d60f9899a0f6571d9 (patch) | |
| tree | 9041c01dc0124fe96be467de7bb994daa372efd3 /pydis_site/apps/resources/views | |
| parent | Add bulma-modal, we'll need it later. (diff) | |
Dramatically simplify resources.
We don't need _category_info, we don't need subcategories, we this will
be much simpler now.
Also, rglob is nice.
Diffstat (limited to 'pydis_site/apps/resources/views')
| -rw-r--r-- | pydis_site/apps/resources/views/resources_list.py | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/pydis_site/apps/resources/views/resources_list.py b/pydis_site/apps/resources/views/resources_list.py index 55f22993..0ec74d78 100644 --- a/pydis_site/apps/resources/views/resources_list.py +++ b/pydis_site/apps/resources/views/resources_list.py @@ -1,14 +1,8 @@ -from pathlib import Path from typing import Any, Dict -import yaml -from django.conf import settings -from django.http import Http404 from django.views.generic import TemplateView -from pydis_site.apps.resources.utils import get_resources, get_subcategories - -RESOURCES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "resources", "resources") +from pydis_site.apps.resources.utils import get_resources class ResourcesListView(TemplateView): @@ -19,21 +13,6 @@ class ResourcesListView(TemplateView): def get_context_data(self, **kwargs) -> Dict[str, Any]: """Add resources and subcategories data into context.""" context = super().get_context_data(**kwargs) - - resource_path = RESOURCES_PATH / self.kwargs["category"] - if ( - not resource_path.is_dir() - or not resource_path.joinpath("_category_info.yaml").exists() - ): - raise Http404 - - context["resources"] = get_resources(resource_path) - context["subcategories"] = get_subcategories(resource_path) - context["category_info"] = { - **yaml.safe_load( - resource_path.joinpath("_category_info.yaml").read_text() - ), - "raw_name": resource_path.name - } + context["resources"] = get_resources() return context |