예제 #1
0
 def get_doi_client(self):
     if settings.CROSSREF_URL:
         if self.provider._id == 'ecsarxiv':
             return ECSArXivCrossRefClient(base_url=settings.CROSSREF_URL)
         return CrossRefClient(base_url=settings.CROSSREF_URL)
     else:
         return None
def register_existing_preprints_with_crossref(dry=True):
    """This should do three things:
    Send metadata about the new preprint DOIs to CrossRef for registration,

    The resulting mailgun callbacks
    will add the new Crossref DOIs to the preprint with the category 'doi' while marking the
    legacy_doi identifier as deleted.
    """
    # Exclude ECSArxiv because we use a different client for those
    qs = PreprintService.objects.filter(
        identifiers__category='legacy_doi',
        identifiers__deleted__isnull=True).exclude(
            provider___id='ecsarxiv').select_related(
                'provider', 'node', 'license__node_license').prefetch_related(
                    'node___contributors').order_by('pk')
    crossref_client = CrossRefClient(base_url=settings.CROSSREF_URL)
    logging.info('Sending {} preprints to crossref'.format(qs.count()))
    send_preprints(qs, crossref_client)

    # Send ECSArxiv preprints separately, using the ECSArXivCrossRefClient
    ecs_qs = PreprintService.objects.filter(
        identifiers__category='legacy_doi',
        identifiers__deleted__isnull=True).filter(
            provider___id='ecsarxiv').select_related(
                'provider', 'node', 'license__node_license').prefetch_related(
                    'node___contributors').order_by('pk')
    ecs_crossref_client = ECSArXivCrossRefClient(
        base_url=settings.CROSSREF_URL)
    logging.info('Sending {} ECSArXiv preprints to crossref'.format(
        ecs_qs.count()))
    send_preprints(ecs_qs, ecs_crossref_client)