forked from rDrama/rDrama
posts: add MasterLawlz specific actions
parent
80eedbd58d
commit
ec1affcf85
|
@ -417,3 +417,33 @@ def execute_antispam_comment_check(body, v):
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
abort(403, "Too much spam!")
|
abort(403, "Too much spam!")
|
||||||
|
|
||||||
|
def execute_lawlz_actions(v:User, p:Submission):
|
||||||
|
if v.id != LAWLZ_ID: return
|
||||||
|
if SITE_NAME != 'rDrama': return
|
||||||
|
p.stickied_utc = int(time.time()) + 86400
|
||||||
|
p.stickied = v.username
|
||||||
|
p.distinguish_level = 6
|
||||||
|
p.flair = ":ben10: Required Reading"
|
||||||
|
pin_time = 'for 1 day'
|
||||||
|
ma_1=ModAction(
|
||||||
|
kind="pin_post",
|
||||||
|
user_id=v.id,
|
||||||
|
target_submission_id=p.id,
|
||||||
|
_note=pin_time
|
||||||
|
)
|
||||||
|
ma_2=ModAction(
|
||||||
|
kind="distinguish_post",
|
||||||
|
user_id=v.id,
|
||||||
|
target_submission_id=p.id
|
||||||
|
)
|
||||||
|
ma_3=ModAction(
|
||||||
|
kind="flair_post",
|
||||||
|
user_id=v.id,
|
||||||
|
target_submission_id=p.id,
|
||||||
|
_note=f'"{p.flair}"'
|
||||||
|
)
|
||||||
|
g.db.add(p)
|
||||||
|
g.db.add(ma_1)
|
||||||
|
g.db.add(ma_2)
|
||||||
|
g.db.add(ma_3)
|
||||||
|
|
|
@ -1251,7 +1251,8 @@ def unsticky_post(post_id, v):
|
||||||
post = get_post(post_id)
|
post = get_post(post_id)
|
||||||
if post.stickied:
|
if post.stickied:
|
||||||
if post.stickied.endswith('(pin award)'): abort(403, "Can't unpin award pins!")
|
if post.stickied.endswith('(pin award)'): abort(403, "Can't unpin award pins!")
|
||||||
|
if post.author_id == LAWLZ_ID: abort(403, "Can't unpin lawlzposts!")
|
||||||
|
|
||||||
post.stickied = None
|
post.stickied = None
|
||||||
post.stickied_utc = None
|
post.stickied_utc = None
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
|
@ -163,7 +163,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
|
||||||
|
|
||||||
|
|
||||||
if v: pins = pins.filter(Submission.author_id.notin_(v.userblocks))
|
if v: pins = pins.filter(Submission.author_id.notin_(v.userblocks))
|
||||||
|
if SITE_NAME == 'rDrama':
|
||||||
|
pins = pins.order_by(Submission.author_id == LAWLZ_ID)
|
||||||
pins = pins.order_by(Submission.created_utc.desc()).all()
|
pins = pins.order_by(Submission.created_utc.desc()).all()
|
||||||
|
|
||||||
posts = pins + posts
|
posts = pins + posts
|
||||||
|
|
|
@ -1024,6 +1024,8 @@ def submit_post(v, sub=None):
|
||||||
post.upvotes += 3
|
post.upvotes += 3
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
|
execute_lawlz_actions(v, post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
cache.delete_memoized(User.userpagelisting)
|
cache.delete_memoized(User.userpagelisting)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue