def team_form_clothes(pid, tid): team, project, _redirect = check_the_team_and_project_are_existed(pid=pid, tid=tid) if _redirect: return _redirect if not (g.user['account']['_id'] in team['members'] or \ g.user['account']['_id'] in team['chiefs']): return redirect('/') if request.method == 'GET': return render_template('./form_clothes.html', project=project, team=team) elif request.method == 'POST': post_data = request.get_json() if post_data['casename'] == 'get': data = Form.get_clothes(pid=team['pid'], uid=g.user['account']['_id']) if not data: data = {'data': {'clothes': ''}} return jsonify({'clothes': data['data']['clothes']}) elif post_data['casename'] == 'post': if 'clothes' in post_data and post_data['clothes']: Form.update_clothes(pid=team['pid'], uid=g.user['account']['_id'], data={'clothes': post_data['clothes']}) return jsonify({})
def team_form_clothes(pid, tid): ''' Team form clothes ''' team, project, _redirect = check_the_team_and_project_are_existed(pid=pid, tid=tid) if _redirect: return _redirect if not (g.user['account']['_id'] in team['members'] or g.user['account']['_id'] in team['chiefs']): return redirect('/') if request.method == 'GET': return render_template('./form_clothes.html', project=project, team=team) if request.method == 'POST': post_data = request.get_json() if post_data['casename'] == 'get': data = Form.get_clothes(pid=team['pid'], uid=g.user['account']['_id']) in_action = False htg = '' if not data: data = { 'data': { 'clothes': '', 'htg': htg, 'in_action': in_action } } if project['action_date'] + 86400 * 10 >= arrow.now().timestamp(): in_action = True if 'htg' in data['data']: htg = data['data']['htg'] return jsonify({ 'clothes': data['data']['clothes'], 'htg': htg, 'in_action': in_action, }) if post_data['casename'] == 'post': if 'clothes' in post_data and post_data['clothes']: Form.update_clothes(pid=team['pid'], uid=g.user['account']['_id'], data={ 'clothes': post_data['clothes'], 'htg': post_data['htg'], }) return jsonify({}) return jsonify({})