def remove_team_batch(): ids = [int(x) for x in request.args('id').split(',')] db.session.query(Teams).filter(Teams.id.in_(ids)).delete() db.session.commit() for id in ids: redis_store.hdel('teams', id) return jsonify({'message': '删除成功', 'type': 'success'})
def batch_delete_chal(): chalids = [int(x) for x in request.form.get('ids').split(',')] chal = Challenges.query.filter(Challenges.id._in(chalids)).first() if not chal: return abort(404) db.session.delete(chal) db.session.commit() redis_store.hdel('chals', chal.id) return jsonify({'code': '200', 'msg': '删除成功', 'type': 'success'})
def remove_team(): id = int(request.form['id']) team = Teams.query.filter(Teams.id == id).first() if not team: abort(404) db.session.delete(team) db.session.commit() if redis_store.hget('teams', request.form['id']): redis_store.hdel('teams', request.form['id']) return jsonify({'message': '删除成功', 'type': 'success'})
def delete_chal(): chalid=request.form.get('id') chal=Challenges.query.filter(Challenges.id==chalid).first() if not chal: return abort(404) db.session.delete(chal) db.session.commit() if redis_store.hget('chals',request.form['id']): redis_store.hdel('chals',request.form['id']) return jsonify({ 'code':200, 'msg':'删除成功', 'type':'fail' })