示例#1
0
文件: api.py 项目: krzysztof/zenodo
    def _publish_edited(self):
        """Publish the edited deposit with communities merging."""
        pid, record = self.fetch_published()
        dep_comms = self.get('communities', [])
        rec_comms = record.get('communities', [])

        # Already accepted communities which should be removed
        removals = set(rec_comms) - set(dep_comms)

        # New communities by user
        new_comms = set(dep_comms) - set(rec_comms)

        # New communities, which should be added automatically
        new_owned_comms = set(self._filter_by_owned_communities(new_comms))

        # Communities which are to be added to every published record
        auto_added = self._get_auto_added()

        # New communities, for which the InclusionRequests should be made
        new_ir_comms = set(new_comms) - new_owned_comms - set(auto_added)

        # Communities which are to be auto-requested to each published record
        auto_request = self._get_auto_requested()

        self._remove_accepted_communities(removals, record)

        self._autoadd_communities(new_owned_comms | set(auto_added), record)
        self._create_inclusion_requests(new_ir_comms | set(auto_request),
                                        record)

        # Remove obsolete InclusionRequests
        self._remove_obsolete_irs(dep_comms + auto_request, record)

        # Communities, which should be in record after publishing:
        new_rec_comms = (
            (set(dep_comms) & set(rec_comms)) |
            new_owned_comms |
            set(auto_added)
        )
        edited_record = super(ZenodoDeposit, self)._publish_edited()

        # Preserve some of the previously published record fields
        preserve_record_fields = ['_files', '_oai', '_buckets', '_internal']
        for k in preserve_record_fields:
            if k in record:
                edited_record[k] = record[k]

        # Add communities entry to deposit (self)
        self['communities'] = sorted(set(self.get('communities', []) +
                                         auto_added + auto_request))
        if not self['communities']:
            del self['communities']

        # Add communities entry to record
        edited_record['communities'] = sorted(list(new_rec_comms))
        edited_record = self._sync_oaisets_with_communities(edited_record)
        if not edited_record['communities']:
            del edited_record['communities']
        zenodo_doi_updater(edited_record.id, edited_record)
        return edited_record
示例#2
0
    def _publish_edited(self):
        """Publish the edited deposit with communities merging."""
        pid, record = self.fetch_published()
        dep_comms = set(self.get('communities', []))
        rec_comms = set(record.get('communities', []))

        # Already accepted communities which should be removed
        removals = rec_comms - dep_comms

        # New communities by user
        new_comms = dep_comms - rec_comms

        # New communities, which should be added automatically
        new_owned_comms = set(self._filter_by_owned_communities(new_comms))

        # Communities which are to be added to every published record
        auto_added = set(self._get_auto_added())

        # New communities, for which the InclusionRequests should be made
        new_ir_comms = new_comms - new_owned_comms - auto_added

        # Communities which are to be auto-requested to each published record
        auto_request = set(self._get_auto_requested()) - rec_comms

        self._remove_accepted_communities(removals, record)

        self._autoadd_communities(new_owned_comms | auto_added, record)
        self._create_inclusion_requests(new_ir_comms | auto_request, record)

        # Remove obsolete InclusionRequests
        self._remove_obsolete_irs(dep_comms | auto_request, record)

        # Communities, which should be in record after publishing:
        new_rec_comms = (dep_comms & rec_comms) | new_owned_comms | auto_added
        edited_record = super(ZenodoDeposit, self)._publish_edited()

        # Preserve some of the previously published record fields
        preserve_record_fields = ['_files', '_oai', '_buckets', '_internal']
        for k in preserve_record_fields:
            if k in record:
                edited_record[k] = record[k]

        # Add communities entry to deposit (self)
        self['communities'] = sorted(
            set(self.get('communities', [])) | auto_added | auto_request)
        if not self['communities']:
            del self['communities']

        # Add communities entry to record
        edited_record['communities'] = sorted(new_rec_comms)
        edited_record = self._sync_oaisets_with_communities(edited_record)
        if not edited_record['communities']:
            del edited_record['communities']
        zenodo_doi_updater(edited_record.id, edited_record)
        return edited_record
示例#3
0
文件: api.py 项目: zenodo/zenodo
    def _publish_edited(self):
        """Publish the edited deposit with communities merging."""
        dep_comms = set(self.get('communities', []))
        pid, record = self.fetch_published()
        rec_comms = set(record.get('communities', []))

        edited_record = super(ZenodoDeposit, self)._publish_edited()

        # Preserve some of the previously published record fields
        preserve_record_fields = ['_files', '_oai', '_buckets', '_internal']
        for k in preserve_record_fields:
            if k in record:
                edited_record[k] = record[k]

        zenodo_doi_updater(edited_record.id, edited_record)

        edited_record = self._sync_communities(dep_comms, rec_comms,
                                               edited_record)
        return edited_record
示例#4
0
文件: api.py 项目: PixelDragon/zenodo
    def _publish_edited(self):
        """Publish the edited deposit with communities merging."""
        pid, record = self.fetch_published()
        dep_comms = self.get('communities', [])
        rec_comms = record.get('communities', [])

        # Already accepted communities which should be removed
        removals = set(rec_comms) - set(dep_comms)

        # New communities by user
        new_comms = set(dep_comms) - set(rec_comms)

        # New communities, which should be added automatically
        new_owned_comms = set(self._filter_by_owned_communities(new_comms))

        # New communities, for which the InclusionRequests should be made
        new_ir_comms = set(new_comms) - new_owned_comms

        self._remove_accepted_communities(removals, record)

        # Communities which are to be added to every published record
        auto_added = self._get_auto_added()

        self._autoadd_communities(new_owned_comms | set(auto_added), record)
        self._create_inclusion_requests(new_ir_comms, record)

        # Remove obsolete InclusionRequests
        self._remove_obsolete_irs(dep_comms, record)

        # Communities, which should be in record after publishing:
        new_rec_comms = ((set(dep_comms) & set(rec_comms)) |
                         new_owned_comms | set(auto_added))
        record = super(ZenodoDeposit, self)._publish_edited()

        self['communities'] = sorted(self.get('communities', []) + auto_added)
        if not self['communities']:
            del self['communities']

        record['communities'] = sorted(list(new_rec_comms))
        if not record['communities']:
            del record['communities']
        zenodo_doi_updater(record.id, record)
        return record
示例#5
0
文件: api.py 项目: topless/zenodo
    def _publish_edited(self):
        """Publish the edited deposit with communities merging."""
        dep_comms = set(self.get('communities', []))
        pid, record = self.fetch_published()
        rec_comms = set(record.get('communities', []))

        edited_record = super(ZenodoDeposit, self)._publish_edited()

        # Preserve some of the previously published record fields
        preserve_record_fields = ['_files', '_oai', '_buckets', '_internal']
        for k in preserve_record_fields:
            if k in record:
                edited_record[k] = record[k]

        zenodo_doi_updater(edited_record.id, edited_record)

        edited_record = self._sync_communities(dep_comms, rec_comms,
                                               edited_record)
        return edited_record
示例#6
0
文件: api.py 项目: Baryonsoft/zenodo
    def _publish_edited(self):
        """Publish the edited deposit with communities merging."""
        dep_comms = set(self.get('communities', []))
        pid, record = self.fetch_published()
        rec_comms = set(record.get('communities', []))

        edited_record = super(ZenodoDeposit, self)._publish_edited()

        # Preserve some of the previously published record fields
        preserve_record_fields = ['_files', '_oai', '_buckets', '_internal']
        for k in preserve_record_fields:
            if k in record:
                edited_record[k] = record[k]

        # If non-Zenodo DOIs also sync files
        if not is_doi_locally_managed(self['doi']):
            record_bucket = edited_record.files.bucket
            # Unlock the record's bucket
            record_bucket.locked = False
            sync_buckets(
                src_bucket=self.files.bucket,
                dest_bucket=record_bucket,
                delete_extras=True,
            )

            # Update the record's metadata
            edited_record['_files'] = self.files.dumps(bucket=record_bucket.id)

            # Lock both record and deposit buckets
            record_bucket.locked = True
            self.files.bucket.locked = True

        zenodo_doi_updater(edited_record.id, edited_record)

        edited_record = self._sync_communities(dep_comms, rec_comms,
                                               edited_record)

        new_comms = set(edited_record.get('communities', [])) - (rec_comms
                                                                 or set())
        self._send_community_signals(edited_record, new_comms)

        return edited_record