-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2734 Alter CrossrefDeposit model with multiple identifiers and depos…
…it document
- Loading branch information
Showing
4 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/identifiers/migrations/0007_batch_doi_registration_20220315.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.29 on 2022-03-15 20:06 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
def migrate_current_crossref_deposit_identifiers(apps, schema_editor): | ||
CrossrefDeposit = apps.get_model("identifiers", "CrossrefDeposit") | ||
for crossref_deposit in CrossrefDeposit.objects.all(): | ||
if crossref_deposit.identifier: | ||
crossref_deposit.identifiers.add(crossref_deposit.identifier) | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('identifiers', '0006_crossrefdeposit'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='crossrefdeposit', | ||
name='deposit', | ||
field=models.TextField(blank=True, help_text='The deposit document with rendered XML for the DOI batch.', null=True), | ||
), | ||
migrations.AddField( | ||
model_name='crossrefdeposit', | ||
name='identifiers', | ||
field=models.ManyToManyField(to='identifiers.Identifier'), | ||
), | ||
migrations.AlterField( | ||
model_name='crossrefdeposit', | ||
name='identifier', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='deposit_identifier', to='identifiers.Identifier'), | ||
), | ||
migrations.RunPython(migrate_current_crossref_deposit_identifiers, reverse_code=migrations.RunPython.noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.test import TestCase | ||
|
||
from identifiers import logic, models | ||
from utils.testing import helpers | ||
from utils.shared import clear_cache | ||
|
||
|
||
class TestLogic(TestCase): | ||
|
||
@classmethod | ||
def setUpTestData(cls): | ||
|
||
cls.press = helpers.create_press() | ||
cls.journal_one, cls.journal_two = helpers.create_journals() | ||
cls.ten_articles = [helpers.create_article(cls.journal_one) for i in range(10)] | ||
cls.ten_identifiers = logic.get_doi_identifiers_for_articles(cls.ten_articles) | ||
|
||
|
||
def test_crossref_deposit(self): | ||
template = 'common/identifiers/crossref_doi_batch.xml' | ||
template_context = logic.create_crossref_doi_batch_context( | ||
self.journal_one, | ||
set(self.ten_identifiers) | ||
) | ||
deposit = logic.render_to_string(template, template_context) | ||
crd = models.CrossrefDeposit( | ||
[identifier.pk for identifier in self.ten_identifiers], | ||
deposit=deposit, | ||
) | ||
pass |