mpeltriaux
16e72c3372
* changes unpublish_on to optional value * simplifies fetching of server message news
31 lines
811 B
Python
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)
|