Exemple #1
0
def set_coach_positive(request):
    coach_name = request.POST['coachName']
    remark = "转正"
    result = CoachService.set_coach_positive(coach_name, request.user.username,
                                             remark)
    if result:
        return ext_success()
    return ext_fail()
Exemple #2
0
def delete_period(request):
    post_data = request.POST
    period_id = int(post_data['id'])
    result = PeriodService.delete(period_id)
    if result:
        return ext_success()
    else:
        return ext_fail()
Exemple #3
0
def set_coach_trial(request):
    coach_name = request.POST['coachName']
    remark = request.POST['remark']
    result = CoachService.set_coach_trial(coach_name, request.user.username,
                                          remark)
    if result:
        return ext_success()
    return ext_fail()
Exemple #4
0
def delete_class_template(request):
    post_data = request.POST
    class_template_id = int(post_data['id'])
    result = ClassTemplateService.delete(class_template_id)
    if result:
        return ext_success()
    else:
        return ext_fail()
Exemple #5
0
def cancel_coach_retraining(request):
    coach_name = request.POST['coachName']
    remark = "再培结束"
    result = CoachService.cancel_coach_retraining(coach_name,
                                                  request.user.username,
                                                  remark)
    if result:
        return ext_success()
    else:
        return ext_fail()
Exemple #6
0
def modify_student_to_another_class(request):
    """
    调班
    """
    student_name = request.GET.get('studentName')
    origin_class_id = request.GET.get('originClassId')
    target_class_id = request.GET.get('targetClassId')
    if not student_name or not origin_class_id or not target_class_id:
        return ext_fail(u'无法获取学生名/目标班级ID/原班级ID')

    try:
        origin_class_id = int(origin_class_id)
        target_class_id = int(target_class_id)
    except:
        return ext_fail(u'请输入正确的班级ID')

    remark = u'前台暂未要求输入备注原因'
    result = ClassAdminService.modify_student_to_another_class(
        student_name, origin_class_id, target_class_id, request.user.username,
        remark)
    if result != 1:
        messages = {
            0: u'数据错误,请重试',
            -1: u'调班失败: 该学员已在目标班级中',
            -2: u'调班失败:目标班级不存在或已结束',
            -3: u'调班失败: 目标班级不符',
            -4: u'调班失败: 本班级正在上课',
            -5: u'调班失败: 目标班级正在上课',
            -6: u'调班失败:目标班级剩余课次为0',
            -7: u'调班失败: 目标班级无剩余名额',
            -8: u'调班失败: 目标班型剩余课次不足',
            -9: u'调班失败: 教练学生冲突',
            -10: u'调班失败: 目标班型剩余名额不足',
            -11: u'调班失败: 当前时间已过调班有效时间',
            -12: u'调班失败: 未找到该学生合法的约课记录'
        }
        message = messages.get(result, u'操作失败, 请重试')
        return ext_fail(message)
    return ext_success()
Exemple #7
0
def invite_coach(request):
    task_id = int(request.POST['taskId'])
    coach_name = request.POST['coachName']
    result = ClassAdminService.invite_coach(task_id, coach_name)
    if result > 0:
        return ext_success()
    messages = {
        0: u'数据错误,请重试',
        -1: u'教练不存在,请检查数据后重试',
        -2: u'教练已被邀请或未设置可用时段,不能被邀请',
        -3: u'此教练会导致分班冲突'
    }
    message = messages.get(result, u'操作失败,请您重试')
    return ext_fail(message)
Exemple #8
0
def edit_period(request):
    post_data = request.POST
    data = {
        'id': int(post_data['id']),
        'seasonId': int(post_data['seasonId']),
        'gradeType': int(post_data['gradeType']),
        'startTime': period_str_to_int(post_data['startTime']),
        'endTime': period_str_to_int(post_data['endTime']),
    }
    result = PeriodService.update(data)
    if result:
        return ext_success()
    else:
        return ext_fail()
Exemple #9
0
def send_notification(request):
    """
    发送通知
    """
    alltarget = [u'coach', u'student_in_class', u'student_not_in_class']
    class_id = request.POST.get('classId')
    notification = request.POST.get('notification')
    target = request.POST.getlist('target')
    target = [alltarget.index(identify) for identify in target]
    if not notification or not target:
        return ext_fail()
    if ClassAdminService.send_notification(int(class_id), notification,
                                           target):
        message = u'通知发送成功'
    else:
        message = u'未查询到发送对象手机号, 未发送短信'
    return ext_success(message)
Exemple #10
0
def add_class_template(request):
    post_data = request.POST
    data = {
        'seasonId': int(post_data['seasonId']),
        'periodId': int(post_data['periodId']),
        'subjectId': int(post_data['subjectId']),
        'grade': int(post_data['grade']),
        'cycleDay': int(post_data['cycleDay']),
        'startTime': 0,
        'endTime': 0,
        'maxClassNum': int(post_data['maxClassNum']),
        'maxStudentNum': int(post_data['maxStudentNum']),
    }
    result = ClassTemplateService.add(data)
    if result > 0:
        return ext_success()
    else:
        return ext_fail()
Exemple #11
0
def add_season(request):
    post_data = request.POST
    year = int(post_data['year'])
    season_type = int(post_data['seasonType'])
    start_day = post_data['startDay']
    end_day = post_data['endDay']
    except_days = request.POST.getlist('exceptDays')
    data = {
        'year': year,
        'season_type': season_type,
        'start_day': start_day,
        'end_day': end_day,
        'except_days': [item for item in except_days if item]
    }
    result = SeasonService.add_season(data)
    if result > 0:
        return ext_success()
    else:
        return ext_fail()
Exemple #12
0
def add_period(request):
    post_data = request.POST
    p_list = []
    result = []
    for i in range(1, 7):
        startTime = 'startTime' + str(i)
        endTime = 'endTime' + str(i)
        if startTime in post_data.keys():
            p_list.append({
                'startTime': post_data[startTime],
                'endTime': post_data[endTime]
            })
    for item in p_list:
        data = {
            'seasonId': int(post_data['seasonId']),
            'gradeType': int(post_data['gradeType']),
            'startTime': period_str_to_int(item['startTime']),
            'endTime': period_str_to_int(item['endTime']),
        }
        result.append(PeriodService.add(data))
    if len(result) > 0:
        return ext_success()
    else:
        return ext_fail()