diff --git a/institution/wagtail_hooks.py b/institution/wagtail_hooks.py index 0adef5f20..c5b3f0ee3 100644 --- a/institution/wagtail_hooks.py +++ b/institution/wagtail_hooks.py @@ -24,11 +24,9 @@ class InstitutionViewSet(SnippetViewSet): ) search_fields = ( "name", + ) + list_filter = ( "institution_type", - "creator", - "updated", - "created", - "updated_by", ) list_export = ( "name", diff --git a/journal/migrations/0015_alter_officialjournal_next_journal_title.py b/journal/migrations/0015_alter_officialjournal_next_journal_title.py new file mode 100644 index 000000000..34529b52f --- /dev/null +++ b/journal/migrations/0015_alter_officialjournal_next_journal_title.py @@ -0,0 +1,17 @@ +# Generated by Django 5.2.3 on 2026-06-17 13:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("journal", "0014_alter_journal_title_alter_officialjournal_title"), + ] + + operations = [ + migrations.AlterField( + model_name="officialjournal", + name="next_journal_title", + field=models.CharField(blank=True, max_length=500, null=True), + ), + ] diff --git a/journal/models.py b/journal/models.py index f89f8bece..39c4edabb 100644 --- a/journal/models.py +++ b/journal/models.py @@ -121,7 +121,7 @@ class OfficialJournal(CommonControlField): ) issnl = models.CharField(_("ISSNL"), max_length=9, null=True, blank=True) previous_journal_title = models.CharField(max_length=500, null=True, blank=True) - next_journal_title = models.CharField(max_length=128, null=True, blank=True) + next_journal_title = models.CharField(max_length=500, null=True, blank=True) base_form_class = OfficialJournalForm @@ -269,23 +269,20 @@ def __str__(self): FieldPanel("core_synchronized"), ] - panels_owner = [ - InlinePanel("owner", label=_("Owner"), classname="collapsed"), - ] - - panels_publisher = [ - InlinePanel("publisher", label=_("Publisher"), classname="collapsed"), + panels_institution = [ + InlinePanel("owner", label=_("Owner")), + InlinePanel("publisher", label=_("Publisher")), + InlinePanel("sponsor", label=_("Sponsor")), ] panels_mission = [ - InlinePanel("mission", label=_("Mission"), classname="collapsed"), + InlinePanel("mission", label=_("Mission")), ] edit_handler = TabbedInterface( [ ObjectList(panels_identification, heading=_("Identification")), - ObjectList(panels_owner, heading=_("Owners")), - ObjectList(panels_publisher, heading=_("Publisher")), + ObjectList(panels_institution, heading=_("Institutions")), ObjectList(panels_mission, heading=_("Mission")), ] ) diff --git a/locale/es/LC_MESSAGES/django.po b/locale/es/LC_MESSAGES/django.po index 2faeef21b..177408eee 100644 --- a/locale/es/LC_MESSAGES/django.po +++ b/locale/es/LC_MESSAGES/django.po @@ -1468,7 +1468,7 @@ msgstr "Propietario" #: journal/models.py:277 journal/models.py:288 msgid "Publisher" -msgstr "Editor" +msgstr "Publicador" #: journal/models.py:281 journal/models.py:289 msgid "Mission" diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po index 2faeef21b..177408eee 100644 --- a/locale/pt_BR/LC_MESSAGES/django.po +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -1468,7 +1468,7 @@ msgstr "Propietario" #: journal/models.py:277 journal/models.py:288 msgid "Publisher" -msgstr "Editor" +msgstr "Publicador" #: journal/models.py:281 journal/models.py:289 msgid "Mission" diff --git a/proc/source_classic_website.py b/proc/source_classic_website.py index ae65c5e0f..e80c58a31 100644 --- a/proc/source_classic_website.py +++ b/proc/source_classic_website.py @@ -123,7 +123,7 @@ def migrate_journal( """ try: event = None - detail = None + detail = {} detail = { "journal_proc": str(journal_proc), "force_update": force_update, @@ -191,7 +191,7 @@ def migrate_issue(user, issue_proc, force_update): """ try: event = None - detail = None + detail = {} detail = { "issue_proc": str(issue_proc), "force_update": force_update, diff --git a/proc/source_core_api.py b/proc/source_core_api.py index 4c9f38c5e..25d6546ac 100644 --- a/proc/source_core_api.py +++ b/proc/source_core_api.py @@ -364,9 +364,11 @@ def process_journal_result( foundation_year=official.get("foundation_year"), user=user, ) + next_jt = result.get("next_journal_title") + prev_jt = result.get("previous_journal_title") official_journal.add_related_journal( - result.get("previous_journal_title"), - result.get("next_journal_title"), + prev_jt.get("previous_journal_title") if isinstance(prev_jt, dict) else prev_jt, + next_jt.get("next_journal_title") if isinstance(next_jt, dict) else next_jt, ) # Cria/atualiza o journal @@ -396,10 +398,21 @@ def process_journal_result( for item in result.get("subject") or []: journal.subject.add(Subject.create_or_update(user, item["value"])) - # Processa publishers + institution_names = set() for item in result.get("publisher") or []: - institution = Institution.get_or_create( - inst_name=item["name"], + institution_names.add(item["name"]) + + # Processa owners + for item in result.get("owner") or []: + institution_names.add(item["name"]) + + for item in result.get("sponsor") or []: + institution_names.add(item["name"]) + + institutions = {} + for name in institution_names: + institutions[name] = Institution.get_or_create( + inst_name=name, inst_acronym=None, level_1=None, level_2=None, @@ -407,31 +420,25 @@ def process_journal_result( location=None, user=user, ) + + # Processa publishers + for item in result.get("publisher") or []: + institution = institutions.get(item["name"]) + if not institution: + continue journal.publisher.add(Publisher.create_or_update(user, journal, institution)) # Processa owners for item in result.get("owner") or []: - institution = Institution.get_or_create( - inst_name=item["name"], - inst_acronym=None, - level_1=None, - level_2=None, - level_3=None, - location=None, - user=user, - ) + institution = institutions.get(item["name"]) + if not institution: + continue journal.owner.add(Owner.create_or_update(user, journal, institution)) for item in result.get("sponsor") or []: - institution = Institution.get_or_create( - inst_name=item["name"], - inst_acronym=None, - level_1=None, - level_2=None, - level_3=None, - location=None, - user=user, - ) + institution = institutions.get(item["name"]) + if not institution: + continue journal.sponsor.add(Sponsor.create_or_update(user, journal, institution)) no_lang = [] diff --git a/publication/api/journal.py b/publication/api/journal.py index 2c81e9415..81b9d997f 100644 --- a/publication/api/journal.py +++ b/publication/api/journal.py @@ -20,8 +20,8 @@ def publish_journal(journal_proc, api_data): fetch_and_create_journal( user=journal_proc.updated_by or journal_proc.creator, collection_acron=journal_proc.collection.acron, - issn_electronic=journal.issn_print, - issn_print=journal.issn_electronic, + issn_electronic=journal.issn_electronic, + issn_print=journal.issn_print, force_update=True, ) except: @@ -199,6 +199,8 @@ def add_issue_count(self, issue_count): def add_sponsor(self, sponsor): # Sponsors + if not sponsor: + return self.data["sponsors"].append({"name": sponsor}) @staticmethod @@ -299,5 +301,7 @@ def add_is_public(self, availability_status): self.data["is_public"] = availability_status == "C" def add_publisher(self, name): + if not name: + return self.data.setdefault("institution_responsible_for", []) self.data["institution_responsible_for"].append({"name": name}) diff --git a/publication/api/publication.py b/publication/api/publication.py index f6308ebd1..64a016b54 100644 --- a/publication/api/publication.py +++ b/publication/api/publication.py @@ -75,8 +75,6 @@ def post_data(self, payload, kwargs=None): # logging.info(f"payload={payload}") response = None try: - if not self.enabled: - raise ValueError(_("Website enabled is False ({})").format(self.post_data_url)) if not self.token: self.get_token() response = self._post_data(payload, self.token, kwargs) @@ -109,8 +107,11 @@ def get_token(self): """ curl --request POST http://0.0.0.0:8000/api/v1/auth -u "useremail:password" """ + if not self.enabled: + raise ValueError(_("Website enabled is False ({})").format(self.post_data_url)) + if not self.get_token_url: - return + raise ValueError(_("Website.get_token_url is not set")) resp = post_data( self.get_token_url, @@ -121,6 +122,8 @@ def get_token(self): ) # logging.info(resp) self.token = resp.get("token") + if not self.token: + raise Exception(f"Failed to get token from {self.get_token_url} with username {self.username}: {resp}") return self.token def _post_data(self, payload, token, kwargs=None): diff --git a/publication/utils/journal.py b/publication/utils/journal.py index 41327a1ba..39c55747c 100644 --- a/publication/utils/journal.py +++ b/publication/utils/journal.py @@ -76,17 +76,19 @@ def build_journal( for sponsor in journal.sponsor.all(): builder.add_sponsor(sponsor.institution.name) - names = [] + names = set() for item in journal.owner.all(): name = item.institution.name - if name not in names: - names.append(name) - builder.add_publisher(name) + if not name: + continue + names.add(name) + builder.add_publisher(name) for item in journal.publisher.all(): name = item.institution.name - if name not in names: - names.append(name) - builder.add_publisher(name) + if not name: + continue + names.add(name) + builder.add_publisher(name) builder.add_thematic_scopes( subject_categories=journal.wos_areas,