master
Aevann1 2021-11-16 23:21:53 +02:00
parent b139ed44df
commit 6713493d5f
9 changed files with 63 additions and 29 deletions

View File

@ -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 "<p>COUNTRY CLUB ONLY</p>"
if self.post and self.post.club and not (v and v.paid_dues): return f"<p>{cc} ONLY</p>"
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 "<p>COUNTRY CLUB ONLY</p>"
if self.post and self.post.club and not (v and v.paid_dues): return f"<p>{cc} ONLY</p>"
body = self.body

View File

@ -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" <i>({self.note})</i>"
@ -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",
},

View File

@ -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 "<p>COUNTRY CLUB ONLY</p>"
if self.club and not (v and v.paid_dues): return f"<p>{cc} ONLY</p>"
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 "<p>COUNTRY CLUB ONLY</p>"
if self.club and not (v and v.paid_dues): return f"<p>{cc} ONLY</p>"
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)

View File

@ -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/<id>/<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("/@<username>/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("/@<username>/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!"}

View File

@ -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!"}

View File

@ -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

View File

@ -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") %}
<style>
@keyframes train {
@ -466,12 +472,12 @@
{% endif %}
{% if p.realurl(v) %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3"><a {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}">
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">COUNTRY CLUB</span>{% endif %}
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">>{{cc}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</a></h1>
{% else %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3">
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">COUNTRY CLUB</span>{% endif %}
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">>{{cc}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</h1>
{% endif %}

View File

@ -32,6 +32,12 @@
})
</script>
{% if request.host == 'pcmemes.net' %}
{% set cc='SPLASH MOUNTAIN' %}
{% else %}
{% set cc='COUNTRY CLUB' %}
{% endif %}
{% for p in listing %}
<div style="display:none" id="popover-{{p.id}}">
@ -225,7 +231,7 @@
</div>
<h5 class="card-title post-title text-left w-lg-75 mb-0 pb-0 pb-md-1"><a {% if v and v.newtab %}target="_blank"{% endif %} {% if v %}href="{{p.permalink}}"{% else %}href="/logged_out{{p.permalink}}"{% endif %} class="stretched-link">
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">COUNTRY CLUB</span>{% endif %}
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:10px; line-height:2;">{{cc}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</a></h5>

View File

@ -12,6 +12,12 @@
<meta name="author" content="">
<link rel="icon" type="image/png" href="/assets/images/{{'SITE_NAME' | app_config}}/icon.webp?v=1">
{% if request.host == 'pcmemes.net' %}
{% set cc='Splash Mountain' %}
{% else %}
{% set cc='Country Club' %}
{% endif %}
{% include "emoji_modal.html" %}
{% include "gif_modal.html" %}
@ -135,7 +141,7 @@
{% if v.paid_dues %}
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="clubCheck" name="club">
<label class="custom-control-label" for="clubCheck">Country Club thread</label>
<label class="custom-control-label" for="clubCheck">{{cc}} thread</label>
</div>
{% endif %}
<pre>