From c061936b53e3457165b0eec67cbad2680e070752 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 2 Oct 2023 17:24:09 +0300 Subject: [PATCH] make award immunity only apply to negative awards --- files/assets/js/bottom.js | 13 +++++ files/classes/user.py | 8 +-- files/helpers/config/awards.py | 70 ++++++++++++++++++++++++ files/helpers/config/const.py | 4 +- files/routes/awards.py | 4 +- files/routes/jinja2.py | 2 +- files/templates/comments.html | 4 +- files/templates/modals/award.html | 2 +- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- 10 files changed, 96 insertions(+), 15 deletions(-) diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index 2647f0671..b6f0d0bdf 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -163,6 +163,8 @@ register_new_elements(document); bs_trigger(document); +const negative_awards = document.querySelectorAll("[data-positive=False]") + document.addEventListener("click", function (e) { let element = e.target if (element.tagName == "I") @@ -197,6 +199,17 @@ document.addEventListener("click", function (e) { else { effect_author_tab.classList.remove('disabled') } + + if (element.dataset.immune == 'True') { + for (const award of negative_awards) { + award.classList.add('disabled') + } + } + else { + for (const award of negative_awards) { + award.classList.remove('disabled') + } + } } diff --git a/files/classes/user.py b/files/classes/user.py index 026579af0..cd72a426c 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -381,20 +381,18 @@ class User(Base): @lazy - def immune_to_awards(self, v): + def immune_to_negative_awards(self, v): if SITE_NAME != 'rDrama': return False - if IS_EVENT(): - return False if v.id == self.id: return False - if v.id in IMMUNE_TO_AWARDS: + if v.id in IMMUNE_TO_NEGATIVE_AWARDS: return False if v.admin_level >= PERMS['IGNORE_AWARD_IMMUNITY']: return False if self.alts: return False - if self.id in IMMUNE_TO_AWARDS: + if self.id in IMMUNE_TO_NEGATIVE_AWARDS: return True if self.new_user and not self.alts: return True diff --git a/files/helpers/config/awards.py b/files/helpers/config/awards.py index 8341f1e20..3d32a12f2 100644 --- a/files/helpers/config/awards.py +++ b/files/helpers/config/awards.py @@ -18,6 +18,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": False, + "positive": True, }, ### Deprecated @@ -32,6 +33,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": False, + "positive": True, }, "nword": { "kind": "nword", @@ -44,6 +46,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": False, + "positive": True, }, "fish": { "kind": "fish", @@ -56,6 +59,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": False, + "positive": True, }, @@ -71,6 +75,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": IS_FISTMAS() or IS_HOMOWEEN(), + "positive": True, }, ### Fistmas @@ -85,6 +90,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_FISTMAS(), + "positive": True, }, "snow": { "kind": "snow", @@ -97,6 +103,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_FISTMAS(), + "positive": True, }, "gingerbread": { "kind": "gingerbread", @@ -109,6 +116,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_FISTMAS(), + "positive": True, }, "lights": { "kind": "lights", @@ -121,6 +129,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_FISTMAS(), + "positive": True, }, "frostbite": { "kind": "frostbite", @@ -133,6 +142,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_FISTMAS(), + "positive": True, }, "candycane": { "kind": "candycane", @@ -145,6 +155,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_FISTMAS(), + "positive": True, }, "grinch": { "kind": "grinch", @@ -157,6 +168,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": IS_FISTMAS(), + "positive": True, }, ### Homoween @@ -171,6 +183,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "fog": { "kind": "fog", @@ -183,6 +196,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "bones": { "kind": "bones", @@ -195,6 +209,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "pumpkin": { "kind": "pumpkin", @@ -207,6 +222,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "candy-corn": { "kind": "candy-corn", @@ -219,6 +235,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "ectoplasm": { "kind": "ectoplasm", @@ -231,6 +248,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "stab": { "kind": "stab", @@ -243,6 +261,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "upsidedown": { "kind": "upsidedown", @@ -255,6 +274,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "flashlight": { "kind": "flashlight", @@ -267,6 +287,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "haunt": { "kind": "haunt", @@ -279,6 +300,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_HOMOWEEN(), + "positive": True, }, "jumpscare": { @@ -292,6 +314,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": IS_HOMOWEEN(), + "positive": True, }, "bite": { "kind": "bite", @@ -304,6 +327,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": IS_HOMOWEEN(), + "positive": True, }, "vax": { "kind": "vax", @@ -316,6 +340,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": IS_HOMOWEEN(), + "positive": True, }, "hw-grinch": { "kind": "hw-grinch", @@ -328,6 +353,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": IS_HOMOWEEN(), + "positive": True, }, ### Birthgay/Birthdead @@ -342,6 +368,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": IS_BIRTHGAY() or IS_BIRTHDEAD(), + "positive": True, }, ### Standard @@ -356,6 +383,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "marsify": { "kind": "marsify", @@ -368,6 +396,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "rainbow": { "kind": "rainbow", @@ -380,6 +409,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": not FEATURES['HOUSES'], + "positive": False, }, "sharpen": { "kind": "sharpen", @@ -392,6 +422,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": not FEATURES['HOUSES'], + "positive": False, }, "shit": { "kind": "shit", @@ -404,6 +435,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "fireflies": { "kind": "fireflies", @@ -416,6 +448,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "train": { "kind": "train", @@ -428,6 +461,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "scooter": { "kind": "scooter", @@ -440,6 +474,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "wholesome": { "kind": "wholesome", @@ -452,6 +487,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "firework": { "kind": "firework", @@ -464,6 +500,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "ricardo": { "kind": "ricardo", @@ -476,6 +513,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": True, }, "tilt": { "kind": "tilt", @@ -488,6 +526,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": False, }, "glowie": { "kind": "glowie", @@ -500,6 +539,7 @@ AWARDS = { "cosmetic": True, "ghost": True, "enabled": True, + "positive": False, }, "spider": { "kind": "spider", @@ -512,6 +552,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "owoify": { "kind": "owoify", @@ -524,6 +565,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": not FEATURES['HOUSES'], + "positive": False, }, "flairlock": { "kind": "flairlock", @@ -536,6 +578,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "rehab": { "kind": "rehab", @@ -548,6 +591,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "namelock": { "kind": "namelock", @@ -560,6 +604,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "queen": { "kind": "queen", @@ -572,6 +617,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "offsitementions": { "kind": "offsitementions", @@ -584,6 +630,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "unpin": { "kind": "unpin", @@ -596,6 +643,7 @@ AWARDS = { "cosmetic": False, "ghost": True, "enabled": True, + "positive": False, }, "chud": { "kind": "chud", @@ -608,6 +656,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "pin": { "kind": "pin", @@ -620,6 +669,7 @@ AWARDS = { "cosmetic": False, "ghost": True, "enabled": True, + "positive": True, }, "progressivestack": { "kind": "progressivestack", @@ -632,6 +682,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "pizzashill": { "kind": "pizzashill", @@ -644,6 +695,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "bird": { "kind": "bird", @@ -656,6 +708,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "marsey": { "kind": "marsey", @@ -668,6 +721,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "ban": { "kind": "ban", @@ -680,6 +734,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "unban": { "kind": "unban", @@ -692,6 +747,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "deflector": { "kind": "deflector", @@ -704,6 +760,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "benefactor": { "kind": "benefactor", @@ -716,6 +773,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": FEATURES['MARSEYBUX'], + "positive": True, }, "eye": { "kind": "eye", @@ -728,6 +786,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "grass": { "kind": "grass", @@ -740,6 +799,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": False, }, "unblockable": { "kind": "unblockable", @@ -752,6 +812,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "pause": { "kind": "pause", @@ -764,6 +825,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "unpausable": { "kind": "unpausable", @@ -776,6 +838,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "alt": { "kind": "alt", @@ -788,6 +851,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, "checkmark": { "kind": "checkmark", @@ -800,6 +864,7 @@ AWARDS = { "cosmetic": False, "ghost": False, "enabled": True, + "positive": True, }, } @@ -821,6 +886,7 @@ HOUSE_AWARDS = { "deflectable": True, "cosmetic": False, "ghost": False, + "positive": False, }, "Femboy": { "kind": "Femboy", @@ -832,6 +898,7 @@ HOUSE_AWARDS = { "deflectable": True, "cosmetic": False, "ghost": False, + "positive": False, }, "Vampire": { "kind": "Vampire", @@ -843,6 +910,7 @@ HOUSE_AWARDS = { "deflectable": True, "cosmetic": False, "ghost": False, + "positive": False, }, "Racist": { "kind": "Racist", @@ -854,6 +922,7 @@ HOUSE_AWARDS = { "deflectable": True, "cosmetic": False, "ghost": False, + "positive": False, }, "Edgy": { "kind": "Edgy", @@ -865,6 +934,7 @@ HOUSE_AWARDS = { "deflectable": True, "cosmetic": False, "ghost": False, + "positive": False, }, } diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 377231a81..f42038e69 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -528,7 +528,7 @@ AEVANN_ID = 0 GTIX_ID = 0 LAWLZ_ID = 0 -IMMUNE_TO_AWARDS = {} +IMMUNE_TO_NEGATIVE_AWARDS = {} EXEMPT_FROM_1WEEK_EDITING_LIMIT = {} MODMAIL_ID = 2 @@ -647,7 +647,7 @@ if SITE in {'rdrama.net', 'staging.rdrama.net'}: AEVANN_ID = 1 LAWLZ_ID = 3833 - IMMUNE_TO_AWARDS = {PIZZASHILL_ID, CARP_ID} + IMMUNE_TO_NEGATIVE_AWARDS = {PIZZASHILL_ID, CARP_ID} NOTIFIED_USERS = { 'aevan': AEVANN_ID, diff --git a/files/routes/awards.py b/files/routes/awards.py index 0b382ef9e..efd83fc40 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -181,8 +181,8 @@ def award_thing(v, thing_type, id): safe_username = f"@{thing.author_name} is" - if author.immune_to_awards(v): - abort(403, f"{safe_username} immune to awards!") + if author.immune_to_negative_awards(v): + abort(403, f"{safe_username} immune to negative awards!") if kind == "benefactor" and author.id == v.id: abort(403, "You can't use this award on yourself!") diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index ba0d1be3b..16760c4da 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -140,7 +140,7 @@ def inject_constants(): "DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, "git_head":git_head, "max_days":max_days, "EMOJI_KINDS":EMOJI_KINDS, "BIO_FRIENDS_ENEMIES_LENGTH_LIMIT":BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, - "IMMUNE_TO_AWARDS": IMMUNE_TO_AWARDS, "SITE_FULL_IMAGES": SITE_FULL_IMAGES, + "SITE_FULL_IMAGES": SITE_FULL_IMAGES, "IS_EVENT":IS_EVENT, "IS_FISTMAS":IS_FISTMAS, "IS_HOMOWEEN":IS_HOMOWEEN, "IS_DKD":IS_DKD, "IS_BIRTHGAY":IS_BIRTHGAY, "IS_BIRTHDEAD":IS_BIRTHDEAD, "CHUD_PHRASES":CHUD_PHRASES, "hasattr":hasattr, "calc_users":calc_users, "HOLE_INACTIVITY_DELETION":HOLE_INACTIVITY_DELETION, "LIGHT_THEMES":LIGHT_THEMES, diff --git a/files/templates/comments.html b/files/templates/comments.html index 3863c1212..9629dba34 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -386,7 +386,7 @@ {% if FEATURES['AWARDS'] -%} - + {%- endif %} @@ -595,7 +595,7 @@ {% if FEATURES['AWARDS'] -%} - + {%- endif %} diff --git a/files/templates/modals/award.html b/files/templates/modals/award.html index a5662470c..01afa82ef 100644 --- a/files/templates/modals/award.html +++ b/files/templates/modals/award.html @@ -22,7 +22,7 @@ {% macro iterate_awards(awards) %} {% for award in awards %} {% set price = (award.price*v.award_discount)|int %} -
+
{{award.title}}
{{award.owned}} owned
diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index 54e4a0369..dde14e0bb 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -8,7 +8,7 @@ {% endif %} {% if v and FEATURES['AWARDS'] %} - + {% endif %} diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index 14533af01..304a11a67 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -16,7 +16,7 @@ {% if FEATURES['AWARDS'] -%} - + {%- endif %}