Skip to content

Commit

Permalink
FS-4919 - Renaming fund-builder blueprint to index
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrm500 committed Dec 24, 2024
1 parent 1b7b7a2 commit 65c0cbd
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
8 changes: 4 additions & 4 deletions app/blueprints/application/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -133,7 +133,7 @@ def configure_forms_in_section(round_id, section_id):
new_section_index = max(len(section.forms) + 1, 1)
clone_single_form(form_id=template_id, new_section_id=section_id, section_index=new_section_index)

return redirect(url_for("build_fund_bp.section", round_id=round_id, section_id=section_id))
return redirect(url_for("index_bp.section", round_id=round_id, section_id=section_id))


@application_bp.route("/<round_id>/application_config")
Expand All @@ -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": "#"},
]
Expand Down
20 changes: 10 additions & 10 deletions app/blueprints/application/templates/build_application.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ <h2 class="govuk-heading-m">{{ fund.short_name }} - {{round.title_json["en"]}} (
</div>
{{ govukButton({
"text": "View All Questions",
"href": url_for("build_fund_bp.view_all_questions", round_id=round.round_id) ,
"href": url_for("index_bp.view_all_questions", round_id=round.round_id) ,
"classes": "govuk-button--secondary"
})
}}
{{ govukButton({
"text": "Create export files for round",
"href": url_for("build_fund_bp.create_export_files", round_id=round.round_id) ,
"href": url_for("index_bp.create_export_files", round_id=round.round_id) ,
"classes": "govuk-button--secondary"
})
}}
<ul class="app-task-list__items">
{{ govukButton({
"text": "Add Section",
"href": url_for("build_fund_bp.section", round_id=round.round_id) ,
"href": url_for("index_bp.section", round_id=round.round_id) ,
"classes": "govuk-button--secondary"
})
}}
Expand All @@ -35,13 +35,13 @@ <h2 class="govuk-heading-m">{{ fund.short_name }} - {{round.title_json["en"]}} (
<h3 class="govuk-heading-m">{{ section.index }}. {{ section.name_in_apply_json["en"] }}</h3>
</span>
<span class="app-task-list__task-actions">
<a class="govuk-link--no-visited-state" href='{{ url_for("build_fund_bp.section", round_id=round.round_id, section_id=section.section_id) }}'>Edit</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("build_fund_bp.section",round_id=round.round_id, section_id=section.section_id, action="remove") }}'>Remove</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("index_bp.section", round_id=round.round_id, section_id=section.section_id) }}'>Edit</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("index_bp.section",round_id=round.round_id, section_id=section.section_id, action="remove") }}'>Remove</a>&nbsp;
{% if section.index > 1 %}
<a class="govuk-link--no-visited-state" href='{{ url_for("build_fund_bp.section",round_id=round.round_id, index=section.index, action="move_up") }}'>Move up</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("index_bp.section",round_id=round.round_id, index=section.index, action="move_up") }}'>Move up</a>&nbsp;
{% endif %}
{% if section.index < round.sections | length %}
<a class="govuk-link--no-visited-state" href='{{ url_for("build_fund_bp.section",round_id=round.round_id, index=section.index, action="move_down") }}'> Move down</a>
<a class="govuk-link--no-visited-state" href='{{ url_for("index_bp.section",round_id=round.round_id, index=section.index, action="move_down") }}'> Move down</a>
{% endif %}
</span>
<ul class="app-task-list__items">
Expand All @@ -53,9 +53,9 @@ <h3 class="govuk-body">
</h3>
</span>
<span class="app-task-list__task-actions">
<a class="govuk-link--no-visited-state" href="{{ url_for('build_fund_bp.view_form_questions', round_id=round.round_id, form_id=form.form_id) }}">View</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("build_fund_bp.download_form_json", form_id=form.form_id) }}'>Download</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("build_fund_bp.preview_form", form_id=form.form_id) }}'>Preview</a>&nbsp;
<a class="govuk-link--no-visited-state" href="{{ url_for('index_bp.view_form_questions', round_id=round.round_id, form_id=form.form_id) }}">View</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("index_bp.download_form_json", form_id=form.form_id) }}'>Download</a>&nbsp;
<a class="govuk-link--no-visited-state" href='{{ url_for("index_bp.preview_form", form_id=form.form_id) }}'>Preview</a>&nbsp;
</span>
</li>
{% endfor %}
Expand Down
8 changes: 4 additions & 4 deletions app/blueprints/application/templates/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ <h3 class="govuk-body">{{ app_form.section_index }}.&nbsp;{{ app_form.name_in_ap
</span>
<span class="app-task-list__task-actions">
<a class="govuk-link--no-visited-state"
href="{{ url_for('build_fund_bp.configure_forms_in_section', round_id=round_id, section_id=app_form.section_id, form_id=app_form.form_id, action='remove') }}">Remove</a>&nbsp;
href="{{ url_for('index_bp.configure_forms_in_section', round_id=round_id, section_id=app_form.section_id, form_id=app_form.form_id, action='remove') }}">Remove</a>&nbsp;
{% if app_form.section_index > 1 %}
<a class="govuk-link--no-visited-state"
href="{{ url_for('build_fund_bp.configure_forms_in_section', round_id=round_id, section_id=app_form.section_id, index=app_form.section_index, action='move_up') }}">Move up</a>&nbsp;
href="{{ url_for('index_bp.configure_forms_in_section', round_id=round_id, section_id=app_form.section_id, index=app_form.section_index, action='move_up') }}">Move up</a>&nbsp;
{% endif %}
{% if app_form.section_index < forms_in_section | length %}
<a class="govuk-link--no-visited-state"
href="{{ url_for('build_fund_bp.configure_forms_in_section', round_id=round_id, section_id=app_form.section_id, index=app_form.section_index, action='move_down') }}"> Move down</a>
href="{{ url_for('index_bp.configure_forms_in_section', round_id=round_id, section_id=app_form.section_id, index=app_form.section_index, action='move_down') }}"> Move down</a>
{% endif %}
</span>
</li>
{% endfor %}
</ul>
<h3 class="govuk-heading-m">Add Form From Template</h3>
<form method="POST"
action="{{ url_for('build_fund_bp.configure_forms_in_section', round_id=round_id,section_id=form.section_id.data) }}">
action="{{ url_for('index_bp.configure_forms_in_section', round_id=round_id,section_id=form.section_id.data) }}">
{{ govukSelect({
"id": "template_id",
"name": "template_id",
Expand Down
8 changes: 4 additions & 4 deletions app/blueprints/fund/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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": "#"},
]

Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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/<form_id>", methods=["GET"])
@index_bp.route("/preview/<form_id>", 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
Expand All @@ -74,7 +74,7 @@ def preview_form(form_id):
return redirect(f"{Config.FORM_RUNNER_URL_REDIRECT}/{form_id}")


@build_fund_bp.route("/download/<form_id>", methods=["GET"])
@index_bp.route("/download/<form_id>", methods=["GET"])
def download_form_json(form_id):
"""
Generates form json for the selected form and returns it as a file download
Expand Down
6 changes: 3 additions & 3 deletions app/blueprints/round/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
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
from app.db.queries.fund import get_all_funds
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(
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/blueprints/template/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _build_rows(forms: list[Form]) -> list[dict]:
row = [
{
"html": "<a class='govuk-link--no-visited-state' "
f"href='{url_for('build_fund_bp.preview_form', form_id=form.form_id)}'>{form.template_name}</a>"
f"href='{url_for('index_bp.preview_form', form_id=form.form_id)}'>{form.template_name}</a>"
},
{"text": form.name_in_apply_json["en"]},
{"text": form.runner_publish_name},
Expand All @@ -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": "#"},
],
}
Expand Down Expand Up @@ -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": "#"},
],
Expand Down
8 changes: 4 additions & 4 deletions app/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]


Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down

0 comments on commit 65c0cbd

Please sign in to comment.