Cleanup
[wolnelektury.git] / src / funding / models.py
index 838d2ab..3280d64 100644 (file)
@@ -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.
 #
@@ -69,7 +70,6 @@ class Offer(models.Model):
 
     def clear_cache(self):
         clear_cached_renders(self.top_bar)
-        clear_cached_renders(self.list_bar)
         clear_cached_renders(self.detail_bar)
         clear_cached_renders(self.status)
         clear_cached_renders(self.status_more)
@@ -202,12 +202,20 @@ 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,
         }
 
+    @cached_render('funding/includes/offer_status.html')
+    def status(self):
+        return {'offer': self}
+
+    @cached_render('funding/includes/offer_status_more.html')
+    def status_more(self):
+        return {'offer': self}
+
     @cached_render('funding/includes/funding.html')
     def top_bar(self):
         ctx = self.basic_info()
@@ -218,15 +226,6 @@ class Offer(models.Model):
         })
         return ctx
 
-    @cached_render('funding/includes/funding.html')
-    def list_bar(self):
-        ctx = self.basic_info()
-        ctx.update({
-            'link': True,
-            'show_title_calling': False,
-        })
-        return ctx
-
     @cached_render('funding/includes/funding.html')
     def detail_bar(self):
         ctx = self.basic_info()
@@ -235,14 +234,6 @@ class Offer(models.Model):
         })
         return ctx
 
-    @cached_render('funding/includes/offer_status.html')
-    def status(self):
-        return {'offer': self}
-
-    @cached_render('funding/includes/offer_status_more.html')
-    def status_more(self):
-        return {'offer': self}
-
 
 class Perk(models.Model):
     """ A perk offer.