Add "boards" context processor
This adds the "boards" context data to all pages, so they can render the boards nav page. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
from django.conf import settings as django_settings
|
from django.conf import settings as django_settings
|
||||||
|
from board.models import Board
|
||||||
|
|
||||||
|
|
||||||
def settings(request):
|
def settings(request):
|
||||||
return {"settings": django_settings}
|
return {"settings": django_settings}
|
||||||
|
|
||||||
|
|
||||||
|
def boards(request):
|
||||||
|
return {"boards": Board.objects.filter(readonly=False)}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from board.views import *
|
|||||||
app_name = "board"
|
app_name = "board"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Index
|
# Index
|
||||||
path("", HomeView.as_view(), name="home"),
|
path("", TemplateView.as_view(template_name="board/home.html"), name="home"),
|
||||||
# News views
|
# News views
|
||||||
path("news/", NewsListView.as_view(), name="news_list"),
|
path("news/", NewsListView.as_view(), name="news_list"),
|
||||||
# Rules views
|
# Rules views
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ __all__ = (
|
|||||||
"BanSuccessView",
|
"BanSuccessView",
|
||||||
"BannedView",
|
"BannedView",
|
||||||
"BoardView",
|
"BoardView",
|
||||||
"HomeView",
|
|
||||||
"NewsListView",
|
"NewsListView",
|
||||||
"PostCreateView",
|
"PostCreateView",
|
||||||
"PostModifyView",
|
"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):
|
class ActionSuccessView(TemplateView):
|
||||||
template_name = "board/action_success.html"
|
template_name = "board/action_success.html"
|
||||||
message = "Action completed."
|
message = "Action completed."
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ TEMPLATES = [
|
|||||||
"django.contrib.auth.context_processors.auth",
|
"django.contrib.auth.context_processors.auth",
|
||||||
"django.contrib.messages.context_processors.messages",
|
"django.contrib.messages.context_processors.messages",
|
||||||
"board.context_processors.settings",
|
"board.context_processors.settings",
|
||||||
|
"board.context_processors.boards",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user