From 27ede573ea18f7293f28608aedc7ed2a57d849e0 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 11 Oct 2023 19:11:33 +0300 Subject: [PATCH] improve ginger and pumpking award code --- files/classes/post.py | 11 ++++++++--- files/templates/events/fistmas/awards.html | 3 +-- files/templates/events/homoween/awards.html | 9 ++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/files/classes/post.py b/files/classes/post.py index 53e40dced..66b642c96 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -258,9 +258,14 @@ class Post(Base): return 0 num = len([x for x in self.awards if x.kind == kind]) - if num > 4 and kind not in {"shit", "fireflies", "gingerbread", "pumpkin", "stalker"}: - return 4 - return num + + if kind in {"shit", "fireflies", "stalker"}: + return num + + if kind in {"gingerbread", "pumpkin"}: + return min(num, 10) + + return min(num, 4) @lazy def realurl(self, v): diff --git a/files/templates/events/fistmas/awards.html b/files/templates/events/fistmas/awards.html index 8b2e2552d..4964c2f17 100644 --- a/files/templates/events/fistmas/awards.html +++ b/files/templates/events/fistmas/awards.html @@ -1,6 +1,5 @@
- {% set gingerbread_count = p.award_count("gingerbread", v) * 2 if p.award_count("gingerbread", v) <= 10 else 20 %} - {% for i in range(gingerbread_count) %} + {% for i in range(p.award_count("gingerbread", v)) %}
animate marsey gingerbread icon
diff --git a/files/templates/events/homoween/awards.html b/files/templates/events/homoween/awards.html index 3758600a7..df7cab016 100644 --- a/files/templates/events/homoween/awards.html +++ b/files/templates/events/homoween/awards.html @@ -41,12 +41,11 @@ {% endif %} {% if p.award_count("pumpkin", v) %} - {% set count = p.award_count("pumpkin", v) * 2 if p.award_count("pumpkin", v) <= 10 else 20 %}
- {% for i in range(count) %} -
- animate marsey pumpkin icon -
+ {% for i in range(p.award_count("pumpkin", v)) %} +
+ animate marsey pumpkin icon +
{% endfor %}
{% endif %}