Gain de points quand on créé un topic ou poste un message
This commit is contained in:
parent
f6be314ed7
commit
1be5ec93da
|
@ -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))
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue