forked from rDrama/rDrama
rename a bunch of columns
parent
5592418745
commit
9804a365da
|
@ -6,7 +6,7 @@
|
|||
--gray: #888;
|
||||
--upvote: #ff8b60;
|
||||
--downvote: #9393ff;
|
||||
--sticky: #228822;
|
||||
--pinned: #228822;
|
||||
--background: 255, 255, 255;
|
||||
}
|
||||
|
||||
|
@ -82,11 +82,11 @@ input, textarea, .form-control {
|
|||
}
|
||||
|
||||
.fa-thumbtack.text-admin {
|
||||
color: var(--sticky);
|
||||
color: var(--pinned);
|
||||
}
|
||||
|
||||
.fa-broom {
|
||||
color: var(--sticky) !important;
|
||||
color: var(--pinned) !important;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
|
@ -152,8 +152,8 @@ a.btn-block[href~="/submit"] {
|
|||
color: #369;
|
||||
}
|
||||
|
||||
#frontpage .card.stickied .post-title a {
|
||||
color: var(--sticky);
|
||||
#frontpage .card.pinned .post-title a {
|
||||
color: var(--pinned);
|
||||
}
|
||||
|
||||
/*posts*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function pinPost(t, id) {
|
||||
postToast(t, `/sticky/${id}`,
|
||||
postToast(t, `/pin_post/${id}`,
|
||||
{
|
||||
},
|
||||
(xhr) => {
|
||||
|
@ -15,7 +15,7 @@ function pinPost(t, id) {
|
|||
}
|
||||
|
||||
function unpinPost(t, id) {
|
||||
postToast(t, `/unsticky/${id}`,
|
||||
postToast(t, `/unpin_post/${id}`,
|
||||
{
|
||||
},
|
||||
() => {
|
||||
|
|
|
@ -189,8 +189,8 @@ class Comment(Base):
|
|||
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
top_comment_id = Column(Integer)
|
||||
is_bot = Column(Boolean, default=False)
|
||||
stickied = Column(String)
|
||||
stickied_utc = Column(Integer)
|
||||
pinned = Column(String)
|
||||
pinned_utc = Column(Integer)
|
||||
num_of_pinned_children = Column(Integer, default=0)
|
||||
sentto = Column(Integer, ForeignKey("users.id"))
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
|
@ -288,7 +288,7 @@ class Comment(Base):
|
|||
if self.replies2 != None:
|
||||
return self.replies2
|
||||
|
||||
replies = g.db.query(Comment).filter_by(parent_comment_id=self.id).order_by(Comment.stickied, Comment.num_of_pinned_children.desc())
|
||||
replies = g.db.query(Comment).filter_by(parent_comment_id=self.id).order_by(Comment.pinned, Comment.num_of_pinned_children.desc())
|
||||
if not self.parent_post: sort='old'
|
||||
return sort_objects(sort, replies, Comment).all()
|
||||
|
||||
|
@ -382,7 +382,7 @@ class Comment(Base):
|
|||
'deleted_utc': self.deleted_utc,
|
||||
'is_nsfw': self.nsfw,
|
||||
'permalink': f'/comment/{self.id}#context',
|
||||
'stickied': self.stickied,
|
||||
'pinned': self.pinned,
|
||||
'distinguished': self.distinguished,
|
||||
'post_id': self.post.id if self.post else 0,
|
||||
'score': self.score,
|
||||
|
|
|
@ -39,12 +39,12 @@ class Post(Base):
|
|||
views = Column(Integer, default=0)
|
||||
deleted_utc = Column(Integer, default=0)
|
||||
distinguished = Column(Boolean, default=False)
|
||||
stickied = Column(String)
|
||||
stickied_utc = Column(Integer)
|
||||
pinned = Column(String)
|
||||
pinned_utc = Column(Integer)
|
||||
profile_pinned = Column(Boolean, default=False)
|
||||
hole_pinned = Column(String)
|
||||
hole = Column(String, ForeignKey("holes.name"))
|
||||
is_pinned = Column(Boolean, default=False)
|
||||
private = Column(Boolean, default=False)
|
||||
draft = Column(Boolean, default=False)
|
||||
comment_count = Column(Integer, default=0)
|
||||
is_approved = Column(Integer, ForeignKey("users.id"))
|
||||
is_bot = Column(Boolean, default=False)
|
||||
|
@ -252,8 +252,8 @@ class Post(Base):
|
|||
'score': self.score,
|
||||
'upvotes': self.upvotes,
|
||||
'downvotes': self.downvotes,
|
||||
'stickied': self.stickied,
|
||||
'private' : self.private,
|
||||
'pinned': self.pinned,
|
||||
'draft' : self.draft,
|
||||
'distinguished': self.distinguished,
|
||||
'voted': self.voted if hasattr(self, 'voted') else 0,
|
||||
'reports': reports,
|
||||
|
|
|
@ -847,7 +847,7 @@ class User(Base):
|
|||
Post.created_utc > self.last_viewed_post_notifs,
|
||||
Post.deleted_utc == 0,
|
||||
Post.is_banned == False,
|
||||
Post.private == False,
|
||||
Post.draft == False,
|
||||
Post.author_id != self.id,
|
||||
Post.author_id.notin_(self.userblocks),
|
||||
or_(Post.hole == None, Post.hole.notin_(self.hole_blocks)),
|
||||
|
|
|
@ -262,8 +262,8 @@ def execute_snappy(post, v):
|
|||
g.db.add(snappy)
|
||||
|
||||
if FEATURES['PINS'] and (body.startswith(':#marseypin:') or body.startswith(':#marseypin2:')):
|
||||
post.stickied = "Snappy"
|
||||
post.stickied_utc = int(time.time()) + 3600
|
||||
post.pinned = "Snappy"
|
||||
post.pinned_utc = int(time.time()) + 3600
|
||||
|
||||
elif SITE_NAME == 'rDrama' and body.startswith(':#marseyban:'):
|
||||
days = 0.01
|
||||
|
@ -463,7 +463,7 @@ def execute_antispam_post_check(title, v, url):
|
|||
|
||||
for post in similar_posts + similar_urls:
|
||||
post.is_banned = True
|
||||
post.is_pinned = False
|
||||
post.profile_pinned = False
|
||||
post.ban_reason = "AutoJanny"
|
||||
g.db.add(post)
|
||||
ma = ModAction(
|
||||
|
|
|
@ -156,7 +156,7 @@ def _hole_inactive_purge_task():
|
|||
one_week_ago = time.time() - 604800
|
||||
active_holes = [x[0] for x in g.db.query(Post.hole).distinct() \
|
||||
.filter(Post.hole != None, Post.created_utc > one_week_ago,
|
||||
Post.private == False, Post.is_banned == False,
|
||||
Post.draft == False, Post.is_banned == False,
|
||||
Post.deleted_utc == 0)]
|
||||
active_holes.extend(['changelog','countryclub','museumofrdrama','highrollerclub','test']) # holes immune from deletion
|
||||
|
||||
|
@ -330,11 +330,11 @@ def _unpin_expired():
|
|||
pins = []
|
||||
|
||||
for cls in (Post, Comment):
|
||||
pins += g.db.query(cls).options(load_only(cls.id)).filter(cls.stickied_utc < t)
|
||||
pins += g.db.query(cls).options(load_only(cls.id)).filter(cls.pinned_utc < t)
|
||||
|
||||
for pin in pins:
|
||||
pin.stickied = None
|
||||
pin.stickied_utc = None
|
||||
pin.pinned = None
|
||||
pin.pinned_utc = None
|
||||
g.db.add(pin)
|
||||
if isinstance(pin, Comment):
|
||||
pin.unpin_parents()
|
||||
|
|
|
@ -1386,11 +1386,11 @@ def remove_post(post_id, v):
|
|||
post.is_banned = True
|
||||
post.is_approved = None
|
||||
|
||||
if not FEATURES['AWARDS'] or not post.stickied or not post.stickied.endswith(PIN_AWARD_TEXT):
|
||||
post.stickied = None
|
||||
post.stickied_utc = None
|
||||
if not FEATURES['AWARDS'] or not post.pinned or not post.pinned.endswith(PIN_AWARD_TEXT):
|
||||
post.pinned = None
|
||||
post.pinned_utc = None
|
||||
|
||||
post.is_pinned = False
|
||||
post.profile_pinned = False
|
||||
post.ban_reason = v.username
|
||||
g.db.add(post)
|
||||
|
||||
|
@ -1443,26 +1443,26 @@ def approve_post(post_id, v):
|
|||
return {"message": "Post approved!"}
|
||||
|
||||
|
||||
@app.post("/sticky/<int:post_id>")
|
||||
@app.post("/pin_post/<int:post_id>")
|
||||
@feature_required('PINS')
|
||||
@limiter.limit('1/second', scope=rpath)
|
||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||
def sticky_post(post_id, v):
|
||||
def pin_post(post_id, v):
|
||||
post = get_post(post_id)
|
||||
|
||||
if post.is_banned:
|
||||
abort(403, "Can't sticky removed posts!")
|
||||
abort(403, "Can't pin removed posts!")
|
||||
|
||||
if FEATURES['AWARDS'] and post.stickied and post.stickied.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
if FEATURES['AWARDS'] and post.pinned and post.pinned.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
abort(403, "Can't pin award pins!")
|
||||
|
||||
pins = g.db.query(Post).filter(Post.stickied != None, Post.is_banned == False).count()
|
||||
pins = g.db.query(Post).filter(Post.pinned != None, Post.is_banned == False).count()
|
||||
|
||||
if not post.stickied_utc:
|
||||
post.stickied_utc = int(time.time()) + 3600
|
||||
if not post.pinned_utc:
|
||||
post.pinned_utc = int(time.time()) + 3600
|
||||
pin_time = 'for 1 hour'
|
||||
code = 200
|
||||
if v.id != post.author_id:
|
||||
|
@ -1470,11 +1470,11 @@ def sticky_post(post_id, v):
|
|||
else:
|
||||
if pins >= PIN_LIMIT + 1:
|
||||
abort(403, f"Can't exceed {PIN_LIMIT} pinned posts limit!")
|
||||
post.stickied_utc = None
|
||||
post.pinned_utc = None
|
||||
pin_time = 'permanently'
|
||||
code = 201
|
||||
|
||||
post.stickied = v.username
|
||||
post.pinned = v.username
|
||||
|
||||
g.db.add(post)
|
||||
|
||||
|
@ -1491,20 +1491,20 @@ def sticky_post(post_id, v):
|
|||
return {"message": f"Post pinned {pin_time}!"}, code
|
||||
|
||||
|
||||
@app.post("/unsticky/<int:post_id>")
|
||||
@app.post("/unpin_post/<int:post_id>")
|
||||
@limiter.limit('1/second', scope=rpath)
|
||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||
def unsticky_post(post_id, v):
|
||||
def unpin_post(post_id, v):
|
||||
post = get_post(post_id)
|
||||
if post.stickied:
|
||||
if FEATURES['AWARDS'] and post.stickied.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
if post.pinned:
|
||||
if FEATURES['AWARDS'] and post.pinned.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
abort(403, "Can't unpin award pins!")
|
||||
|
||||
post.stickied = None
|
||||
post.stickied_utc = None
|
||||
post.pinned = None
|
||||
post.pinned_utc = None
|
||||
g.db.add(post)
|
||||
|
||||
ma = ModAction(
|
||||
|
@ -1520,23 +1520,23 @@ def unsticky_post(post_id, v):
|
|||
cache.delete_memoized(frontlist)
|
||||
return {"message": "Post unpinned!"}
|
||||
|
||||
@app.post("/sticky_comment/<int:cid>")
|
||||
@app.post("/pin_comment/<int:cid>")
|
||||
@limiter.limit('1/second', scope=rpath)
|
||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||
def sticky_comment(cid, v):
|
||||
def pin_comment(cid, v):
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if comment.is_banned:
|
||||
abort(403, "Can't sticky removed comments!")
|
||||
abort(403, "Can't pin removed comments!")
|
||||
|
||||
if FEATURES['AWARDS'] and comment.stickied and comment.stickied.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
if FEATURES['AWARDS'] and comment.pinned and comment.pinned.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
abort(403, "Can't pin award pins!")
|
||||
|
||||
if not comment.stickied:
|
||||
comment.stickied = v.username
|
||||
if not comment.pinned:
|
||||
comment.pinned = v.username
|
||||
g.db.add(comment)
|
||||
|
||||
ma = ModAction(
|
||||
|
@ -1555,21 +1555,21 @@ def sticky_comment(cid, v):
|
|||
return {"message": "Comment pinned!"}
|
||||
|
||||
|
||||
@app.post("/unsticky_comment/<int:cid>")
|
||||
@app.post("/unpin_comment/<int:cid>")
|
||||
@limiter.limit('1/second', scope=rpath)
|
||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||
def unsticky_comment(cid, v):
|
||||
def unpin_comment(cid, v):
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if comment.stickied:
|
||||
if FEATURES['AWARDS'] and comment.stickied.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
if comment.pinned:
|
||||
if FEATURES['AWARDS'] and comment.pinned.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
|
||||
abort(403, "Can't unpin award pins!")
|
||||
|
||||
comment.stickied = None
|
||||
comment.stickied_utc = None
|
||||
comment.pinned = None
|
||||
comment.pinned_utc = None
|
||||
g.db.add(comment)
|
||||
|
||||
ma = ModAction(
|
||||
|
|
|
@ -311,39 +311,39 @@ def award_thing(v, thing_type, id):
|
|||
if not FEATURES['PINS']: abort(403)
|
||||
if obj.is_banned: abort(403)
|
||||
|
||||
if obj.stickied and not obj.stickied_utc:
|
||||
if obj.pinned and not obj.pinned_utc:
|
||||
abort(400, f"This {thing_type} is already pinned permanently!")
|
||||
|
||||
if isinstance(obj, Comment): add = 3600*6
|
||||
else: add = 3600
|
||||
|
||||
if obj.stickied_utc:
|
||||
obj.stickied_utc += add
|
||||
if obj.pinned_utc:
|
||||
obj.pinned_utc += add
|
||||
else:
|
||||
obj.stickied_utc = int(time.time()) + add
|
||||
obj.pinned_utc = int(time.time()) + add
|
||||
if isinstance(obj, Comment):
|
||||
obj.pin_parents()
|
||||
|
||||
obj.stickied = f'{v.username}{PIN_AWARD_TEXT}'
|
||||
obj.pinned = f'{v.username}{PIN_AWARD_TEXT}'
|
||||
|
||||
if isinstance(obj, Post):
|
||||
cache.delete_memoized(frontlist)
|
||||
elif kind == "unpin":
|
||||
if not obj.stickied_utc: abort(400)
|
||||
if not obj.pinned_utc: abort(400)
|
||||
if not obj.author.deflector or v == obj.author:
|
||||
if isinstance(obj, Comment):
|
||||
t = obj.stickied_utc - 3600*6
|
||||
t = obj.pinned_utc - 3600*6
|
||||
else:
|
||||
t = obj.stickied_utc - 3600
|
||||
t = obj.pinned_utc - 3600
|
||||
|
||||
if time.time() > t:
|
||||
obj.stickied = None
|
||||
obj.stickied_utc = None
|
||||
obj.pinned = None
|
||||
obj.pinned_utc = None
|
||||
if isinstance(obj, Post):
|
||||
cache.delete_memoized(frontlist)
|
||||
else:
|
||||
obj.unpin_parents()
|
||||
else: obj.stickied_utc = t
|
||||
else: obj.pinned_utc = t
|
||||
elif kind == "queen":
|
||||
if not author.queen:
|
||||
characters = list(filter(str.isalpha, author.username))
|
||||
|
|
|
@ -439,9 +439,9 @@ def delete_comment(cid, v):
|
|||
c.deleted_utc = int(time.time())
|
||||
g.db.add(c)
|
||||
|
||||
if c.stickied:
|
||||
c.stickied = None
|
||||
c.stickied_utc = None
|
||||
if c.pinned:
|
||||
c.pinned = None
|
||||
c.pinned_utc = None
|
||||
c.unpin_parents()
|
||||
|
||||
if not (c.parent_post in ADMIGGER_THREADS and c.level == 1):
|
||||
|
@ -498,11 +498,11 @@ def pin_comment(cid, v):
|
|||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if not comment.stickied:
|
||||
if not comment.pinned:
|
||||
if v.id != comment.post.author_id: abort(403)
|
||||
|
||||
if comment.post.ghost: comment.stickied = "(OP)"
|
||||
else: comment.stickied = v.username + " (OP)"
|
||||
if comment.post.ghost: comment.pinned = "(OP)"
|
||||
else: comment.pinned = v.username + " (OP)"
|
||||
|
||||
g.db.add(comment)
|
||||
|
||||
|
@ -526,14 +526,14 @@ def unpin_comment(cid, v):
|
|||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if comment.stickied:
|
||||
if comment.pinned:
|
||||
if v.id != comment.post.author_id: abort(403)
|
||||
|
||||
if not comment.stickied.endswith(" (OP)"):
|
||||
if not comment.pinned.endswith(" (OP)"):
|
||||
abort(403, "You can only unpin comments you have pinned!")
|
||||
|
||||
comment.stickied = None
|
||||
comment.stickied_utc = None
|
||||
comment.pinned = None
|
||||
comment.pinned_utc = None
|
||||
g.db.add(comment)
|
||||
|
||||
comment.unpin_parents()
|
||||
|
@ -646,7 +646,7 @@ def toggle_comment_nsfw(cid, v):
|
|||
def edit_comment(cid, v):
|
||||
c = get_comment(cid, v=v)
|
||||
|
||||
if time.time() - c.created_utc > 31*24*60*60 and not (c.post and c.post.private) \
|
||||
if time.time() - c.created_utc > 31*24*60*60 and not (c.post and c.post.draft) \
|
||||
and v.admin_level < PERMS["IGNORE_1MONTH_EDITING_LIMIT"] and v.id not in EXEMPT_FROM_1MONTH_EDITING_LIMIT:
|
||||
abort(403, "You can't edit comments older than 1 month!")
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
|
||||
posts = posts.filter(
|
||||
Post.is_banned == False,
|
||||
Post.private == False,
|
||||
Post.draft == False,
|
||||
Post.deleted_utc == 0,
|
||||
)
|
||||
|
||||
|
@ -148,7 +148,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
|
||||
if pins and not gt and not lt:
|
||||
if hole: posts = posts.filter(Post.hole_pinned == None)
|
||||
else: posts = posts.filter(Post.stickied == None)
|
||||
else: posts = posts.filter(Post.pinned == None)
|
||||
|
||||
if v:
|
||||
posts = posts.filter(Post.author_id.notin_(v.userblocks))
|
||||
|
@ -193,7 +193,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
if hole:
|
||||
pins = g.db.query(Post).options(load_only(Post.id)).filter(Post.hole == hole.name, Post.hole_pinned != None)
|
||||
else:
|
||||
pins = g.db.query(Post).options(load_only(Post.id)).filter(Post.stickied != None, Post.is_banned == False)
|
||||
pins = g.db.query(Post).options(load_only(Post.id)).filter(Post.pinned != None, Post.is_banned == False)
|
||||
|
||||
if v:
|
||||
pins = pins.filter(or_(Post.hole == None, Post.hole.notin_(v.hole_blocks)))
|
||||
|
@ -216,7 +216,7 @@ def random_post(v):
|
|||
p = g.db.query(Post.id).filter(
|
||||
Post.deleted_utc == 0,
|
||||
Post.is_banned == False,
|
||||
Post.private == False,
|
||||
Post.draft == False,
|
||||
or_(Post.hole == None, Post.hole.notin_(v.hole_blocks)),
|
||||
).order_by(func.random()).first()
|
||||
|
||||
|
@ -255,7 +255,7 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
|
|||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.author_id.notin_(v.userblocks),
|
||||
or_(Comment.parent_post == None, Post.private == False),
|
||||
or_(Comment.parent_post == None, Post.draft == False),
|
||||
)
|
||||
|
||||
if gt: comments = comments.filter(Comment.created_utc > gt)
|
||||
|
|
|
@ -900,10 +900,10 @@ def pin_comment_mod(cid, v):
|
|||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if not comment.stickied:
|
||||
if not comment.pinned:
|
||||
if not v.mods_hole(comment.post.hole): abort(403)
|
||||
|
||||
comment.stickied = v.username + " (Mod)"
|
||||
comment.pinned = v.username + " (Mod)"
|
||||
|
||||
g.db.add(comment)
|
||||
|
||||
|
@ -933,11 +933,11 @@ def unpin_comment_mod(cid, v):
|
|||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if comment.stickied:
|
||||
if comment.pinned:
|
||||
if not v.mods_hole(comment.post.hole): abort(403)
|
||||
|
||||
comment.stickied = None
|
||||
comment.stickied_utc = None
|
||||
comment.pinned = None
|
||||
comment.pinned_utc = None
|
||||
g.db.add(comment)
|
||||
|
||||
comment.unpin_parents()
|
||||
|
|
|
@ -188,7 +188,7 @@ def notifications_posts(v):
|
|||
listing = g.db.query(Post).filter(
|
||||
Post.deleted_utc == 0,
|
||||
Post.is_banned == False,
|
||||
Post.private == False,
|
||||
Post.draft == False,
|
||||
Post.author_id != v.id,
|
||||
Post.author_id.notin_(v.userblocks),
|
||||
or_(Post.hole == None, Post.hole.notin_(v.hole_blocks)),
|
||||
|
|
|
@ -54,11 +54,12 @@ def _add_post_view(pid):
|
|||
def publish(pid, v):
|
||||
p = get_post(pid)
|
||||
|
||||
if not p.private: return {"message": "Post published!"}
|
||||
if not p.draft:
|
||||
return {"message": "Post published!"}
|
||||
|
||||
if p.author_id != v.id: abort(403)
|
||||
|
||||
p.private = False
|
||||
p.draft = False
|
||||
p.created_utc = int(time.time())
|
||||
g.db.add(p)
|
||||
|
||||
|
@ -70,7 +71,7 @@ def publish(pid, v):
|
|||
p.title_html = filter_emojis_only(p.title, golden=False, obj=p, author=p.author)
|
||||
p.body_html = sanitize(p.body, golden=False, limit_pings=100, obj=p, author=p.author)
|
||||
|
||||
if p.private or not complies_with_chud(p):
|
||||
if p.draft or not complies_with_chud(p):
|
||||
abort(403, f'You have to include "{p.author.chud_phrase}" in your post!')
|
||||
|
||||
notify_users = NOTIFY_USERS(f'{p.title} {p.body}', v, ghost=p.ghost, obj=p, followers_ping=False)
|
||||
|
@ -138,8 +139,8 @@ def post_id(pid, v, anything=None, hole=None):
|
|||
comments, output = get_comments_v_properties(v, None, Comment.parent_post == p.id, Comment.level < 10)
|
||||
|
||||
if sort == "hot":
|
||||
pinned = [c[0] for c in comments.filter(Comment.stickied != None).order_by(Comment.created_utc.desc())]
|
||||
comments = comments.filter(Comment.stickied == None)
|
||||
pinned = [c[0] for c in comments.filter(Comment.pinned != None).order_by(Comment.created_utc.desc())]
|
||||
comments = comments.filter(Comment.pinned == None)
|
||||
|
||||
comments = comments.filter(Comment.level == 1)
|
||||
comments = sort_objects(sort, comments, Comment)
|
||||
|
@ -148,8 +149,8 @@ def post_id(pid, v, anything=None, hole=None):
|
|||
comments = g.db.query(Comment).filter(Comment.parent_post == p.id)
|
||||
|
||||
if sort == "hot":
|
||||
pinned = comments.filter(Comment.stickied != None).order_by(Comment.created_utc.desc()).all()
|
||||
comments = comments.filter(Comment.stickied == None)
|
||||
pinned = comments.filter(Comment.pinned != None).order_by(Comment.created_utc.desc()).all()
|
||||
comments = comments.filter(Comment.pinned == None)
|
||||
|
||||
comments = comments.filter(Comment.level == 1)
|
||||
comments = sort_objects(sort, comments, Comment)
|
||||
|
@ -224,7 +225,7 @@ def view_more(v, pid, sort, offset):
|
|||
comments, output = get_comments_v_properties(v, None, Comment.parent_post == pid, Comment.id.notin_(ids), Comment.level < 10)
|
||||
|
||||
if sort == "hot":
|
||||
comments = comments.filter(Comment.stickied == None)
|
||||
comments = comments.filter(Comment.pinned == None)
|
||||
|
||||
comments = comments.filter(Comment.level == 1)
|
||||
comments = sort_objects(sort, comments, Comment)
|
||||
|
@ -238,7 +239,7 @@ def view_more(v, pid, sort, offset):
|
|||
)
|
||||
|
||||
if sort == "hot":
|
||||
comments = comments.filter(Comment.stickied == None)
|
||||
comments = comments.filter(Comment.pinned == None)
|
||||
|
||||
comments = sort_objects(sort, comments, Comment)
|
||||
|
||||
|
@ -321,7 +322,7 @@ def postprocess_post(post_url, post_body, post_body_html, pid, generate_thumb, e
|
|||
p.body_html = post_body_html
|
||||
g.db.add(p)
|
||||
|
||||
if not p.private and not edit:
|
||||
if not p.draft and not edit:
|
||||
execute_snappy(p, p.author)
|
||||
|
||||
g.db.commit()
|
||||
|
@ -591,7 +592,7 @@ def submit_post(v, hole=None):
|
|||
if SITE_NAME == 'WPD':
|
||||
p.cw = request.values.get("cw", False, bool)
|
||||
|
||||
if not p.private:
|
||||
if not p.draft:
|
||||
p.chudded = v.chud and hole != 'chudrama' and not (p.is_longpost and not v.chudded_by)
|
||||
p.queened = v.queen and not p.is_longpost
|
||||
p.sharpened = v.sharpen and not p.is_longpost
|
||||
|
@ -660,7 +661,7 @@ def submit_post(v, hole=None):
|
|||
else:
|
||||
abort(415)
|
||||
|
||||
if not p.private and not complies_with_chud(p):
|
||||
if not p.draft and not complies_with_chud(p):
|
||||
p.is_banned = True
|
||||
p.ban_reason = "AutoJanny"
|
||||
|
||||
|
@ -695,7 +696,7 @@ def submit_post(v, hole=None):
|
|||
autojanny.comment_count += 1
|
||||
g.db.add(autojanny)
|
||||
|
||||
if not p.private:
|
||||
if not p.draft:
|
||||
notify_users = NOTIFY_USERS(f'{title} {body}', v, ghost=p.ghost, obj=p, followers_ping=False)
|
||||
|
||||
if notify_users:
|
||||
|
@ -710,8 +711,8 @@ def submit_post(v, hole=None):
|
|||
g.db.add(v)
|
||||
|
||||
if v.id in PINNED_POSTS_IDS and not p.ghost and not (p.hole and p.hole_obj.stealth):
|
||||
p.stickied_utc = time.time() + PINNED_POSTS_IDS[v.id] * 3600
|
||||
p.stickied = "AutoJanny"
|
||||
p.pinned_utc = time.time() + PINNED_POSTS_IDS[v.id] * 3600
|
||||
p.pinned = "AutoJanny"
|
||||
|
||||
cache.delete_memoized(frontlist)
|
||||
cache.delete_memoized(userpagelisting)
|
||||
|
@ -756,9 +757,9 @@ def delete_post_pid(pid, v):
|
|||
|
||||
if not p.deleted_utc:
|
||||
p.deleted_utc = int(time.time())
|
||||
p.is_pinned = False
|
||||
p.stickied = None
|
||||
p.stickied_utc = None
|
||||
p.profile_pinned = False
|
||||
p.pinned = None
|
||||
p.pinned_utc = None
|
||||
|
||||
g.db.add(p)
|
||||
|
||||
|
@ -917,7 +918,7 @@ def unsave_post(pid, v):
|
|||
|
||||
return {"message": "Post unsaved!"}
|
||||
|
||||
@app.post("/pin/<int:post_id>")
|
||||
@app.post("/profile_pin/<int:post_id>")
|
||||
@limiter.limit('1/second', scope=rpath)
|
||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
|
@ -927,10 +928,10 @@ def pin_post(post_id, v):
|
|||
p = get_post(post_id)
|
||||
if p:
|
||||
if v.id != p.author_id: abort(403, "Only the post author can do that!")
|
||||
p.is_pinned = not p.is_pinned
|
||||
p.profile_pinned = not p.profile_pinned
|
||||
g.db.add(p)
|
||||
cache.delete_memoized(userpagelisting)
|
||||
if p.is_pinned: return {"message": "Post pinned!"}
|
||||
if p.profile_pinned: return {"message": "Post pinned!"}
|
||||
else: return {"message": "Post unpinned!"}
|
||||
return abort(404, "Post not found!")
|
||||
|
||||
|
@ -1023,7 +1024,7 @@ def edit_post(pid, v):
|
|||
if not v.can_edit(p): abort(403)
|
||||
|
||||
# Disable edits on things older than 1wk unless it's a draft or editor is a jannie
|
||||
if time.time() - p.created_utc > 31*24*60*60 and not p.private \
|
||||
if time.time() - p.created_utc > 31*24*60*60 and not p.draft \
|
||||
and v.admin_level < PERMS["IGNORE_1MONTH_EDITING_LIMIT"] and v.id not in EXEMPT_FROM_1MONTH_EDITING_LIMIT:
|
||||
abort(403, "You can't edit posts older than 1 month!")
|
||||
|
||||
|
@ -1044,7 +1045,7 @@ def edit_post(pid, v):
|
|||
abort(400, "Please enter a better title!")
|
||||
|
||||
|
||||
if not p.private:
|
||||
if not p.draft:
|
||||
notify_users = NOTIFY_USERS(f'{title} {body}', v, oldtext=f'{p.title} {p.body}', ghost=p.ghost, obj=p, followers_ping=False)
|
||||
if notify_users:
|
||||
cid, text = notif_comment_mention(p)
|
||||
|
@ -1093,7 +1094,7 @@ def edit_post(pid, v):
|
|||
gevent.spawn(postprocess_post, p.url, p.body, p.body_html, p.id, False, True)
|
||||
|
||||
|
||||
if not p.private and not complies_with_chud(p):
|
||||
if not p.draft and not complies_with_chud(p):
|
||||
abort(403, f'You have to include "{p.author.chud_phrase}" in your post!')
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ def searchposts(v):
|
|||
posts = posts.filter(
|
||||
Post.deleted_utc == 0,
|
||||
Post.is_banned == False,
|
||||
Post.private == False)
|
||||
Post.draft == False)
|
||||
|
||||
if 'author' in criteria:
|
||||
author = get_user(criteria['author'], v=v)
|
||||
|
@ -245,7 +245,7 @@ def searchcomments(v):
|
|||
comments = apply_time_filter(t, comments, Comment)
|
||||
|
||||
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
|
||||
private = [x[0] for x in g.db.query(Post.id).filter(Post.private == True)]
|
||||
private = [x[0] for x in g.db.query(Post.id).filter(Post.draft == True)]
|
||||
|
||||
comments = comments.filter(
|
||||
Comment.is_banned==False,
|
||||
|
|
|
@ -404,10 +404,10 @@ def all_upvoters_downvoters(v, username, vote_dir, is_who_simps_hates):
|
|||
votes = []
|
||||
votes2 = []
|
||||
if is_who_simps_hates:
|
||||
votes = g.db.query(Post.author_id, func.count(Post.author_id)).join(Vote).filter(Post.private == False, Post.ghost == False, Post.is_banned == False, Post.deleted_utc == 0, Vote.vote_type==vote_dir, Vote.user_id==id).group_by(Post.author_id).order_by(func.count(Post.author_id).desc()).all()
|
||||
votes = g.db.query(Post.author_id, func.count(Post.author_id)).join(Vote).filter(Post.draft == False, Post.ghost == False, Post.is_banned == False, Post.deleted_utc == 0, Vote.vote_type==vote_dir, Vote.user_id==id).group_by(Post.author_id).order_by(func.count(Post.author_id).desc()).all()
|
||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==vote_dir, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||
else:
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Post).filter(Post.private == False, Post.ghost == False, Post.is_banned == False, Post.deleted_utc == 0, Vote.vote_type==vote_dir, Post.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Post).filter(Post.draft == False, Post.ghost == False, Post.is_banned == False, Post.deleted_utc == 0, Vote.vote_type==vote_dir, Post.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==vote_dir, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
total_items = sum(votes.values())
|
||||
|
@ -954,10 +954,9 @@ def u_username(v, username):
|
|||
ids, total = userpagelisting(u, v=v, page=page, sort=sort, t=t)
|
||||
|
||||
if page == 1 and sort == 'new':
|
||||
sticky = []
|
||||
sticky = g.db.query(Post).filter_by(is_pinned=True, author_id=u.id, is_banned=False).all()
|
||||
if sticky:
|
||||
for p in sticky:
|
||||
pinned = []
|
||||
pinned = g.db.query(Post).filter_by(profile_pinned=True, author_id=u.id, is_banned=False).all()
|
||||
for p in pinned:
|
||||
ids = [p.id] + ids
|
||||
|
||||
listing = get_posts(ids, v=v)
|
||||
|
@ -992,7 +991,7 @@ def u_username(v, username):
|
|||
|
||||
@cache.memoize()
|
||||
def userpagelisting(u, v=None, page=1, sort="new", t="all"):
|
||||
posts = g.db.query(Post).filter_by(author_id=u.id, is_pinned=False).options(load_only(Post.id))
|
||||
posts = g.db.query(Post).filter_by(author_id=u.id, profile_pinned=False).options(load_only(Post.id))
|
||||
|
||||
if v.id != u.id and v.admin_level < PERMS['POST_COMMENT_MODERATION']:
|
||||
posts = posts.filter_by(is_banned=False, private=False, ghost=False)
|
||||
|
|
|
@ -173,8 +173,8 @@
|
|||
{%- include 'admin/shadowbanned_tooltip.html' -%}
|
||||
{% endwith %}
|
||||
|
||||
{% if c.stickied %}
|
||||
<i id='pinned-{{c.id}}'class="fas fa-thumbtack fa-rotate--45 pr-1 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{c.stickied}}" {% if c.stickied_utc %}data-onmouseover="pinned_timestamp('pinned-{{c.id}}')" data-timestamp={{c.stickied_utc}} data-nonce="{{g.nonce}}"{% endif %}></i>
|
||||
{% if c.pinned %}
|
||||
<i id='pinned-{{c.id}}'class="fas fa-thumbtack fa-rotate--45 pr-1 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{c.pinned}}" {% if c.pinned_utc %}data-onmouseover="pinned_timestamp('pinned-{{c.id}}')" data-timestamp={{c.pinned_utc}} data-nonce="{{g.nonce}}"{% endif %}></i>
|
||||
{% endif %}
|
||||
|
||||
{% if c.distinguished and not c.ghost %}
|
||||
|
@ -467,7 +467,7 @@
|
|||
{% set url = "" %}
|
||||
|
||||
{% if v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
{% set url = "sticky_comment" %}
|
||||
{% set url = "pin_comment" %}
|
||||
{% elif v.id == c.post.author_id %}
|
||||
{% set url = "pin_comment" %}
|
||||
{% elif v.mods_hole(c.post.hole) %}
|
||||
|
@ -475,9 +475,9 @@
|
|||
{% endif %}
|
||||
|
||||
{% if url != "" %}
|
||||
<button type="button" id="pin-{{c.id}}" class="dropdown-item list-inline-item {% if not c.stickied %}d-md-block{% endif %} text-muted d-none text-info" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/{{url}}/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}','d-md-block')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Pin</button>
|
||||
<button type="button" id="pin-{{c.id}}" class="dropdown-item list-inline-item {% if not c.pinned %}d-md-block{% endif %} text-muted d-none text-info" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/{{url}}/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}','d-md-block')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Pin</button>
|
||||
|
||||
<button type="button" id="unpin-{{c.id}}" class="dropdown-item list-inline-item {% if c.stickied %}d-md-block{% endif %} text-muted d-none text-info" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/un{{url}}/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}','d-md-block')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Unpin</button>
|
||||
<button type="button" id="unpin-{{c.id}}" class="dropdown-item list-inline-item {% if c.pinned %}d-md-block{% endif %} text-muted d-none text-info" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/un{{url}}/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}','d-md-block')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Unpin</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -683,11 +683,11 @@
|
|||
|
||||
{% if v.admin_level < PERMS['POST_COMMENT_MODERATION'] %}
|
||||
{% if c.parent_post and v.id == c.post.author_id %}
|
||||
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.stickied %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
|
||||
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.stickied %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unpin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
|
||||
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.pinned %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
|
||||
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.pinned %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unpin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
|
||||
{% elif v.mods_hole(c.post.hole) %}
|
||||
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.stickied %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin_comment_mod/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
|
||||
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.stickied %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unpin_comment_mod/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
|
||||
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.pinned %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin_comment_mod/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
|
||||
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.pinned %}d-none{% endif %} text-info" data-bs-target="#actionsModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unpin_comment_mod/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -733,8 +733,8 @@
|
|||
<button type="button" id="undistinguish2-{{c.id}}" class="list-group-item {% if not c.distinguished %}d-none{% endif %} text-info" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/distinguish_comment/{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info mr-2"></i>Undistinguish</button>
|
||||
{% endif %}
|
||||
|
||||
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.stickied %}d-none{% endif %} text-info" data-bs-target="#adminModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/sticky_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
|
||||
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.stickied %}d-none{% endif %} text-info" data-bs-target="#adminModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unsticky_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
|
||||
<button type="button" id="pin2-{{c.id}}" class="list-group-item {% if c.pinned %}d-none{% endif %} text-info" data-bs-target="#adminModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Pin</button>
|
||||
<button type="button" id="unpin2-{{c.id}}" class="list-group-item {% if not c.pinned %}d-none{% endif %} text-info" data-bs-target="#adminModal-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unpin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info mr-2"></i>Unpin</button>
|
||||
|
||||
{% if FEATURES['NSFW_MARKING'] %}
|
||||
<button type="button" id="mark2-{{c.id}}" class="{% if c.nsfw %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger mr-2"></i>Mark NSFW</button>
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
|
||||
<div id="post-root" class="col-12">
|
||||
|
||||
<div class="card border-0 mt-3 {% if p.stickied %}stickied{% endif %} {% if voted == 1 %}upvoted{% elif voted==-1 %} downvoted{% endif %}">
|
||||
<div class="card border-0 mt-3 {% if p.pinned %}pinned{% endif %} {% if voted == 1 %}upvoted{% elif voted==-1 %} downvoted{% endif %}">
|
||||
<div id="post-{{p.id}}" class="actual-post {% if p.ghost %}ghost-post{% endif %} {% if p.is_banned %}banned{% endif %} {% if p.deleted_utc %}deleted {% endif %} d-flex flex-row-reverse flex-nowrap justify-content-end">
|
||||
|
||||
{% if p.thumb_url and not p.deleted_utc and not p.is_image and not p.is_video and not p.is_audio and not p.embed %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% if v and v.id == p.author_id and p.private %}
|
||||
{% if v and v.id == p.author_id and p.draft %}
|
||||
<button type="button" class="list-inline-item" data-areyousure="postToastReload(this,'/publish/{{p.id}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)"><i class="fas fa-globe"></i>Publish</button>
|
||||
{% endif %}
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
|||
|
||||
{% if v and v.id == p.author_id %}
|
||||
{% if request.path.startswith('/@') %}
|
||||
<button type="button" id="pin-profile-{{p.id}}" class="{% if p.is_pinned %}d-none{% endif %} list-inline-item" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin/{{p.id}}','unpin-profile-{{p.id}}','pin-profile-{{p.id}}','d-none')"><i class="fas fa-thumbtack fa-rotate--45"></i>Pin to profile</button>
|
||||
<button type="button" id="unpin-profile-{{p.id}}" class="{% if not p.is_pinned %}d-none{% endif %} list-inline-item" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin/{{p.id}}','unpin-profile-{{p.id}}','pin-profile-{{p.id}}','d-none')"><i class="fas fa-thumbtack fa-rotate--45"></i>Unpin from profile</button>
|
||||
<button type="button" id="pin-profile-{{p.id}}" class="{% if p.profile_pinned %}d-none{% endif %} list-inline-item" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/profile_pin/{{p.id}}','unpin-profile-{{p.id}}','pin-profile-{{p.id}}','d-none')"><i class="fas fa-thumbtack fa-rotate--45"></i>Pin to profile</button>
|
||||
<button type="button" id="unpin-profile-{{p.id}}" class="{% if not p.profile_pinned %}d-none{% endif %} list-inline-item" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/profile_pin/{{p.id}}','unpin-profile-{{p.id}}','pin-profile-{{p.id}}','d-none')"><i class="fas fa-thumbtack fa-rotate--45"></i>Unpin from profile</button>
|
||||
{% endif %}
|
||||
|
||||
<button type="button" id="delete2-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} list-inline-item" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" data-nonce="{{g.nonce}}" data-onclick="delete_postModal('{{p.id}}')"><i class="fas fa-trash-alt"></i>Delete</button>
|
||||
|
@ -64,8 +64,8 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
<button type="button" id="pin-{{p.id}}" class="dropdown-item {% if p.stickied and not p.stickied_utc %}d-none{% endif %} list-inline-item text-info" data-nonce="{{g.nonce}}" data-onclick="pinPost(this, '{{p.id}}')"><i class="fas fa-thumbtack fa-rotate--45"></i>Pin {% if p.stickied_utc %}permanently{% else %}for 1 hour{% endif %}</button>
|
||||
<button type="button" id="unpin-{{p.id}}" class="dropdown-item {% if not p.stickied %}d-none{% endif %} list-inline-item text-info" data-nonce="{{g.nonce}}" data-onclick="unpinPost(this, '{{p.id}}')"><i class="fas fa-thumbtack fa-rotate--45"></i>Unpin</button>
|
||||
<button type="button" id="pin-{{p.id}}" class="dropdown-item {% if p.pinned and not p.pinned_utc %}d-none{% endif %} list-inline-item text-info" data-nonce="{{g.nonce}}" data-onclick="pinPost(this, '{{p.id}}')"><i class="fas fa-thumbtack fa-rotate--45"></i>Pin {% if p.pinned_utc %}permanently{% else %}for 1 hour{% endif %}</button>
|
||||
<button type="button" id="unpin-{{p.id}}" class="dropdown-item {% if not p.pinned %}d-none{% endif %} list-inline-item text-info" data-nonce="{{g.nonce}}" data-onclick="unpinPost(this, '{{p.id}}')"><i class="fas fa-thumbtack fa-rotate--45"></i>Unpin</button>
|
||||
{% endif %}
|
||||
|
||||
{% if v.mods_hole(p.hole) %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% if v.id == p.author_id and p.private %}
|
||||
{% if v.id == p.author_id and p.draft %}
|
||||
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-areyousure="postToastReload(this,'/publish/{{p.id}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)" data-dismiss="modal">
|
||||
<i class="fas fa-globe text-center text-muted mr-2"></i>Publish
|
||||
</button>
|
||||
|
@ -31,8 +31,8 @@
|
|||
<button type="button" id="unsave2-{{p.id}}" class="{% if not p.id in v.saved_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unsave_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save text-center text-muted mr-2"></i>Unsave {% if p.num_savers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of users who saved this post">[{{p.num_savers}}]</span>{% endif %}</button>
|
||||
|
||||
{% if v.id == p.author_id and request.path.startswith('/@') %}
|
||||
<button type="button" id="pin-profile2-{{p.id}}" class="{% if p.is_pinned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-muted text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin/{{p.id}}','pin-profile2-{{p.id}}','unpin-profile2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center mr-2"></i>Pin to profile</button>
|
||||
<button type="button" id="unpin-profile2-{{p.id}}" class="{% if not p.is_pinned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-muted text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/pin/{{p.id}}','pin-profile2-{{p.id}}','unpin-profile2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center mr-2"></i>Unpin from profile</button>
|
||||
<button type="button" id="pin-profile2-{{p.id}}" class="{% if p.profile_pinned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-muted text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/profile_pin/{{p.id}}','pin-profile2-{{p.id}}','unpin-profile2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center mr-2"></i>Pin to profile</button>
|
||||
<button type="button" id="unpin-profile2-{{p.id}}" class="{% if not p.profile_pinned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-muted text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/profile_pin/{{p.id}}','pin-profile2-{{p.id}}','unpin-profile2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center mr-2"></i>Unpin from profile</button>
|
||||
{% endif %}
|
||||
|
||||
{% if v.id == p.author_id %}
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
<button type="button" id="pin2-{{p.id}}" class="{% if p.stickied and not p.stickied_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" data-nonce="{{g.nonce}}" data-onclick="pinPost(this,'{{p.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center text-primary mr-2"></i>Pin {% if p.stickied_utc %}permanently{% else %}for 1 hour{% endif %}</button>
|
||||
<button type="button" id="unpin2-{{p.id}}" class="{% if not p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" data-nonce="{{g.nonce}}" data-onclick="unpinPost(this,'{{p.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center text-primary mr-2"></i>Unpin</button>
|
||||
<button type="button" id="pin2-{{p.id}}" class="{% if p.pinned and not p.pinned_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" data-nonce="{{g.nonce}}" data-onclick="pinPost(this,'{{p.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center text-primary mr-2"></i>Pin {% if p.pinned_utc %}permanently{% else %}for 1 hour{% endif %}</button>
|
||||
<button type="button" id="unpin2-{{p.id}}" class="{% if not p.pinned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" data-nonce="{{g.nonce}}" data-onclick="unpinPost(this,'{{p.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center text-primary mr-2"></i>Unpin</button>
|
||||
|
||||
<button type="button" id="remove2-{{p.id}}" class="{% if p.is_banned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" data-nonce="{{g.nonce}}" data-onclick="removePost(this,'{{p.id}}','remove2-{{p.id}}','approve2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-ban text-center mr-2"></i>Remove</button>
|
||||
<button type="button" id="approve2-{{p.id}}" class="{% if not p.is_banned and request.path != '/admin/reported/posts' %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" data-nonce="{{g.nonce}}" data-onclick="approvePost(this,'{{p.id}}','remove2-{{p.id}}','approve2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-check text-center mr-2"></i>Approve</button>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
{{macros.reports(p, 'post')}}
|
||||
|
||||
<div id="post-{{p.id}}" class="actual-post card {% if u and p.is_pinned %}pinned-to-profile{% endif %} {% if p.ghost %}ghost-post{% endif %} {% if p.unread %}unread{% endif %} {% if p.is_banned %} banned{% endif %}{% if p.deleted_utc %} deleted{% endif %}{% if p.stickied %} stickied{% endif %}{% if voted == 1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}{% if p.nsfw %} nsfw{% endif %}">
|
||||
<div id="post-{{p.id}}" class="actual-post card {% if u and p.profile_pinned %}pinned-to-profile{% endif %} {% if p.ghost %}ghost-post{% endif %} {% if p.unread %}unread{% endif %} {% if p.is_banned %} banned{% endif %}{% if p.deleted_utc %} deleted{% endif %}{% if p.pinned %} pinned{% endif %}{% if voted == 1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}{% if p.nsfw %} nsfw{% endif %}">
|
||||
<div class="d-flex flex-row-reverse flex-md-row flex-nowrap" style="align-items:flex-start">
|
||||
<div class="voting my-2 d-none d-md-flex pr-2">
|
||||
{% if v %}
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
{%- include 'admin/shadowbanned_tooltip.html' -%}
|
||||
{% endwith %}
|
||||
|
||||
{% if p.stickied %}
|
||||
<i id='pinned-{{p.id}}' class="fas fa-thumbtack fa-rotate--45 pr-1 ml-1 mt-3 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{p.stickied}}" {% if p.stickied_utc %}data-onmouseover="pinned_timestamp('pinned-{{p.id}}')" data-timestamp={{p.stickied_utc}} data-nonce="{{g.nonce}}"{% endif %}></i>
|
||||
{% if p.pinned %}
|
||||
<i id='pinned-{{p.id}}' class="fas fa-thumbtack fa-rotate--45 pr-1 ml-1 mt-3 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{p.pinned}}" {% if p.pinned_utc %}data-onmouseover="pinned_timestamp('pinned-{{p.id}}')" data-timestamp={{p.pinned_utc}} data-nonce="{{g.nonce}}"{% endif %}></i>
|
||||
{% endif %}
|
||||
|
||||
{% if p.hole_pinned %}
|
||||
|
@ -60,14 +60,14 @@
|
|||
{%- endif -%}
|
||||
, speaking officially"></i>
|
||||
{% endif %}
|
||||
{% if p.is_pinned and request.path != '/' %}
|
||||
{% if p.profile_pinned and request.path != '/' %}
|
||||
<i class="fas fa-thumbtack fa-rotate--45 pr-1 ml-1 mt-3 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned to profile"></i>
|
||||
{% endif %}
|
||||
{% if p.nsfw %}<span class="badge badge-danger text-small-extra mr-1">NSFW</span>{% endif %}
|
||||
{% if p.is_bot %} <i class="fas fa-robot text-info" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bot"></i>{% endif %}
|
||||
{% if p.is_blocking and not p.ghost %}<i class="fas fa-user-minus text-warning" data-bs-toggle="tooltip" data-bs-placement="bottom" title="You're blocking this user."></i>{% endif %}
|
||||
{% if p.is_blocked and not p.ghost %}<i class="fas fa-user-minus text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="This user is blocking you."></i>{% endif %}
|
||||
{% if p.private %}<span class="mr-2 badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||
{% if p.draft %}<span class="mr-2 badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||
|
||||
{% if p.active_reports(v) %}
|
||||
<button type="button" class="btn btn-primary mx-1" style="padding:1px 5px; font-size:10px" data-nonce="{{g.nonce}}" data-toggleelement="#reports-{{p.id}}" data-toggleattr="d-none">{{p.active_reports(v)}} Report{{plural(p.active_reports(v))}}</button>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
alter table posts rename column private to draft;
|
||||
|
||||
alter table posts rename column is_pinned to profile_pinned;
|
||||
alter table posts rename column stickied to pinned;
|
||||
alter table posts rename column stickied_utc to pinned_utc;
|
||||
alter table comments rename column stickied to pinned;
|
||||
alter table comments rename column stickied_utc to pinned_utc;
|
||||
|
||||
alter index post_is_pinned_idx rename to post_profile_pinned_idx;
|
||||
alter index posts_stickied_idx rename to post_pinned_idex;
|
||||
alter index post_sticked_utc_idx rename to post_pinned_utc_idex;
|
||||
|
||||
alter index comment_sticked_utc_idx rename to comment_pinned_utc_idex;
|
29
schema.sql
29
schema.sql
|
@ -438,13 +438,13 @@ CREATE TABLE public.comments (
|
|||
app_id integer,
|
||||
sentto integer,
|
||||
bannedfor character varying(313),
|
||||
stickied character varying(40),
|
||||
pinned character varying(40),
|
||||
body character varying(10000),
|
||||
body_html character varying(40000),
|
||||
ban_reason character varying(25),
|
||||
realupvotes integer DEFAULT 1 NOT NULL,
|
||||
top_comment_id integer,
|
||||
stickied_utc integer,
|
||||
pinned_utc integer,
|
||||
ghost boolean DEFAULT false NOT NULL,
|
||||
slots_result character varying(36),
|
||||
blackjack_result character varying(860),
|
||||
|
@ -837,17 +837,17 @@ CREATE TABLE public.posts (
|
|||
deleted_utc integer DEFAULT 0 NOT NULL,
|
||||
is_approved integer,
|
||||
edited_utc integer DEFAULT 0 NOT NULL,
|
||||
is_pinned boolean DEFAULT false NOT NULL,
|
||||
profile_pinned boolean DEFAULT false NOT NULL,
|
||||
upvotes integer DEFAULT 1 NOT NULL,
|
||||
downvotes integer DEFAULT 0 NOT NULL,
|
||||
app_id integer,
|
||||
thumburl character varying(200),
|
||||
private boolean DEFAULT false NOT NULL,
|
||||
draft boolean DEFAULT false NOT NULL,
|
||||
views integer DEFAULT 0 NOT NULL,
|
||||
is_bot boolean DEFAULT false NOT NULL,
|
||||
bannedfor character varying(313),
|
||||
comment_count integer DEFAULT 0 NOT NULL,
|
||||
stickied character varying(40),
|
||||
pinned character varying(40),
|
||||
title character varying(500) NOT NULL,
|
||||
url character varying(2083),
|
||||
body character varying(100000),
|
||||
|
@ -857,7 +857,7 @@ CREATE TABLE public.posts (
|
|||
title_html character varying(1500) NOT NULL,
|
||||
realupvotes integer,
|
||||
flair character varying(350),
|
||||
stickied_utc integer,
|
||||
pinned_utc integer,
|
||||
ghost boolean DEFAULT false NOT NULL,
|
||||
hole character varying(25),
|
||||
new boolean,
|
||||
|
@ -1709,10 +1709,10 @@ CREATE INDEX comment_post_id_index ON public.comments USING btree (parent_post);
|
|||
|
||||
|
||||
--
|
||||
-- Name: comment_sticked_utc_idx; Type: INDEX; Schema: public; Owner: -
|
||||
-- Name: comment_pinned_utc_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX comment_sticked_utc_idx ON public.comments USING btree (stickied_utc);
|
||||
CREATE INDEX comment_pinned_utc_idx ON public.comments USING btree (pinned_utc);
|
||||
|
||||
|
||||
--
|
||||
|
@ -2094,10 +2094,10 @@ CREATE INDEX post_deleted_utc_idx ON public.posts USING btree (deleted_utc);
|
|||
|
||||
|
||||
--
|
||||
-- Name: post_is_pinned_idx; Type: INDEX; Schema: public; Owner: -
|
||||
-- Name: post_profile_pinned_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX post_is_pinned_idx ON public.posts USING btree (is_pinned);
|
||||
CREATE INDEX post_profile_pinned_idx ON public.posts USING btree (profile_pinned);
|
||||
|
||||
|
||||
--
|
||||
|
@ -2115,10 +2115,10 @@ CREATE INDEX post_nsfw_idx ON public.posts USING btree (nsfw);
|
|||
|
||||
|
||||
--
|
||||
-- Name: post_sticked_utc_idx; Type: INDEX; Schema: public; Owner: -
|
||||
-- Name: post_pinned_utc_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX post_sticked_utc_idx ON public.posts USING btree (stickied_utc);
|
||||
CREATE INDEX post_pinned_utc_idx ON public.posts USING btree (pinned_utc);
|
||||
|
||||
|
||||
--
|
||||
|
@ -2129,10 +2129,10 @@ CREATE INDEX posts_bump_utc_idx ON public.posts USING btree (bump_utc);
|
|||
|
||||
|
||||
--
|
||||
-- Name: posts_stickied_idx; Type: INDEX; Schema: public; Owner: -
|
||||
-- Name: posts_pinned_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX posts_stickied_idx ON public.posts USING btree (stickied);
|
||||
CREATE INDEX posts_pinned_idx ON public.posts USING btree (pinned);
|
||||
|
||||
|
||||
--
|
||||
|
@ -3073,4 +3073,3 @@ ALTER TABLE ONLY public.comments
|
|||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
|
|
Loading…
Reference in New Issue