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
11 register = template.Library()
15 def funding_top_bar():
16 offer = Offer.current()
17 return offer.top_bar() if offer is not None else ''
20 @register.simple_tag(takes_context=True)
21 def fundings(context, offer):
22 fundings = offer.funding_payed()
23 page = context['request'].GET.get('page', 1)
24 paginator = Paginator(fundings, 10, 2)
26 page_obj = paginator.page(int(page))
30 return render_to_string("funding/includes/fundings.html", {
31 "paginator": paginator,
33 "fundings": page_obj.object_list,