diff --git a/article/models.py b/article/models.py index 0798d5f5..2ae610db 100755 --- a/article/models.py +++ b/article/models.py @@ -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"), + 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): + 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, + ) \ No newline at end of file diff --git a/article/tasks.py b/article/tasks.py index 1fc6eaa0..9c2a8bec 100644 --- a/article/tasks.py +++ b/article/tasks.py @@ -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 @@ -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")) + articles = Article.objects.filter(journal__in=journals) diff --git a/journal/models.py b/journal/models.py index 81fca3a5..07feb35b 100755 --- a/journal/models.py +++ b/journal/models.py @@ -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: diff --git a/journal/sources/am_to_core.py b/journal/sources/am_to_core.py index d54f66dc..800afaa0 100644 --- a/journal/sources/am_to_core.py +++ b/journal/sources/am_to_core.py @@ -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, @@ -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,