当前位置: 首页>>代码示例>>Python>>正文


Python Deposition.update方法代码示例

本文整理汇总了Python中invenio_deposit.models.Deposition.update方法的典型用法代码示例。如果您正苦于以下问题:Python Deposition.update方法的具体用法?Python Deposition.update怎么用?Python Deposition.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invenio_deposit.models.Deposition的用法示例。


在下文中一共展示了Deposition.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_note_entry

# 需要导入模块: from invenio_deposit.models import Deposition [as 别名]
# 或者: from invenio_deposit.models.Deposition import update [as 别名]
def add_note_entry(obj, eng):
    """Add note entry to sip metadata on approval."""
    entry = {'value': '*Temporary entry*'} if obj.extra_data.get("core") \
        else {'value': '*Brief entry*'}
    deposition = Deposition(obj)
    metadata = deposition.get_latest_sip(sealed=True).metadata
    if metadata.get('public_notes') is None or not isinstance(metadata.get("public_notes"), list):
        metadata['public_notes'] = [entry]
    else:
        metadata['public_notes'].append(entry)
    deposition.update()
开发者ID:jma,项目名称:inspire-next,代码行数:13,代码来源:submission.py

示例2: user_pdf_get

# 需要导入模块: from invenio_deposit.models import Deposition [as 别名]
# 或者: from invenio_deposit.models.Deposition import update [as 别名]
def user_pdf_get(obj, eng):
    """Upload user PDF file, if requested."""
    if obj.extra_data.get('pdf_upload', False):
        fft = {'url': obj.extra_data.get('submission_data').get('pdf'),
               'docfile_type': 'INSPIRE-PUBLIC'}
        deposition = Deposition(obj)
        metadata = deposition.get_latest_sip(sealed=True).metadata
        if metadata.get('fft'):
            metadata['fft'].append(fft)
        else:
            metadata['fft'] = [fft]
        deposition.update()
        obj.log.info("PDF file added to FFT.")
开发者ID:jma,项目名称:inspire-next,代码行数:15,代码来源:submission.py

示例3: do_upgrade

# 需要导入模块: from invenio_deposit.models import Deposition [as 别名]
# 或者: from invenio_deposit.models.Deposition import update [as 别名]
def do_upgrade():
    """Implement your upgrades here."""
    from invenio_workflows.models import (
        BibWorkflowObject,
        Workflow,
        ObjectVersion
    )
    from invenio_workflows.registry import workflows
    from invenio_deposit.models import Deposition

    from inspire.dojson.utils import legacy_export_as_marc
    from inspire.dojson.hep import hep2marc
    from inspire.modules.workflows.dojson import bibfield
    from inspire.modules.workflows.models import Payload

    def rename_object_action(obj):
        if obj.get_action() == "arxiv_approval":
            obj.set_action("hep_approval", obj.get_action_message())

    def reset_workflow_object_states(obj):
        """Fix workflow positions and states.

        Old states from Prod/QA:
        {(), (0,), (5, 3, 14), (5, 3, 14, 0), (5, 3, 15), (5, 3, 15, 1)}

        {(),
         (0,),
         (5,),
         (5, 3, 1),
         (5, 3, 10),
         (5, 3, 11),
         (5, 3, 12),
         (5, 3, 14),
         (5, 3, 14, 0),
         (6, 3, 4)}

        OLD -> NEW
        5, 3, 14 -> 0 end
        5, 3, 10 -> 14, 0 halted
        """
        pos = obj.get_current_task()
        if obj.version == ObjectVersion.COMPLETED:
            obj.save(task_counter=[len(workflows.get(obj.workflow.name).workflow) - 1])
            return
        elif obj.version == ObjectVersion.RUNNING:
            # Running? Nah that cannot be.
            obj.version = ObjectVersion.ERROR
        try:
            obj.get_current_task_info()
        except IndexError:
            # The current task counter is Invalid
            obj.version = ObjectVersion.ERROR

        if obj.workflow.name == "process_record_arxiv":
            if tuple(pos) in [
                    (5,), (5, 3, 14), (5, 3, 14, 0), (5, 3, 15), (5, 3, 15, 1)]:
                pos = [len(workflows.get(obj.workflow.name).workflow) - 1]  # finished
            elif tuple(pos) in [(5, 3, 10), (5, 3, 11), (5, 3, 12)]:
                pos = [14, 0]  # halted
            elif len(pos) > 1 and pos[0] == 6:
                # We need to update pos from 6 to start of pre_processing part
                pos = [7]
            else:
                pos = [0]  # Nothing here, we go to start
            obj.save(task_counter=pos)

    # Special submission handling
    for deposit in BibWorkflowObject.query.filter(
            BibWorkflowObject.module_name == "webdeposit"):
        reset_workflow_object_states(deposit)
        d = Deposition(deposit)
        sip = d.get_latest_sip()
        if sip:
            sip.metadata = bibfield.do(sip.metadata)
            sip.package = legacy_export_as_marc(hep2marc.do(sip.metadata))
            d.update()
        deposit.save()

    # Special workflow handling
    workflows_to_fix = ["process_record_arxiv"]
    workflow_objects = []
    for workflow_name in workflows_to_fix:
        workflow_objects += BibWorkflowObject.query.join(
            BibWorkflowObject.workflow).filter(Workflow.name == workflow_name).all()

    for obj in workflow_objects:
        metadata = obj.get_data()
        reset_workflow_object_states(obj)
        rename_object_action(obj)
        if isinstance(metadata, six.string_types):
            # Ignore records that have string as data
            continue
        if 'drafts' in metadata:
            # New data model detected
            continue
        if hasattr(metadata, 'dumps'):
            metadata = metadata.dumps(clean=True)
        obj.data = bibfield.do(metadata)
        payload = Payload.create(
            type=obj.workflow.name,
#.........这里部分代码省略.........
开发者ID:jalavik,项目名称:inspire-next,代码行数:103,代码来源:inspire_2015_10_01_update_workflow_data.py


注:本文中的invenio_deposit.models.Deposition.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。