From 7aac9995e84d9570df32f9c734b3fccc0985ed16 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 16:19:49 +0200 Subject: [PATCH 01/11] sneed --- drama/routes/comments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 553ed829d..8d9a83dbe 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -433,7 +433,7 @@ def api_comment(v): included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*""" - body = body.replace("\n", "\n\n") + #body = body.replace("\n", "\n\n") with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) From 027e77597590a0df4cb25cf9b0acda8c86a13967 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 17:14:28 +0200 Subject: [PATCH 02/11] sneed --- drama/templates/submission.html | 2 +- drama/templates/submission_listing.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drama/templates/submission.html b/drama/templates/submission.html index e8921b16b..c5eb7f13b 100644 --- a/drama/templates/submission.html +++ b/drama/templates/submission.html @@ -227,7 +227,7 @@ {% if p.private %}unlisted{% endif %} {% if p.repost_id %}repost{% endif %} {% if p.flags %}{{p.active_flags}} Reports{% endif %} -    {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %} +    {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} ({% if p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) diff --git a/drama/templates/submission_listing.html b/drama/templates/submission_listing.html index 02359401d..63b4dffa7 100644 --- a/drama/templates/submission_listing.html +++ b/drama/templates/submission_listing.html @@ -121,7 +121,7 @@ {% if p.private %}unlisted{% endif %} {% if p.repost_id %} repost{% endif %} {% if p.flags %}{{p.active_flags}} Reports{% endif %} -  {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %} +  {{p.author.username}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %}  {{p.age_string}}   ({% if p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) From 091679142e4034bbe450eb3db94c223e1d3021f3 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 17:37:38 +0200 Subject: [PATCH 03/11] sneed --- drama/classes/user.py | 22 ++++++++++++++++++++++ drama/routes/users.py | 4 ++-- drama/templates/userpage.html | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drama/classes/user.py b/drama/classes/user.py index 3d668d68c..2df1f5e78 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -277,6 +277,28 @@ class User(Base, Stndrd, Age_times): def __repr__(self): return f"" + @property + def unban_string(self): + if self.unban_utc == 0: + return "permanently banned" + + wait = self.unban_utc - int(time.time()) + + if wait < 60: + text = "a few moments" + else: + days = wait//(24*60*60) + wait -= days*24*60*60 + + hours = wait//(60*60) + wait -= hours*60*60 + + mins = wait//60 + + text = f"{days} days {hours:02d} hours {mins:02d} minutes" + + return f"Unban in {text}" + @property @lazy def post_notifications_count(self): diff --git a/drama/routes/users.py b/drama/routes/users.py index eaade85f3..839021d19 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -304,9 +304,9 @@ def u_username(username, v=None): listing = get_posts(ids, v=v) if u.unban_utc: - unban = datetime.fromtimestamp(u.unban_utc).strftime('%c') + #unban = datetime.fromtimestamp(u.unban_utc).strftime('%c') return {'html': lambda: render_template("userpage.html", - unban=unban, + unban=u.unban_string, u=u, v=v, listing=listing, diff --git a/drama/templates/userpage.html b/drama/templates/userpage.html index 4eea1f9ad..caf74f901 100644 --- a/drama/templates/userpage.html +++ b/drama/templates/userpage.html @@ -67,7 +67,7 @@
{% if u.is_banned %}
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
- {% if unban %}
until {{unban}}
{% endif %} + {% if unban %}
{{unban}}
{% endif %} {% endif %}
@@ -282,7 +282,7 @@
{% if u.is_banned %}
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
- {% if unban %}
until {{unban}}
{% endif %} + {% if unban %}
{{unban}}
{% endif %} {% endif %}

{{u.username}}

From e54127a1bd35e7dd1b25eb24965c9b6af15fe844 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 17:43:16 +0200 Subject: [PATCH 04/11] sneed --- drama/templates/userpage.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drama/templates/userpage.html b/drama/templates/userpage.html index caf74f901..e4d3e273d 100644 --- a/drama/templates/userpage.html +++ b/drama/templates/userpage.html @@ -65,7 +65,7 @@
- {% if u.is_banned %} + {% if u.is_suspended %}
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
{% if unban %}
{{unban}}
{% endif %} {% endif %} @@ -280,7 +280,7 @@
- {% if u.is_banned %} + {% if u.is_suspended %}
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
{% if unban %}
{{unban}}
{% endif %} {% endif %} From 01c08f95d5d3df6991da22b696236e0fe5bb80ca Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 22:31:13 +0200 Subject: [PATCH 05/11] sneed --- drama/routes/login.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drama/routes/login.py b/drama/routes/login.py index 5fff1b2bf..cffd90be5 100644 --- a/drama/routes/login.py +++ b/drama/routes/login.py @@ -338,7 +338,8 @@ def sign_up_post(v): email=email, created_utc=int(time.time()), referred_by=ref_id or None, - ban_evade = int(any([x.is_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])) + ban_evade = int(any([x.is_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])), + agendaposter = any([x.agendaposter for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]) ) except Exception as e: From 69a010e2a6a8d3383499081b180733ab3e486164 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 22:51:29 +0200 Subject: [PATCH 06/11] sneed --- drama/classes/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drama/classes/user.py b/drama/classes/user.py index 2df1f5e78..1588c113a 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -285,7 +285,7 @@ class User(Base, Stndrd, Age_times): wait = self.unban_utc - int(time.time()) if wait < 60: - text = "a few moments" + text = f"{wait}s" else: days = wait//(24*60*60) wait -= days*24*60*60 @@ -295,7 +295,7 @@ class User(Base, Stndrd, Age_times): mins = wait//60 - text = f"{days} days {hours:02d} hours {mins:02d} minutes" + text = f"{days}d {hours:02d}h {mins:02d}m" return f"Unban in {text}" From 022d0b9018083b57ba4db602511e6f964d38675f Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 23:31:50 +0200 Subject: [PATCH 07/11] sneed --- drama/routes/settings.py | 6 ++++++ drama/templates/comments.html | 5 +++++ drama/templates/submission.html | 7 +++++++ drama/templates/userpage.html | 8 ++++---- drama/templates/userpage_blocking.html | 7 ++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index 94c9ea49e..3818a72d5 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -465,6 +465,9 @@ def settings_block_user(v): if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!") if request.args.get("notoast"): return "", 204 + + if v.admin_level == 1: return jsonify({"message": f"@{user.username} banned!"}) + return jsonify({"message": f"@{user.username} blocked."}) @@ -487,6 +490,9 @@ def settings_unblock_user(v): if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!") if request.args.get("notoast"): return "", 204 + + if v.admin_level == 1: return jsonify({"message": f"@{user.username} unbanned!"}) + return jsonify({"message": f"@{user.username} unblocked."}) diff --git a/drama/templates/comments.html b/drama/templates/comments.html index 4f8a13ca6..3589cc042 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -318,6 +318,11 @@ >Block user {% endif %} + {% if not v.id==c.author_id and v.admin_level == 1 %} + Ban user + {% endif %} + {% if v.admin_level>=3 %} {% if not c.is_banned %} Remove diff --git a/drama/templates/submission.html b/drama/templates/submission.html index c5eb7f13b..66eeb5d5a 100644 --- a/drama/templates/submission.html +++ b/drama/templates/submission.html @@ -389,6 +389,13 @@ >Unblock user {% endif %} + {% if not v.id==p.author_id and v.admin_level == 1 %} +
  • Ban user
  • +
  • Unban user
  • + {% endif %} + {% if v.admin_level >=3 and v.id!=p.author_id %} {% if p.author.is_banned %}
  • {% endif %} - {% if u.admin_level > 1 %} + {% if u.admin_level > 1 or (u.admin_level == 1 and not v or v.admin_level < 2) %} {% elif u.admin_level == 1 %} - + {% endif %} {% if v and v.has_follower(u) %} @@ -157,7 +157,7 @@ Edit profile Profile views {% endif %} - {% if v and v.id != u.id and v.admin_level > 0 and u.admin_level == 0 %} + {% if v and v.id != u.id and v.admin_level > 1 and u.admin_level <= 1 %}

    @@ -337,7 +337,7 @@ - {% if v.admin_level > 0 and u.admin_level == 0 %} + {% if v.admin_level > 1 and u.admin_level <= 1 %}

    diff --git a/drama/templates/userpage_blocking.html b/drama/templates/userpage_blocking.html index b51c0fa10..53515e938 100644 --- a/drama/templates/userpage_blocking.html +++ b/drama/templates/userpage_blocking.html @@ -38,10 +38,15 @@
    - + {% if v.admin_level == 1 %}{% else %}{% endif %} + {% if v.admin_level == 1 %} +

    @{{u.username}} is banned

    +

    This account has been suspended.

    + {% else %}

    You are blocking @{{u.username}}.

    So we aren't going to show you their profile.

    + {% endif %}
    From aad37fe6741beec70587ce0468b470958f6d426a Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 23:35:24 +0200 Subject: [PATCH 08/11] sneed --- drama/templates/userpage.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/templates/userpage.html b/drama/templates/userpage.html index aedc0508e..f4bc2c597 100644 --- a/drama/templates/userpage.html +++ b/drama/templates/userpage.html @@ -77,7 +77,7 @@ {% endif %} - {% if u.admin_level > 1 or (u.admin_level == 1 and not v or v.admin_level < 2) %} + {% if u.admin_level > 1 or (u.admin_level == 1 and (not v or v.admin_level < 2)) %} From 63e5a338f3ef9ca3514b0ef10d7df85d8f0c3650 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Wed, 28 Jul 2021 23:45:32 +0200 Subject: [PATCH 09/11] sneed --- drama/templates/comments.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/templates/comments.html b/drama/templates/comments.html index 3589cc042..037be7cc9 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -121,7 +121,7 @@ {% if c.distinguish_level %} {% endif %} {% if c.is_op %} {% endif %} {% if c.is_bot %} {% endif %} - {% if c.is_blocking %} {% endif %} + {% if c.is_blocking %} {% endif %} {% if c.is_blocked %} {% endif %} {{c.author.username}}{% if c.author.customtitle %}  {{c.author.customtitle | safe}}{% endif %} From a2b826cd22da82982c5b104ede1408e5d736c9e6 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Thu, 29 Jul 2021 00:11:18 +0200 Subject: [PATCH 10/11] sneed --- drama/routes/admin.py | 4 ++-- drama/routes/comments.py | 2 +- drama/templates/comments.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drama/routes/admin.py b/drama/routes/admin.py index a1f5eb432..1b58c8664 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -633,7 +633,7 @@ def ban_user(user_id, v): user = g.db.query(User).filter_by(id=user_id).first() - if user.admin_level != 0: abort(403) + if user.admin_level >= v.admin_level: abort(403) # check for number of days for suspension days = int(request.form.get("days")) if request.form.get('days') else 0 @@ -642,7 +642,7 @@ def ban_user(user_id, v): if not user: abort(400) - if user.admin_level > 0: abort(403) + #if user.admin_level > 0: abort(403) if days > 0: if message: diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 8d9a83dbe..cb7f93f6d 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -920,7 +920,7 @@ def toggle_comment_pin(cid, v): comment = get_comment(cid, v=v) - if v.admin_level != 6 and v.id != comment.post.author_id: + if v.admin_level < 1 and v.id != comment.post.author_id: abort(403) comment.is_pinned = not comment.is_pinned diff --git a/drama/templates/comments.html b/drama/templates/comments.html index 037be7cc9..96ca0b8ee 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -336,7 +336,7 @@ {% endif %} {% endif %} - {% if v and c.post and (v.admin_level == 6 or v.id == c.post.author_id) %} + {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) %} {% if c.level == 1 %} {{"Unpin" if c.is_pinned else "Pin"}} From 3476d197d58e48974284fd885cc2f98c0b049145 Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Thu, 29 Jul 2021 00:13:46 +0200 Subject: [PATCH 11/11] sneed --- drama/templates/comments.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/templates/comments.html b/drama/templates/comments.html index 96ca0b8ee..b51c87fe0 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -523,7 +523,7 @@ {% endif %} {% endif %} - {% if v and c.post and (v.admin_level == 6 or v.id == c.post.author_id) %} + {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) %} {% if c.level == 1 %}
  • {{'Unpin' if c.is_pinned else 'Pin'}}