Skip to content

Commit

Permalink
Merge pull request #2140 from gitnnolabs/disable_enable_section_filter
Browse files Browse the repository at this point in the history
Garante que o parâmetro section_filter funcione somente quando a variável de confirguração FILTER_SECTION_ENABLE
  • Loading branch information
gitnnolabs authored Nov 18, 2021
2 parents 9a15db3 + bceb24b commit 9b54202
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions opac/webapp/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ def issue_toc_legacy(url_seg, url_seg_issue):
@main.route('/j/<string:url_seg>/i/<string:url_seg_issue>/')
@cache.cached(key_prefix=cache_key_with_lang_with_qs)
def issue_toc(url_seg, url_seg_issue):
section_filter = None
goto = request.args.get("goto", None, type=str)
if goto not in ("previous", "next"):
goto = None
Expand All @@ -810,8 +811,9 @@ def issue_toc(url_seg, url_seg_issue):
# idioma da sessão
language = session.get('lang', get_locale())

# seção dos documentos, se selecionada
section_filter = request.args.get('section', '', type=str).upper()
if current_app.config["FILTER_SECTION_ENABLE"]:
# seção dos documentos, se selecionada
section_filter = request.args.get('section', '', type=str).upper()

# obtém o issue
issue = controllers.get_issue_by_url_seg(url_seg, url_seg_issue)
Expand Down Expand Up @@ -843,7 +845,7 @@ def issue_toc(url_seg, url_seg_issue):
# obtém as seções dos documentos deste sumário
sections = []

if section_filter != '':
if current_app.config["FILTER_SECTION_ENABLE"] and section_filter != '':
# obtém somente os documentos da seção selecionada
articles = [a for a in articles if a.section.upper() == section_filter]

Expand Down
4 changes: 2 additions & 2 deletions opac/webapp/templates/issue/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h1>{% trans %}Sumário{% endtrans %}</h1>

{% if sections %}
<li>
<a href="{{this_page_url}}">
<a href="{{this_page_url}}" rel="nofollow">
{% if section_filter|length == 0 %}
{% trans %}Todas as seções{% endtrans %} <span style="color: #6789d3;">&laquo;</span>
{% else %}
Expand All @@ -114,7 +114,7 @@ <h1>{% trans %}Sumário{% endtrans %}</h1>
{% for section in sections %}
{% if section %}
<li>
<a href="{{this_page_url}}?section={{ section|upper }}">
<a href="{{this_page_url}}?section={{ section|upper }}" rel="nofollow">
{% if section_filter|upper == section|upper %}
{{ section }} <span style="color: #6789d3;">&laquo;</span>
{% else %}
Expand Down

0 comments on commit 9b54202

Please sign in to comment.