def deleteHistory(id): h = HistoryModel() history = h.getHistoryById(id) h.deleteHistory(id) # Send email to admins and author u = UserModel() user = u.getUserByUsername(history['username']) admins = u.getAllAdmins() for admin in admins: sendDeletedHistoryNotification(admin, history) if not user['admin']: sendDeletedHistoryNotification(user, history) return jsonify({'result': 'true'})