Skip to content

Commit

Permalink
Tidied up journey
Browse files Browse the repository at this point in the history
  • Loading branch information
srh-sloan committed Sep 16, 2024
1 parent 3c671f5 commit 5f5c06a
Show file tree
Hide file tree
Showing 14 changed files with 291 additions and 377 deletions.
2 changes: 2 additions & 0 deletions app/all_questions/metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def build_components_from_page(
title, text = determine_title_and_text_for_component(
c, include_html_components=include_html_components, form_lists=form_lists
)
field_type = c["type"]
if not title and not text:
continue

Expand Down Expand Up @@ -386,6 +387,7 @@ def build_components_from_page(
"title": title,
"text": text,
"hide_title": c["options"]["hideTitle"] if "hideTitle" in c["options"] else False,
"type": field_type,
}
components.append(component)
return components
Expand Down
51 changes: 15 additions & 36 deletions app/blueprints/fund_builder/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from app.db.queries.fund import get_all_funds
from app.db.queries.fund import get_fund_by_id
from app.db.queries.round import add_round
from app.db.queries.round import get_all_rounds
from app.db.queries.round import get_round_by_id
from app.export_config.generate_all_questions import print_html
from app.export_config.generate_form import build_form_json
Expand All @@ -56,24 +55,6 @@
)


@build_fund_bp.route("/fund/round/configure", methods=["GET", "POST"])
def configure_round():
"""
Renders a template providing a drop down list of funds. If a fund is selected, renders its config info
"""
all_rounds = get_all_rounds()

params = {
"all_rounds": [{"text": f"{r.short_name} - {r.title_json['en']}", "value": str(r.round_id)} for r in all_rounds]
}
if round_id := request.form.get("round_id") or request.args.get("round_id"):
round = get_round_by_id(round_id)
params["round"] = round
params["selected_round_id"] = round_id

return render_template("application.html", **params)


@build_fund_bp.route("/fund/round/<round_id>/section", methods=["GET", "POST"])
def section(round_id):
form: SectionForm = SectionForm()
Expand Down Expand Up @@ -103,8 +84,8 @@ def section(round_id):
}
)

flash(f"Saved section {form.name_in_apply_en.data}")
return redirect(url_for("build_fund_bp.configure_round"), code=307)
# flash(f"Saved section {form.name_in_apply_en.data}")
return redirect(url_for("build_fund_bp.view_app_config", round_id=round.round_id))
if section_id := request.args.get("section_id"):
existing_section = get_section_by_id(section_id)
form.section_id.data = section_id
Expand Down Expand Up @@ -154,7 +135,7 @@ def view_fund():
params["fund"] = fund
params["selected_fund_id"] = fund_id

return render_template("view_fund_config.html", **params)
return render_template("fund_config.html", **params)


@build_fund_bp.route("/fund/round/<round_id>/application_config")
Expand All @@ -164,7 +145,7 @@ def view_app_config(round_id):
"""
round = get_round_by_id(round_id)
fund = get_fund_by_id(round.fund_id)
return render_template("view_application_config.html", round=round, fund=fund)
return render_template("build_application.html", round=round, fund=fund)


@build_fund_bp.route("/fund/<fund_id>/round/<round_id>/clone")
Expand All @@ -176,16 +157,6 @@ def clone_round(round_id, fund_id):
return redirect(url_for("build_fund_bp.view_fund", fund_id=fund_id))


@build_fund_bp.route("/fund/round/<round_id>/assessment_config")
def view_assess_config(round_id):
"""
Renders a template displaying assessment configuration info for the chosen round
"""
round = get_round_by_id(round_id)
fund = get_fund_by_id(round.fund_id)
return render_template("view_assessment_config.html", round=round, fund=fund)


@build_fund_bp.route("/fund", methods=["GET", "POST"])
def fund():
"""
Expand Down Expand Up @@ -305,7 +276,13 @@ def view_all_questions(round_id):
lang="en",
)
html = print_html(print_data)
return render_template("view_questions.html", round=round, fund=fund, question_html=html)
return render_template(
"view_questions.html",
round=round,
fund=fund,
question_html=html,
title=f"All Questions for {fund.short_name} - {round.short_name}",
)


@build_fund_bp.route("/fund/round/<round_id>/all_questions/<form_id>", methods=["GET"])
Expand All @@ -328,8 +305,10 @@ def view_form_questions(round_id, form_id):
section_data,
lang="en",
)
html = print_html(print_data)
return render_template("view_questions.html", round=round, fund=fund, question_html=html)
html = print_html(print_data, True)
return render_template(
"view_questions.html", round=round, fund=fund, question_html=html, title=form.name_in_apply_json["en"]
)


@build_fund_bp.route("/create_export_files/<round_id>", methods=["GET"])
Expand Down
49 changes: 0 additions & 49 deletions app/blueprints/fund_builder/templates/application.html

This file was deleted.

61 changes: 61 additions & 0 deletions app/blueprints/fund_builder/templates/build_application.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% extends "base.html" %}
{%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%}
{%- from "govuk_frontend_jinja/components/accordion/macro.html" import govukAccordion -%}
{%- from "govuk_frontend_jinja/components/summary-list/macro.html" import govukSummaryList -%}
{%- from "govuk_frontend_jinja/components/select/macro.html" import govukSelect -%}
{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-l">Build Application</h1>
<h2 class="govuk-heading-m">{{ fund.short_name }} - {{ round.short_name }}</h2>
</div>
</div>
{{ govukButton({
"text": "View All Questions",
"href": url_for("build_fund_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) ,
"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) ,
"classes": "govuk-button--secondary"
})
}}
{% for section in round.sections %}
<li class="">
<span class="app-task-list__task-name">
<h3 class="govuk-heading-m">{{ section.index }}. {{ section.name_in_apply_json["en"] }}</h3>
</span>
<span class="app-task-list__task-actions">
<a href='{{ url_for("build_fund_bp.section", round_id=round.round_id, section_id=section.section_id) }}'>Edit</a>
<a href='{{ url_for("build_fund_bp.section",round_id=round.round_id, section_id=section.section_id, action="remove") }}'>Remove</a>
</span>
<ul class="app-task-list__items">
{% for form in section.forms %}
<li class="app-task-list__item task-list__new-design">
<span class="app-task-list__task-name">
<h3 class="govuk-body">
{{ section.index }}.&nbsp;{{ form.section_index }}.&nbsp;{{ form.name_in_apply_json["en"] }}
</h3>
</span>
<span class="app-task-list__task-actions">
<a href="{{ url_for('build_fund_bp.view_form_questions', round_id=round.round_id, form_id=form.form_id) }}">View</a>&nbsp;
<a href='{{ url_for("build_fund_bp.download_form_json", form_id=form.form_id) }}'>Download</a>&nbsp;
<a href='{{ url_for("build_fund_bp.preview_form", form_id=form.form_id) }}'>Preview</a>&nbsp;
<a href="{{ url_for('build_fund_bp.configure_forms_in_section', round_id=round.round_id, section_id=section.section_id, form_id=form.form_id, action='remove') }}">Remove</a>&nbsp;
</span>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
{% endblock content %}
Loading

0 comments on commit 5f5c06a

Please sign in to comment.