Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions institution/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ class InstitutionViewSet(SnippetViewSet):
)
search_fields = (
"name",
)
list_filter = (
"institution_type",
"creator",
"updated",
"created",
"updated_by",
)
list_export = (
"name",
Expand Down
Original file line number Diff line number Diff line change
@@ -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),
),
]
17 changes: 7 additions & 10 deletions journal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")),
]
)
Expand Down
2 changes: 1 addition & 1 deletion locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion locale/pt_BR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions proc/source_classic_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def migrate_journal(
"""
try:
event = None
detail = None
detail = {}
detail = {
"journal_proc": str(journal_proc),
"force_update": force_update,
Expand Down Expand Up @@ -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,
Expand Down
53 changes: 30 additions & 23 deletions proc/source_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Comment on lines +367 to 372

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poderia usar um helper como:

def extract_title(value, key):
    return value.get(key) if isinstance(value, dict) else value

official_journal.add_related_journal(
    extract_title(result.get("previous_journal_title"), "previous_journal_title"),
    extract_title(result.get("next_journal_title"), "next_journal_title"),
)


# Cria/atualiza o journal
Expand Down Expand Up @@ -396,42 +398,47 @@ 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 []:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

é garantido que result.get("publisher") sempre retorna um iterável?

institution = Institution.get_or_create(
inst_name=item["name"],
institution_names.add(item["name"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não seria mais seguro usar item.get("name") or ""


# Processa owners
for item in result.get("owner") or []:
institution_names.add(item["name"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não seria mais seguro usar item.get("name") or ""


for item in result.get("sponsor") or []:
institution_names.add(item["name"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não seria mais seguro usar item.get("name") or ""


institutions = {}
for name in institution_names:
institutions[name] = Institution.get_or_create(
inst_name=name,
inst_acronym=None,
level_1=None,
level_2=None,
level_3=None,
location=None,
user=user,
)

# Processa publishers
for item in result.get("publisher") or []:
institution = institutions.get(item["name"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não seria mais seguro usar item.get("name") or ""

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"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não seria mais seguro usar item.get("name") or ""

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"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não seria mais seguro usar item.get("name") or ""

if not institution:
continue
journal.sponsor.add(Sponsor.create_or_update(user, journal, institution))

no_lang = []
Expand Down
8 changes: 6 additions & 2 deletions publication/api/journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment on lines -23 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

force_update=True,
)
except:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})
16 changes: 9 additions & 7 deletions publication/utils/journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down