From 0c45c9704c2a04bca00ff7e9b245e450715e4159 Mon Sep 17 00:00:00 2001 From: William May Date: Tue, 24 Dec 2024 01:06:15 +0000 Subject: [PATCH] FS-4919 - Renaming fund-builder blueprint to index and moving login and dashboard templates into its directory --- app/blueprints/application/routes.py | 6 +++--- .../templates/build_application.html | 4 ++-- app/blueprints/fund/routes.py | 8 ++++---- .../{fund_builder => index}/routes.py | 20 +++++++++---------- .../index}/templates/dashboard.html | 0 .../index}/templates/login.html | 0 app/blueprints/round/routes.py | 6 +++--- app/blueprints/template/routes.py | 6 +++--- app/create_app.py | 8 ++++---- app/templates/base.html | 2 +- 10 files changed, 30 insertions(+), 30 deletions(-) rename app/blueprints/{fund_builder => index}/routes.py (82%) rename app/{ => blueprints/index}/templates/dashboard.html (100%) rename app/{ => blueprints/index}/templates/login.html (100%) diff --git a/app/blueprints/application/routes.py b/app/blueprints/application/routes.py index 9395fb75..06188a1b 100644 --- a/app/blueprints/application/routes.py +++ b/app/blueprints/application/routes.py @@ -43,7 +43,7 @@ from app.export_config.generate_fund_round_html import generate_all_round_html from config import Config -BUILD_FUND_BP_DASHBOARD = "build_fund_bp.dashboard" +INDEX_BP_DASHBOARD = "index_bp.dashboard" # Blueprint for routes used by v1 of FAB - using the DB application_bp = Blueprint( @@ -105,7 +105,7 @@ def section(round_id): ] params["breadcrumb_items"] = [ - {"text": "Home", "href": url_for(BUILD_FUND_BP_DASHBOARD)}, + {"text": "Home", "href": url_for(INDEX_BP_DASHBOARD)}, {"text": fund_obj.name_json["en"], "href": url_for("fund_bp.view_fund", fund_id=fund_obj.fund_id)}, { "text": round_obj.title_json["en"], @@ -144,7 +144,7 @@ def build_application(round_id): round = get_round_by_id(round_id) fund = get_fund_by_id(round.fund_id) breadcrumb_items = [ - {"text": "Home", "href": url_for(BUILD_FUND_BP_DASHBOARD)}, + {"text": "Home", "href": url_for(INDEX_BP_DASHBOARD)}, {"text": fund.name_json["en"], "href": url_for("fund_bp.view_fund", fund_id=fund.fund_id)}, {"text": round.title_json["en"], "href": "#"}, ] diff --git a/app/blueprints/application/templates/build_application.html b/app/blueprints/application/templates/build_application.html index 541900f0..9dfd6f3b 100644 --- a/app/blueprints/application/templates/build_application.html +++ b/app/blueprints/application/templates/build_application.html @@ -54,8 +54,8 @@

View  - Download  - Preview  + Download  + Preview  {% endfor %} diff --git a/app/blueprints/fund/routes.py b/app/blueprints/fund/routes.py index 2cbd5dac..fcad5af6 100644 --- a/app/blueprints/fund/routes.py +++ b/app/blueprints/fund/routes.py @@ -10,12 +10,12 @@ ) from app.blueprints.fund.forms import FundForm -from app.blueprints.fund_builder.routes import all_funds_as_govuk_select_items +from app.blueprints.index.routes import all_funds_as_govuk_select_items from app.db.models.fund import Fund, FundingType from app.db.queries.fund import add_fund, get_all_funds, get_fund_by_id, update_fund from app.shared.helpers import error_formatter -BUILD_FUND_BP_DASHBOARD = "build_fund_bp.dashboard" +INDEX_BP_DASHBOARD = "index_bp.dashboard" # Blueprint for routes used by v1 of FAB - using the DB fund_bp = Blueprint( @@ -42,7 +42,7 @@ def view_fund(): params["fund"] = fund params["selected_fund_id"] = fund_id params["breadcrumb_items"] = [ - {"text": "Home", "href": url_for(BUILD_FUND_BP_DASHBOARD)}, + {"text": "Home", "href": url_for(INDEX_BP_DASHBOARD)}, {"text": fund.title_json["en"] if fund else "Manage Application Configuration", "href": "#"}, ] @@ -109,7 +109,7 @@ def fund(fund_id=None): ) add_fund(new_fund) flash(f"Created fund {form.name_en.data}") - return redirect(url_for(BUILD_FUND_BP_DASHBOARD)) + return redirect(url_for(INDEX_BP_DASHBOARD)) error = error_formatter(form) return render_template("fund.html", form=form, fund_id=fund_id, error=error) diff --git a/app/blueprints/fund_builder/routes.py b/app/blueprints/index/routes.py similarity index 82% rename from app/blueprints/fund_builder/routes.py rename to app/blueprints/index/routes.py index ccd1b8c9..b7a1cae6 100644 --- a/app/blueprints/fund_builder/routes.py +++ b/app/blueprints/index/routes.py @@ -16,31 +16,31 @@ from app.export_config.generate_form import build_form_json from config import Config -BUILD_FUND_BP_DASHBOARD = "build_fund_bp.dashboard" +INDEX_BP_DASHBOARD = "index_bp.dashboard" # Blueprint for routes used by v1 of FAB - using the DB -build_fund_bp = Blueprint( - "build_fund_bp", +index_bp = Blueprint( + "index_bp", __name__, url_prefix="/", template_folder="templates", ) -@build_fund_bp.route("/") +@index_bp.route("/") @login_requested def index(): if not g.is_authenticated: - return redirect(url_for("build_fund_bp.login")) - return redirect(url_for("build_fund_bp.dashboard")) + return redirect(url_for("index_bp.login")) + return redirect(url_for("index_bp.dashboard")) -@build_fund_bp.route("/login", methods=["GET"]) +@index_bp.route("/login", methods=["GET"]) def login(): return render_template("login.html") -@build_fund_bp.route("/dashboard", methods=["GET"]) +@index_bp.route("/dashboard", methods=["GET"]) def dashboard(): return render_template("dashboard.html") @@ -53,7 +53,7 @@ def all_funds_as_govuk_select_items(all_funds: list) -> list: return [{"text": f"{f.short_name} - {f.name_json['en']}", "value": str(f.fund_id)} for f in all_funds] -@build_fund_bp.route("/preview/", methods=["GET"]) +@index_bp.route("/preview/", methods=["GET"]) def preview_form(form_id): """ Generates the form json for a chosen form, does not persist this, but publishes it to the form runner using the @@ -74,7 +74,7 @@ def preview_form(form_id): return redirect(f"{Config.FORM_RUNNER_URL_REDIRECT}/{form_id}") -@build_fund_bp.route("/download/", methods=["GET"]) +@index_bp.route("/download/", methods=["GET"]) def download_form_json(form_id): """ Generates form json for the selected form and returns it as a file download diff --git a/app/templates/dashboard.html b/app/blueprints/index/templates/dashboard.html similarity index 100% rename from app/templates/dashboard.html rename to app/blueprints/index/templates/dashboard.html diff --git a/app/templates/login.html b/app/blueprints/index/templates/login.html similarity index 100% rename from app/templates/login.html rename to app/blueprints/index/templates/login.html diff --git a/app/blueprints/round/routes.py b/app/blueprints/round/routes.py index b0d5d203..8b9bd22f 100644 --- a/app/blueprints/round/routes.py +++ b/app/blueprints/round/routes.py @@ -11,7 +11,7 @@ url_for, ) -from app.blueprints.fund_builder.routes import all_funds_as_govuk_select_items +from app.blueprints.index.routes import all_funds_as_govuk_select_items from app.blueprints.round.forms import RoundForm, get_datetime from app.db.models.round import Round from app.db.queries.clone import clone_single_round @@ -19,7 +19,7 @@ from app.db.queries.round import add_round, get_round_by_id, update_round from app.shared.helpers import error_formatter -BUILD_FUND_BP_DASHBOARD = "build_fund_bp.dashboard" +INDEX_BP_DASHBOARD = "index_bp.dashboard" # Blueprint for routes used by v1 of FAB - using the DB round_bp = Blueprint( @@ -66,7 +66,7 @@ def round(round_id=None): return redirect(url_for("fund_bp.view_fund", fund_id=round.fund_id)) create_new_round(form) flash(f"Created round {form.title_en.data}") - return redirect(url_for(BUILD_FUND_BP_DASHBOARD)) + return redirect(url_for(INDEX_BP_DASHBOARD)) params["round_id"] = round_id params["form"] = form diff --git a/app/blueprints/template/routes.py b/app/blueprints/template/routes.py index 29e6f196..82e45284 100644 --- a/app/blueprints/template/routes.py +++ b/app/blueprints/template/routes.py @@ -36,7 +36,7 @@ def _build_rows(forms: list[Form]) -> list[dict]: row = [ { "html": "{form.template_name}" + f"href='{url_for('index_bp.preview_form', form_id=form.form_id)}'>{form.template_name}" }, {"text": form.name_in_apply_json["en"]}, {"text": form.runner_publish_name}, @@ -62,7 +62,7 @@ def view_templates(): "form_template_rows": _build_rows(forms), "uploadform": form, "breadcrumb_items": [ - {"text": "Home", "href": url_for("build_fund_bp.dashboard")}, + {"text": "Home", "href": url_for("index_bp.dashboard")}, {"text": "Manage Templates", "href": "#"}, ], } @@ -97,7 +97,7 @@ def edit_form_template(form_id): template_form = TemplateFormForm() params = { "breadcrumb_items": [ - {"text": "Home", "href": url_for("build_fund_bp.dashboard")}, + {"text": "Home", "href": url_for("index_bp.dashboard")}, {"text": "Manage Templates", "href": url_for("template_bp.view_templates")}, {"text": "Rename Template", "href": "#"}, ], diff --git a/app/create_app.py b/app/create_app.py index 6a96f748..c915cff2 100644 --- a/app/create_app.py +++ b/app/create_app.py @@ -8,14 +8,14 @@ from app.blueprints.application.routes import application_bp from app.blueprints.fund.routes import fund_bp -from app.blueprints.fund_builder.routes import build_fund_bp +from app.blueprints.index.routes import index_bp from app.blueprints.round.routes import round_bp from app.blueprints.template.routes import template_bp PUBLIC_ROUTES = [ "static", - "build_fund_bp.index", - "build_fund_bp.login", + "index_bp.index", + "index_bp.login", ] @@ -32,7 +32,7 @@ def protect_private_routes(flask_app: Flask) -> Flask: def create_app() -> Flask: init_sentry() flask_app = Flask("__name__", static_url_path="/assets") - flask_app.register_blueprint(build_fund_bp) + flask_app.register_blueprint(index_bp) flask_app.register_blueprint(fund_bp) flask_app.register_blueprint(round_bp) flask_app.register_blueprint(application_bp) diff --git a/app/templates/base.html b/app/templates/base.html index fa9b5247..6e03ada6 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -12,7 +12,7 @@ {{ govukHeader({ 'useTudorCrown': 'yes', 'serviceName': 'Fund Application Builder', - 'serviceUrl': url_for('build_fund_bp.index'), + 'serviceUrl': url_for('index_bp.index'), }) }} {% endblock header %}