def cancel_like(): uid = g.user.uid form = LikeForm().validate_for_api() cid = form.data["art_id"] type = form.data["type"] Tap.cancel_like(uid, cid, type) if type != 400: Classic.cancel_like(cid) return Success()
def classic_add_latest(): temp = { 'content': '人生不能象做菜,把所有料准备好再下锅', 'fav_num': 11, 'image': 'http://bl.7yue.pro/images/movie.8.png', 'index': 8, 'like_status': 0, 'pubdate': '2018-06-22', 'title': '李安《饮食男女》', 'type': 100 } with db.auto_commit(): classic = Classic() classic.set_attrs(temp) db.session.add(classic) return "add success"
def get_favor(): start, count = offset_limit() member_id = get_current_member().id classic = Classic.get_favor(member_id, start, count) for model in classic['models']: model.like_status = True model._fields = [ 'id', 'type', 'summary', 'image', 'fav_nums', 'like_status' ] return jsonify(classic)
def get_detail(type, id): classic = Classic.get_detail(type, id) return jsonify(classic)
def get_previous(index): classic = Classic.get_previous(index) # classic_with_like_status(classic) return jsonify(classic)
def get_latest(): classic = Classic.get_latest() # classic_with_like_status(classic) return jsonify(classic)
def delete_classic(): form = CreateOrUpdateClassicForm().validate_for_api() Classic.remove_classic(form.data) return Success(msg='已删除期刊')
def update_classic(): form = CreateOrUpdateClassicForm().validate_for_api() Classic.new_or_edit_classic(form.data) return Success(msg='已加入期刊')
def get_classics(): start, count = paginate() classics = Classic.get_paginate_models(start, count) return jsonify(classics)
def get_my_favor(): res = Classic.my_favor() classic = ClassicCollection() result = classic.fill(res) return jsonify(result)
def get_favor_info(type, id): form = ClassicFavorForm(data={'type': type, 'id': id}).validate_for_api() res = Classic.favor_info(form.type.data, form.id.data) return jsonify(res)
def get_detail(type, id): form = ClassicDetailForm(data={'type': type, 'id': id}).validate_for_api() res = Classic().detail(form.type.data, form.id.data) classic = ClassicCollection() data = classic.fill_single(res) return jsonify(data)
def get_previous(index): form = ClassicForm(data={'index': index}).validate_for_api() res = Classic().previous(form.index.data) classic = ClassicCollection() data = classic.fill_single(res) return jsonify(data)
def get_latest(): res = Classic().latest classic = ClassicCollection() data = classic.fill_single(res) return jsonify(data)