forked from rDrama/rDrama
add pronouns
parent
c504b76329
commit
6428dd08c5
|
@ -129,6 +129,7 @@ class User(Base):
|
|||
total_held_lottery_tickets = Column(Integer, default=0)
|
||||
total_lottery_winnings = Column(Integer, default=0)
|
||||
last_viewed_post_notifs = Column(Integer, default=0)
|
||||
pronouns = Column(String, default='they/them')
|
||||
|
||||
badges = relationship("Badge", order_by="Badge.created_utc", back_populates="user")
|
||||
subscriptions = relationship("Subscription", back_populates="user")
|
||||
|
|
|
@ -101,6 +101,8 @@ search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A)
|
|||
|
||||
git_regex = re.compile("ref: (refs/.+)", flags=re.A)
|
||||
|
||||
pronouns_regex = re.compile("[a-z]{1-5}\/[a-z]{1-5}", flags=re.A)
|
||||
|
||||
def sub_matcher(match, upper=False):
|
||||
if match.group(0).startswith('<'):
|
||||
return match.group(0)
|
||||
|
|
|
@ -880,6 +880,26 @@ def settings_title_change(v):
|
|||
return redirect("/settings/profile")
|
||||
|
||||
|
||||
@app.post("/settings/pronouns_change")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')
|
||||
@auth_required
|
||||
def settings_pronouns_change(v):
|
||||
|
||||
pronouns = request.values.get("pronouns").replace("𒐪","").lower().strip()
|
||||
|
||||
if pronouns == v.pronouns:
|
||||
return render_template("settings_profile.html", v=v, error="You didn't change anything")
|
||||
|
||||
if not pronouns_regex.fullmatch(pronouns):
|
||||
return render_template("settings_profile.html", v=v, error="The pronouns you entered don't match the required format {1-5 characters}/{1-5 characters}")
|
||||
|
||||
v.pronouns = pronouns
|
||||
g.db.add(v)
|
||||
|
||||
return redirect("/settings/profile")
|
||||
|
||||
|
||||
@app.post("/settings/checkmark_text")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')
|
||||
|
|
|
@ -206,6 +206,9 @@
|
|||
{% endif %}
|
||||
<span {% if c.author.patron and not c.distinguish_level %}class="patron" style="background-color:#{{c.author.namecolor}};"{% elif c.distinguish_level %}class="mod"{% endif %}>{{c.author_name}}</span>
|
||||
</a>
|
||||
{% if SITE_NAME == 'rDrama' %}
|
||||
<span class="pronouns" style="background-color:#{{c.author.titlecolor}}">{{c.author.pronouns}}</span>
|
||||
{% endif %}
|
||||
{% if c.author.customtitle %}
|
||||
<bdi style="color: #{{c.author.titlecolor}}"> {{c.author.customtitle | safe}}</bdi>
|
||||
{% endif %}
|
||||
|
|
|
@ -458,6 +458,25 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="body d-lg-flex border-bottom">
|
||||
|
||||
<label class="text-black w-lg-25">Pronouns</label>
|
||||
|
||||
<div class="w-lg-100">
|
||||
<form id="profile-settings" action="/settings/pronoun_change" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input maxlength=9 autocomplete="off" id="pronounbody" type="text" name="pronouns" class="form-control" placeholder='Enter pronouns here' value="{% if v.pronouns %}{{v.pronouns}}{% endif %}">
|
||||
<div class="d-flex mt-2">
|
||||
<small>{1-5 characters} / {1-5 characters}</small>
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" id="pronounsSave" type="submit" onclick="disable(this)" value="Change Pronouns">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="body d-lg-flex border-bottom">
|
||||
|
||||
<label class="text-black w-lg-25">Flair</label>
|
||||
|
|
|
@ -676,6 +676,9 @@
|
|||
{% endif %}
|
||||
<span {% if p.author.patron and not p.distinguish_level %}class="patron" style="background-color:#{{p.author.namecolor}};"{% elif p.distinguish_level %}class="mod"{% endif %}>{{p.author_name}}</span>
|
||||
</a>
|
||||
{% if SITE_NAME == 'rDrama' %}
|
||||
<span class="pronouns" style="background-color:#{{p.author.titlecolor}}">{{p.author.pronouns}}</span>
|
||||
{% endif %}
|
||||
{% if p.author.customtitle %}
|
||||
<bdi style="color: #{{p.author.titlecolor}}"> {{p.author.customtitle | safe}}</bdi>
|
||||
{% endif %}
|
||||
|
|
|
@ -207,6 +207,9 @@
|
|||
{% endif %}
|
||||
<span {% if p.author.patron and not p.distinguish_level %}class="patron" style="background-color:#{{p.author.namecolor}};"{% elif p.distinguish_level %}class="mod"{% endif %}>{{p.author_name}}</span>
|
||||
</a>
|
||||
{% if SITE_NAME == 'rDrama' %}
|
||||
<span class="pronouns" style="background-color:#{{p.author.titlecolor}}">{{p.author.pronouns}}</span>
|
||||
{% endif %}
|
||||
{% if p.author.customtitle %}
|
||||
<bdi style="color: #{{p.author.titlecolor}}"> {{p.author.customtitle | safe}}</bdi>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{%-
|
||||
set CACHE_VER = {
|
||||
'css/main.css': 385,
|
||||
'css/main.css': 386,
|
||||
|
||||
'css/4chan.css': 61,
|
||||
'css/classic.css': 61,
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
alter table users add column pronouns varchar(11) not null default 'they/them';
|
||||
alter table users alter column pronouns drop default;
|
Loading…
Reference in New Issue