Add news posts
You know. For basic information. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -82,3 +82,8 @@ class BanTemplateAdmin(admin.ModelAdmin):
|
|||||||
@admin.register(Capcode)
|
@admin.register(Capcode)
|
||||||
class CapcodeAdmin(GuardedModelAdmin):
|
class CapcodeAdmin(GuardedModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(NewsPost)
|
||||||
|
class NewsPostAdmin(admin.ModelAdmin):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -397,3 +397,14 @@ class Capcode(models.Model):
|
|||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.suffix
|
return self.suffix
|
||||||
|
|
||||||
|
|
||||||
|
class NewsPost(models.Model):
|
||||||
|
# The time that this news post was created.
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
# The title for this news post.
|
||||||
|
title = models.CharField(max_length=300)
|
||||||
|
# The author of this news post.
|
||||||
|
author = models.CharField(max_length=100, blank=True)
|
||||||
|
# The content of this news post.
|
||||||
|
body = models.TextField(blank=True)
|
||||||
|
|||||||
@@ -158,6 +158,11 @@ th {
|
|||||||
right: 0px;
|
right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* News */
|
||||||
|
.news_header {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
|
|
||||||
a:link {
|
a:link {
|
||||||
|
|||||||
41
board/templates/board/news_list.html
Normal file
41
board/templates/board/news_list.html
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{% extends "board/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
News
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="column"> </div>
|
||||||
|
<div class="column"><h1>News</h1></div>
|
||||||
|
<div class="column"> </div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="column"> </div>
|
||||||
|
<div class="column">
|
||||||
|
{% for post in object_list %}
|
||||||
|
<div class="row">
|
||||||
|
<section>
|
||||||
|
<h3>{{post.title}}</h3>
|
||||||
|
<header class="news_header">
|
||||||
|
{% blocktranslate with created=post.created author=post.author %}
|
||||||
|
by {{author}} at <time>{{created}}</time>
|
||||||
|
{% endblocktranslate %}
|
||||||
|
</header>
|
||||||
|
<article>
|
||||||
|
<p>{{post.body|safe|linebreaks}}</p>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="column"> </div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
@@ -6,6 +6,8 @@ from board.views import *
|
|||||||
|
|
||||||
app_name = "board"
|
app_name = "board"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
# News views
|
||||||
|
path("news/", NewsListView.as_view(), name="board_news"),
|
||||||
# Board views
|
# Board views
|
||||||
path("<slug:url>/", BoardView.as_view(), name="board_detail"),
|
path("<slug:url>/", BoardView.as_view(), name="board_detail"),
|
||||||
path("<slug:url>/page/<int:page>/", BoardView.as_view(), name="board_detail"),
|
path("<slug:url>/page/<int:page>/", BoardView.as_view(), name="board_detail"),
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ from django.http import Http404, HttpResponseRedirect
|
|||||||
from django.http.request import QueryDict
|
from django.http.request import QueryDict
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.views.generic import edit
|
from django.views.generic import edit, list
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from guardian.shortcuts import get_objects_for_user
|
from guardian.shortcuts import get_objects_for_user
|
||||||
|
|
||||||
from board.forms import *
|
from board.forms import *
|
||||||
from board.models import Ban, BanTemplate, Board, Post, Report
|
from board.models import Ban, BanTemplate, Board, NewsPost, Post, Report
|
||||||
from board.utils import *
|
from board.utils import *
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@@ -23,6 +23,7 @@ __all__ = (
|
|||||||
"BanSuccessView",
|
"BanSuccessView",
|
||||||
"BannedView",
|
"BannedView",
|
||||||
"BoardView",
|
"BoardView",
|
||||||
|
"NewsListView",
|
||||||
"PostCreateView",
|
"PostCreateView",
|
||||||
"PostModifyView",
|
"PostModifyView",
|
||||||
"PostModifySuccessView",
|
"PostModifySuccessView",
|
||||||
@@ -372,3 +373,9 @@ class BanSuccessView(PermissionRequiredMixin, TemplateView):
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["window_timeout"] = settings.BAN_WINDOW_CLOSE_TIMEOUT
|
context["window_timeout"] = settings.BAN_WINDOW_CLOSE_TIMEOUT
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class NewsListView(list.ListView):
|
||||||
|
model = NewsPost
|
||||||
|
template_name = "board/news_list.html"
|
||||||
|
ordering = ("-created",)
|
||||||
|
|||||||
Reference in New Issue
Block a user