diff --git a/files/classes/hats.py b/files/classes/hats.py index 25fcbb45c..a90f72136 100644 --- a/files/classes/hats.py +++ b/files/classes/hats.py @@ -2,6 +2,7 @@ from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base from files.helpers.lazy import lazy +from files.helpers.regex import censor_slurs from flask import g class HatDef(Base): @@ -20,6 +21,10 @@ class HatDef(Base): def number_sold(self): return g.db.query(Hat).filter_by(hat_id=self.id).count() + @lazy + def censored_description(self, v): + return censor_slurs(self.description, v) + class Hat(Base): __tablename__ = "hats" diff --git a/files/classes/user.py b/files/classes/user.py index b738d2db1..db1502ad8 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -665,9 +665,8 @@ class User(Base): return '' - @property @lazy - def hat_tooltip(self): + def hat_tooltip(v, self): if not FEATURES['HATS']: return '' @@ -675,7 +674,7 @@ class User(Base): return "I've spent another year rotting my brain with dramaposting, please ridicule me 🤓" if self.equipped_hat_id: - return self.equipped_hat.description + return self.equipped_hat.censored_description(v) return '' diff --git a/files/templates/comments.html b/files/templates/comments.html index 0d47e1cb7..8f9b630fd 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -212,7 +212,7 @@
{% if c.author.hat_active -%} - + {%- endif %}
{{c.author_name}} diff --git a/files/templates/hats.html b/files/templates/hats.html index ec8ef238c..c63e17125 100644 --- a/files/templates/hats.html +++ b/files/templates/hats.html @@ -42,7 +42,7 @@ {{hat.name}} {{hat.name}} - {{hat.description}} + {{hat.censored_description(v)}} {% if SITE == 'rdrama.net' %} {{user.username}} {% endif %} @@ -62,7 +62,7 @@ {{hat.name}} {{hat.name}} - {{hat.description}} + {{hat.censored_description(v)}} {% if SITE == 'rdrama.net' %} {{user.username}} {% endif %} diff --git a/files/templates/header.html b/files/templates/header.html index 4ae237a95..33147c60c 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -207,7 +207,7 @@
{% if v.hat_active -%} - + {%- endif %}
diff --git a/files/templates/submission.html b/files/templates/submission.html index 22f2c243c..33cd48d6c 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -677,7 +677,7 @@
{% if p.author.hat_active -%} - + {%- endif %}
{{p.author_name}} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 98cda8df8..55018e92f 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -213,7 +213,7 @@
{% if p.author.hat_active -%} - + {%- endif %}
{{p.author_name}} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index bffed2dcb..ad13e50c6 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -42,7 +42,7 @@ {% if u.hat_active -%} - + {%- endif %}
@@ -407,7 +407,7 @@ {% if u.hat_active -%} - + {%- endif %}