Skip to content

Commit

Permalink
Fix: function xmlsps.get_or_create_issues (#862)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
samuelveigarangel authored Oct 1, 2024
1 parent d96fde2 commit 7c68571
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions article/sources/xmlsps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c68571

Please sign in to comment.