예제 #1
0
    def decorated_view(*args, **kwargs):
        board_id = kwargs['board_id']

        if not Board.objects(id=board_id, is_deleted=False):
            return jsonify(message='없는 게시판입니다.'), 404

        return f(*args, **kwargs)
예제 #2
0
 def get_category(self):
     """
     게시판 카테고리 조회 API
     :return: 게시판 카테고리
     """
     boards = Board.objects(is_deleted=False)
     board_category = BoardCategorySchema(many=True).dump(boards)
     return {'category': board_category}, 200
예제 #3
0
    def delete(self, board_id):
        """
        게시판 삭제 API
        :param board_id: 게시판 objectId
        :return: message
        """
        if not g.master_role:
            return jsonify(message='권한이 없는 사용자입니다.'), 403

        board = Board.objects(id=board_id, is_deleted=False).get()
        board.update(is_deleted=True)

        return jsonify(message='삭제되었습니다.'), 200
예제 #4
0
    def update(self, board_id):
        """
        게시판 이름 수정 API
        :param board_id: 게시판 objectId
        :return: message
        """
        try:
            if not g.master_role:
                return jsonify(message='권한이 없는 사용자입니다.'), 403

            data = BoardUpdateSchema().load(json.loads(request.data))
            board = Board.objects(id=board_id, is_deleted=False).get()

            if board.is_duplicate(data['name']):
                return jsonify(message='이미 등록된 게시판입니다.'), 409

            board.update(**data)
            return '', 200

        except ValidationError as err:
            return err.messages, 422
예제 #5
0
 def get_board_id_and_name(self, obj):
     board_id = obj['board']
     return {"id": str(board_id),
             "name": Board.objects(id=board_id).get().name}
예제 #6
0
 def test_board_갯수가_증가한다(self, subject):
     total_board_count = Board.objects().count()
     assert total_board_count == 1
예제 #7
0
 def test_board이름이_입력값과_동일하다(self, subject, form):
     board_name = Board.objects().get().name
     assert board_name == form['name']
예제 #8
0
 def make_boards(self, data, **kwargs):
     if not Board.objects(name=data['name'], is_deleted=False):
         board = Board(**data)
         return board
     return False