From 7c68571b8b5660c8cb8019c7b32339306155219a Mon Sep 17 00:00:00 2001 From: Samuel Veiga Rangel <82840278+samuelveigarangel@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:03:23 -0300 Subject: [PATCH] Fix: function xmlsps.get_or_create_issues (#862) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Evita erro de NoneType object has no attribute 'get' em collection_date * Corrige obtenção das datas de coleção e artigo ao criar ou recuperar issues --- article/sources/xmlsps.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/article/sources/xmlsps.py b/article/sources/xmlsps.py index a6044480..0df9a61d 100755 --- a/article/sources/xmlsps.py +++ b/article/sources/xmlsps.py @@ -585,16 +585,23 @@ def get_or_create_article_type(xmltree, user): def get_or_create_issues(xmltree, user, item): issue_data = ArticleMetaIssue(xmltree=xmltree).data - collection_date = HistoryDates(xmltree=xmltree).collection_date + history_dates = HistoryDates(xmltree=xmltree) + collection_date = history_dates.collection_date or {} + article_date = history_dates.article_date or {} + + season = collection_date.get("season") + year = collection_date.get("year") or article_date.get("year") + month = collection_date.get("month") + suppl = collection_date.get("suppl") try: obj = Issue.get_or_create( journal=get_journal(xmltree=xmltree), number=issue_data.get("number"), volume=issue_data.get("volume"), - season=collection_date.get("season"), - year=collection_date.get("year"), - month=collection_date.get("month"), - supplement=collection_date.get("suppl"), + season=season, + year=year, + month=month, + supplement=suppl, user=user, ) return obj