def get_rank_class_num(request): """ 获取等级对应的班级数量 """ data = ClassService.get_rank_class_num() total = len(data) return ext_success({'rows': data, 'total': total})
def change_coach_status_list(request): offset = int(request.GET['start']) limit = int(request.GET['limit']) data, total = ClassService.get_change_class_coach_list(limit, offset) for item in data: item.startTime = period_int_to_time(item.startTime).strftime('%H:%M') item.endTime = period_int_to_time(item.endTime).strftime('%H:%M') return ext_success({'rows': data, 'total': total})
def class_temporary_substitute_state(request): params = {} offset = int(request.GET['start']) limit = int(request.GET['limit']) data, total = ClassService.get_temporary_substitute_list( limit, offset, **params) for item in data: item.startTime = period_int_to_time(item.startTime).strftime('%H:%M') item.endTime = period_int_to_time(item.endTime).strftime('%H:%M') return ext_success({'rows': data, 'total': total})
def update_rank_class_num(request): fields = ('id', 'rank', 'spring_base_num', 'spring_max_num', 'winter_base_num', 'winter_max_num') data = json.loads(request.body) print data for item in data: if item.get('id') < 0: return ext_fail(u"数据中缺少ID") flag = {k in fields for k in item.keys()} if False in flag: return ext_fail(u"非法数据") if ClassService.update_rank_class_num(request.body): return ext_success() return ext_fail(u"数据错误")
def temp_replace_class_time(request): class_id = int(request.GET['class_id']) class_info = ClassService.get_class_by_id(class_id) lesson_plan = json.loads(class_info[0].lessonPlan) now = arrow.now('+08:00').strftime('%Y-%m-%d %X') output_days = [] for item in lesson_plan: cur_day = "%s %s" % (item['day'], item['start_time']) if now < cur_day: output_days.append({ 'classTime': item['day'], 'startTime': item['start_time'][:5], 'endTime': item['end_time'][:5] }) return ext_success({'rows': output_days, 'total': len(output_days)})
def class_list(request): offset = int(request.GET['start']) limit = int(request.GET['limit']) args = request.GET parameters = {} data = {} para_key = [ 'classID', 'templateID', 'teacherName', 'startDate', 'year', 'season', 'grade', 'subject' ] for key in para_key: if args.get(key): parameters[key] = request.GET[key] data, total = ClassService.filter_class(limit, offset, **parameters) for item in data: item.startTime = period_int_to_time(item.startTime).strftime('%H:%M') item.endTime = period_int_to_time(item.endTime).strftime('%H:%M') return ext_success({'rows': data, 'total': total})
def modify_class_for_student(request): para_list = request.POST student_id = int(para_list['student_id']) change_list = json.loads(para_list['change_list']) data = ClassService.modify_class_for_student(student_id, change_list) return ext_success({'rows': '', 'total': ''})
def student_info_in_class_by_class_id(request): class_id = int(request.GET['class_id']) data = ClassService.get_students_in_this_class(class_id) return ext_success({'rows': data, 'total': ''})