コード例 #1
0
ファイル: models.py プロジェクト: jmartinm/inspire-next
    def create(cls, user=None, type=None, workflow_object=None):
        """
        Create a new deposition object.

        To persist the deposition, you must call save() on the created object.
        If no type is defined, the default deposition type will be assigned.

        @param user: The owner of the deposition
        @param type: Deposition type identifier.
        """
        if user is not None:
            user = user.get_id()

        if workflow_object:
            sip = SubmissionInformationPackage(metadata=workflow_object.data)
            workflow_object.data = {
                "sips": [sip.__getstate__()],
                "files": [],
                "title": "",
                "drafts": {},
                "type": type,
            }
            workflow_object.set_data(workflow_object.data)
            workflow_object.save()

        # Note: it is correct to pass 'type' and not 't' below to constructor.
        obj = cls(workflow_object=workflow_object, type=type, user_id=user)
        return obj
コード例 #2
0
ファイル: models.py プロジェクト: gitter-badger/inspire-next
    def create(cls, user=None, type=None, workflow_object=None):
        """Create a new payload object."""
        if user is not None:
            user = user.get_id()

        if workflow_object:
            sip = SubmissionInformationPackage(metadata=workflow_object.data)
            workflow_object.data = {
                "sips": [sip.__getstate__()],
                "files": [],
                "title": "",
                "drafts": {},
                "type": type,
            }
            workflow_object.set_data(workflow_object.data)
            if workflow_object.id is None:
                workflow_object.save()

        # Note: it is correct to pass 'type' and not 't' below to constructor.
        obj = cls(workflow_object=workflow_object, type=type, user_id=user)
        return obj
コード例 #3
0
ファイル: models.py プロジェクト: gitter-badger/inspire-next
 def __setstate__(self, state):
     """Deserialize deposition from state stored in BibWorkflowObject."""
     self.type = self.get_type(state['type'])  # FIXME only difference
     self.title = state['title']
     self.files = [
         DepositionFile.factory(
             f_state,
             uuid=f_state['id'],
             backend=DepositionStorage(self.id),
         )
         for f_state in state['files']
     ]
     self.drafts = dict(
         [(d_id, DepositionDraft.factory(d_state, d_id,
                                         deposition_ref=self))
          for d_id, d_state in state['drafts'].items()]
     )
     self.sips = [
         SubmissionInformationPackage.factory(s_state, uuid=s_state['id'])
         for s_state in state.get('sips', [])
     ]