コード例 #1
0
 def get_dtl(self):
     result = super(Exam, self).to_dict()
     result = Region.bind_auto(result, 'name', 'city_id', 'id', 'city')
     result = Region.bind_auto(result, 'name', 'province_id', 'id', 'province')
     result = Region.bind_auto(result, 'name', 'area_id', 'id', 'area')
     result = School.bind_auto(result, 'name', 'school_id', 'id', 'school')
     return result
コード例 #2
0
    def get_exam(id):
        result = Exam.query.get(int(id))
        if result is not None:
            result = result.to_dict()
        else:
            return None
        result = Region.bind_auto(result, 'name', 'city_id', 'id', 'city')
        result = Region.bind_auto(result, 'name', 'province_id', 'id', 'province')
        result = Region.bind_auto(result, 'name', 'area_id', 'id', 'area')
        result = School.bind_auto(result, 'name', 'school_id', 'id', 'school')

        return result
コード例 #3
0
def list_quest_review_log():

    query = Preprocess.query.\
        filter_by(operator_id=g.user.id).\
        order_by(Preprocess.created_at.desc()).\
        join(Exam, Exam.id==Preprocess.exam_id)
    if request.args.get('name'):
        query = query.filter(
            Exam.name.like('%{}%'.format(request.args.get('name'))))
    if request.args.get('subject'):
        query = query.filter(Exam.subject == request.args.get('subject'))
    if request.args.get('paper_types'):
        query = query.filter(
            Exam.paper_types == request.args.get('paper_types'))
    if request.args.get('province_id'):
        query = query.filter(
            Exam.province_id == request.args.get('province_id'))
    if request.args.get('city_id'):
        query = query.filter(Exam.city_id == request.args.get('city_id'))
    if request.args.get('area_id'):
        query = query.filter(Exam.area_id == request.args.get('area_id'))
    if request.args.get('school_id'):
        query = query.filter(Exam.school_id == request.args.get('school_id'))
    if request.args.get('year'):
        query = query.filter(Exam.year == request.args.get('year'))
    if request.args.get('grade'):
        query = query.filter(Exam.grade == request.args.get('grade'))
    res = pagination(query)
    items = res.get('items', [])
    items = Exam.bind_auto(items, [
        'name', 'section', 'school_id', 'subject', 'grade', 'paper_types',
        'province_id', 'city_id', 'area_id'
    ])
    items = School.bind_auto(items, 'name', 'exam_school_id', 'id', 'school')
    items = Region.bind_auto(items, 'name', 'exam_province_id', 'id',
                             'province')
    items = Region.bind_auto(items, 'name', 'exam_city_id', 'id', 'city')
    items = Region.bind_auto(items, 'name', 'exam_area_id', 'id', 'area')
    res['items'] = items
    return render_api(res)