Skip to content

Commit

Permalink
#3394: Record correct galley type when storing article access records
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromsl committed Feb 14, 2023
1 parent 5d1da6a commit e5ab20a
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/journal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
from identifiers import models as id_models
from journal import logic, models, issue_forms, forms, decorators
from journal.logic import get_galley_content
from journal.logic import get_best_galley, get_galley_content
from metrics.logic import store_article_access
from review import forms as review_forms, models as review_models
from submission import encoding
Expand Down Expand Up @@ -428,16 +428,23 @@ def article(request, identifier_type, identifier):

# check if there is a galley file attached that needs rendering
if article_object.is_published:
content = get_galley_content(article_object, galleys, recover=True)
galley = get_best_galley(article_object, galleys)
if galley:
content = galley.file_content(recover=True)
else:
content = ''
tables_in_galley = logic.get_all_tables_from_html(content)
store_article_access(
request,
article_object,
"view",
galley.type if galley else None)
else:
article_object.abstract = (
"<p><strong>This is an accepted article with a DOI pre-assigned"
" that is not yet published.</strong></p>"
) + (article_object.abstract or "")

if article_object.is_published:
store_article_access(request, article_object, 'view')

if request.journal.disable_html_downloads:
# exclude any HTML galleys.
Expand Down Expand Up @@ -483,10 +490,16 @@ def print_article(request, identifier_type, identifier):

content = None
galleys = article_object.galley_set.filter(public=True)
galley = None

# check if there is a galley file attached that needs rendering
if article_object.stage == submission_models.STAGE_PUBLISHED:
content = get_galley_content(article_object, galleys, recover=True)
galley = get_best_galley(article, galleys)
if galley:
content = galley.file_content(recover=True)
else:
content = ''


else:
article_object.abstract = "This is an accepted article with a DOI pre-assigned that is not yet published."
Expand All @@ -498,7 +511,8 @@ def print_article(request, identifier_type, identifier):
article_object.large_image_file.uuid_filename = "carousel1.png"
article_object.large_image_file.is_remote = True

store_article_access(request, article_object, 'view')
store_article_access(
request, article_object, 'view', galley.type if galley else None)

template = 'journal/print.html'
context = {
Expand Down

0 comments on commit e5ab20a

Please sign in to comment.