-
Notifications
You must be signed in to change notification settings - Fork 9
Permitir customização de logo da coleção no header, menu, rodapé e páginas internas #405
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
Changes from all commits
6de5c38
0a79f21
1bfc847
518e1f6
64d654f
648dddb
a66b849
8a31e89
47763af
81c9df0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,3 +55,90 @@ def test_collection_trans_home(self): | |||||||||||||||||||||||||||||
| self.assertStatus(response, 200) | ||||||||||||||||||||||||||||||
| expected_anchor = "colección falsa" | ||||||||||||||||||||||||||||||
| self.assertIn(expected_anchor, response.data.decode("utf-8")) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def test_home_logo_shown_when_configured(self): | ||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||
| Verificamos se a home exibe o logo da coleção quando está configurado. | ||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| with current_app.app_context(): | ||||||||||||||||||||||||||||||
| utils.makeOneCollection( | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| "name_pt": "coleção falsa", | ||||||||||||||||||||||||||||||
| "home_logo_pt": "http://example.com/logo_pt.png", | ||||||||||||||||||||||||||||||
| "home_logo_en": "http://example.com/logo_en.png", | ||||||||||||||||||||||||||||||
| "home_logo_es": "http://example.com/logo_es.png", | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| with self.client as c: | ||||||||||||||||||||||||||||||
| # idioma em 'pt_br' | ||||||||||||||||||||||||||||||
| response = c.get( | ||||||||||||||||||||||||||||||
| url_for("main.set_locale", lang_code="pt_BR"), | ||||||||||||||||||||||||||||||
| headers={"Referer": "/"}, | ||||||||||||||||||||||||||||||
| follow_redirects=True, | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self.assertStatus(response, 200) | ||||||||||||||||||||||||||||||
| self.assertIn( | ||||||||||||||||||||||||||||||
| "http://example.com/logo_pt.png", | ||||||||||||||||||||||||||||||
| response.data.decode("utf-8"), | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| self.assertNotIn( | ||||||||||||||||||||||||||||||
| 'id="collectionNameHome"', response.data.decode("utf-8") | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # idioma em 'en' | ||||||||||||||||||||||||||||||
| response = c.get( | ||||||||||||||||||||||||||||||
| url_for("main.set_locale", lang_code="en"), | ||||||||||||||||||||||||||||||
| headers={"Referer": "/"}, | ||||||||||||||||||||||||||||||
| follow_redirects=True, | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self.assertStatus(response, 200) | ||||||||||||||||||||||||||||||
| self.assertIn( | ||||||||||||||||||||||||||||||
| "http://example.com/logo_en.png", | ||||||||||||||||||||||||||||||
| response.data.decode("utf-8"), | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| # idioma em 'es' | |
| response = c.get( | |
| url_for("main.set_locale", lang_code="es"), | |
| headers={"Referer": "/"}, | |
| follow_redirects=True, | |
| ) | |
| self.assertStatus(response, 200) | |
| self.assertIn( | |
| "http://example.com/logo_es.png", | |
| response.data.decode("utf-8"), | |
| ) |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esse teste fica bem frágil por depender de uma string HTML completa e exata (incluindo aspas/ordem/possíveis mudanças de espaçamento/alterações de tradução). Sugestão: tornar a asserção mais resiliente checando separadamente que o HTML contém aria-label= e que o valor contém o nome dinâmico da coleção (ex.: procurar apenas pelo fragmento com coleção falsa, ou usar uma asserção menos estrita para o atributo).
| self.assertIn( | |
| 'aria-label="Acessar site coleção coleção falsa"', | |
| response.data.decode("utf-8"), | |
| ) | |
| html = response.data.decode("utf-8") | |
| # Garante que existe um atributo aria-label na página | |
| self.assertIn("aria-label=", html) | |
| # Garante que algum aria-label contém o nome dinâmico da coleção, | |
| # sem depender da string completa exata. | |
| self.assertRegex(html, r'aria-label="[^"]*coleção falsa[^"]*"') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,12 @@ <h2 class="logo-svg"> | |
| <div class="scielo__mainMenu" id="mainMenu"> | ||
| <div class="row"> | ||
| <div class="col text-center"> | ||
| <div class="scielo__logo-scielo--small"></div> | ||
| {%- set menu_logo_url = cimages.get_menu_logo(g.collection, session.lang)|default('')|trim -%} | ||
| {%- if menu_logo_url -%} | ||
| {{ cimages.render_logo(menu_logo_url, coll_macro.get_collection_name(), img_class='img-fluid') }} | ||
|
Comment on lines
+48
to
+50
|
||
| {%- else -%} | ||
| <a href="/" aria-label="{% trans %}Página inicial da coleção{% endtrans %} {{ coll_macro.get_collection_name() }}"><div class="scielo__logo-scielo--small" aria-hidden="true"></div></a> | ||
| {%- endif -%} | ||
| </div> | ||
| </div> | ||
| <nav> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||
| {% import 'macros/collection.html' as coll_macro %} | ||||||
| {% import 'macros/images.html' as img_macro %} | ||||||
|
|
||||||
| <details class="scielo__accessibleMenu"> | ||||||
| <summary> | ||||||
|
|
@@ -8,7 +9,12 @@ | |||||
| <nav style="max-height: 780px;"> | ||||||
| <ul> | ||||||
| <li class="logo"> | ||||||
| <div class="scielo__logo-scielo--small"></div> | ||||||
| {%- set menu_logo_url = img_macro.get_menu_logo(g.collection, session.lang)|default('')|trim -%} | ||||||
| {%- if menu_logo_url -%} | ||||||
| {{ img_macro.render_logo(menu_logo_url, coll_macro.get_collection_name(), img_class='img-fluid') }} | ||||||
| {%- else -%} | ||||||
| <a href="/" aria-label="{% trans %}Página inicial da coleção{% endtrans %} {{ coll_macro.get_collection_name() }}"><div class="scielo__logo-scielo--small" aria-hidden="true"></div></a> | ||||||
| {%- endif -%} | ||||||
| </li> | ||||||
| <li> | ||||||
| <a href="{{ url_for('.index') }}" alt="{% trans %}Acessar site coleção{% endtrans %} {{ coll_macro.get_collection_name() }}" aria-label="{% trans %}Acessar site coleção{% endtrans %} {{ coll_macro.get_collection_name() }}"> | ||||||
|
||||||
| <a href="{{ url_for('.index') }}" alt="{% trans %}Acessar site coleção{% endtrans %} {{ coll_macro.get_collection_name() }}" aria-label="{% trans %}Acessar site coleção{% endtrans %} {{ coll_macro.get_collection_name() }}"> | |
| <a href="{{ url_for('.index') }}" aria-label="{% trans %}Acessar site coleção{% endtrans %} {{ coll_macro.get_collection_name() }}"> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,11 +8,16 @@ | |||||
| {% include "collection/includes/nav.html" %} | ||||||
| </div> | ||||||
| <div class="col col-md-3"> | ||||||
| <a href="/" title="{% trans %}Ir para a homepage da coleção: {% endtrans %}{{ coll_macro.get_collection_name() }}"> | ||||||
| {%- set header_logo_url = cimages.get_header_logo(g.collection, session.lang)|default('')|trim -%} | ||||||
|
||||||
| {%- set header_logo_url = cimages.get_header_logo(g.collection, session.lang)|default('')|trim -%} | |
| {%- set header_logo_url = cimages.get_header_logo(g.collection, session.lang)|default('', true)|trim -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O template escolhe o logo por idioma (
pt/en/es), mas o teste só validapt_BReen. Para cobrir o comportamento introduzido (seleção por idioma), faltou validar tambémes. Além disso, os asserts atuais checam apenas a presença da URL no HTML; para reduzir falso-positivo, vale checar uma substring mais específica (ex.:<img src="...">) e, no cenário de fallback, afirmar que não existe<imgquando não há logo configurado.