X-Git-Url: https://git.mdrn.pl/prawokultury.git/blobdiff_plain/44090c986d9a16f6913047c25319c446bb9308ad..df7591ba8d0b16c2faf45c0064a86a6f31a3733b:/events/views.py diff --git a/events/views.py b/events/views.py index 60f00ef..b2dccc7 100644 --- a/events/views.py +++ b/events/views.py @@ -1 +1,20 @@ -# Create your views here. +from datetime import datetime +from django.shortcuts import render +from events.models import Event + + +def events(request): + events = Event.objects.filter(date__gte=datetime.now()) + events = events.filter(**{"published_%s" % request.LANGUAGE_CODE: True}) + return render(request, 'events/event_list.html', { + 'object_list': events, + }) + + +def events_past(request): + events = Event.objects.filter(date__lte=datetime.now()).order_by('-date') + events = events.filter(**{"published_%s" % request.LANGUAGE_CODE: True}) + return render(request, 'events/event_list.html', { + 'object_list': events, + 'past': True, + })