本文整理汇总了Python中apps.packages.TakesPackageService.get_take_by_take_no方法的典型用法代码示例。如果您正苦于以下问题:Python TakesPackageService.get_take_by_take_no方法的具体用法?Python TakesPackageService.get_take_by_take_no怎么用?Python TakesPackageService.get_take_by_take_no使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.packages.TakesPackageService
的用法示例。
在下文中一共展示了TakesPackageService.get_take_by_take_no方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_rewrite
# 需要导入模块: from apps.packages import TakesPackageService [as 别名]
# 或者: from apps.packages.TakesPackageService import get_take_by_take_no [as 别名]
def _update_rewrite(self, original):
"""Removes the reference from the rewritten story in published collection."""
rewrite_service = ArchiveRewriteService()
if original.get('rewrite_of') and original.get('event_id'):
rewrite_service._clear_rewritten_flag(original.get('event_id'),
original[config.ID_FIELD], 'rewritten_by')
# write the rewritten_by to the take before spiked
archive_service = get_resource_service(ARCHIVE)
published_service = get_resource_service('published')
takes_service = TakesPackageService()
takes_package = takes_service.get_take_package(original)
if takes_package and takes_package.get(SEQUENCE, 0) > 1 and original.get('rewritten_by'):
# get the rewritten by
rewritten_by = archive_service.find_one(req=None, _id=original.get('rewritten_by'))
# get the take
take_id = takes_service.get_take_by_take_no(original,
take_no=takes_package.get(SEQUENCE) - 1,
package=takes_package)
take = archive_service.find_one(req=None, _id=take_id)
# update the take and takes package with rewritten_by
if take.get('rewritten_by') != rewritten_by[config.ID_FIELD]:
if take.get(ITEM_STATE) in PUBLISH_STATES:
published_service.update_published_items(take_id, 'rewritten_by', rewritten_by[config.ID_FIELD])
archive_service.system_update(take[config.ID_FIELD],
{'rewritten_by': rewritten_by[config.ID_FIELD]}, take)
if takes_package.get('rewritten_by') != rewritten_by[config.ID_FIELD]:
if takes_package.get(ITEM_STATE) in PUBLISH_STATES:
published_service.update_published_items(takes_package.get(config.ID_FIELD),
'rewritten_by', rewritten_by[config.ID_FIELD])
archive_service.system_update(takes_package[config.ID_FIELD],
{'rewritten_by': rewritten_by[config.ID_FIELD]}, takes_package)
if rewritten_by.get('rewrite_of') != takes_package.get(config.ID_FIELD):
archive_service.system_update(rewritten_by[config.ID_FIELD],
{'rewrite_of': takes_package.get(config.ID_FIELD)},
rewritten_by)
elif original.get('rewritten_by') or (takes_package and takes_package.get('rewritten_by')):
# you are spike the story from which the rewrite was triggered.
# in this case both rewrite_of and rewritten_by are published.
rewrite_id = original.get('rewritten_by') or takes_package.get('rewritten_by')
rewritten_by = archive_service.find_one(req=None, _id=rewrite_id)
archive_service.system_update(rewrite_id, {'rewrite_of': None, 'rewrite_sequence': 0}, rewritten_by)