1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django import template
5 from django.template.loader import render_to_string
6 from django.core.paginator import Paginator, InvalidPage
8 from ..models import Offer
9 from ..utils import sanitize_payment_title
12 register = template.Library()
16 def funding_top_bar():
17 offer = Offer.current()
18 return offer.top_bar() if offer is not None else ''
21 register.filter(sanitize_payment_title)
24 @register.simple_tag(takes_context=True)
25 def fundings(context, offer):
26 fundings = offer.funding_payed()
27 page = context['request'].GET.get('page', 1)
28 paginator = Paginator(fundings, 10, 2)
30 page_obj = paginator.page(int(page))
34 return render_to_string("funding/includes/fundings.html", {
35 "paginator": paginator,
37 "fundings": page_obj.object_list,