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_comments_xtd.models import XtdComment
6 from django import template
7 from migdal.models import Category
9 register = template.Library()
13 def entry_begin(entry):
14 t = template.loader.select_template((
15 'migdal/entry/%s/entry_begin.html' % entry.type,
16 'migdal/entry/entry_begin.html',
18 context = {'object': entry}
19 return t.render(template.Context(context))
23 def entry_short(entry):
24 t = template.loader.select_template((
25 'migdal/entry/%s/entry_short.html' % entry.type,
26 'migdal/entry/entry_short.html',
28 context = {'object': entry}
29 return t.render(template.Context(context))
32 @register.inclusion_tag('migdal/categories.html', takes_context=True)
33 def categories(context):
34 context.update({'object_list': Category.objects.all()})
38 @register.inclusion_tag('migdal/last_comments.html')
39 def last_comments(limit=10):
40 return {'object_list':
41 XtdComment.objects.filter(is_public=True, is_removed=False).order_by('-submit_date')[:limit]}