Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
WIP merge from application store
Browse files Browse the repository at this point in the history
  • Loading branch information
srh-sloan committed Nov 8, 2024
1 parent 33cd935 commit 1eb62cd
Show file tree
Hide file tree
Showing 56 changed files with 3,711 additions and 81 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dockerComposeFile": [
"../docker-compose.yml"
],
"name": "assesplication",
"service": "assesplication-store",
"workspaceFolder": "/assesplication-store",
"shutdownAction": "none",
Expand Down
184 changes: 106 additions & 78 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// launch command is python -m debugpy --listen 0.0.0.0:5678 -m wsgi
"name": "Python Debugger: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
},
{
"name": "Docker-Runner assessment-store",
"type": "python",
Expand All @@ -25,7 +41,10 @@
"type": "python",
"request": "launch",
"module": "flask",
"args": ["run", "--no-reload"],
"args": [
"run",
"--no-reload"
],
"jinja": true,
"justMyCode": false,
"envFile": "${workspaceFolder}/.env.development",
Expand All @@ -39,45 +58,47 @@
"host": "localhost",
"port": 9091,
"cwd": "${workspaceFolder}",
"env": { "PYTHONPATH":"${workspaceFolder}"},
"env": {
"PYTHONPATH": "${workspaceFolder}"
},
"envFile": "${workspaceFolder}/.env.development",
"justMyCode": false,
},
{
"name": "Upgrade DB",
"type": "python",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"db",
"upgrade"
]
},
{
"name": "Downgrade DB",
"type": "python",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"db",
"downgrade",
"6c8205510de6" // modify the downgrade revision accordingly
]
},
{
"name": "Prepare DB Migration",
"type": "python",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"db",
"migrate"
]
},
{
},
{
"name": "Upgrade DB",
"type": "python",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"db",
"upgrade"
]
},
{
"name": "Downgrade DB",
"type": "python",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"db",
"downgrade",
"6c8205510de6" // modify the downgrade revision accordingly
]
},
{
"name": "Prepare DB Migration",
"type": "python",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"db",
"migrate"
]
},
{
"name": "Import Applications to Assessment",
"type": "python",
"request": "launch",
Expand All @@ -88,14 +109,16 @@
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env.development",
"env": {
"PYTHONPATH":"${workspaceFolder}",
"PYTHONPATH": "${workspaceFolder}",
},
"justMyCode": false,
// modify the args accordingly
"args": [
"--fundround", "NSTFR2"]
},
{
"--fundround",
"NSTFR2"
]
},
{
"name": "Seed Applications in assessment-store",
"type": "python",
"request": "launch",
Expand All @@ -106,38 +129,43 @@
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env.development",
"justMyCode": false,
"args": ["seed_dev_db"]
},
{
"name": "Feed location in assessment-store",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/scripts/populate_location_data.py",
"console": "integratedTerminal",
"host": "localhost",
"port": 9091,
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env.development",
"env": {
"PYTHONPATH":"${workspaceFolder}",
"args": [
"seed_dev_db"
]
},
{
"name": "Feed location in assessment-store",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/scripts/populate_location_data.py",
"console": "integratedTerminal",
"host": "localhost",
"port": 9091,
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env.development",
"env": {
"PYTHONPATH": "${workspaceFolder}",
},
"justMyCode": false,
// modify the args accordingly
"args": [
"--fundround",
"NSTFR2",
"--update_db",
"True",
"--write_csv",
"False"
]
},
"justMyCode": false,
// modify the args accordingly
"args": [
"--fundround", "NSTFR2",
"--update_db", "True",
"--write_csv", "False"
]
},
{
{
"name": "Run Tests: All",
"type": "python",
"request": "launch",
"module": "pytest",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env.development",
},
{
},
{
"name": "Run Tests: Current File (debug)",
"type": "python",
"request": "launch",
Expand All @@ -146,13 +174,13 @@
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"-c",
"pytest.ini",
"${file}"
"-c",
"pytest.ini",
"${file}"
],
"justMyCode": false
},
{
},
{
"name": "Run Tests: Current Function (debug)",
"type": "python",
"request": "launch",
Expand All @@ -161,12 +189,12 @@
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env.development",
"args": [
"-c",
"pytest.ini",
"-k",
"test_get_application_fields_export" // modify this accordingly
"-c",
"pytest.ini",
"-k",
"test_get_application_fields_export" // modify this accordingly
],
"justMyCode": false
},
},
]
}
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"cSpell.language": "en-GB",
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
},
}
2 changes: 2 additions & 0 deletions _helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# noqa
from .application import order_applications # noqa
from .form import get_blank_forms # noqa
19 changes: 19 additions & 0 deletions _helpers/application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from operator import itemgetter


def order_applications(applications, order_by, order_rev):
"""Returns a list of ordered applications."""
if order_by and order_by in [
"id",
"status",
"account_id",
"assessment_deadline",
"started_at",
"last_edited",
]:
applications = sorted(
applications,
key=itemgetter(order_by),
reverse=int(order_rev),
)
return applications
39 changes: 39 additions & 0 deletions _helpers/form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from services.apply import get_application_sections


def get_form_name(section):
forms = set()
if section["children"]:
for child in section["children"]:
forms.update(get_form_name(child))
if section["form_name"]:
forms.add(section["form_name"])
return forms


def get_forms_from_sections(sections):
mint_form_list = set()
for section in sections:
mint_form_list.update(get_form_name(section))
return mint_form_list


def get_blank_forms(fund_id: str, round_id: str, language: str):
"""Get the list of forms required to populate a blank application for a fund
round.
Args:
fund_id: (str) The id of the fund
round_id: (str) The id of the fund round
Returns:
A list of json forms to populate the form
"""
application_sections = get_application_sections(fund_id, round_id, language)
if application_sections:
forms = get_forms_from_sections(application_sections)
if not forms:
raise Exception(f"Could not find forms for {fund_id} - {round_id}")
return forms
raise Exception(f"Could not find fund round for {fund_id} - {round_id} in fund store.")
2 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def create_app() -> FlaskApp:
health.add_check(FlaskRunningChecker())
health.add_check(DbChecker(db))

# TODO work out sqs stuff where same app is writing to and reading from the queue

# Initialize sqs extended client
# create_sqs_extended_client(flask_app)

Expand Down
2 changes: 2 additions & 0 deletions apply/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from apply.api.routes.application.routes import ApplicationsView # noqa
from apply.api.routes.queues.routes import QueueView # noqa
Empty file added apply/api/routes/__init__.py
Empty file.
Empty file.
Loading

0 comments on commit 1eb62cd

Please sign in to comment.