From 6713493d5fe000cedc92fbb895c7df18acbf26ef Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 16 Nov 2021 23:21:53 +0200 Subject: [PATCH] splash --- files/classes/comment.py | 6 +++--- files/classes/mod_logs.py | 11 ++++++++--- files/classes/submission.py | 10 ++++++---- files/routes/admin.py | 20 ++++++++++++-------- files/routes/comments.py | 17 ++++++++++------- files/routes/votes.py | 2 ++ files/templates/submission.html | 10 ++++++++-- files/templates/submission_listing.html | 8 +++++++- files/templates/submit.html | 8 +++++++- 9 files changed, 63 insertions(+), 29 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 27f7dd826..e1f947c3a 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -207,7 +207,7 @@ class Comment(Base): @property @lazy def shortlink(self): - return f"http://{site}/comment/{self.id}" + return f"http://{site}/comment/{self.id}#context" @property @lazy @@ -302,7 +302,7 @@ class Comment(Base): return data def realbody(self, v): - if self.post and self.post.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" + if self.post and self.post.club and not (v and v.paid_dues): return f"

{cc} ONLY

" body = self.body_html @@ -335,7 +335,7 @@ class Comment(Base): return body def plainbody(self, v): - if self.post and self.post.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" + if self.post and self.post.club and not (v and v.paid_dues): return f"

{cc} ONLY

" body = self.body diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index aa9f8af12..63046ccc7 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -3,6 +3,11 @@ from sqlalchemy.orm import relationship from files.__main__ import Base import time from files.helpers.lazy import lazy +from os import environ + +site = environ.get("DOMAIN").strip() +if site == 'pcmemes.net': cc = "splash mountain" +else: cc = "country club" class ModAction(Base): __tablename__ = "modactions" @@ -77,7 +82,7 @@ class ModAction(Base): @lazy def string(self): - output = ACTIONTYPES[self.kind]["str"].format(self=self) + output = ACTIONTYPES[self.kind]["str"].format(self=self).format(cc=cc) if self.note: output += f" ({self.note})" @@ -160,12 +165,12 @@ ACTIONTYPES={ "color": "bg-muted", }, "club_allow":{ - "str":'allowed user {self.target_link} into the country club', + "str":'allowed user {self.target_link} into the {cc}', "icon":"fa-user-slash", "color": "bg-danger", }, "club_ban":{ - "str":'disallowed user {self.target_link} from the country club', + "str":'disallowed user {self.target_link} from the {cc}', "icon": "fa-user-slash", "color": "bg-muted", }, diff --git a/files/classes/submission.py b/files/classes/submission.py index 884958bf5..003d4be6d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -15,6 +15,8 @@ from flask import g site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() +if site == 'pcmemes.net': cc = "SPLASH MOUNTAIN" +else: cc = "COUNTRY CLUB" class Submission(Base): __tablename__ = "submissions" @@ -317,7 +319,7 @@ class Submission(Base): else: return "" def realbody(self, v): - if self.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" + if self.club and not (v and v.paid_dues): return f"

{cc} ONLY

" body = self.body_html body = censor_slurs(body, v) @@ -335,7 +337,7 @@ class Submission(Base): return body def plainbody(self, v): - if self.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" + if self.club and not (v and v.paid_dues): return f"

{cc} ONLY

" body = self.body body = censor_slurs(body, v) @@ -348,7 +350,7 @@ class Submission(Base): def realtitle(self, v): if self.club and not (v and v.paid_dues) and not (v and v.admin_level > 1): if v: return random.choice(TROLLTITLES).format(username=v.username) - else: return 'COUNTRY CLUB MEMBERS ONLY' + else: return f'{cc} MEMBERS ONLY' elif self.title_html: title = self.title_html else: title = self.title @@ -360,7 +362,7 @@ class Submission(Base): def plaintitle(self, v): if self.club and not (v and v.paid_dues) and not (v and v.admin_level > 1): if v: return random.choice(TROLLTITLES).format(username=v.username) - else: return 'COUNTRY CLUB MEMBERS ONLY' + else: return f'{cc} MEMBERS ONLY' else: title = self.title title = censor_slurs(title, v) diff --git a/files/routes/admin.py b/files/routes/admin.py index ee178fa2f..322470ec8 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -18,6 +18,8 @@ from .front import frontlist from files.helpers.discord import add_role SITE_NAME = environ.get("SITE_NAME", "").strip() +if SITE_NAME == 'PCM': cc = "splash mountain" +else: cc = "country club" @app.get("/name//") @admin_level_required(2) @@ -104,7 +106,7 @@ def club_allow(v, username): g.db.add(ma) g.db.commit() - return {"message": f"@{username} has been allowed into the country club!"} + return {"message": f"@{username} has been allowed into the {cc}!"} @app.post("/@/club_ban") @limiter.limit("1/second") @@ -133,7 +135,7 @@ def club_ban(v, username): g.db.add(ma) g.db.commit() - return {"message": f"@{username} has been kicked from the country club. Deserved."} + return {"message": f"@{username} has been kicked from the {cc}. Deserved."} @app.post("/@/make_admin") @@ -993,15 +995,17 @@ def api_sticky_post(post_id, v): cache.delete_memoized(frontlist) if post.stickied: - message = f"@{v.username} has pinned your [post](/post/{post_id})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() - if not existing: send_notification(post.author_id, message) + if v.id != post.author_id: + message = f"@{v.username} has pinned your [post](/post/{post_id})!" + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + if not existing: send_notification(post.author_id, message) g.db.commit() return {"message": "Post pinned!"} else: - message = f"@{v.username} has unpinned your [post](/post/{post_id})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() - if not existing: send_notification(post.author_id, message) + if v.id != post.author_id: + message = f"@{v.username} has unpinned your [post](/post/{post_id})!" + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + if not existing: send_notification(post.author_id, message) g.db.commit() return {"message": "Post unpinned!"} diff --git a/files/routes/comments.py b/files/routes/comments.py index a9ee4b0c2..2bc10e1e6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -11,8 +11,9 @@ from flask import * from files.__main__ import app, limiter from files.helpers.sanitize import filter_title - site = environ.get("DOMAIN").strip() +if site == 'pcmemes.net': cc = "SPLASH MOUNTAIN" +else: cc = "COUNTRY CLUB" beams_client = PushNotifications( instance_id=PUSHER_INSTANCE_ID, @@ -862,15 +863,17 @@ def toggle_pin_comment(cid, v): g.db.commit() if comment.is_pinned: - message = f"@{v.username} has pinned your [comment]({comment.permalink})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() - if not existing: send_notification(comment.author_id, message) + if v.id != comment.author_id: + message = f"@{v.username} has pinned your [comment]({comment.permalink})!" + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + if not existing: send_notification(comment.author_id, message) g.db.commit() return {"message": "Comment pinned!"} else: - message = f"@{v.username} has unpinned your [comment]({comment.permalink})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() - if not existing: send_notification(comment.author_id, message) + if v.id != comment.author_id: + message = f"@{v.username} has unpinned your [comment]({comment.permalink})!" + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + if not existing: send_notification(comment.author_id, message) g.db.commit() return {"message": "Comment unpinned!"} diff --git a/files/routes/votes.py b/files/routes/votes.py index afc9a58d3..bc3f59e3c 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -22,6 +22,8 @@ def admin_vote_info_get(v): else: abort(400) except: abort(400) + if thing.author.shadowbanned and not (v and v.admin_level): return render_template('errors/500.html', v=v), 500 + if isinstance(thing, Submission): ups = g.db.query(Vote diff --git a/files/templates/submission.html b/files/templates/submission.html index b4c4da9ee..aa8ee2d68 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -13,6 +13,12 @@ {% block title %} +{% if request.host == 'pcmemes.net' %} + {% set cc='SPLASH MOUNTAIN' %} +{% else %} + {% set cc='COUNTRY CLUB' %} +{% endif %} + {% if p.award_count("train") %}