def post(self, category_id=None, user_id=None): """Create or update a subject 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: { "subject_category_id": { "name": "name of the category", "description": "description of the category (optional)" } } :internal_api: add_subject_category """ data = ModelManager.add_subject_category(user_id=user_id, value=request.json) return {"subject_categories": data}
def post(self, category_id=None, user_id=None): """Create or update a subject 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: { "subject_category_id": { "name": "name of the category", "description": "description of the category" } } :internal_api: add_subject_category """ try: data = ModelManager.add_subject_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 {"subject_categories": data}
def add_subject_category(cat_id=None, value=None): from python_moondb.core import ModelManager category = ModelManager.add_subject_category(user_id=None, category_id=cat_id, value=value) return category