Repository navigation
Torna configurável a exibição do link para o site antigo #1489
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
2cb40bd
3164f00
969ebb2
ff87a04
1f11c56
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||||||
| from urllib.parse import urlparse | ||||||||||||
|
|
||||||||||||
| from django.conf import settings | ||||||||||||
| from django.db import models | ||||||||||||
| from django.db.models import Prefetch, Q | ||||||||||||
|
|
@@ -74,10 +76,29 @@ def default_journal_filter(search_term, starts_with_letter, active_or_discontinu | |||||||||||
|
|
||||||||||||
| def _default_context(context): | ||||||||||||
| context["social_networks"] = get_social_networks("scl") | ||||||||||||
| context["old_scielo_url"] = settings.SCIELO_OLD_URL | ||||||||||||
| context["old_scielo_link"] = get_old_scielo_link() | ||||||||||||
| context["page_about"] = get_page_about() | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def get_old_scielo_link(): | ||||||||||||
| """ | ||||||||||||
| Retorna o link para o site antigo como {"url": ..., "label": ...}, | ||||||||||||
| ou None se o link estiver desabilitado (SCIELO_OLD_URL_ENABLED=False). | ||||||||||||
| SCIELO_OLD_URL deve começar com http:// ou https://; caso contrário, | ||||||||||||
| usa o valor padrão. O label é a URL sem o protocolo. | ||||||||||||
| """ | ||||||||||||
| if not getattr(settings, "SCIELO_OLD_URL_ENABLED", True): | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O fallback do
Suggested change
|
||||||||||||
| return None | ||||||||||||
|
|
||||||||||||
| default_url = "http://old.scielo.org/" | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||||||||||||
| url = (getattr(settings, "SCIELO_OLD_URL", None) or "").strip() | ||||||||||||
| if urlparse(url).scheme not in ("http", "https"): | ||||||||||||
| url = default_url | ||||||||||||
|
Comment on lines
+95
to
+96
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uma URL com esquema válido mas sem host (
Suggested change
|
||||||||||||
|
|
||||||||||||
| label = url.split("://", 1)[1].rstrip("/") | ||||||||||||
| return {"url": url, "label": label} | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def get_page_about(): | ||||||||||||
| try: | ||||||||||||
| locale = _get_current_locale() | ||||||||||||
|
|
||||||||||||
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.
Com
default=False, o link deixa de aparecer em produção no próximo deploy, a menos que alguém defina a variável. A descrição avisa, mas.envs/.production/.django(versionado) não foi atualizado, então o aviso depende de alguém lê-lo na hora do deploy.Duas opções: manter o comportamento atual com
default=Truee deixar a desativação como escolha explícita; ou incluirSCIELO_OLD_URL_ENABLED=Trueem.envs/.production/.djangoneste PR.