Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into fs-4528
Browse files Browse the repository at this point in the history
rebase
  • Loading branch information
Tiny49 committed Aug 12, 2024
2 parents 1f8fb08 + 144d844 commit 296eb94
Show file tree
Hide file tree
Showing 53 changed files with 2,911 additions and 254 deletions.
67 changes: 47 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// 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",
"env": {
"FLASK_ENV": "development"
},
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python Debugger: Flask",
"type": "debugpy",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.app.py",
"FLASK_DEBUG": "1"
},
"args": ["run", "--debug"],
"jinja": true,
"autoStartBrowser": false
},
{
"name": "Docker Runner FAB",
"type": "debugpy",
"env": {
"FLASK_APP": "app.app.py",
"FLASK_DEBUG": "1"
},
"request": "attach",
"connect": {
"host": "localhost",
"port": 5686
},
"pathMappings": [
{
"name": "Python Debugger: Flask",
"type": "debugpy",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.app.py",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--debug"
],
"jinja": true,
"autoStartBrowser": false
"localRoot": "${workspaceFolder:funding-service-design-fund-application-builder}",
"remoteRoot": "."
}
]
],
"justMyCode": true
}
]
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ Run the app with `flask run` (include `--debug` for auto reloading on file chang
## Helper Tasks
Contained in [db_tasks.py](./tasks/db_tasks.py)

## Configuration Export Tasks
Contained in [export_tasks.py](./tasks/export_tasks.py)

The configuration output is generated by the [config_generator](./app/config_generator/README.md) module. This module contains functions to generate fund and round configuration, form JSONs, and HTML representations for a given funding round.

## Database
### Schema
The database schema is defined in [app/db/models.py](./app/db/models.py) and is managed by Alembic. The migrations are stored in [app/db/migrations/versions](./app/db/migrations/versions/)

### Entity Relationship Diagram
See [Here](./app/db/database_ERD_9-8-24.png)

### Recreate Local DBs
For both `DATABASE_URL` and `DATABASE_URL_UNIT_TEST`, drops the database if it exists and then recreates it.

Expand Down
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_generator.generate_all_questions import print_html
from app.config_generator.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
129 changes: 122 additions & 7 deletions app/blueprints/self_serve/data/data_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from app.blueprints.self_serve.data.not_a_db import LISTS
from app.blueprints.self_serve.data.not_a_db import PAGES
from app.blueprints.self_serve.data.not_a_db import SECTIONS
from app.db.queries.application import insert_new_section

saved_responses = []
saved_sections = {}
Expand Down Expand Up @@ -66,20 +67,134 @@ def get_list_by_id(id: str) -> dict:
return LISTS.get(id, None)


def save_question(question: dict):
# TODO Implement front end journey that can use the section/form/page/component CRUD operations
# from app.db.queries.application import insert_new_section
# from app.db.queries.application import insert_new_form
# from app.db.queries.application import insert_new_page
# from app.db.queries.application import insert_new_component


def save_template_component(component: dict):
"""
TODO:
Save a template component to the database
Parameters:
component: dict The component to save to the database as a template
Returns:
dict The saved component
component_config = {
"page_id": component.get("page_id"),
"theme_id": component.get("theme_id"),
"title": component.get("title"),
"hint_text": component.get("hint"),
"options": component.get("options"),
"type": component.get("question_type"),
"template_name": component.get("template_name"),
"is_template": True,
"audit_info": component.get("audit_info"),
"page_index": component.get("page_index"),
"theme_index": component.get("theme_index"),
"conditions": component.get("conditions"),
"runner_component_name": component.get("runner_component_name"),
"list_id": component.get("list_id"),
}
return insert_new_component(component_config)
"""

# temp in memory solution
COMPONENTS.append(
{
"json_snippet": {
"options": {},
"type": question["question_type"],
"title": question["title"],
"hint": question["hint"],
"type": component["question_type"],
"title": component["title"],
"hint": component["hint"],
},
"id": question["id"],
"builder_display_name": question["builder_display_name"],
"id": component["id"],
"builder_display_name": component["builder_display_name"],
}
)


def save_section(section: dict):
def save_template_page(page: dict):
"""
TODO:
Save a template page to the database
Parameters:
page: dict The page to save to the database as a template
Returns:
dict The saved page
page_config = {
"form_id": page.get("form_id"),
"name_in_apply_json": {
"en": page.get("form_display_name"),
},
"template_name": page.get("builder_display_name"),
"is_template": True,
"audit_info": page.get("audit_info"),
"form_index": page.get("form_index"),
"display_path": page.get("display_path"),
"controller": page.get("controller"),
}
return insert_new_page(page_config)
"""

# Temp in memory solution
PAGES.append(page)


def save_template_form(form: dict):
"""
TODO:
Save a template form to the database
Parameters:
form: dict The form to save to the database as a template
Returns:
dict The saved form
form_config = {
"name_in_apply_json": {
"en": form.get("form_title"),
},
"is_template": True,
"template_name": form.get("builder_display_name"),
"audit_info": form.get("audit_info"),
"section_id": form.get("section_id"),
"section_index": form.get("section_index"),
"runner_publish_name": None # This is a template
}
insert_new_form(form_config)
"""

# Temp in memory solution
FORMS.append(form)


def save_template_section(section: dict):
"""
TODO:
Save a template section to the database
Parameters:
section: dict The section to save to the database as a template
Returns:
dict The saved section
section_config = {
"name_in_apply_json": {
"en": section.get("section_display_name"),
},
"is_template": True, # Assuming this remains a constant value
"template_name": section.get("builder_display_name"),
"description": section.get("description"),
"audit_info": section.get("audit_info"),
}
return insert_new_section(section_config)
"""

# Temp in memory solution
SECTIONS.append(section)
Loading

0 comments on commit 296eb94

Please sign in to comment.