diff options
author | 2020-09-20 18:14:08 +0300 | |
---|---|---|
committer | 2020-09-20 18:14:08 +0300 | |
commit | f674709a84e24a2ae9f2c32e0f937432b269af50 (patch) | |
tree | c8f381c413afc0603cbc5aa72f087d340249229f /pydis_site/apps/guides/views/guide.py | |
parent | Remove unnecessary debug path displaying for 404 on guide view (diff) |
Add handling for invalid category for category guide
Diffstat (limited to 'pydis_site/apps/guides/views/guide.py')
-rw-r--r-- | pydis_site/apps/guides/views/guide.py | 3 |
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"] |