forum: balance XP of topic creation and deletion

This commit is contained in:
Lephe 2021-07-12 20:05:32 +02:00
parent 9f0cbc810b
commit 306f1bab64
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 4 additions and 2 deletions

View File

@ -87,6 +87,7 @@ def edit_post(postid):
def delete_post(postid):
next_page = request.referrer
p = Post.query.filter_by(id=postid).first_or_404()
xp = -1
if current_user.is_anonymous or not current_user.can_delete_post(p):
abort(403)
@ -94,10 +95,11 @@ def delete_post(postid):
# When deleting topics, return to forum page
if isinstance(p, Topic):
next_page = url_for('forum_page', f=p.forum)
xp = -2
if isinstance(p.author, Member):
amount = -3 if request.args.get('penalty') == 'True' else -1
p.author.add_xp(amount)
factor = 3 if request.args.get('penalty') == 'True' else 1
p.author.add_xp(xp * factor)
db.session.add(p.author)
p.delete()