1 # -*- coding: utf-8 -*-
2 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django import template
6 from events import app_settings
7 from events.models import Event
9 register = template.Library()
10 from datetime import datetime
13 @register.inclusion_tag('events/snippets/events_box.html', takes_context=True)
14 def events_box(context, limit=app_settings.BOX_LENGTH):
15 lang = context['request'].LANGUAGE_CODE
16 objects = Event.objects.filter(**{"published_%s" % lang: True})
17 objects = objects.filter(date_end__gte=datetime.now())[:limit]
18 return {'objects': objects}
21 @register.inclusion_tag('events/snippets/event_short.html')
22 def event_short(event):
23 return {'event': event}