예제 #1
0
    def post(self, category_id=None, user_id=None):
        """Create or update a object category.

        :param category_id: must not be used here
        :param user_id: user ID who do the request
        :request body: {
            "name": "name of the category (mandatory)",
            "description": "description of the category (optional)"
        }
        :return: {
            "object_category_id": {
                "name": "name of the category",
                "description": "description of the category (optional)"
            }
        }
        :internal_api: add_object_category
        """

        data = ModelManager.add_object_category(user_id=user_id,
                                                value=request.json)

        return {"object_categories": data}
예제 #2
0
파일: meta_data.py 프로젝트: Kryndex/moon
    def post(self, category_id=None, user_id=None):
        """Create or update a object category.

        :param category_id: must not be used here
        :param user_id: user ID who do the request
        :request body: {
            "name": "name of the category",
            "description": "description of the category"
        }
        :return: {
            "object_category_id": {
                "name": "name of the category",
                "description": "description of the category"
            }
        }
        :internal_api: add_object_category
        """
        try:
            data = ModelManager.add_object_category(user_id=user_id,
                                                    value=request.json)
        except Exception as e:
            logger.error(e, exc_info=True)
            return {"result": False, "error": str(e)}, 500
        return {"object_categories": data}
예제 #3
0
def add_object_category(cat_id=None, value=None):
    from python_moondb.core import ModelManager
    category = ModelManager.add_object_category(user_id=None,
                                                category_id=cat_id,
                                                value=value)
    return category