konova/news/views.py
mpeltriaux 7fdc93fefd Server Messages unpublish
* changes unpublish_on to optional value
* simplifies fetching of server message news
2023-03-24 07:34:50 +01:00

31 lines
811 B
Python

from django.contrib.auth.decorators import login_required
from django.http import HttpRequest
from django.shortcuts import render
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from konova.contexts import BaseContext
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
from news.models import ServerMessage
@login_required
def index_view(request: HttpRequest):
""" Renders an overview of all news
Args:
request (HttpRequest): The incoming request
Returns:
"""
template = "news/index.html"
news = ServerMessage.get_current_news()
context = {
"news": news,
TAB_TITLE_IDENTIFIER: _("News"),
}
context = BaseContext(request, context).context
return render(request, template, context)