def jwc(): args=request.args token = args['token'] jwc_username = args['jwc_username'] jwc_password = args['jwc_password'] s=type(login(jwc_username,jwc_password)) if not s==type('string'): username=getUsernameFromToken(token) #token不通过 if not username: ret={ 'version': 1.0, 'status': 2, } return jsonify(ret) user = User.query.filter_by(username=username).one() data = json.loads(user.json) data['jwc_username']=jwc_username data['jwc_password']=jwc_password user.json = json.dumps(args) db.session.add(user) db.session.commit() ret={ 'version': 1.0, 'status': 0, } return jsonify(ret) else: ret={ 'version': 1.0, 'status': 1, } return jsonify(ret)
def set_info(): args=request.args token = args['token'] username=getUsernameFromToken(token) #token不通过 if not username: ret={ 'version': 1.0, 'status': 2, } return jsonify(ret) user = User.query.filter_by(username=username).one() data = json.loads(user.json) set_data={} set_list=["nickname","realname","sex","signature"] for key,value in args.items(): if key in set_list: print (key) set_data[key]=value data.update(set_data) user.json=json.dumps(data) db.session.add(user) db.session.commit() ret_data={} ret_data['version']=1.0 ret_data['status']=0 return jsonify(ret_data)
def set_background(): args=request.args print (args) token = args['token'] username=getUsernameFromToken(token) #token不通过 if not username: ret={ 'version': 1.0, 'status': 2, } return jsonify(ret) file = request.files['file'] if file: filename = username+'.png' filepath=os.path.join(app.config['BACKGROUND_FOLDER'], filename) file.save(os.path.join(app.config['BACKGROUND_FOLDER'], filename)) ret={ 'version': 1.0, 'status': 0, 'url': '/static/background/'+filename, } return jsonify(ret) return jsonify(ret_data)
def set_info(): args = request.args token = args['token'] username = getUsernameFromToken(token) #token不通过 if not username: ret = { 'version': 1.0, 'status': 2, } return jsonify(ret) user = User.query.filter_by(username=username).one() data = json.loads(user.json) set_data = {} set_list = ["nickname", "realname", "sex", "signature"] for key, value in args.items(): if key in set_list: print(key) set_data[key] = value data.update(set_data) user.json = json.dumps(data) db.session.add(user) db.session.commit() ret_data = {} ret_data['version'] = 1.0 ret_data['status'] = 0 return jsonify(ret_data)
def get_class_by_auth(): jwcpw = request.args['jwcpw'] token = request.args['token'] year = request.args['year'] term = request.args['term'] year, term = int(year), int(term) username = getUsernameFromToken(token) if not username: return jsonify(version=1.0, status='AuthNotPass') else: user = User.query.filter_by(username=username).one() data = json.loads(user.json) id, pw = data['jwcid'], jwcpw return jsonify(version=1.0, data=get_class_table2(id, pw, year, term))
def get_username(): args=request.args token = args['token'] username=getUsernameFromToken(token) #token不通过 if not username: ret={ 'version': 1.0, 'status': 2, } return jsonify(ret) ret={ 'version': 1.0, 'username':username, 'status': 0, } return jsonify(ret)
def get_username(): args = request.args token = args['token'] username = getUsernameFromToken(token) #token不通过 if not username: ret = { 'version': 1.0, 'status': 2, } return jsonify(ret) ret = { 'version': 1.0, 'username': username, 'status': 0, } return jsonify(ret)
def sync(): args = hebing(request.form, request.args) token = args.get('token') username = getUsernameFromToken(token) dic = delete(dic) return_val = dict( version=1.0, data=None ) q = User.query.filter_by(username=username).all() user = q[0] dic = json.loads(user.json) user.json = json.dumps(dic) db.session.add(user) db.session.commit() return_val['data'] = delete(dic) return jsonify(return_val)
def get_info(): args = request.args token = args['token'] username = args['username'] self_username = getUsernameFromToken(token) #token不通过 if not self_username: ret = { 'version': 1.0, 'status': 2, } return jsonify(ret) q = User.query.filter_by(username=username).all() #用户不存在 if len(q) == 0: ret = { 'version': 1.0, 'status': 4, } return jsonify(ret) user = q[0] data = json.loads(user.json) ret_data = {} ret_list = [ "nickname", "realname", "sex", "signature", "avatar", "background" ] for key, value in data.items(): if key in ret_list: ret_data[key] = value if data.has_key('tid'): ret_data['avatar'] = '/static/avatar/' + username + '-' + data[ 'tid'] + '.png' ret_data['background'] = '/static/background/' + username + '-' + data[ 'tid'] + '.png' ret_data['version'] = 1.0 ret_data['status'] = 0 return jsonify(ret_data)
def set_avatar(): args=request.args print (args) token = args['token'] import time tid=str(time.time()) username=getUsernameFromToken(token) #token不通过 if not username: ret={ 'version': 1.0, 'status': 2, } return jsonify(ret) user = User.query.filter_by(username=username).one() data = json.loads(user.json) data['tid']=tid user.json=json.dumps(data) db.session.add(user) db.session.commit() file = request.files['file'] if file: filename = username+'-'+tid+'.png' filepath=os.path.join(app.config['HEADER_FOLDER'], filename) file.save(os.path.join(app.config['HEADER_FOLDER'], filename)) ret={ 'version': 1.0, 'status': 0, 'url': "/static/avatar/"+filename, } return jsonify(ret) return jsonify(ret_data)
def get_info(): args=request.args token = args['token'] username = args['username'] self_username=getUsernameFromToken(token) #token不通过 if not self_username: ret={ 'version': 1.0, 'status': 2, } return jsonify(ret) q = User.query.filter_by(username=username).all() #用户不存在 if len(q)==0: ret={ 'version': 1.0, 'status': 4, } return jsonify(ret) user=q[0] data = json.loads(user.json) ret_data={} ret_list=["nickname","realname","sex","signature","avatar","background"] for key,value in data.items(): if key in ret_list: ret_data[key]=value if data.has_key('tid'): ret_data['avatar']='/static/avatar/'+username+'-'+data['tid']+'.png' ret_data['background']='/static/background/'+username+'-'+data['tid']+'.png' ret_data['version']=1.0 ret_data['status']=0 return jsonify(ret_data)
def set_avatar(): args = request.args print(args) token = args['token'] import time tid = str(time.time()) username = getUsernameFromToken(token) #token不通过 if not username: ret = { 'version': 1.0, 'status': 2, } return jsonify(ret) user = User.query.filter_by(username=username).one() data = json.loads(user.json) data['tid'] = tid user.json = json.dumps(data) db.session.add(user) db.session.commit() file = request.files['file'] if file: filename = username + '-' + tid + '.png' filepath = os.path.join(app.config['HEADER_FOLDER'], filename) file.save(os.path.join(app.config['HEADER_FOLDER'], filename)) ret = { 'version': 1.0, 'status': 0, 'url': "/static/avatar/" + filename, } return jsonify(ret) return jsonify(ret_data)