diff --git a/board/context_processors.py b/board/context_processors.py index 6fd946a..6abf227 100644 --- a/board/context_processors.py +++ b/board/context_processors.py @@ -1,5 +1,10 @@ from django.conf import settings as django_settings +from board.models import Board def settings(request): return {"settings": django_settings} + + +def boards(request): + return {"boards": Board.objects.filter(readonly=False)} diff --git a/board/urls.py b/board/urls.py index 4a47ef7..cd7fcd3 100644 --- a/board/urls.py +++ b/board/urls.py @@ -10,7 +10,7 @@ from board.views import * app_name = "board" urlpatterns = [ # Index - path("", HomeView.as_view(), name="home"), + path("", TemplateView.as_view(template_name="board/home.html"), name="home"), # News views path("news/", NewsListView.as_view(), name="news_list"), # Rules views diff --git a/board/views.py b/board/views.py index ec4a854..bc606cb 100644 --- a/board/views.py +++ b/board/views.py @@ -24,7 +24,6 @@ __all__ = ( "BanSuccessView", "BannedView", "BoardView", - "HomeView", "NewsListView", "PostCreateView", "PostModifyView", @@ -49,15 +48,6 @@ def can_modify(user): ) -class HomeView(TemplateView): - template_name = "board/home.html" - - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: - context = super().get_context_data(**kwargs) - context["boards"] = Board.objects.filter(readonly=False) - return context - - class ActionSuccessView(TemplateView): template_name = "board/action_success.html" message = "Action completed." diff --git a/threadchat/settings.py b/threadchat/settings.py index e648d30..12ac408 100644 --- a/threadchat/settings.py +++ b/threadchat/settings.py @@ -73,6 +73,7 @@ TEMPLATES = [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "board.context_processors.settings", + "board.context_processors.boards", ], }, },