pinprovements
parent
a25169cbea
commit
548f2613c7
|
@ -5,16 +5,19 @@ function pinPost(t, id) {
|
|||
{
|
||||
},
|
||||
(xhr) => {
|
||||
if(xhr.status == 200) {
|
||||
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin permanently')
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
response = JSON.parse(xhr.response);
|
||||
length = response["length"];
|
||||
if (length == "permanently") {
|
||||
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin for 1 hour');
|
||||
t.classList.add('d-none');
|
||||
} else {
|
||||
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin permanently');
|
||||
}
|
||||
t.nextElementSibling.classList.remove('d-none');
|
||||
t.disabled = false;
|
||||
t.classList.remove("disabled");
|
||||
}
|
||||
else if(xhr.status == 201) {
|
||||
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin for 1 hour')
|
||||
t.classList.add('d-none')
|
||||
}
|
||||
t.nextElementSibling.classList.remove('d-none')
|
||||
t.disabled = false;
|
||||
t.classList.remove("disabled");
|
||||
}
|
||||
);
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -152,6 +152,7 @@ AGENDAPOSTER_MSG_HTML = """<p>Hi <a href="/id/{id}"><img loading="lazy" src="/pp
|
|||
|
||||
DISCORD_CHANGELOG_CHANNEL_IDS = [1022232469606498324]
|
||||
WPD_CHANNEL_ID = 1013990963846332456
|
||||
PIN_AWARD_TEXT = " (pin award)"
|
||||
|
||||
################################################################################
|
||||
### SITE SPECIFIC CONSTANTS
|
||||
|
|
|
@ -1121,7 +1121,7 @@ def remove_post(post_id, v):
|
|||
post = get_post(post_id)
|
||||
post.is_banned = True
|
||||
post.is_approved = None
|
||||
if post.stickied and not post.stickied.endswith('(pin award)'):
|
||||
if post.stickied and not post.stickied.endswith(PIN_AWARD_TEXT):
|
||||
post.stickied = None
|
||||
post.is_pinned = False
|
||||
post.ban_reason = v.username
|
||||
|
@ -1208,7 +1208,7 @@ def distinguish_post(post_id, v):
|
|||
def sticky_post(post_id, v):
|
||||
post = get_post(post_id)
|
||||
if post.is_banned: abort(403, "Can't sticky removed posts!")
|
||||
if post.stickied and post.stickied.endswith('(pin award)'):
|
||||
if post.stickied and post.stickied.endswith(PIN_AWARD_TEXT):
|
||||
abort(403, "Can't pin award pins!")
|
||||
|
||||
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count()
|
||||
|
@ -1243,15 +1243,14 @@ def sticky_post(post_id, v):
|
|||
|
||||
cache.delete_memoized(frontlist)
|
||||
|
||||
return {"message": f"Post pinned {pin_time}!"}, code
|
||||
return {"message": f"Post pinned {pin_time}!", "length": pin_time}, 201
|
||||
|
||||
@app.post("/unsticky/<post_id>")
|
||||
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
|
||||
def unsticky_post(post_id, v):
|
||||
|
||||
post = get_post(post_id)
|
||||
if post.stickied:
|
||||
if post.stickied.endswith('(pin award)'): abort(403, "Can't unpin award pins!")
|
||||
if post.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!")
|
||||
if post.author_id == LAWLZ_ID and post.stickied_utc and SITE_NAME == 'rDrama': abort(403, "Can't unpin lawlzposts!")
|
||||
|
||||
post.stickied = None
|
||||
|
@ -1302,7 +1301,7 @@ def unsticky_comment(cid, v):
|
|||
comment = get_comment(cid, v=v)
|
||||
|
||||
if comment.stickied:
|
||||
if comment.stickied.endswith("(pin award)"): abort(403, "Can't unpin award pins!")
|
||||
if comment.stickied.endswith(PIN_AWARD_TEXT): abort(403, "Can't unpin award pins!")
|
||||
|
||||
comment.stickied = None
|
||||
g.db.add(comment)
|
||||
|
|
|
@ -224,7 +224,7 @@ def award_thing(v, thing_type, id):
|
|||
if thing.stickied and thing.stickied_utc:
|
||||
thing.stickied_utc += 3600
|
||||
else:
|
||||
thing.stickied = f'{v.username} (pin award)'
|
||||
thing.stickied = f'{v.username}{PIN_AWARD_TEXT}'
|
||||
if thing_type == 'comment':
|
||||
thing.stickied_utc = int(time.time()) + 3600*6
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue