From 1f885af8662a50fc10f9db34d48d37eb3a7d472f Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 2 Jan 2022 02:05:22 +0200 Subject: [PATCH] fd --- files/classes/user.py | 5 +++++ files/routes/admin.py | 6 +++++- files/routes/login.py | 16 ++++++++++++++++ files/routes/static.py | 4 ++++ files/routes/users.py | 6 ++---- files/templates/comments.html | 8 ++++---- files/templates/userpage.html | 19 ++++++++++++++++++- 7 files changed, 54 insertions(+), 10 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index ec4fb4ebe..e5ad022af 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -267,6 +267,11 @@ class User(Base): return [x[0] for x in posts] + @property + @lazy + def follow_count(self): + return g.db.query(Follow.id).filter_by(user_id=self.id).count() + @property @lazy def bio_html_eager(self): diff --git a/files/routes/admin.py b/files/routes/admin.py index 05f0c125e..5de5ce49f 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1126,7 +1126,9 @@ def api_unban_comment(c_id, v): comment = g.db.query(Comment).filter_by(id=c_id).first() if not comment: abort(404) - g.db.add(comment) + + if comment.author.agendaposter and 'trans lives matters' not in comment.body.lower(): + return {"error": "You can't bypass the agendaposter award!"} if comment.is_banned: ma=ModAction( @@ -1139,6 +1141,8 @@ def api_unban_comment(c_id, v): comment.is_banned = False comment.is_approved = v.id + g.db.add(comment) + g.db.commit() return {"message": "Comment approved!"} diff --git a/files/routes/login.py b/files/routes/login.py index f5a3f1b2b..f16d64647 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -300,6 +300,22 @@ def sign_up_post(v): ref_id = int(request.values.get("referred_by", 0)) + + if ref_id: + ref_user = g.db.query(User).filter_by(id=ref_id).one_or_none() + + if ref_user: + if ref_user.referral_count > 0: + new_badge = Badge(user_id=ref_user.id, badge_id=10) + g.db.add(new_badge) + if ref_user.referral_count > 9: + new_badge = Badge(user_id=ref_user.id, badge_id=11) + g.db.add(new_badge) + if ref_user.referral_count > 99: + new_badge = Badge(user_id=ref_user.id, badge_id=12) + g.db.add(new_badge) + + id_1 = g.db.query(User.id).filter_by(id=7).count() users_count = g.db.query(User.id).count() if id_1 == 0 and users_count == 7: admin_level=3 diff --git a/files/routes/static.py b/files/routes/static.py index e7229e04a..502d5be3c 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -140,6 +140,10 @@ def cached_chart(days): comment_stats, color='gold') + signup_chart.set_ylim(ymin=0) + posts_chart.set_ylim(ymin=0) + comments_chart.set_ylim(ymin=0) + signup_chart.set_ylabel("Signups") posts_chart.set_ylabel("Posts") comments_chart.set_ylabel("Comments") diff --git a/files/routes/users.py b/files/routes/users.py index 844f0f70d..33d14e0f4 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -522,10 +522,9 @@ def redditor_moment_redirect(username): return redirect(f"/@{username}") @app.get("/@/followers") -@auth_required +@auth_desired def followers(username, v): u = get_user(username, v=v) - # if request.host == 'rdrama.net' and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() if not v or v.oldsite: template = '' @@ -533,10 +532,9 @@ def followers(username, v): return render_template(f"{template}followers.html", v=v, u=u, users=users) @app.get("/@/following") -@auth_required +@auth_desired def following(username, v): u = get_user(username, v=v) - # if request.host == 'rdrama.net' and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() if not v or v.oldsite: template = '' diff --git a/files/templates/comments.html b/files/templates/comments.html index 32cf4d0dd..85ccea4ad 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -459,9 +459,9 @@ {% elif v.id == c.post.author_id %} - + - + {% endif %} {% endif %} @@ -607,8 +607,8 @@ {% if c.post and v.id == c.post.author_id and not v.admin_level %} - Pin - Unpin + Pin + Unpin {% endif %} {% endif %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 6816c659e..0f262d348 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -111,6 +111,10 @@ marseybux   {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %} + + {% if u.follow_count > 0 %}follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}   {% endif %} + + joined {{u.created_date}} {% if u.basedcount %}

Based Count: {{u.basedcount}}

{% endif %} @@ -155,7 +159,12 @@ Gift {{'COINS_NAME' | app_config}} Gift Marseybux - {% if v.admin_level > 2 %} + {% if v.admin_level > 2 %} + {% if request.host != "rdrama.net" %} + Make admin + Remove admin + {% endif %} + Make meme admin Remove meme admin @@ -377,6 +386,9 @@ marseybux   {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %} + + {% if u.follow_count > 0 %}follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}   {% endif %} + {% if u.basedcount %}
Based count: {{u.basedcount}} {% endif %} @@ -437,6 +449,11 @@ Gift Marseybux {% if v.admin_level > 2 %} + {% if request.host != "rdrama.net" %} + Make admin + Remove admin + {% endif %} + Make meme admin Remove meme admin