Gain de points quand on créé un topic ou poste un message

This commit is contained in:
Darks 2019-12-04 12:22:42 +01:00
parent f6be314ed7
commit 1be5ec93da
Signed by: Darks
GPG Key ID: F61F10FA138E797C
2 changed files with 10 additions and 1 deletions

View File

@ -1,13 +1,15 @@
from flask_login import current_user
from flask import request, redirect, url_for, abort, flash
from app import app, db
from config import V5Config
from app.utils.render import render
from app.forms.forum import TopicCreationForm
from app.models.forum import Forum
from app.models.topic import Topic
from app.models.thread import Thread
from app.models.comment import Comment
from app import app, db
@app.route('/forum/')
def forum_index():
@ -36,6 +38,9 @@ def forum_page(f):
db.session.add(t)
db.session.commit()
# Update member's xp
current_user.add_xp(V5Config.XP_POINTS['topic'])
flash('Le sujet a bien été créé', 'ok')
return redirect(url_for('forum_topic', f=f, t=t))

View File

@ -22,6 +22,10 @@ def forum_topic(f, t):
c = Comment(current_user, form.message.data, t.thread)
db.session.add(c)
db.session.commit()
# Update member's xp
current_user.add_xp(V5Config.XP_POINTS['comment'])
flash('Message envoyé', 'ok')
# Redirect to empty the form
return redirect(url_for('forum_topic', f=f, t=t))