Skip to content

Intake profile endpoints #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 38 commits into
base: profile-prototype
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
607e977
Bump cookie and @bundled-es-modules/cookie in /frontend
dependabot[bot] Nov 6, 2024
ca5ac4d
Added endpoint for host/guest json files
johnwroge Feb 21, 2025
d324ca3
Intake profile
johnwroge Feb 21, 2025
cb45078
Trying new endpoints
johnwroge Mar 1, 2025
c51a535
Update endpoints
johnwroge Mar 1, 2025
dfe973a
Fixed intake profile, added missing methods, updated inktake-profile …
johnwroge Mar 1, 2025
f132cdf
Updated json format, fixed contact method field
johnwroge Mar 2, 2025
fe40442
Updated intake-profile controller with pseudocode for new endpoints
johnwroge Mar 2, 2025
1bce26b
add initial sequence diagrams
tylerthome Mar 5, 2025
3c1db17
Create architecture.md
tylerthome Mar 5, 2025
9f37386
Update architecture.md
tylerthome Mar 5, 2025
a212a7c
Update architecture.md
tylerthome Mar 5, 2025
84a67d0
Update architecture.md
tylerthome Mar 5, 2025
327a582
add junction for arch
tylerthome Mar 5, 2025
d908cc2
fix flow syntax on arch
tylerthome Mar 5, 2025
3db28cd
add addtl aws nodes
tylerthome Mar 5, 2025
2b4f1f2
syntax fix for arch
tylerthome Mar 5, 2025
1b3bf1e
connect junctions in arch md
tylerthome Mar 5, 2025
883ee05
cleanup arch md
tylerthome Mar 5, 2025
b4c2d21
db icons for cognito and secrets in arch md
tylerthome Mar 5, 2025
e998775
add svg and drawio for complete diagram
tylerthome Mar 5, 2025
f5ff611
bolded nodes on drawio arch
tylerthome Mar 5, 2025
ed41757
remove backup drawio, committed by mistake
tylerthome Mar 5, 2025
95f30d4
add sequence svg
tylerthome Mar 5, 2025
329b34a
try embed browser svg
tylerthome Mar 5, 2025
bf6c924
Bump jinja2 from 3.1.4 to 3.1.6 in /backend
dependabot[bot] Mar 6, 2025
9904210
Test
johnwroge Mar 19, 2025
02b59e9
Test
johnwroge Mar 19, 2025
e2ad349
Bump @babel/runtime from 7.25.7 to 7.27.0 in /frontend
dependabot[bot] Apr 1, 2025
4bd020b
Merge pull request #827 from hackforla/dependabot/npm_and_yarn/fronte…
tylerthome Apr 8, 2025
ccd2cd6
Merge pull request #833 from hackforla/profile-prototype
tylerthome Apr 8, 2025
621b32b
Bump vite from 5.4.8 to 5.4.17 in /frontend
dependabot[bot] Apr 8, 2025
63c8b49
Merge pull request #871 from hackforla/docs/add-diagrams
tylerthome Apr 8, 2025
f59c565
Merge pull request #872 from hackforla/dependabot/pip/backend/jinja2-…
tylerthome Apr 8, 2025
3c9037a
Merge pull request #897 from hackforla/dependabot/npm_and_yarn/fronte…
tylerthome Apr 8, 2025
6b730c4
Merge pull request #898 from hackforla/dependabot/npm_and_yarn/fronte…
tylerthome Apr 8, 2025
a8a8dda
Merge branch 'main' into intake_profile_endpoints
tylerthome Apr 8, 2025
cfe1f37
Merge branch 'main' into intake_profile_endpoints
tylerthome Apr 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backend/app/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def emit(self, record):
)

logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True)

if settings.HUU_ENVIRONMENT.lower() in ["development", "qa", "local"]:
'''
A logging file can replace logging to standard out by changing sys.stdout to filename.log
'''
if settings.HUU_ENVIRONMENT.lower() in ["development", "local"]:
logger.add(
sys.stdout,
format="<white>{time:YYYY-MM-DD HH:mm:ss}</white> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<green>{function}</green> - <white>{message}</white>",
Expand Down
2 changes: 2 additions & 0 deletions backend/app/modules/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def get_form_1():
import json
with open("form_data/form1.json", "r") as f:
FORM_1 = json.load(f)
FORM_1['id'] = 'guest'
return FORM_1


Expand All @@ -35,6 +36,7 @@ def get_form_2():
import json
with open("form_data/form2.json", "r") as f:
FORM_2 = json.load(f)
FORM_2['id'] = 'host'
return FORM_2
################################################################################

Expand Down
125 changes: 72 additions & 53 deletions backend/app/modules/intake_profile/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,77 @@
router = APIRouter()


@router.put("/responses/{user_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
def update_intake_profile_responses(user_id, body, db_session: DbSessionDep):
pass
# TODO: Implement update intake profile responses
# with db_session.begin() as session:
# user_repo = UserRepository(session)
# forms_repo = FormsRepository(session)
# user = user_repo.get_user(token_info['Username'])

# form = forms_repo.get_form(form_id)
# if not form:
# return f"Form with id {form_id} does not exist.", 404

# valid_field_ids = form.get_field_ids()
# for response in body:
# response["user_id"] = user.id
# if response["field_id"] not in valid_field_ids:
# return f"Form {form_id} does not contain field id {response['field_id']}", 400

# forms_repo.add_user_responses(user.id, body)

# return {}, 204


@router.get("/responses/{user_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
def get_intake_profile_responses(user_id, db_session: DbSessionDep):
pass
# TODO: Implement get Intake Profile responses
# with db_session.begin() as session:
# user_repo = UserRepository(session)
# forms_repo = FormsRepository(session)

# form = forms_repo.get_form_json(form_id)
# if not form:
# return f"Form with id {form_id} does not exist.", 404

# user = user_repo.get_user(token_info['Username'])
# responses = forms_repo.get_user_responses(user.id, form_id)
# if responses:
# return responses, 200
# return [], 202


@router.get("/form/{profile_id}", status_code=status.HTTP_200_OK)
def get_intake_profile_form(profile_id: int,
profile_form_1: Annotated[str, Depends(get_form_1)],
profile_form_2: Annotated[str, Depends(get_form_2)]):
"""Get the Intake Profile form definition."""
if profile_id == 1:
return profile_form_1
if profile_id == 2:
return profile_form_2
# @router.put("/responses/{user_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
# def update_intake_profile_responses(user_id, body, db_session: DbSessionDep):
# pass
# TODO: Implement the functionality to update intake profile responses.
# This should:
# 1. Use the `db_session` to initiate a transaction.
# 2. Retrieve the user data using the `user_id`.
# 3. Get the specific form by `form_id`.
# 4. Check if the form exists. If not, return an error (404).
# 5. Validate the field IDs in the response body against the form's field IDs.
# 6. If any field ID is invalid, return an error (400).
# 7. Save the valid responses in the database.
# 8. Return a success response with status 204 (no content) if everything goes well.

# @router.get("/responses/{user_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
# def get_intake_profile_responses(user_id, db_session: DbSessionDep):
# pass
# TODO: Implement the functionality to retrieve intake profile responses for a user.
# This should:
# 1. Use the `db_session` to begin a transaction.
# 2. Retrieve the user using the `user_id`.
# 3. Fetch the form associated with the user's responses.
# 4. If the form does not exist, return a 404 error.
# 5. Get the user responses for the form from the database.
# 6. If responses are found, return them with status 200.
# 7. If no responses are found, return an empty list with status 202.

# @router.get("/responses/{profile_type}", status_code=status.HTTP_200_OK)
# def get_intake_profile_form(profile_type: str,
# profile_form_1: Annotated[dict, Depends(get_form_1)],
# profile_form_2: Annotated[dict, Depends(get_form_2)]):
# """Get the Intake Profile form definition for host or guest."""
# if profile_type == "guest":
# return profile_form_1
# if profile_type == "host":
# return profile_form_2
# TODO: Return the appropriate form based on the `profile_type` (either "guest" or "host").
# 1. Use `profile_form_1` for the "guest" type and return it.
# 2. Use `profile_form_2` for the "host" type and return it.
# 3. If the `profile_type` is not recognized, raise a 404 error.

# @router.get("/form/{profile_id}", status_code=status.HTTP_200_OK)
# def get_intake_profile_form(profile_id: int,
# profile_form_1: Annotated[str, Depends(get_form_1)],
# profile_form_2: Annotated[str, Depends(get_form_2)]):
# """Get the Intake Profile form definition."""
# if profile_id == 1:
# return profile_form_1
# if profile_id == 2:
# return profile_form_2
# TODO: Return the form based on the `profile_id`.
# 1. If the `profile_id` is 1, return `profile_form_1`.
# 2. If the `profile_id` is 2, return `profile_form_2`.
# 3. If the `profile_id` is not valid, raise a 404 error.

# This is your current working function:
@router.get("/form/{profile_type}", status_code=status.HTTP_200_OK)
def get_intake_profile_form(profile_type: str,
profile_form_1: Annotated[dict, Depends(get_form_1)],
profile_form_2: Annotated[dict, Depends(get_form_2)]):
"""Get the Intake Profile form definition and responses for host or guest."""
if profile_type == "guest":
return {
"form": profile_form_1,
"responses": profile_form_1.get("responses", [])
}
if profile_type == "host":
return {
"form": profile_form_2,
"responses": profile_form_2.get("responses", [])
}

raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail=f"Form with id {profile_id} does not exist.")
detail=f"Form type {profile_type} does not exist.")
Loading
Loading