Ejemplo n.º 1
0
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})
Ejemplo n.º 2
0
def period_find(request):
    season_id = int(request.GET['seasonId'])
    grade_type = int(request.GET['gradeType'])
    data = PeriodService.get_by_season_and_grade_type(season_id, grade_type)
    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': len(data)})
Ejemplo n.º 3
0
def period_list(request):
    offset = int(request.GET['start'])
    limit = int(request.GET['limit'])
    data, total = PeriodService.get_period_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})
Ejemplo n.º 4
0
def class_template_enrollment_schedule(request):
    params = {}
    offset = int(request.GET['start'])
    limit = int(request.GET['limit'])
    data, total = ClassTemplateService.get_class_template_enrollment_schedule(
        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})
Ejemplo n.º 5
0
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})
Ejemplo n.º 6
0
def class_create_task_list(request):
    offset = int(request.GET['start'])
    limit = int(request.GET['limit'])
    data, total = ClassAdminService.get_class_create_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')
        item.isNear = item.taskStatus < 2 and __is_near(
            item.classDay, item.startTime)
    return ext_success({'rows': data, 'total': total})
Ejemplo n.º 7
0
def reservation_list(request):
    offset = int(request.GET['start'])
    limit = int(request.GET['limit'])
    parameters = {}
    data, total = ClassTemplateService.filter_reservation_list(
        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})
Ejemplo n.º 8
0
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})
Ejemplo n.º 9
0
def class_template_list(request):
    offset = int(request.GET['start'])
    limit = int(request.GET['limit'])
    args = request.GET
    parameters = {}
    if args.get('seasonId'):
        parameters['season_id'] = int(request.GET['seasonId'])
    if args.get('grade'):
        parameters['grade'] = int(request.GET['grade'])
    if args.get('subjectId'):
        parameters['subject_id'] = int(request.GET['subjectId'])
    if args.get('periodId'):
        parameters['period_id'] = int(request.GET['periodId'])
    data, total = ClassTemplateService.filter_class_templates(
        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})
Ejemplo n.º 10
0
def monitor_class_list(request):
    offset = int(request.GET['start'])
    limit = int(request.GET['limit'])
    coachOrStudent = int(request.GET['type'])
    # 1表示异常,0表示不异常
    unusual = int(request.GET['unusual'])
    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]
    if coachOrStudent == 0:
        if unusual:
            data, total = MonitorService.filter_unusual_coach_class(
                limit, offset, **parameters)
        else:
            data, total = MonitorService.filter_coach_class(
                limit, offset, **parameters)
    elif coachOrStudent == 1:
        if unusual:
            data, total = MonitorService.filter_unusual_student_class(
                limit, offset, **parameters)
        else:
            data, total = MonitorService.filter_student_class(
                limit, offset, **parameters)
    else:
        totol = 0
    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})
Ejemplo n.º 11
0
def export_class_create_tasks(request):
    book = xlwt.Workbook(encoding='utf8')
    sheet = book.add_sheet('sheet1')
    data, total = ClassAdminService.get_class_create_list(2000, 0)
    title_list = [
        '任务编号', '年级', '科目', '开班日期', '时段', '空余名额', '报名人数', '需组班数量', '已确认教练',
        '完成测试教练'
    ]
    row = 0
    today = arrow.now('+08:00')
    for title_item in title_list:
        sheet.write(0, row, title_item, style=xlwt.Style.default_style)
        row += 1
    start_line = 1
    for line_item in data:
        sheet.write(start_line,
                    0,
                    line_item.id,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    1,
                    __GRADES[line_item.grade],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    2,
                    __SUBJECTS[line_item.subjectId],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    3,
                    line_item.classDay,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    4,
                    "%s~%s" %
                    (period_int_to_time(line_item.startTime).strftime('%H:%M'),
                     period_int_to_time(line_item.endTime).strftime('%H:%M')),
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    5,
                    line_item.remainNum,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    6,
                    line_item.studentNum,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    7,
                    line_item.newClassNum,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    8,
                    line_item.acceptCoachNum,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    9,
                    line_item.testSuccessCoachNum,
                    style=xlwt.Style.default_style)
        start_line += 1
    sheet.write(start_line + 2, 0, "统计日期", style=xlwt.Style.default_style)
    today_str = today.format(u'YYYY年MM月DD日')
    sheet.write(start_line + 2, 1, today_str, style=xlwt.Style.default_style)
    response = HttpResponse(content_type='application/ms-excel')

    response[
        'Content-Disposition'] = 'attachment; filename=taskList%s.xls' % today.format(
            'YYYYMMDD')
    book.save(response)
    return response
Ejemplo n.º 12
0
def export_reservation_data(request):
    book = xlwt.Workbook(encoding='utf8')
    sheet = book.add_sheet('sheet1')
    season_map = __get_season_map()
    data, total = ClassTemplateService.filter_reservation_list(1000, 0)
    title_list = [
        '班型编号', '学季', '科目', '年级', '循环日', '时段', '最大开班数', '每班最大人数', '班型总人数',
        '最小教练需求数', '可用教练数', '已分班人数', '已报名还未分班人数', '累计报名人数'
    ]
    row = 0
    today = arrow.now('+08:00')
    for title_item in title_list:
        sheet.write(0, row, title_item, style=xlwt.Style.default_style)
        row += 1
    start_line = 1
    for line_item in data:
        sheet.write(start_line,
                    0,
                    line_item.id,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    1,
                    __trans_season_id_to_season_string(line_item.seasonId,
                                                       season_map),
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    2,
                    __SUBJECTS[line_item.subjectId],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    3,
                    __GRADES[line_item.grade],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    4,
                    __CYCLE_DAYS[line_item.cycleDay],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    5,
                    "%s~%s" %
                    (period_int_to_time(line_item.startTime).strftime('%H:%M'),
                     period_int_to_time(line_item.endTime).strftime('%H:%M')),
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    6,
                    line_item.maxClassNum,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    7,
                    line_item.maxStudentNum,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    8,
                    line_item.maxStudentInClass,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    9,
                    line_item.minNeededCoachNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    10,
                    line_item.usableCoachNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    11,
                    line_item.allotStudentNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    12,
                    line_item.unallotStudentNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    13,
                    line_item.allStudentNumber,
                    style=xlwt.Style.default_style)
        start_line += 1
    sheet.write(start_line + 2, 0, "统计日期", style=xlwt.Style.default_style)
    today_str = today.format(u'YYYY年MM月DD日')
    sheet.write(start_line + 2, 1, today_str, style=xlwt.Style.default_style)
    response = HttpResponse(content_type='application/ms-excel')

    response[
        'Content-Disposition'] = 'attachment; filename=reservation%s.xls' % today.format(
            'YYYYMMDD')
    book.save(response)
    return response
Ejemplo n.º 13
0
def export_excel_class_template_enrollment_schedule(request):
    book = xlwt.Workbook(encoding='utf8')
    sheet = book.add_sheet('sheet1')
    season_map = __get_season_map()
    data, total = ClassTemplateService.get_class_template_enrollment_schedule(
        500, 0)
    title_list = [
        '编号', '学季', '科目', '年级', '循环日', '时段', '招生名额', '占用名额报名人数', '报名本次课的学员',
        '剩余名额', '本次课剩余名额', '上次课需续约数', '上次课未续约数', '需要在本次课续约数', '上次课新约课总人数',
        '上周新约课总人数'
    ]
    row = 0
    today = arrow.now('+08:00')
    for title_item in title_list:
        sheet.write(0, row, title_item, style=xlwt.Style.default_style)
        row += 1
    start_line = 1
    for line_item in data:
        sheet.write(start_line,
                    0,
                    line_item.templateId,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    1,
                    __trans_season_id_to_season_string(line_item.seasonId,
                                                       season_map),
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    2,
                    __SUBJECTS[line_item.subjectId],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    3,
                    __GRADES[line_item.grade],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    4,
                    __CYCLE_DAYS[line_item.cycleDay],
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    5,
                    "%s~%s" %
                    (period_int_to_time(line_item.startTime).strftime('%H:%M'),
                     period_int_to_time(line_item.endTime).strftime('%H:%M')),
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    6,
                    line_item.totalNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    7,
                    line_item.usedNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    8,
                    line_item.currentClassNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    9,
                    line_item.totalRestNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    10,
                    line_item.currentRestNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    11,
                    line_item.lastClassContinueNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    12,
                    line_item.lastClassUnContinueNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    13,
                    line_item.currentContinueNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    14,
                    line_item.lastClassNewNumber,
                    style=xlwt.Style.default_style)
        sheet.write(start_line,
                    15,
                    line_item.lastWeekTotalNumber,
                    style=xlwt.Style.default_style)
        start_line += 1
    sheet.write(start_line + 2, 0, "统计日期", style=xlwt.Style.default_style)
    today_str = today.format(u'YYYY年MM月DD日')
    sheet.write(start_line + 2, 1, today_str, style=xlwt.Style.default_style)
    response = HttpResponse(content_type='application/ms-excel')

    response[
        'Content-Disposition'] = 'attachment; filename=schedule%s.xls' % today.format(
            'YYYYMMDD')
    book.save(response)
    return response