diff --git a/board/static/board/style.css b/board/static/board/style.css index 3fbc499..9c52b6d 100644 --- a/board/static/board/style.css +++ b/board/static/board/style.css @@ -165,6 +165,10 @@ th { font-size: small; } +.news_recent { + font-size: smaller; +} + /* Misc */ a:link { diff --git a/board/templates/board/board_detail.html b/board/templates/board/board_detail.html index 4b7d5b5..f2cd98f 100644 --- a/board/templates/board/board_detail.html +++ b/board/templates/board/board_detail.html @@ -16,6 +16,18 @@
 

+{# recent news #} +
+
 
+
+

Recent news

+
+ {% include "board/news_snippet.html" %} +
+
+
 
+
+
{# post creation form #}
 
diff --git a/board/templates/board/news_list.html b/board/templates/board/news_list.html index 67179a4..5ddbfbb 100644 --- a/board/templates/board/news_list.html +++ b/board/templates/board/news_list.html @@ -17,7 +17,7 @@
 
{% for post in object_list %} -
+

{{post.title}}

diff --git a/board/templates/board/post_detail.html b/board/templates/board/post_detail.html index d59d117..39b8225 100644 --- a/board/templates/board/post_detail.html +++ b/board/templates/board/post_detail.html @@ -19,6 +19,18 @@
 

+{# recent news #} +
+
 
+
+

Recent news

+
+ {% include "board/news_snippet.html" %} +
+
+
 
+
+
{# post creation form #}
 
diff --git a/board/views.py b/board/views.py index b6cde9d..1852eb7 100644 --- a/board/views.py +++ b/board/views.py @@ -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):