diff --git a/files/classes/comment.py b/files/classes/comment.py index 4052a2a632..d4d26b41ea 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -295,8 +295,6 @@ class Comment(Base): if self.level >= 2: data['parent_comment_id'] = self.parent_comment_id - data['replies'] = [x.json_core for x in self.replies()] - return data @property @@ -313,6 +311,7 @@ class Comment(Base): if self.level >= 2: data["parent"]=self.parent.json_core + data['replies'] = [x.json_core for x in self.replies()] return data diff --git a/files/classes/submission.py b/files/classes/submission.py index da106c4673..68344f642a 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -282,7 +282,7 @@ class Submission(Base): if "replies" in self.__dict__: - data["replies"]=[x.json_core for x in self.replies] + data["replies"]=[x.json for x in self.replies] if "voted" in self.__dict__: data["voted"] = self.voted diff --git a/files/classes/user.py b/files/classes/user.py index ad28b757aa..59782e57ba 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -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") diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 10a5fc242e..bbb92d140e 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -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) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 601f7a0d4b..bf0d0b5b65 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -30,7 +30,7 @@ def unread(v): n.read = True g.db.add(n) - return {"data":[x[1].json for x in listing]} + return {"data":[x[1].json_core for x in listing]} diff --git a/files/routes/settings.py b/files/routes/settings.py index 97f01bdf99..f3fe6572cd 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -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")}') diff --git a/files/templates/comments.html b/files/templates/comments.html index fc0bdee933..e9e7fcad41 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -206,6 +206,9 @@ {% endif %} {{c.author_name}} + {% if SITE_NAME == 'rDrama' %} + {{c.author.pronouns}} + {% endif %} {% if c.author.customtitle %}   {{c.author.customtitle | safe}} {% endif %} diff --git a/files/templates/header.html b/files/templates/header.html index 3abfabd801..bee7c46095 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -154,6 +154,27 @@ + + + + + + + + +