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 def funding_top_bar_2022():
21 offer = Offer.current()
22 return offer.top_bar_2022() if offer is not None else ''
25 @register.simple_tag(takes_context=True)
26 def fundings(context, offer):
27 fundings = offer.funding_payed()
28 page = context['request'].GET.get('page', 1)
29 paginator = Paginator(fundings, 10, 2)
31 page_obj = paginator.page(int(page))
35 return render_to_string("funding/includes/fundings.html", {
36 "paginator": paginator,
38 "fundings": page_obj.object_list,