apply slur filter to hat descriptions

master
Aevann1 2022-09-03 20:55:03 +02:00
parent 256b384e69
commit 5feb479cd2
8 changed files with 15 additions and 11 deletions

View File

@ -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"

View File

@ -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 ''

View File

@ -212,7 +212,7 @@
<div class="profile-pic-30-wrapper">
<img loading="lazy" src="{{c.author.profile_url}}" class="profile-pic-30 mr-2">
{% if c.author.hat_active -%}
<img class="profile-pic-30-hat hat" loading="lazy" src="/i/hats/{{c.author.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{c.author.hat_tooltip}}">
<img class="profile-pic-30-hat hat" loading="lazy" src="/i/hats/{{c.author.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{c.author.hat_tooltip(v)}}">
{%- endif %}
</div>
<span {% if c.author.patron and not c.distinguish_level %}class="patron" style="background-color:#{{c.author.name_color}};"{% elif c.distinguish_level %}class="mod"{% endif %}>{{c.author_name}}</span>

View File

@ -42,7 +42,7 @@
<tr>
<td><img loading="lazy" alt="{{hat.name}}" src="/i/hats/{{hat.name}}.webp?v=1"></td>
<td>{{hat.name}}</td>
<td>{{hat.description}}</td>
<td>{{hat.censored_description(v)}}</td>
{% if SITE == 'rdrama.net' %}
<td><a style="color:#{{user.name_color}}" href="/@{{user.username}}"><img loading="lazy" src="{{user.profile_url}}" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.name_color}}"{% endif %}>{{user.username}}</span></a></td>
{% endif %}
@ -62,7 +62,7 @@
<tr>
<td><img loading="lazy" alt="{{hat.name}}" src="/i/hats/{{hat.name}}.webp?v=1"></td>
<td>{{hat.name}}</td>
<td>{{hat.description}}</td>
<td>{{hat.censored_description(v)}}</td>
{% if SITE == 'rdrama.net' %}
<td><a style="color:#{{user.name_color}}" href="/@{{user.username}}"><img loading="lazy" src="{{user.profile_url}}" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.name_color}}"{% endif %}>{{user.username}}</span></a></td>
{% endif %}

View File

@ -207,7 +207,7 @@
<div class="profile-pic-35-wrapper">
<img loading="lazy" src="{{v.profile_url}}" class="profile-pic-35">
{% if v.hat_active -%}
<img class="profile-pic-35-hat hat" loading="lazy" src="/i/hats/{{v.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{v.hat_tooltip}}">
<img class="profile-pic-35-hat hat" loading="lazy" src="/i/hats/{{v.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{v.hat_tooltip(v)}}">
{%- endif %}
</div>
<div class="text-left pl-2">

View File

@ -677,7 +677,7 @@
<div class="profile-pic-30-wrapper">
<img loading="lazy" src="{{p.author.profile_url}}" class="profile-pic-30 mr-2">
{% if p.author.hat_active -%}
<img class="profile-pic-30-hat hat" loading="lazy" src="/i/hats/{{p.author.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{p.author.hat_tooltip}}">
<img class="profile-pic-30-hat hat" loading="lazy" src="/i/hats/{{p.author.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{p.author.hat_tooltip(v)}}">
{%- endif %}
</div>
<span {% if p.author.patron and not p.distinguish_level %}class="patron" style="background-color:#{{p.author.name_color}};"{% elif p.distinguish_level %}class="mod"{% endif %}>{{p.author_name}}</span>

View File

@ -213,7 +213,7 @@
<div class="profile-pic-30-wrapper">
<img loading="lazy" src="{{p.author.profile_url}}" class="profile-pic-30 mr-2">
{% if p.author.hat_active -%}
<img class="profile-pic-30-hat hat" loading="lazy" src="/i/hats/{{p.author.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{p.author.hat_tooltip}}">
<img class="profile-pic-30-hat hat" loading="lazy" src="/i/hats/{{p.author.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{p.author.hat_tooltip(v)}}">
{%- endif %}
</div>
<span {% if p.author.patron and not p.distinguish_level %}class="patron" style="background-color:#{{p.author.name_color}};"{% elif p.distinguish_level %}class="mod"{% endif %}>{{p.author_name}}</span>

View File

@ -42,7 +42,7 @@
<a rel="nofollow noopener noreferrer" href="{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}" class="profile-pic-100-wrapper">
<img onclick="expandDesktopImage('{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}')" loading="lazy" src="{{u.profile_url}}" class="profile-pic profile-pic-100 mb-5">
{% if u.hat_active -%}
<img onclick="expandDesktopImage('{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}')" class="profile-pic-100-hat hat" loading="lazy" src="/i/hats/{{u.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{u.hat_tooltip}}">
<img onclick="expandDesktopImage('{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}')" class="profile-pic-100-hat hat" loading="lazy" src="/i/hats/{{u.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{u.hat_tooltip(v)}}">
{%- endif %}
</a>
</div>
@ -407,7 +407,7 @@
<a rel="nofollow noopener noreferrer" href="{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}" class="profile-pic-65-wrapper">
<img onclick="expandDesktopImage('{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}')" loading="lazy" src="{{u.profile_url}}" class="profile-pic-65 bg-white border-2 border-white mb-2">
{% if u.hat_active -%}
<img onclick="expandDesktopImage('{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}')" class="profile-pic-65-hat hat" loading="lazy" src="/i/hats/{{u.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{u.hat_tooltip}}">
<img onclick="expandDesktopImage('{% if u.highres %}{{u.highres}}{% else %}{{u.profile_url}}{% endif %}')" class="profile-pic-65-hat hat" loading="lazy" src="/i/hats/{{u.hat_active}}?v=1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{u.hat_tooltip(v)}}">
{%- endif %}
</a>
</div>