Ajout des trophées de post
This commit is contained in:
parent
9f5b607c45
commit
177fb7d84f
|
@ -294,8 +294,10 @@ class Member(User):
|
|||
|
||||
if context in ["new-post", "new-program", "new-tutorial", "new-test",
|
||||
None]:
|
||||
# TODO: Amount of posts by the user
|
||||
post_count = 0
|
||||
# Cannot use ORM tools because it adds circular import issues
|
||||
post_count = db.session.execute(f"""SELECT COUNT(*) FROM post
|
||||
INNER JOIN member ON member.id = post.author_id
|
||||
WHERE member.id = {self.id}""").first()[0]
|
||||
|
||||
levels = {
|
||||
20: "Premiers mots",
|
||||
|
|
|
@ -38,10 +38,10 @@ def forum_page(f):
|
|||
db.session.add(t)
|
||||
db.session.commit()
|
||||
|
||||
# Update member's xp
|
||||
# Update member's xp and trophies
|
||||
current_user.add_xp(V5Config.XP_POINTS['topic'])
|
||||
db.session.merge(current_user)
|
||||
db.session.commit()
|
||||
current_user.update_trophies('new-post')
|
||||
|
||||
|
||||
flash('Le sujet a bien été créé', 'ok')
|
||||
return redirect(url_for('forum_topic', f=f, t=t))
|
||||
|
|
|
@ -24,10 +24,9 @@ def forum_topic(f, t):
|
|||
db.session.add(c)
|
||||
db.session.commit()
|
||||
|
||||
# Update member's xp
|
||||
# Update member's xp and trophies
|
||||
current_user.add_xp(V5Config.XP_POINTS['comment'])
|
||||
db.session.merge(current_user)
|
||||
db.session.commit()
|
||||
current_user.update_trophies('new-post')
|
||||
|
||||
flash('Message envoyé', 'ok')
|
||||
# Redirect to empty the form
|
||||
|
|
Loading…
Reference in New Issue