Beispiel #1
0
    def get(self):
        """
        설문지 리스트 조회
        """
        response = [mongo_to_dict(survey, ['target']) for survey in SurveyModel.objects]

        return self.unicode_safe_json_response(response)
Beispiel #2
0
    def get(self):
        """
        상벌점 규칙 목록 조회
        """
        response = [mongo_to_dict(rule) for rule in PointRuleModel.objects]

        return self.unicode_safe_json_response(response)
Beispiel #3
0
    def get(self):
        """
        시설고장신고 정보 조회
        """
        response = [
            mongo_to_dict(report, ['report_time'])
            for report in FacilityReportModel.objects
        ]

        return self.unicode_safe_json_response(response)
Beispiel #4
0
    def get_preview_item_as_response(self, model):
        post = model.objects(pinned=True).first()

        if not post:
            post = model.objects.first()
            if not post:
                return Response('', 204)

        data = mongo_to_dict(post, ['id'])

        return self.unicode_safe_json_response(data)
Beispiel #5
0
    def get_item_as_response(self, model, post_id):
        if len(post_id) != 24:
            return Response('', 204)

        post = model.objects(id=post_id).first()

        if not post:
            return Response('', 204)

        data = mongo_to_dict(post, ['id'])

        return self.unicode_safe_json_response(data)
Beispiel #6
0
    def get(self):
        """
        특정 학생의 상벌점 내역 조회
        """
        id = request.args['id']
        student = StudentModel.objects(id=id).first()
        if not student:
            return Response('', 204)

        response = [
            mongo_to_dict(history) for history in student.point_histories
        ]

        return self.unicode_safe_json_response(response)
Beispiel #7
0
    def get(self):
        """
        설문지의 질문 리스트 조회
        """
        survey_id = request.args['survey_id']
        if len(survey_id) != 24:
            return Response('', 204)

        survey = SurveyModel.objects(id=survey_id).first()
        if not survey:
            return Response('', 204)

        response = [mongo_to_dict(question, ['survey']) for question in QuestionModel.objects(survey=survey)]

        return self.unicode_safe_json_response(response)
Beispiel #8
0
    def get_list_as_response(self, model):
        data = [mongo_to_dict(obj, ['content']) for obj in model.objects]

        return self.unicode_safe_json_response(data)