Remove achievement when nobody endorses it
This commit is contained in:
parent
10b81c454f
commit
a284514663
1 changed files with 8 additions and 2 deletions
|
@ -36,5 +36,11 @@ def unendorse_achievement(id):
|
|||
return "Can't unendorse if you never endorsed..."
|
||||
achievement.endorsed_by.remove(current_user)
|
||||
db.session.add(achievement)
|
||||
if len(achievement.endorsed_by) == 0:
|
||||
db.session.delete(achievement)
|
||||
db.session.commit()
|
||||
return redirect(url_for("all_users"))
|
||||
else:
|
||||
db.session.commit()
|
||||
return redirect(url_for("get_achievement", id=id))
|
||||
|
||||
|
|
Loading…
Reference in a new issue