Restructure govuk-alerts endpoint to be internal

In response to: https://github.com/alphagov/notifications-api/pull/3305#pullrequestreview-726672421

Previously this was added among the public /v2 endpoints, but it's
only meant for internal use. While only the govuk-alerts app would
be able to access it, the location and /v2 URL suggested otherwise.
This restructures the endpoint so it resembles other internal ones.
This commit is contained in:
Ben Thorner
2021-09-15 15:21:20 +01:00
parent d61ec50fb1
commit 6a53871455
7 changed files with 19 additions and 26 deletions

View File

@@ -1,11 +0,0 @@
from flask import Blueprint
from app.v2.errors import register_errors
v2_govuk_alerts_blueprint = Blueprint(
"v2_govuk-alerts_blueprint",
__name__,
url_prefix='/v2/govuk-alerts',
)
register_errors(v2_govuk_alerts_blueprint)

View File

@@ -1,23 +0,0 @@
from flask import jsonify
from app.dao.broadcast_message_dao import dao_get_all_broadcast_messages
from app.utils import get_dt_string_or_none
from app.v2.govuk_alerts import v2_govuk_alerts_blueprint
@v2_govuk_alerts_blueprint.route('')
def get_broadcasts():
broadcasts = dao_get_all_broadcast_messages()
broadcasts_dict = {"alerts": [{
"id": broadcast.id,
"reference": broadcast.reference,
"channel": broadcast.channel,
"content": broadcast.content,
"areas": broadcast.areas,
"status": broadcast.status,
"starts_at": get_dt_string_or_none(broadcast.starts_at),
"finishes_at": get_dt_string_or_none(broadcast.finishes_at),
"approved_at": get_dt_string_or_none(broadcast.approved_at),
"cancelled_at": get_dt_string_or_none(broadcast.cancelled_at),
} for broadcast in broadcasts]}
return jsonify(broadcasts_dict), 200