Skip to content

Commit

Permalink
Merge pull request #2761 from gitnnolabs/bug2022
Browse files Browse the repository at this point in the history
Garante a apresentação do botão de ``ahead`` somente quanto há artigos.
  • Loading branch information
gitnnolabs authored Jul 30, 2023
2 parents f34276f + acd3691 commit 71da2bc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
48 changes: 48 additions & 0 deletions opac/tests/test_main_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,54 @@ def test_issue_grid_social_meta_tags(self):
response.data.decode("utf-8"),
)

def test_issue_grid_ahead_with_articles(self):
"""
Teste da ``view function`` ``issue_grid`` acessando a grade de números
de um periódico. Em caso de artigos no fasciculo de ``ahead`` o botão de ahead
deve ser apresentado.
"""

with current_app.app_context():
utils.makeOneCollection()

journal = utils.makeOneJournal()

issue = utils.makeOneIssue(attrib={"journal": journal.id, "type": "ahead"})

utils.makeAnyArticle(attrib={"issue": issue})

response = self.client.get(
url_for("main.issue_grid", url_seg=journal.url_segment)
)

self.assertStatus(response, 200)
self.assertTemplateUsed("issue/grid.html")

self.assertIn("ahead", response.data.decode("utf-8"))

def test_issue_grid_ahead_without_articles(self):
"""
Teste da ``view function`` ``issue_grid`` acessando a grade de números
de um periódico. Em caso de artigos no fasciculo de ``ahead`` o botão de ahead
não deve ser apresentado.
"""

with current_app.app_context():
utils.makeOneCollection()

journal = utils.makeOneJournal()

utils.makeOneIssue(attrib={"journal": journal.id, "type": "ahead"})

response = self.client.get(
url_for("main.issue_grid", url_seg=journal.url_segment)
)

self.assertStatus(response, 200)
self.assertTemplateUsed("issue/grid.html")

self.assertNotIn("ahead", response.data.decode("utf-8"))


class TestIssueToc(BaseTestCase):
def test_issue_toc(self):
Expand Down
6 changes: 6 additions & 0 deletions opac/webapp/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,12 @@ def get_issues_for_grid_by_jid(jid, **kwargs):
**kwargs,
).order_by(*order_by)
issue_ahead = issues.filter(type="ahead").first()

if issue_ahead:
# Verifica que contém artigos no issue de ahead
if not get_articles_by_iid(issue_ahead.id, is_public=True):
issue_ahead = None

issues_without_ahead = issues.filter(type__ne="ahead")

volume_issue = {}
Expand Down

0 comments on commit 71da2bc

Please sign in to comment.