Beispiel #1
0
    def generate_excel(self):
        wb, ws = self.ready_worksheet()

        for apply in self.model.objects:
            student = apply.student

            number_cell, name_cell, status_cell = get_cell_positions_from_student_number(student)

            stay_apply = StayApplyModel.objects(student=student).first()

            if stay_apply.value < 3:
                ws[number_cell] = None
                ws[name_cell] = None
                continue
            else:
                ws[number_cell] = student.number
                ws[name_cell] = student.name

            ws.column_dimensions['D'].width = 20
            ws.column_dimensions['H'].width = 20
            ws.column_dimensions['L'].width = 20
            ws.column_dimensions['P'].width = 20

            ws[status_cell] = self.get_status(apply)

        self.save_excel(wb)
Beispiel #2
0
    def testApplySuccess(self):
        # (1) 잔류신청
        resp = self._request()

        # (2) status code 201
        self.assertEqual(resp.status_code, 201)

        # (3) 데이터베이스 확인
        self.assertTrue(
            StayApplyModel.objects(student=self.student, value=self.value))
Beispiel #3
0
    def post(self):
        """
        잔류신청
        """
        student = g.user

        now = datetime.now()

        if current_app.testing or (now.weekday() == 6 and now.time() > time(20, 30)) or (0 <= now.weekday() < 3) or (now.weekday() == 3 and now.time() < time(22, 00)):
            # 신청 가능 범위
            # - 일요일 오후 8시 30분 이후부터 목요일 오후 10시까지
            # weekday는 월요일이 0, 일요일이 6
            value = int(request.form['value'])

            StayApplyModel.objects(student=student).delete()
            StayApplyModel(student=student, value=value, apply_date=datetime.now()).save()

            return Response('', 201)
        else:
            return Response('', 204)
Beispiel #4
0
    def get(self):
        """
        잔류신청 정보 조회
        """
        student = g.user

        apply = StayApplyModel.objects(student=student).first()

        return self.unicode_safe_json_response({
            'value': apply.value
        }, 200)
Beispiel #5
0
    def get(self):
        """
        외출신청 엑셀 다운로드
        """
        wb = Workbook()
        ws = wb.active

        ready_applyment_worksheet(ws)

        for apply in GoingoutApplyModel.objects:
            student = apply.student

            number_cell, name_cell, status_cell = get_cell_positions_from_student_number(
                student)

            stay_apply = StayApplyModel.objects(student=student).first()

            if stay_apply.value < 3:
                ws[number_cell] = None
                ws[name_cell] = None
                continue
            else:
                ws[number_cell] = student.number
                ws[name_cell] = student.name

            if apply.on_saturday and apply.on_sunday:
                status = '토요일, 일요일 외출'
            elif apply.on_saturday:
                status = '토요일 외출'
            elif apply.on_sunday:
                status = '일요일 외출'
            else:
                status = ''
            ws.column_dimensions['D'].width = 20
            ws.column_dimensions['H'].width = 20
            ws.column_dimensions['L'].width = 20
            ws.column_dimensions['P'].width = 20

            ws[status_cell] = status

        filename = 'goingout.xlsx'

        wb.save('{}'.format(filename))
        wb.close()

        resp = make_response(send_from_directory('../', filename))
        resp.headers.extend({'Cache-Control': 'no-cache'})

        return resp
Beispiel #6
0
    def get(self):
        """
        학생 잔류 신청 확인
        """
        stay = StayApplyModel.objects(student=g.user).first()

        if not stay:
            stay = StayApplyModel(
                student=g.user,
                value=4
            ).save()

        return {
            'value': stay.value
        }
Beispiel #7
0
    def generate_excel(self):
        wb, ws = self.ready_worksheet()

        for apply in self.model.objects:
            student = apply.student

            number_cell, name_cell, status_cell = get_cell_positions_from_student_number(
                student)

            ws[number_cell] = student.number
            ws[name_cell] = student.name

            apply = StayApplyModel.objects(student=student).first()

            ws[status_cell] = self.get_status(apply)

        self.save_excel(wb)
Beispiel #8
0
    def get(self):
        """
        잔류신청 엑셀 다운로드
        """
        wb = Workbook()
        ws = wb.active

        ready_applyment_worksheet(ws)

        for student in StudentModel.objects:
            number_cell, name_cell, status_cell = get_cell_positions_from_student_number(
                student)

            ws[number_cell] = student.number
            ws[name_cell] = student.name

            apply = StayApplyModel.objects(student=student).first()

            if not apply or apply.value == 4:
                status = '잔류'
            elif apply.value == 1:
                status = '금요 귀가'
            elif apply.value == 2:
                status = '토요 귀가'
            elif apply.value == 3:
                status = '토요 귀사'
            else:
                status = '잔류'

            ws[status_cell] = status

        filename = 'stay.xlsx'

        wb.save('{}'.format(filename))
        wb.close()

        resp = make_response(send_from_directory('../', filename))
        resp.headers.extend({'Cache-Control': 'no-cache'})

        return resp
Beispiel #9
0
    def get(self):
        """
        학생 신청 정보 확인
        """
        extension11 = ExtensionApply11Model.objects(student=g.user).first()
        extension12 = ExtensionApply12Model.objects(student=g.user).first()
        goingout = GoingoutApplyModel.objects(student=g.user).first()
        stay = StayApplyModel.objects(student=g.user).first()

        if not goingout:
            goingout = GoingoutApplyModel(
                student=g.user,
                on_saturday=False,
                on_sunday=False
            ).save()

        if not stay:
            stay = StayApplyModel(
                student=g.user,
                value=4
            ).save()

        return {
            'extension11': {
                'classNum': extension11.class_,
                'seatNum': extension11.seat
            } if extension11 else None,
            'extension12': {
                'classNum': extension12.class_,
                'seatNum': extension12.seat
            } if extension12 else None,
            'goingout': {
                'sat': goingout.on_saturday,
                'sun': goingout.on_sunday
            },
            'stay': stay.value
        }
Beispiel #10
0
 def get(self):
     """
     학생 잔류 신청 확인
     """
     return {'value': StayApplyModel.objects(student=g.user).first().value}