From 6c403fcb18d1910844c3d879fe774f0586c53c3b Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 6 Oct 2023 20:39:27 +0300 Subject: [PATCH] change "king" award to "gold" award --- files/classes/badges.py | 1 - files/classes/comment.py | 5 ++-- files/classes/post.py | 1 - files/classes/user.py | 1 - files/helpers/config/awards.py | 26 +++++++++---------- files/helpers/cron.py | 2 -- files/routes/awards.py | 7 ----- files/routes/comments.py | 1 - files/routes/posts.py | 1 - ...231006-change-king-award-to-gold-award.sql | 6 +++++ 10 files changed, 21 insertions(+), 30 deletions(-) create mode 100644 migrations/20231006-change-king-award-to-gold-award.sql diff --git a/files/classes/badges.py b/files/classes/badges.py index cb441a428..aafe0a1c0 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -69,7 +69,6 @@ class Badge(Base): if self.badge_id == 281: return self.user.namechanged if self.badge_id == 285: return self.user.queen if self.badge_id == 289: return self.user.sharpen - if self.badge_id == 302: return self.user.king return None diff --git a/files/classes/comment.py b/files/classes/comment.py index 547410aad..38453a9b4 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -26,10 +26,10 @@ def get_award_classes(obj, v, title=False): if not (v and v.poor): if obj.award_count('glowie', v): classes.append("glow") + if obj.award_count('gold', v): + classes.append("gold-text") if obj.rainbowed: classes.append("rainbow-text") - # if obj.golden: - # classes.append("gold-text") if obj.queened: classes.append("queen") if obj.sharpened: @@ -197,7 +197,6 @@ class Comment(Base): casino_game_id = Column(Integer, ForeignKey("casino_games.id")) chudded = Column(Boolean, default=False) rainbowed = Column(Boolean, default=False) - golden = Column(Boolean, default=False) queened = Column(Boolean, default=False) sharpened = Column(Boolean, default=False) diff --git a/files/classes/post.py b/files/classes/post.py index f793a828e..ac5614a18 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -63,7 +63,6 @@ class Post(Base): notify = Column(Boolean) chudded = Column(Boolean, default=False) rainbowed = Column(Boolean, default=False) - golden = Column(Boolean, default=False) queened = Column(Boolean, default=False) sharpened = Column(Boolean, default=False) ping_cost = Column(Integer, default=0) diff --git a/files/classes/user.py b/files/classes/user.py index 49de68a4b..87fc6b33c 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -90,7 +90,6 @@ class User(Base): lootboxes_bought = Column(Integer, default=0) chud = Column(Integer, default=0) queen = Column(Integer, default=0) - king = Column(Integer, default=0) chud_phrase = Column(String) email_verified = Column(Boolean, default=False) shadowbanned = Column(Integer, ForeignKey("users.id")) diff --git a/files/helpers/config/awards.py b/files/helpers/config/awards.py index 079434cb5..003cd8905 100644 --- a/files/helpers/config/awards.py +++ b/files/helpers/config/awards.py @@ -541,6 +541,19 @@ AWARDS = { "enabled": True, "positive": False, }, + "gold": { + "kind": "gold", + "title": "Gold", + "description": "Gold is a virtual good you can use on Reddit to reward, recognize, and celebrate content from redditors you love. If you like a post or comment and want to show your appreciation for it, you can give it gold. This will help the post or comment stand out on Reddit.", + "icon": "fas fa-coin", + "color": "text-gold", + "price": 500, + "deflectable": False, + "cosmetic": True, + "ghost": True, + "enabled": True, + "positive": True, + }, "spider": { "kind": "spider", "title": "Spider!", @@ -606,19 +619,6 @@ AWARDS = { "enabled": True, "positive": False, }, - "king": { - "kind": "king", - "title": "King", - "description": "Gives the recipient golden text for 24 hours.", - "icon": "fas fa-crown", - "color": "text-gold", - "price": 1000, - "deflectable": True, - "cosmetic": False, - "ghost": False, - "enabled": True, - "positive": True, - }, "queen": { "kind": "queen", "title": "Queen", diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 64f73e710..82a69a28d 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -174,7 +174,6 @@ def _create_post(title, body, pin_hours): ghost=False, chudded=False, rainbowed=False, - golden=False, queened=False, sharpened=False, stickied_utc=stickied_utc, @@ -405,7 +404,6 @@ def _award_timers_task(): _process_timer(User.marsify, [170], "The marsify award you received has expired!") _process_timer(User.rainbow, [171], "The rainbow award you received has expired!") _process_timer(User.queen, [285], "The queen award you received has expired!") - _process_timer(User.king, [302], "The king award you received has expired!") _process_timer(User.spider, [179], "The spider award you received has expired!") _process_timer(User.namechanged, [281], "The namelock award you received has expired. You're now back to your old username!", { User.username: User.prelock_username, diff --git a/files/routes/awards.py b/files/routes/awards.py index 278973776..acfbb4f44 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -540,13 +540,6 @@ def award_thing(v, thing_type, id): if thing_type == 'comment' and (not thing.author.deflector or v == thing.author): thing.rainbowed = True g.db.add(thing) - elif kind == 'king': - if author.king: author.king += 86400 - else: author.king = int(time.time()) + 86400 - badge_grant(user=author, badge_id=302) - if thing_type == 'comment' and (not thing.author.deflector or v == thing.author): - thing.golden = True - g.db.add(thing) elif kind == "emoji": award.note = award.note.strip(":").lower() emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none() diff --git a/files/routes/comments.py b/files/routes/comments.py index bfe7c3270..1257c2062 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -277,7 +277,6 @@ def comment(v): ghost=ghost, chudded=chudded, rainbowed=bool(v.rainbow), - golden=bool(v.king), queened=bool(v.queen), sharpened=bool(v.sharpen), ) diff --git a/files/routes/posts.py b/files/routes/posts.py index 4bd223791..867e03b95 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -571,7 +571,6 @@ def submit_post(v, sub=None): ghost=flag_ghost, chudded=flag_chudded, rainbowed=bool(v.rainbow), - golden=bool(v.king), queened=bool(v.queen), sharpened=bool(v.sharpen), ) diff --git a/migrations/20231006-change-king-award-to-gold-award.sql b/migrations/20231006-change-king-award-to-gold-award.sql new file mode 100644 index 000000000..44116b94d --- /dev/null +++ b/migrations/20231006-change-king-award-to-gold-award.sql @@ -0,0 +1,6 @@ +delete from badges where badge_id=302; +delete from badge_defs where id=302; + +alter table users drop column king; +alter table posts drop column golden; +alter table comments drop column golden;