code in 10 and 100 badges

pull/225/head
Aevann 2024-03-06 05:42:31 +02:00
parent 15e62e6b1f
commit a3c07db3a0
2 changed files with 19 additions and 2 deletions

View File

@ -26,9 +26,19 @@ class ArtSubmission(Base):
@property
@lazy
def badge_id(self):
def badge_id_1(self):
return 99 if self.kind == "sidebar" else 101
@property
@lazy
def badge_id_10(self):
return 331 if self.kind == "sidebar" else 333
@property
@lazy
def badge_id_100(self):
return 332 if self.kind == "sidebar" else 334
@property
@lazy
def resize(self):

View File

@ -107,7 +107,6 @@ def approve_art(v, id):
author = get_user(author)
entry.author_id = author.id
g.db.add(entry)
badge_grant(author, entry.badge_id)
entry_url = f"{SITE_FULL_IMAGES}/i/{SITE_NAME}/{entry.location_kind}/{entry.id}.webp"
@ -142,6 +141,14 @@ def approve_art(v, id):
entry.approved = True
all_by_author = g.db.query(ArtSubmission).filter_by(kind=entry.kind, author_id=author.id, approved=True).count()
if all_by_author >= 99:
badge_grant(badge_id=entry.badge_id_100, user=author)
elif all_by_author >= 9:
badge_grant(badge_id=entry.badge_id_10, user=author)
else:
badge_grant(badge_id=entry.badge_id_1, user=author)
return {"message": f"{entry.msg_kind} approved!"}
@app.post("/remove/art/<int:id>")