本文整理汇总了Python中models.category.Category.init_from_category_id方法的典型用法代码示例。如果您正苦于以下问题:Python Category.init_from_category_id方法的具体用法?Python Category.init_from_category_id怎么用?Python Category.init_from_category_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.category.Category
的用法示例。
在下文中一共展示了Category.init_from_category_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import init_from_category_id [as 别名]
def post(self, *args, **kwargs):
category_id = self.get_angular_argument('id')
if not category_id:
self.on_error(**ErrorCodeMessage.category_not_exists)
return
category = Category.init_from_category_id(category_id)
if not category:
self.on_error(**ErrorCodeMessage.category_not_exists)
return
if category.recover():
self.on_success()
else:
self.on_error(**ErrorCodeMessage.database_error)
示例2: delete
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import init_from_category_id [as 别名]
def delete(self, category_id=0, *args, **kwargs):
"""删除"""
category_id = category_id
if not category_id:
self.on_error(**ErrorCodeMessage.category_not_exists)
return
category = Category.init_from_category_id(category_id)
if not category:
self.on_error(**ErrorCodeMessage.category_not_exists)
return
if category.delete():
self.on_success()
else:
self.on_error(**ErrorCodeMessage.database_error)
示例3: put
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import init_from_category_id [as 别名]
def put(self, *args, **kwargs):
"""改名"""
category_name = self.get_angular_argument('name')
category_id = self.get_angular_argument('id')
if not category_id:
self.on_error(**ErrorCodeMessage.category_not_exists)
return
category = Category.init_from_category_id(category_id)
if not category:
self.on_error(**ErrorCodeMessage.category_not_exists)
return
if not category_name:
self.on_error(**ErrorCodeMessage.category_name_illegal)
return
if category.edit_name(category_name):
self.on_success()
else:
self.on_error(**ErrorCodeMessage.database_error)