def p_version(request): """ @api {get} /system/version [系统]检查版本 @apiGroup system @apiParamExample {json} 请求示例 {"type":客户端类型, "api":客户端当前内部版本号} type客户端类型: 9安卓学生 10安卓教师 11苹果学生 12苹果教师 13 H5学生 14 H5教师 15 H5活动 16 H5学测评学生 17 H5学测评教师 @apiSuccessExample {json} 成功返回 { "message": "", "next": "", "data": { "title": "同步课堂手机客户端", "last_version": "2.3.12", "release_date": "2016-06-27 10:55:04", "update": 2, # 0:不更新 1:选择性更新 2:强制更新 "content": "2.2.3巫妖王", "download": "http://file.tbkt.cn/upload_media/apk/tbkt_stu_android/tbkt_stu_android-release-16.apk" }, "response": "ok", "error": "" } @apiSuccessExample {json} 失败返回 { "message": "找不到该类型的版本信息", "next": "", "data": "", "response": "fail", "error": "" } """ args = request.QUERY.casts(type=int, api=int) type = args.type or 0 user_api = args.api or 0 version = db.slave.system_version.filter(type=type).order_by( 'api', 'release_date').last() if not version: return ajax.jsonp_fail(request, message="找不到该类型的版本信息") data = Struct() data.last_version = version.version data.release_date = version.release_date data.title = version.title data.content = version.content data.download = version.download data.update = 0 # 0:不更新 1:选择性更新 2:强制更新 min_version = db.slave.system_version.filter(type=type, must=1).order_by( 'api', 'release_date').last() # 最低版本 if min_version and user_api < min_version.api: data.update = 2 # 用户版本小于系统设置最低版本则强制更新 elif user_api < version.api: # 小于最新版本 data.update = 2 if version.must else 1 # 根据最新版本设置返回是否需要强制更新 return ajax.jsonp_ok(request, data)
def _get_question(question_ids): """ get question :param question_ids: :return: """ if not isinstance(question_ids, (list, tuple)): return [] questions = db.tbkt_yw.yw_question.select( "content", "video", "image", "type", "show_parse", "category", "id", "article_text").filter(id__in=question_ids)[:] if not questions: return [] out = [] ask_map = get_ask(question_ids) for k, i in enumerate(questions): d = Struct() d.article_title = "" d.article_text = "" d.content = "" if i.type == 8: # 阅读理解 d.article_title = format_content(i.content) d.article_text = i.article_text else: # 不是阅读理解 d.content = i.content d.video = get_absurl(i.video).replace("//", "/") d.image = get_absurl(i.image).replace("//", "/") d.type = i.type d.category = i.category d.no = num_to_ch(k + 1) d.num = k + 1 d.asks = ask_map.get(i.id, []) d.id = i.id out.append(d) return out
def base_option(options): """ 选项基础数据 :param options: :return: """ if not options: return [] option = [] for i in options: d = Struct() d.id = i.id d.content = i.content d.image = get_absurl(i.image) d.is_right = i.is_right d.option = i.option d.ask_id = i.question_id d.link_id = i.link_id option.append(d) return option