Esempio n. 1
0
    def get(self, category_id=None, user_id=None):
        """Retrieve all subject categories or a specific one

        :param category_id: uuid of the subject category
        :param user_id: user ID who do the request
        :return: {
            "subject_category_id": {
                "name": "name of the category",
                "description": "description of the category (optional)"
            }
        }
        :internal_api: get_subject_categories
        """
        data = ModelManager.get_subject_categories(user_id=user_id,
                                                   category_id=category_id)

        return {"subject_categories": data}
Esempio n. 2
0
    def get(self, category_id=None, user_id=None):
        """Retrieve all subject categories or a specific one

        :param category_id: uuid of the subject category
        :param user_id: user ID who do the request
        :return: {
            "subject_category_id": {
                "name": "name of the category",
                "description": "description of the category"
            }
        }
        :internal_api: get_subject_categories
        """
        try:
            data = ModelManager.get_subject_categories(user_id=user_id,
                                                       category_id=category_id)
        except Exception as e:
            logger.error(e, exc_info=True)
            return {"result": False, "error": str(e)}, 500
        return {"subject_categories": data}
Esempio n. 3
0
def get_subject_category(cat_id=None):
    from python_moondb.core import ModelManager
    category = ModelManager.get_subject_categories(user_id=None,
                                                   category_id=cat_id)
    return category