From 0e4677d342ed9e50cf284515405d61b3270a86b1 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 10 Aug 2023 00:38:35 +0300 Subject: [PATCH] centeralize award limit of 4 --- files/classes/comment.py | 3 ++- files/classes/post.py | 3 ++- files/templates/awards.html | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 39af182c82..2151867618 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -262,7 +262,8 @@ class Comment(Base): def award_count(self, kind, v): if v and v.poor and kind.islower(): return 0 num = len([x for x in self.awards if x.kind == kind]) - if kind == 'tilt' and num > 4: return 4 + if num > 4 and kind not in {"shit", "fireflies", "gingerbread"}: + return 4 return num @property diff --git a/files/classes/post.py b/files/classes/post.py index 6929962ef5..ab5ede6122 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -255,7 +255,8 @@ class Post(Base): return 0 num = len([x for x in self.awards if x.kind == kind]) - if kind == 'tilt' and num > 4: return 4 + if num > 4 and kind not in {"shit", "fireflies", "gingerbread"}: + return 4 return num @lazy diff --git a/files/templates/awards.html b/files/templates/awards.html index e49997bbd5..cbe1032995 100644 --- a/files/templates/awards.html +++ b/files/templates/awards.html @@ -1,7 +1,7 @@
{% macro stackable_award(award, src, alt) %}
- {% for i in range(min(p.award_count(award, v), 4)) %} + {% for i in range(p.award_count(award, v)) %}
{{alt}}