Пример #1
0
    def delete(self):
        """
        학생 11시 연장 신청 취소
        """
        if not (current_app.testing or can_apply_11()):
            return Response('', 204)

        ExtensionApply11Model.objects(student=g.user).delete()

        return Response('', 200)
Пример #2
0
    def delete(self):
        """
        11시 연장신청 취소
        """
        student = g.user

        now = datetime.now().time()

        if not current_app.testing and not APPLY_START < now < APPLY_END_11:
            # Not testing, can't apply
            return Response('', 204)

        ExtensionApply11Model.objects(student=student).delete()

        return Response('', 200)
Пример #3
0
    def get(self):
        """
        학생 11시 연장 신청 정보 조회
        """
        extension = ExtensionApply11Model.objects(student=g.user).first()

        return self.unicode_safe_json_dumps({
            'classNum': extension.class_,
            'seatNum': extension.seat
        }) if extension else Response('', 204)
Пример #4
0
    def get(self):
        """
        11시 연장신청 정보 조회
        """
        student = g.user

        apply = ExtensionApply11Model.objects(student=student)

        return ({
            'class_num': apply.class_,
            'seat_num': apply.seat
        }, 200) if apply else ('', 204)
Пример #5
0
    def post(self):
        """
        11시 연장신청
        """
        student = g.user

        now = datetime.now().time()

        if not current_app.testing and not APPLY_START < now < APPLY_END_11:
            # Not testing, can't apply
            return Response('', 204)

        class_ = int(request.form['class_num'])
        seat = int(request.form['seat_num'])

        ExtensionApply11Model.objects(student=student).delete()

        if ExtensionApply11Model.objects(class_=class_, seat=seat):
            return Response('', 204)

        ExtensionApply11Model(student=student, class_=class_, seat=seat, apply_date=datetime.now()).save()

        return Response('', 201)
Пример #6
0
def _create_extension_map(class_, hour):
    seat_count = 1

    map_ = MAPS[class_]
    for i, row in enumerate(map_):
        for j, seat in enumerate(row):
            if map_[i][j]:
                apply = ExtensionApply11Model.objects(class_=class_, seat=seat_count).first() if hour == 11 \
                    else ExtensionApply12Model.objects(class_=class_, seat=seat_count).first()

                if apply:
                    map_[i][j] = apply.student.name
                else:
                    map_[i][j] = seat_count

                seat_count += 1

    return map_
Пример #7
0
    def testAfterApply(self):
        extension_apply_11 = ExtensionApply11Model(student=self.student,
                                                   class_=1,
                                                   seat=15).save()

        extension_apply_12 = ExtensionApply12Model(student=self.student,
                                                   class_=3,
                                                   seat=13).save()

        goingout_apply = GoingoutApplyModel(student=self.student,
                                            on_saturday=True,
                                            on_sunday=False).save()

        stay_apply = StayApplyModel(student=self.student, value=1).save()

        # (1) 신청 정보 확인
        resp = self._request()

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

        # (3) response data
        self.assertDictEqual(
            resp.json, {
                'extension11': {
                    'classNum': extension_apply_11.class_,
                    'seatNum': extension_apply_11.seat
                },
                'extension12': {
                    'classNum': extension_apply_12.class_,
                    'seatNum': extension_apply_12.seat
                },
                'goingout': {
                    'sat': goingout_apply.on_saturday,
                    'sun': goingout_apply.on_sunday
                },
                'stay': stay_apply.value
            })
Пример #8
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
        }