unpin award

remotes/1693045480750635534/spooky-22
Aevann1 2021-10-21 01:37:53 +02:00
parent 792156c5ec
commit cbf7405c97
8 changed files with 94 additions and 14 deletions

View File

@ -64,6 +64,14 @@ if site_name == "Drama":
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
else:
AWARDS = {
@ -99,6 +107,14 @@ else:
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}

View File

@ -81,6 +81,14 @@ if site_name == "Drama":
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
else:
AWARDS = {
@ -116,6 +124,14 @@ else:
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
class User(Base):

View File

@ -192,12 +192,14 @@ def monthly(v):
grant_awards["fireflies"] = 10
grant_awards["train"] = 10
grant_awards["ban"] = 5
grant_awards["pin"] = 1
elif u.patron == 5 or u.patron == 8:
grant_awards["shit"] = 20
grant_awards["fireflies"] = 20
grant_awards["train"] = 20
grant_awards["ban"] = 10
grant_awards["pin"] = 2
grant_awards["unpin"] = 1
for name in grant_awards:
for count in range(grant_awards[name]):
@ -439,12 +441,15 @@ def badge_grant_post(v):
grant_awards["fireflies"] = 10
grant_awards["train"] = 10
grant_awards["ban"] = 5
grant_awards["pin"] = 1
elif badge_id == 25:
if user.discord_id: add_role(user, "5")
grant_awards["shit"] = 20
grant_awards["fireflies"] = 20
grant_awards["train"] = 20
grant_awards["ban"] = 10
if user.discord_id: add_role(user, "5")
grant_awards["shit"] = 20
grant_awards["fireflies"] = 20
grant_awards["train"] = 20
grant_awards["ban"] = 10
grant_awards["pin"] = 2
grant_awards["unpin"] = 1
if len(grant_awards):

View File

@ -69,6 +69,14 @@ def shop(v):
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
else:
AWARDS = {
@ -104,6 +112,14 @@ def shop(v):
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
query = g.db.query(
@ -194,6 +210,14 @@ def buy(v, award):
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
else:
AWARDS = {
@ -229,6 +253,14 @@ def buy(v, award):
"color": "text-warning",
"price": 750
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post.",
"icon": "fas fa-thumbtack",
"color": "text-black",
"price": 1000
},
}
if award not in AWARDS: abort(400)
@ -337,6 +369,14 @@ def award_post(pid, v):
post.stickied = f"t:{t}"
g.db.add(post)
cache.delete_memoized(frontlist)
elif kind == "unpin":
if not (post.stickied and post.stickied.startswith("t:")): abort(403)
t = int(post.stickied[2:]) - 3600
if time.time() > t:
post.stickied = None
cache.delete_memoized(frontlist)
else: post.stickied = f"t:{t}"
g.db.add(post)
post.author.received_award_count += 1
g.db.add(post.author)

View File

@ -515,11 +515,11 @@ def submit_post(v):
# filtered = dict((k, v) for k, v in qd.items() if not k.startswith('utm_'))
# new_url = ParseResult(scheme="https",
# netloc=parsed_url.netloc,
# path=parsed_url.path,
# params=parsed_url.params,
# query=urlencode(filtered, doseq=True),
# fragment=parsed_url.fragment)
# netloc=parsed_url.netloc,
# path=parsed_url.path,
# params=parsed_url.params,
# query=urlencode(filtered, doseq=True),
# fragment=parsed_url.fragment)
# url = urlunparse(new_url)
repost = g.db.query(Submission).options(lazyload('*')).filter(

View File

@ -328,12 +328,15 @@ def gumroad(v):
grant_awards["fireflies"] = 10
grant_awards["train"] = 10
grant_awards["ban"] = 5
grant_awards["pin"] = 1
elif tier == 5 or tier == 8:
if v.discord_id: add_role(v, "5")
grant_awards["shit"] = 20
grant_awards["fireflies"] = 20
grant_awards["train"] = 20
grant_awards["ban"] = 10
grant_awards["pin"] = 2
grant_awards["unpin"] = 1
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id

View File

@ -64,7 +64,7 @@
@media (min-width: 767.98px) {
.award-columns {
column-count: 7 !important;
column-count: 8 !important;
}
}
</style>

View File

@ -823,10 +823,10 @@
window.localStorage.setItem("comment-counts", JSON.stringify(comments))
{% endif %}
{% if p.stickied %}
{% if p.stickied %}
const pinned_info = document.getElementById('pinned-{{p.id}}')
{% if p.stickied.startswith('t:') %}
pinned_info.setAttribute("data-bs-original-title", `Pinned until ${Date({{p.stickied[2:]}}).toString()}`)
pinned_info.setAttribute("data-bs-original-title", `Pinned until ${new Date({{p.stickied[2:]}} * 1000).toString()}`)
{% else %}
pinned_info.setAttribute("data-bs-original-title", "Pinned by @{{p.stickied}}")
{%endif%}