X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/2f331ef41f1d5db23305ec79a02dfbff342ce893..bde2a16ae2669bea94ec0f23c60213a26d4881f4:/src/funding/models.py diff --git a/src/funding/models.py b/src/funding/models.py index 8dbc7111a..089b875b1 100644 --- a/src/funding/models.py +++ b/src/funding/models.py @@ -1,3 +1,4 @@ + # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -12,7 +13,7 @@ from django.template.loader import render_to_string from django.urls import reverse from django.utils.html import mark_safe from django.utils.timezone import utc -from django.utils.translation import ugettext_lazy as _, override +from django.utils.translation import gettext_lazy as _, override from catalogue.models import Book from catalogue.utils import get_random_hash from polls.models import Poll @@ -69,8 +70,10 @@ class Offer(models.Model): def clear_cache(self): clear_cached_renders(self.top_bar) + clear_cached_renders(self.top_bar_2022) clear_cached_renders(self.list_bar) clear_cached_renders(self.detail_bar) + clear_cached_renders(self.detail_bar_2022) clear_cached_renders(self.status) clear_cached_renders(self.status_more) @@ -202,7 +205,7 @@ class Offer(models.Model): 'is_current': self.is_current(), 'is_win': offer_sum >= self.target, 'missing': self.target - offer_sum, - 'percentage': 100 * offer_sum / self.target, + 'percentage': min(100, 100 * offer_sum / self.target), 'show_title': True, 'show_title_calling': True, @@ -243,6 +246,24 @@ class Offer(models.Model): def status_more(self): return {'offer': self} + @cached_render('funding/2022/includes/funding.html') + def top_bar_2022(self): + ctx = self.basic_info() + ctx.update({ + 'link': True, + 'closeable': True, + 'add_class': 'funding-top-header', + }) + return ctx + + @cached_render('funding/2022/includes/funding.html') + def detail_bar_2022(self): + ctx = self.basic_info() + ctx.update({ + 'show_title': False, + }) + return ctx + class Perk(models.Model): """ A perk offer.