Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create file article pmc #835

Closed
Show file tree
Hide file tree
Changes from all 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
40 changes: 40 additions & 0 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,3 +828,43 @@ def generate_formats(cls, user, article):
pmc.pipeline_pmc,
indexed_check=False,
)


class ArticleStatusSubmission(Article):
class Meta:
proxy = True

panels = [
InlinePanel("article_pubmed_pmc"),
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel acho que bastaria um único InlinePanel

InlinePanel("article_pubmed"),
]


def article_directory_path_pubmed_pmc(instance, filename):
try:
return os.path.join(
*instance.article.sps_pkg_name.split("-"), instance.format_name, filename
)
except AttributeError:
return os.path.join(instance.article.pid_v3, instance.format_name, filename)


class FileArticleFormatPubmedPmc(CommonControlField):
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel acho que é necessário uma única classe com o parâmetro com nome format para distinguir entre os formatos

Article = ParentalKey(
Article,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="article_pubmed_pmc",
)
file = models.FileField(
null=True,
blank=True,
verbose_name=_("File"),
upload_to=article_directory_path_pubmed_pmc,
)
status = models.CharField(
blank=True,
null=True,
max_length=5,
)
9 changes: 8 additions & 1 deletion article/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
from django.db.models import Q, Count
from django.contrib.auth import get_user_model
from django.utils.translation import gettext as _
from packtools.sps.formats import pmc

from article.models import Article, ArticleFormat

from article.models import Article, ArticleFormat, Journal
from article.sources import xmlsps
from article.sources.preprint import harvest_preprints
from config import celery_app
Expand Down Expand Up @@ -295,3 +297,8 @@ def remove_duplicate_articles(pid_v3=None):
def remove_duplicate_articles_task(self, user_id=None, username=None, pid_v3=None):
remove_duplicate_articles(pid_v3)

@celery_app.task(bind=True)
def create_files_articles_pubmed_pmc(self, user_id=None, username=None):
pipeline = pmc.pipeline_pmc
journals = Journal.objects.filter(Q(indexed_at__name="Pubmed") | Q(indexed_at__acronym="pmc"))
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel pubmed e pmc são diferentes. Certamente, nem tudo o que é pmc é pubmed. Talvez nem tudo o que é pubmed é pmc.
Adicione o formato como parâmetro

articles = Article.objects.filter(journal__in=journals)
6 changes: 3 additions & 3 deletions journal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2446,9 +2446,9 @@ def create(
obj = cls()
obj.creator = user
obj.journal = journal
obj.indexed_at = indexed_at or obj.indexed_at
obj.title = title or obj.title
obj.identifier = identifier or obj.identifier
obj.indexed_at = indexed_at
obj.title = title
obj.identifier = identifier
obj.save()
return obj
except IntegrityError:
Expand Down
28 changes: 16 additions & 12 deletions journal/sources/am_to_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,21 @@ def update_panel_scope_and_about(
def update_panel_interoperation(
journal, indexed_at, secs_code, medline_code, medline_short_title, user
):
titles_in_db = []
get_or_create_indexed_at(journal, indexed_at=indexed_at, user=user)

update_title_in_database(user=user, journal=journal, code=secs_code, acronym="secs")
update_title_in_database(
user=user,
journal=journal,
code=medline_code,
acronym="medline",
title=medline_short_title,
)

if secs_code:
obj = update_title_in_database(user=user, journal=journal, code=secs_code, acronym="secs")
titles_in_db.append(obj)
if medline_code:
obj = update_title_in_database(
user=user,
journal=journal,
code=medline_code,
acronym="medline",
title=medline_short_title,
)
titles_in_db.append(obj)
journal.title_in_database.set(titles_in_db)

def update_panel_information(
journal,
Expand Down Expand Up @@ -879,13 +883,13 @@ def update_title_in_database(user, journal, code, acronym, title=None):
title = journal.title
else:
title = extract_value(title)
create_or_update_title_in_database(
return create_or_update_title_in_database(
user=user, journal=journal, indexed_at=indexed_at, identifier=code, title=title
)


def create_or_update_title_in_database(user, journal, indexed_at, title, identifier):
TitleInDatabase.create_or_update(
return TitleInDatabase.create_or_update(
user=user,
journal=journal,
indexed_at=indexed_at,
Expand Down
Loading