limit hole pins to 2 per poll

pull/142/head
Aevann 2023-03-15 08:24:48 +02:00
parent 9f44a3f9fb
commit dd509a00aa
1 changed files with 4 additions and 0 deletions

View File

@ -672,6 +672,10 @@ def hole_pin(v:User, pid):
if not v.mods(p.sub): abort(403)
num = db.query(Submission).filter(Submission.sub == p.sub, Submission.hole_pinned != None).count()
if num >= 2:
abort(403, f"You can only pin 2 posts to /h/{p.sub}")
p.hole_pinned = v.username
db.add(p)