Add recent news header to boards and posts
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -83,6 +83,13 @@ class BoardMixin:
|
||||
return get_object_or_404(Board, url=self.kwargs["url"]) # type: ignore
|
||||
|
||||
|
||||
class NewsSnippetMixin:
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["news"] = NewsPost.objects.order_by("-id")[:3]
|
||||
return context
|
||||
|
||||
|
||||
class CreateView(BoardMixin, edit.CreateView):
|
||||
"""
|
||||
Helper class that sets a few variables for posts and check against bans.
|
||||
@@ -107,7 +114,7 @@ class CreateView(BoardMixin, edit.CreateView):
|
||||
return super(CreateView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class BoardView(BoardMixin, TemplateView):
|
||||
class BoardView(NewsSnippetMixin, BoardMixin, TemplateView):
|
||||
template_name = "board/board_detail.html"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
@@ -234,7 +241,7 @@ class ReplyCreateView(CreateView):
|
||||
return reverse("board:post_success") + "?" + query.urlencode()
|
||||
|
||||
|
||||
class PostView(TemplateView):
|
||||
class PostView(NewsSnippetMixin, TemplateView):
|
||||
template_name = "board/post_detail.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user