blob: d3dcdf3f3a66d26570fac10abc048617ec3e2fff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
from typing import List
from django.conf import settings
from django.http import Http404
from django.views.generic import TemplateView
class PageView(TemplateView):
"""Handles event pages showing."""
def get_template_names(self) -> List[str]:
"""Get specific template names."""
page_path = settings.PAGES_PATH / self.kwargs['path']
if page_path.is_dir():
page_path = page_path / "_index.html"
self.kwargs['path'] = f"{self.kwargs['path']}/_index.html"
else:
page_path = settings.PAGES_PATH / f"{self.kwargs['path']}.html"
self.kwargs['path'] = f"{self.kwargs['path']}.html"
if not page_path.exists():
raise Http404
return [f"events/{settings.PAGES_PATH.name}/{self.kwargs['path']}"]
|