aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-09-20 18:14:08 +0300
committerGravatar ks129 <[email protected]>2020-09-20 18:14:08 +0300
commitf674709a84e24a2ae9f2c32e0f937432b269af50 (patch)
treec8f381c413afc0603cbc5aa72f087d340249229f
parentRemove unnecessary debug path displaying for 404 on guide view (diff)
Add handling for invalid category for category guide
-rw-r--r--pydis_site/apps/guides/views/guide.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/pydis_site/apps/guides/views/guide.py b/pydis_site/apps/guides/views/guide.py
index cb30a525..deb1b8c4 100644
--- a/pydis_site/apps/guides/views/guide.py
+++ b/pydis_site/apps/guides/views/guide.py
@@ -21,6 +21,9 @@ class GuideView(View):
category_name = None
else:
dir_path = os.path.join(settings.BASE_DIR, "pydis_site", "apps", "guides", "resources", "guides", category)
+ if not os.path.exists(dir_path) or not os.path.isdir(dir_path):
+ raise Http404("Category not found.")
+
path = os.path.join(dir_path, f"{guide}.md")
with open(os.path.join(dir_path, "_info.yml")) as f:
category_name = yaml.load(f.read())["name"]