def edit_user(): id = request.args.get("id") type = request.args.get("type") # get previous type previous_type = Database.get_user_by_id(id)['type'] Database.edit_user(id, type=type) # handle score addition # if normal -> admin: +2 # if normal -> moderator: +2 # if admin -> moderator: 0 # if moderator -> admin: 0 if previous_type == "normal" and (type == "admin" or type == "moderator"): Database.add_user_score(id, 2) return redirect_previous_url()