aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/resources
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2022-01-30 12:34:29 +0100
committerGravatar Leon Sandøy <[email protected]>2022-01-30 12:34:29 +0100
commitd8c5571a266438d5e2e0c9fd4a35adf469688730 (patch)
tree751f00debfc9372f635e04ba9d5be12e08f8b547 /pydis_site/apps/resources
parentClean up hover effects. (diff)
Support dashful redirects.
Previously, trying to go to `resources/project%20ideas` would crash the filtering JS. This has now been sorted out, so that these types of redirects have their spaces replaced by dashes, which makes them valid again.
Diffstat (limited to 'pydis_site/apps/resources')
-rw-r--r--pydis_site/apps/resources/views/resources.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/pydis_site/apps/resources/views/resources.py b/pydis_site/apps/resources/views/resources.py
index b828d89a..709fad6c 100644
--- a/pydis_site/apps/resources/views/resources.py
+++ b/pydis_site/apps/resources/views/resources.py
@@ -82,9 +82,12 @@ class ResourceView(View):
def get(self, request: WSGIRequest, resource_type: t.Optional[str] = None) -> HttpResponse:
"""List out all the resources, and any filtering options from the URL."""
- # Add type filtering if the request is made to somewhere like /resources/video
- if resource_type and resource_type.title() not in self.filters['Type']['filters']:
+ # Add type filtering if the request is made to somewhere like /resources/video.
+ # We also convert all spaces to dashes, so they'll correspond with the filters.
+ dashless_resource_type = resource_type.replace("-", " ")
+ if resource_type and dashless_resource_type.title() not in self.filters['Type']['filters']:
return HttpResponseNotFound()
+ resource_type = resource_type.replace(" ", "-")
return render(
request,