mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
remove header banner when site is down
This commit is contained in:
@@ -118,6 +118,8 @@ from notifications_utils.formatters import (
|
|||||||
from notifications_utils.recipients import format_phone_number_human_readable
|
from notifications_utils.recipients import format_phone_number_human_readable
|
||||||
from notifications_utils.url_safe_token import generate_token
|
from notifications_utils.url_safe_token import generate_token
|
||||||
|
|
||||||
|
from app.utils.api_health import is_api_down
|
||||||
|
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
csrf = CSRFProtect()
|
csrf = CSRFProtect()
|
||||||
talisman = Talisman()
|
talisman = Talisman()
|
||||||
@@ -185,6 +187,10 @@ def create_app(application):
|
|||||||
# FEATURE_ABOUT_PAGE_ENABLED=feature_about_page_enabled,
|
# FEATURE_ABOUT_PAGE_ENABLED=feature_about_page_enabled,
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
@application.context_processor
|
||||||
|
def inject_is_api_down():
|
||||||
|
return {"is_api_down": is_api_down()}
|
||||||
|
|
||||||
@application.context_processor
|
@application.context_processor
|
||||||
def inject_initial_signin_url():
|
def inject_initial_signin_url():
|
||||||
ttl = 24 * 60 * 60
|
ttl = 24 * 60 * 60
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from app.main.views.sub_navigation_dictionaries import (
|
|||||||
about_notify_nav,
|
about_notify_nav,
|
||||||
using_notify_nav,
|
using_notify_nav,
|
||||||
)
|
)
|
||||||
from app.utils.api_health import is_api_down
|
|
||||||
from app.utils.user import user_is_logged_in
|
from app.utils.user import user_is_logged_in
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -47,16 +46,10 @@ def index():
|
|||||||
if current_user and current_user.is_authenticated:
|
if current_user and current_user.is_authenticated:
|
||||||
return redirect(url_for("main.choose_account"))
|
return redirect(url_for("main.choose_account"))
|
||||||
|
|
||||||
try:
|
|
||||||
counts = status_api_client.get_count_of_live_services_and_organizations()
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"API down when loading homepage: {e}")
|
|
||||||
counts = None
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"views/signedout.html",
|
"views/signedout.html",
|
||||||
sms_rate=CURRENT_SMS_RATE,
|
sms_rate=CURRENT_SMS_RATE,
|
||||||
counts=counts,
|
counts=status_api_client.get_count_of_live_services_and_organizations()
|
||||||
is_api_down=is_api_down(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,29 +29,31 @@
|
|||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{% include 'components/usa_banner.html' %}
|
{% include 'components/usa_banner.html' %}
|
||||||
{% if current_user.is_authenticated or current_service or current_user.platform_admin %}
|
{% if not is_api_down %}
|
||||||
<section class="usa-site-alert usa-site-alert--info" aria-label="Site alert,,,,">
|
{% if current_user.is_authenticated or current_service or current_user.platform_admin %}
|
||||||
<div class="usa-alert">
|
<section class="usa-site-alert usa-site-alert--info" aria-label="Site alert,,,,">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert">
|
||||||
<p class="usa-alert__heading text-bold">Notify.gov Service Ending</p>
|
<div class="usa-alert__body">
|
||||||
<p class="usa-alert__text">
|
<p class="usa-alert__heading text-bold">Notify.gov Service Ending</p>
|
||||||
GSA will no longer offer the Notify.gov service after June 8th, 2025. Visit
|
<p class="usa-alert__text">
|
||||||
<a class="usa-link" href="/notify-service-ending">Notify.gov Service Ending</a> for more information.
|
GSA will no longer offer the Notify.gov service after June 8th, 2025. Visit
|
||||||
</p>
|
<a class="usa-link" href="/notify-service-ending">Notify.gov Service Ending</a> for more information.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</section>
|
{% else %}
|
||||||
{% else %}
|
<section class="usa-site-alert usa-site-alert--emergency usa-site-alert--no-heading" aria-label="Site alert,,,,">
|
||||||
<section class="usa-site-alert usa-site-alert--emergency usa-site-alert--no-heading" aria-label="Site alert,,,,">
|
<div class="usa-alert">
|
||||||
<div class="usa-alert">
|
<div class="usa-alert__body">
|
||||||
<div class="usa-alert__body">
|
<p class="usa-alert__heading text-bold">Notify.gov Service Ending</p>
|
||||||
<p class="usa-alert__heading text-bold">Notify.gov Service Ending</p>
|
<p class="usa-alert__text">
|
||||||
<p class="usa-alert__text">
|
Notify.gov is no longer accepting new partners.
|
||||||
Notify.gov is no longer accepting new partners.
|
</p>
|
||||||
</p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</section>
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include 'components/header.html' %}
|
{% include 'components/header.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import logging
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def is_api_down():
|
def is_api_down():
|
||||||
api_base_url = os.getenv("API_BASE_URL", "http://localhost:6011")
|
api_base_url = os.getenv("API_HOST_NAME")
|
||||||
try:
|
try:
|
||||||
response = requests.get(api_base_url, timeout=2)
|
response = requests.get(api_base_url, timeout=2)
|
||||||
return response.status_code != 200
|
is_down = response.status_code != 200
|
||||||
except RequestException:
|
if is_down:
|
||||||
|
logger.warning(f"API responded with status {response.status_code} at {api_base_url}")
|
||||||
|
return is_down
|
||||||
|
except RequestException as e:
|
||||||
|
logger.error(f"API down when loading homepage {e}")
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user