From 7dc431962d2d82705686355d220e5ca9340948f7 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 14:45:41 -0300 Subject: [PATCH 01/19] Adiciona indexe no molode Language --- core/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/models.py b/core/models.py index 4a51da10..78f6b235 100755 --- a/core/models.py +++ b/core/models.py @@ -145,6 +145,13 @@ def autocomplete_label(self): class Meta: verbose_name = _("Language") verbose_name_plural = _("Languages") + indexes = [ + models.Index( + fields=[ + "code2", + ] + ), + ] def __unicode__(self): if self.name or self.code2: From 6898f1806e16134671261452d3d6a6244e19a8b2 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 14:52:04 -0300 Subject: [PATCH 02/19] Adiciona data.append --- article/sources/xmlsps.py | 1 + 1 file changed, 1 insertion(+) diff --git a/article/sources/xmlsps.py b/article/sources/xmlsps.py index 88920254..d3c904a6 100755 --- a/article/sources/xmlsps.py +++ b/article/sources/xmlsps.py @@ -449,6 +449,7 @@ def get_or_create_institution_authors(xmltree, user, item): affiliation=affiliation, user=user, ) + data.append(obj) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() UnexpectedEvent.create( From d3bea05e183d736ee73d0fee4c648a0b0b7d5872 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 14:58:32 -0300 Subject: [PATCH 03/19] Adiciona logging ao final de load_article --- article/sources/xmlsps.py | 1 + 1 file changed, 1 insertion(+) diff --git a/article/sources/xmlsps.py b/article/sources/xmlsps.py index d3c904a6..d866cd3b 100755 --- a/article/sources/xmlsps.py +++ b/article/sources/xmlsps.py @@ -123,6 +123,7 @@ def load_article(user, xml=None, file_path=None, v3=None): article.publisher = get_or_create_publisher(xmltree=xmltree, user=user, item=pid_v3) article.valid = True article.save() + logging.info(f"The article {pid_v3} has been processed") except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() xml_detail_error = etree.tostring(xmltree) From 4ed2425f50b05deb87b937c3854b1ba0ced6ffc7 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 14:58:55 -0300 Subject: [PATCH 04/19] Remove logging desnecessario --- location/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/location/models.py b/location/models.py index 0f6dba4c..a93e769c 100755 --- a/location/models.py +++ b/location/models.py @@ -457,7 +457,6 @@ def create_or_update( country_names[lang_code2] = name for lang_code2, text in country_names.items(): - logging.info(f"{lang_code2} {text}") language = Language.get_or_create(code2=lang_code2) CountryName.create_or_update( country=obj, language=language, text=text, user=user From b95640041b3eaf04e47fe83c18ab76792119c35b Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 14:59:26 -0300 Subject: [PATCH 05/19] Melhora join_names --- researcher/models.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/researcher/models.py b/researcher/models.py index ac48feb2..0444bb56 100644 --- a/researcher/models.py +++ b/researcher/models.py @@ -322,11 +322,7 @@ def get_full_name(self): @staticmethod def join_names(given_names, last_name, suffix): return " ".join( - [ - remove_extra_spaces(item) - for item in (given_names, last_name, suffix) - if remove_extra_spaces(item) - ] + filter(None, [given_names, last_name, suffix]) ) @classmethod @@ -380,6 +376,7 @@ def _create( obj.gender = gender obj.gender_identification_status = gender_identification_status obj.save() + return obj except IntegrityError: return cls._get(given_names, last_name, suffix, fullname, declared_name) except Exception as e: @@ -408,8 +405,7 @@ def get_or_create( given_names = remove_extra_spaces(given_names) last_name = remove_extra_spaces(last_name) suffix = remove_extra_spaces(suffix) - fullname = remove_extra_spaces(fullname) - fullname = fullname or PersonName.join_names(given_names, last_name, suffix) + fullname = remove_extra_spaces(fullname) or PersonName.join_names(given_names, last_name, suffix) try: return cls._get(given_names, last_name, suffix, fullname, declared_name) From 90153bca2c1125e1d91d1322736d34e177d78d61 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 14:59:59 -0300 Subject: [PATCH 06/19] melhora remove_extra_spaces --- core/utils/standardizer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/utils/standardizer.py b/core/utils/standardizer.py index a8f06914..4e9be771 100644 --- a/core/utils/standardizer.py +++ b/core/utils/standardizer.py @@ -9,11 +9,10 @@ def remove_extra_spaces(text): - text = text and text.strip() if not text: return text - # padroniza a quantidade de espaços - return " ".join([item.strip() for item in text.split() if item.strip()]) + # Padroniza a quantidade de espaços + return " ".join(text.split()) def standardize_code_and_name(original): From 2835bd61ef9ee00fff9e8990eb21d58f65e79767 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 15:00:19 -0300 Subject: [PATCH 07/19] Adiciona teste para funcao remove_extra_spaces --- core/tests_standardizer.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/core/tests_standardizer.py b/core/tests_standardizer.py index 93377b24..42df4087 100644 --- a/core/tests_standardizer.py +++ b/core/tests_standardizer.py @@ -1,4 +1,4 @@ -from django.test import TestCase +from django.test import TestCase, SimpleTestCase # Create your tests here. from core.utils import standardizer @@ -65,3 +65,23 @@ def test_standardize_name(self): for i, item in enumerate(result): with self.subTest(i): self.assertEqual({"name": expected[i]}, item) + + +class StandardizerRemoveSpaceExtraTest(SimpleTestCase): + + def test_remove_extra_spaces(self): + test_cases = [ + (" Palavra1", "Palavra1"), + (" Palavra1 Palavra2 ", "Palavra1 Palavra2"), + ("", ""), + (" ", ""), + (" Palavra1 Palavra2 Palavra3 ", "Palavra1 Palavra2 Palavra3"), + (" Multiple spaces between words ", "Multiple spaces between words"), + ("\tTabs\tand\nnewlines\n", "Tabs and newlines"), + ] + + for text, expected in test_cases: + with self.subTest(text=text, expected=expected): + result = standardizer.remove_extra_spaces(text=text) + self.assertEqual(expected, result) + From f86db6b3c2974c790a2fadbe5cab6406af4b3633 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Mon, 27 May 2024 15:00:33 -0300 Subject: [PATCH 08/19] Adiciona teste para JoinNameTest --- researcher/tests.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/researcher/tests.py b/researcher/tests.py index 7ce503c2..111e624b 100644 --- a/researcher/tests.py +++ b/researcher/tests.py @@ -1,3 +1,18 @@ -from django.test import TestCase +from django.test import SimpleTestCase # Create your tests here. +from researcher.models import PersonName + + +class PersonNameJoinNameTest(SimpleTestCase): + def test_person_name_join_name(self): + test_cases = [ + (['Palavra1', None, None], 'Palavra1'), + (['Palavra1', 'Palavra2', None], 'Palavra1 Palavra2' ), + (['Palavra1', 'Palavra2', 'Palavra3'], 'Palavra1 Palavra2 Palavra3'), + ] + + for text, expected in test_cases: + with self.subTest(text=text, excepted=expected): + result = PersonName.join_names(*text) + self.assertEqual(expected, result) \ No newline at end of file From 5772fc489dadffd0d5d78c615e6a22dd546bf4d6 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 11:49:47 -0300 Subject: [PATCH 09/19] Adiciona campo article_license no modelo Article --- article/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/article/models.py b/article/models.py index 1b7f4d65..3c876c4f 100755 --- a/article/models.py +++ b/article/models.py @@ -81,6 +81,7 @@ class Article(CommonControlField, ClusterableModel): license = models.ForeignKey( License, on_delete=models.SET_NULL, null=True, blank=True ) + article_license = models.CharField(max_length=255, null=True, blank=True) issue = models.ForeignKey(Issue, on_delete=models.SET_NULL, null=True, blank=True) first_page = models.CharField(max_length=20, null=True, blank=True) last_page = models.CharField(max_length=20, null=True, blank=True) From ba6dc655f1d273830595f54d419a0b9d7332f721 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 11:51:03 -0300 Subject: [PATCH 10/19] Modifica funcao get_licenses para set_license --- article/sources/xmlsps.py | 65 ++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/article/sources/xmlsps.py b/article/sources/xmlsps.py index d866cd3b..51a6f8b6 100755 --- a/article/sources/xmlsps.py +++ b/article/sources/xmlsps.py @@ -115,7 +115,7 @@ def load_article(user, xml=None, file_path=None, v3=None): ) article.doi.set(get_or_create_doi(xmltree=xmltree, user=user)) - article.license_statements.set(get_licenses(xmltree=xmltree, user=user)) + article.license_statements.set(set_license(xmltree=xmltree, article=article, user=user)) for ls in article.license_statements.iterator(): article.license = ls.license article.save() @@ -259,36 +259,43 @@ def get_or_create_toc_sections(xmltree, user): return data -def get_licenses(xmltree, user): +def set_license(xmltree, article, user): xml_licenses = ArticleLicense(xmltree=xmltree).licenses - data = [] - license = None for xml_license in xml_licenses: - - if not license and xml_license.get("link"): - url_data = LicenseStatement.parse_url(xml_license.get("link")) - license_type = url_data.get("license_type") - if license_type: - license = License.create_or_update( - user=user, - license_type=license_type, - ) - if license or xml_license.get("license_p"): - try: - license_p = xml_license.get("license_p") - license_p = license_p["html_text"] - except (ValueError, TypeError, KeyError): - pass - - obj = LicenseStatement.create_or_update( - user=user, - url=xml_license.get("link"), - language=Language.get_or_create(code2=xml_license.get("lang")), - license_p=license_p, - license=license, - ) - data.append(obj) - return data + if license := xml_license.get("link"): + article.article_license = license + + +# def get_licenses(xmltree, user): +# xml_licenses = ArticleLicense(xmltree=xmltree).licenses +# data = [] +# license = None +# for xml_license in xml_licenses: + +# if not license and xml_license.get("link"): +# url_data = LicenseStatement.parse_url(xml_license.get("link")) +# license_type = url_data.get("license_type") +# if license_type: +# license = License.create_or_update( +# user=user, +# license_type=license_type, +# ) +# if license or xml_license.get("license_p"): +# try: +# license_p = xml_license.get("license_p") +# license_p = license_p["html_text"] +# except (ValueError, TypeError, KeyError): +# pass + +# obj = LicenseStatement.create_or_update( +# user=user, +# url=xml_license.get("link"), +# language=Language.get_or_create(code2=xml_license.get("lang")), +# license_p=license_p, +# license=license, +# ) +# data.append(obj) +# return data def create_or_update_keywords(xmltree, user, item): From f22cf62875281fe47779813c5deeb2320533abbd Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 11:51:27 -0300 Subject: [PATCH 11/19] Adiciona teste para migracao --- article/tests.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/article/tests.py b/article/tests.py index 7ce503c2..e883d6d5 100755 --- a/article/tests.py +++ b/article/tests.py @@ -1,3 +1,57 @@ from django.test import TestCase +from django.apps import apps +from django.db import connection, migrations + + +class TestMigration(TestCase): + + migrate_from = ('article', '0012_alter_article_publisher') + migrate_to = ('article', '0013_article_article_license') + + def setUp(self): + self.migrate_to_state(self.migrate_from) + + Article = apps.get_model('article', 'Article') + License = apps.get_model('article', 'License') + LicenseStatement = apps.get_model('article', 'LicenseStatement') + + self.license1 = License.objects.create(license_type='by-nc') + self.license2 = License.objects.create(license_type='by') + self.license_statement1 = LicenseStatement.objects.create(url='https://creativecommons.org/licenses/by/4.0/') + self.license_statement2 = LicenseStatement.objects.create(url='http://creativecommons.org/licenses/nc/4.0/') + self.license_statement3 = LicenseStatement.objects.create(url='http://creativecommons.org/licenses/by-nc/4.0/') + + self.article1 = Article.objects.create(license=self.license) + self.article1.license_statements.add(self.license_statement1) + + self.article2 = Article.objects.create(license=self.license) + self.article2.license_statements.add(self.license_statement2) + + self.article3 = Article.objects.create(license=None) + self.article3.license_statements.add(self.license1) + + def migrate_to_state(self, state): + with connection.schema_editor() as schema_editor: + migrate_apps = migrations.state.ProjectState.from_apps(apps) + migration = self.get_migration(state) + migration.apply(state=migrate_apps, schema_editor=schema_editor) + + def get_migration(self, state): + for migration in migrations.loader.MigrationLoader(connection).graph.leaf_nodes(): + if migration[0] == state[0] and migration[1] == state[1]: + return migrations.loader.MigrationLoader(connection).get_migration(migration) + + def test_migration(self): + self.migrate_to_state(self.migrate_to) + + Article = apps.get_model('article', 'Article') + + article1 = Article.objects.get(id=self.article1.id) + self.assertEqual(article1.article_license, 'https://creativecommons.org/licenses/by/4.0/') + + article2 = Article.objects.get(id=self.article2.id) + self.assertEqual(article2.article_license, 'http://creativecommons.org/licenses/nc/4.0/') + + article3 = Article.objects.get(id=self.article3.id) + self.assertEqual(article3.article_license, 'by-nc') -# Create your tests here. From c764ad77f86998a091dbf1b3688f42376ff29176 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 11:51:35 -0300 Subject: [PATCH 12/19] migracoes --- .../0013_article_article_license.py | 38 +++++++++++++++++++ ...4_language_core_langua_code2_4f7261_idx.py | 19 ++++++++++ 2 files changed, 57 insertions(+) create mode 100644 article/migrations/0013_article_article_license.py create mode 100644 core/migrations/0004_language_core_langua_code2_4f7261_idx.py diff --git a/article/migrations/0013_article_article_license.py b/article/migrations/0013_article_article_license.py new file mode 100644 index 00000000..4011ca1f --- /dev/null +++ b/article/migrations/0013_article_article_license.py @@ -0,0 +1,38 @@ +# Generated by Django 5.0.3 on 2024-05-27 23:04 + +from django.db import migrations, models + +def transfer_license_statements_fk_to_article_license(apps, schema_editor): + Article = apps.get_model('article', 'Article') + + articles_to_update = [] + for instance in Article.objects.all(): + + new_license = None + if instance.license_statements.exists() and instance.license_statements.first().url: + new_license = instance.license_statements.first().url + elif instance.license and instance.license.license_type: + new_license = instance.license.license_type + + if new_license: + instance.article_license = new_license + articles_to_update.append(instance) + + if articles_to_update: + Article.objects.bulk_update(articles_to_update, ['article_license']) + + +class Migration(migrations.Migration): + + dependencies = [ + ("article", "0012_alter_article_publisher"), + ] + + operations = [ + migrations.AddField( + model_name="article", + name="article_license", + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.RunPython(transfer_license_statements_fk_to_article_license), + ] diff --git a/core/migrations/0004_language_core_langua_code2_4f7261_idx.py b/core/migrations/0004_language_core_langua_code2_4f7261_idx.py new file mode 100644 index 00000000..dfd3ec70 --- /dev/null +++ b/core/migrations/0004_language_core_langua_code2_4f7261_idx.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.3 on 2024-05-27 17:45 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0003_gender_created_gender_creator_gender_updated_and_more"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddIndex( + model_name="language", + index=models.Index(fields=["code2"], name="core_langua_code2_4f7261_idx"), + ), + ] From ea88bbb50c56f84bd129029575997fde73c4c76b Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 23:31:17 -0300 Subject: [PATCH 13/19] Modifica teste de migracao --- article/tests.py | 67 +++++++++++------------------------------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/article/tests.py b/article/tests.py index e883d6d5..7886547b 100755 --- a/article/tests.py +++ b/article/tests.py @@ -1,57 +1,20 @@ from django.test import TestCase -from django.apps import apps -from django.db import connection, migrations +from django_test_migrations.migrator import Migrator +class TestArticleMigration(TestCase): + def test_migration_0013_article_article_license(self): + migrator = Migrator(database='default') + old_state = migrator.apply_initial_migration(('article', '0012_alter_article_publisher')) + Article = old_state.apps.get_model('article', 'Article') + LicenseStatement = old_state.apps.get_model('core', 'LicenseStatement') + article = Article.objects.create() + license_statement = LicenseStatement.objects.create(url="https://www.teste.com.br") + article.license_statements.add(license_statement) -class TestMigration(TestCase): + new_state = migrator.apply_tested_migration(('article', '0013_article_article_license')) - migrate_from = ('article', '0012_alter_article_publisher') - migrate_to = ('article', '0013_article_article_license') - - def setUp(self): - self.migrate_to_state(self.migrate_from) - - Article = apps.get_model('article', 'Article') - License = apps.get_model('article', 'License') - LicenseStatement = apps.get_model('article', 'LicenseStatement') - - self.license1 = License.objects.create(license_type='by-nc') - self.license2 = License.objects.create(license_type='by') - self.license_statement1 = LicenseStatement.objects.create(url='https://creativecommons.org/licenses/by/4.0/') - self.license_statement2 = LicenseStatement.objects.create(url='http://creativecommons.org/licenses/nc/4.0/') - self.license_statement3 = LicenseStatement.objects.create(url='http://creativecommons.org/licenses/by-nc/4.0/') - - self.article1 = Article.objects.create(license=self.license) - self.article1.license_statements.add(self.license_statement1) - - self.article2 = Article.objects.create(license=self.license) - self.article2.license_statements.add(self.license_statement2) - - self.article3 = Article.objects.create(license=None) - self.article3.license_statements.add(self.license1) - - def migrate_to_state(self, state): - with connection.schema_editor() as schema_editor: - migrate_apps = migrations.state.ProjectState.from_apps(apps) - migration = self.get_migration(state) - migration.apply(state=migrate_apps, schema_editor=schema_editor) - - def get_migration(self, state): - for migration in migrations.loader.MigrationLoader(connection).graph.leaf_nodes(): - if migration[0] == state[0] and migration[1] == state[1]: - return migrations.loader.MigrationLoader(connection).get_migration(migration) - - def test_migration(self): - self.migrate_to_state(self.migrate_to) - - Article = apps.get_model('article', 'Article') - - article1 = Article.objects.get(id=self.article1.id) - self.assertEqual(article1.article_license, 'https://creativecommons.org/licenses/by/4.0/') - - article2 = Article.objects.get(id=self.article2.id) - self.assertEqual(article2.article_license, 'http://creativecommons.org/licenses/nc/4.0/') - - article3 = Article.objects.get(id=self.article3.id) - self.assertEqual(article3.article_license, 'by-nc') + Article = new_state.apps.get_model('article', 'Article') + article = Article.objects.first() + self.assertEqual(article.article_license, 'https://www.teste.com.br') + migrator.reset() \ No newline at end of file From f0353fcd6e379190075e029935bba664b7d5bd52 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 23:31:32 -0300 Subject: [PATCH 14/19] Adiciona dependencia de django-teste-migrations --- requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/local.txt b/requirements/local.txt index ba7f919a..abbfeab1 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -12,7 +12,7 @@ mypy==1.6.1 # https://github.com/python/mypy django-stubs==4.2.7 # https://github.com/typeddjango/django-stubs pytest==7.4.3 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.7 # https://github.com/Frozenball/pytest-sugar - +django-test-migrations==1.3.0 # Documentation # ------------------------------------------------------------------------------ sphinx==7.2.6 # https://github.com/sphinx-doc/sphinx From 6f1d127a1ee4719951f0ea8e48f29d0c9f3fb823 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 23:31:50 -0300 Subject: [PATCH 15/19] Fix env de FETCH_DATA_TIMEOUT --- config/settings/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/settings/base.py b/config/settings/base.py index 6be753ca..d6fb8150 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -489,4 +489,4 @@ # Timeout function fetch_data -FETCH_DATA_TIMEOUT = env.str("FETCH_DATA_TIMEOUT", default=10) \ No newline at end of file +FETCH_DATA_TIMEOUT = env.int("FETCH_DATA_TIMEOUT", default=10) \ No newline at end of file From 23476860f32403b7041326db96f79af23c167c7f Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 23:32:16 -0300 Subject: [PATCH 16/19] Migracao faltante de doi_manager --- doi_manager/migrations/0001_initial.py | 99 ++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 doi_manager/migrations/0001_initial.py diff --git a/doi_manager/migrations/0001_initial.py b/doi_manager/migrations/0001_initial.py new file mode 100644 index 00000000..7159b67c --- /dev/null +++ b/doi_manager/migrations/0001_initial.py @@ -0,0 +1,99 @@ +# Generated by Django 5.0.3 on 2024-05-28 15:21 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name="CrossRefConfiguration", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "created", + models.DateTimeField( + auto_now_add=True, verbose_name="Creation date" + ), + ), + ( + "updated", + models.DateTimeField( + auto_now=True, verbose_name="Last update date" + ), + ), + ( + "prefix", + models.CharField( + blank=True, max_length=10, null=True, verbose_name="Prefix" + ), + ), + ( + "depositor_name", + models.CharField( + blank=True, + max_length=64, + null=True, + verbose_name="Depositor Name", + ), + ), + ( + "depositor_email_address", + models.EmailField( + blank=True, + max_length=64, + null=True, + verbose_name="Depositor e-mail", + ), + ), + ( + "registrant", + models.CharField( + blank=True, max_length=64, null=True, verbose_name="Registrant" + ), + ), + ( + "creator", + models.ForeignKey( + editable=False, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="%(class)s_creator", + to=settings.AUTH_USER_MODEL, + verbose_name="Creator", + ), + ), + ( + "updated_by", + models.ForeignKey( + blank=True, + editable=False, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="%(class)s_last_mod_user", + to=settings.AUTH_USER_MODEL, + verbose_name="Updater", + ), + ), + ], + options={ + "abstract": False, + }, + ), + ] From ed538557a873fd260a34e6facdaaad821bfe1b79 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 23:32:29 -0300 Subject: [PATCH 17/19] Adiciona reveser migration --- .../migrations/0013_article_article_license.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/article/migrations/0013_article_article_license.py b/article/migrations/0013_article_article_license.py index 4011ca1f..73c1f297 100644 --- a/article/migrations/0013_article_article_license.py +++ b/article/migrations/0013_article_article_license.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.3 on 2024-05-27 23:04 +# Generated by Django 5.0.3 on 2024-05-28 18:09 from django.db import migrations, models @@ -22,6 +22,17 @@ def transfer_license_statements_fk_to_article_license(apps, schema_editor): Article.objects.bulk_update(articles_to_update, ['article_license']) +def reverse_transfer_license_statements_fk_to_article_license(apps, schema_editor): + Article = apps.get_model('article', 'Article') + + articles_to_update = [] + for instance in Article.objects.all(): + instance.article_license = None + articles_to_update.append(instance) + + if articles_to_update: + Article.objects.bulk_update(articles_to_update, ['article_license']) + class Migration(migrations.Migration): dependencies = [ @@ -34,5 +45,8 @@ class Migration(migrations.Migration): name="article_license", field=models.CharField(blank=True, max_length=255, null=True), ), - migrations.RunPython(transfer_license_statements_fk_to_article_license), + migrations.RunPython( + transfer_license_statements_fk_to_article_license, + reverse_transfer_license_statements_fk_to_article_license, + ), ] From 53df82f04868f9851fd2440b437a557ff26da334 Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 28 May 2024 23:32:37 -0300 Subject: [PATCH 18/19] __init__ --- doi_manager/migrations/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 doi_manager/migrations/__init__.py diff --git a/doi_manager/migrations/__init__.py b/doi_manager/migrations/__init__.py new file mode 100644 index 00000000..e69de29b From 2b3f86b7a54d41bd6b715a856f076f36a76b82fa Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel Date: Tue, 4 Jun 2024 23:19:01 -0300 Subject: [PATCH 19/19] Remove atribuicao do campo license na carga de artigos. --- article/sources/xmlsps.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/article/sources/xmlsps.py b/article/sources/xmlsps.py index 51a6f8b6..8f5e4b15 100755 --- a/article/sources/xmlsps.py +++ b/article/sources/xmlsps.py @@ -116,10 +116,6 @@ def load_article(user, xml=None, file_path=None, v3=None): article.doi.set(get_or_create_doi(xmltree=xmltree, user=user)) article.license_statements.set(set_license(xmltree=xmltree, article=article, user=user)) - for ls in article.license_statements.iterator(): - article.license = ls.license - article.save() - break article.publisher = get_or_create_publisher(xmltree=xmltree, user=user, item=pid_v3) article.valid = True article.save()