Skip to content

Commit

Permalink
file rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-W1 committed Aug 1, 2024
1 parent 4ff5fb9 commit b9da458
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{"name":"Python Debugger: Current File","type":"debugpy","request":"launch","program":"${file}","console":"integratedTerminal"},
{
"name": "Python Debugger: Flask",
"type": "debugpy",
Expand Down Expand Up @@ -35,6 +36,6 @@
}
]
}

]
}
File renamed without changes.
4 changes: 2 additions & 2 deletions app/blueprints/fund_builder/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from app.all_questions.metadata_utils import generate_print_data_for_sections
from app.blueprints.fund_builder.forms.fund import FundForm
from app.blueprints.fund_builder.forms.round import RoundForm
from app.config_reuse.generate_all_questions import print_html
from app.config_reuse.generate_form import build_form_json
from app.db.models.fund import Fund
from app.db.models.round import Round
from app.db.queries.application import clone_single_round
Expand All @@ -23,8 +25,6 @@
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_round_by_id
from app.question_reuse.generate_all_questions import print_html
from app.question_reuse.generate_form import build_form_json
from config import Config

# Blueprint for routes used by v1 of FAB - using the DB
Expand Down
4 changes: 2 additions & 2 deletions app/blueprints/self_serve/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from app.blueprints.self_serve.forms.page_form import PageForm
from app.blueprints.self_serve.forms.question_form import QuestionForm
from app.blueprints.self_serve.forms.section_form import SectionForm
from app.question_reuse.generate_all_questions import print_html
from app.question_reuse.generate_form import build_form_json
from app.config_reuse.generate_all_questions import print_html
from app.config_reuse.generate_form import build_form_json

FORM_RUNNER_URL = os.getenv("FORM_RUNNER_INTERNAL_HOST", "http://form-runner:3009")
FORM_RUNNER_URL_REDIRECT = os.getenv("FORM_RUNNER_EXTERNAL_HOST", "http://localhost:3009")
Expand Down
7 changes: 3 additions & 4 deletions app/question_reuse/README → app/config_reuse/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ Having reusable questions also means we can have reusable assessment config - eg

## Reusable configuration
[Components](./config/components_to_reuse.py) Configuration for individual components (fields). Structure is as in the form json, except for conditions which are simplified
[Pages](./config/pages_to_reuse.py) Configuration for pages that can be inserted into forms. Basically each page is a list of component IDs that existin in `components_to_reuse.py` above.
[Lookups](./config/lookups.py) General place to convert from an ID to a display string, eg. organisation_information to Organisation information
[Sub Pages](./config/sub_pages_to_reuse.py) Contains full form json info for some pages that are constant when reused, eg. the summary page. But also ones that are needed for sub flows based on conditions - eg. the 'what alternative names does your org use' page is in here, as it will always be required if you add the component `reuse_organisation_other_names_yes_no`
[Assessment Themes](./config/themes_to_reuse.py) Specifies themes that can be reused across assessments, basically a list of the components in each theme. These component names are the same as in `components_to_reuse.py`
[Pages](./config/pages_to_reuse.py) Configuration for pages that can be inserted into forms. Basically each page is a list of component IDs that exist in `components_to_reuse.py` above.
<!-- [Sub Pages](./config/sub_pages_to_reuse.py) Contains full form json info for some pages that are constant when reused, eg. the summary page. But also ones that are needed for sub flows based on conditions - eg. the 'what alternative names does your org use' page is in here, as it will always be required if you add the component `reuse_organisation_other_names_yes_no`
[Assessment Themes](./config/themes_to_reuse.py) Specifies themes that can be reused across assessments, basically a list of the components in each theme. These component names are the same as in `components_to_reuse.py` -->

## Example inputs - Forms
These are examples of the inputs required from a fund to create forms based on reusable components. Once the form json is generated, it can always be edited to add non-reusable components/pages as well.
Expand Down
Empty file added app/config_reuse/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
# }


# def generate_field_info_from_forms(forms_dir: str) -> dict:
# """Generates the display info for all fields in a form
def generate_field_info_from_forms(forms_dir: str) -> dict:
"""Generates the display info for all fields in a form
# Args:
# forms_dir (str): Directory containing the forms
Args:
forms_dir (str): Directory containing the forms
# Returns:
# dict: Dictionary of field IDs to display info
# """
# results = {}
# for file_name in os.listdir(forms_dir):
# with open(os.path.join(forms_dir, file_name), "r") as f:
# form_data = json.load(f)
# results.update(build_answers_from_form(form_data, file_name.split(".")[0]))
Returns:
dict: Dictionary of field IDs to display info
"""
results = {}
for file_name in os.listdir(forms_dir):
with open(os.path.join(forms_dir, file_name), "r") as f:
form_data = json.load(f)
results.update(build_answers_from_form(form_data, file_name.split(".")[0]))

# return results
return results


def build_answers_from_form(form_data: dict, form_name: str) -> dict:
Expand Down Expand Up @@ -71,7 +71,8 @@ def build_answers_from_form(form_data: dict, form_name: str) -> dict:
"field_id": component["name"],
"form_name": form_name,
"field_type": component["type"],
# TODO fix this "presentation_type": form_json_to_assessment_display_types.get(component["type"].lower(), None),
# TODO fix this "presentation_type":
# form_json_to_assessment_display_types.get(component["type"].lower(), None),
"question": question,
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_build_assessment_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.question_reuse.generate_assessment_config import build_assessment_config
from app.config_reuse.generate_assessment_config import build_assessment_config
from tests.unit_test_data import cri1
from tests.unit_test_data import crit_1_id
from tests.unit_test_data import mock_form_1
Expand Down
15 changes: 7 additions & 8 deletions tests/test_generate_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import pytest

# from app.question_reuse.generate_form import build_conditions
from app.config_reuse.generate_form import build_conditions
from app.config_reuse.generate_form import build_form_json
from app.config_reuse.generate_form import build_lists
from app.config_reuse.generate_form import build_navigation
from app.config_reuse.generate_form import build_page
from app.config_reuse.generate_form import human_to_kebab_case
from app.db.models import Component
from app.db.models import ComponentType
from app.db.models import Lizt
from app.db.models import Page

# from app.question_reuse.generate_form import build_conditions
from app.question_reuse.generate_form import build_conditions
from app.question_reuse.generate_form import build_form_json
from app.question_reuse.generate_form import build_lists
from app.question_reuse.generate_form import build_navigation
from app.question_reuse.generate_form import build_page
from app.question_reuse.generate_form import human_to_kebab_case
from tests.unit_test_data import mock_c_1
from tests.unit_test_data import mock_form_1

Expand Down
4 changes: 2 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

from app.config_reuse.generate_assessment_config import build_assessment_config
from app.config_reuse.generate_form import build_form_json
from app.db.models import Component
from app.db.models import ComponentType
from app.db.models import Form
Expand All @@ -12,8 +14,6 @@
from app.db.models import Section
from app.db.queries.application import get_component_by_id
from app.db.queries.fund import get_fund_by_id
from app.question_reuse.generate_assessment_config import build_assessment_config
from app.question_reuse.generate_form import build_form_json
from tasks.test_data import BASIC_FUND_INFO
from tasks.test_data import BASIC_ROUND_INFO

Expand Down

0 comments on commit b9da458

Please sign in to comment.