-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change provider child relationship to many-to-many #224
base: main
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (updated for commit 557f41f): https://childrens-aid-society--pr224-omer-provider-child-a1qmosjy.web.app (expires Tue, 12 Dec 2023 02:51:55 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 93f6cb7bff946a1edd29d684408e6d31442cf0b1 |
undos.append((provider_service, "delete_provider", provider_response.id)) | ||
except Exception as error: | ||
run_undos() | ||
return jsonify(error), 400 |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job! the GET request works nicely :))
in terms of seeding ur db, u can fill out the provider fields as follows:
# Providers
values = [(1, "Karen Namen", "123123", "primary phone", "secondary phone", "[email protected]", "address", "FOSTER CAREGIVER")]
for value in values:
insert_values(db, "providers", ("intake_id", "name", "file_number", "primary_phone_number", "secondary_phone_number", "email", "address", "relationship_to_child", "additional_contact_notes"), value)
Then,
docker exec -it cas_db /bin/bash -c "psql -U postgres -d cas"
INSERT INTO child_providers (child_id, providers_id) VALUES (1,1);
return jsonify(error), 400 | ||
providers_by_child = child["provider"] | ||
for provider in providers_by_child: | ||
if provider.providerId in children_providers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i c wat ur going for here, but when the user POSTs the intake obj, the provider
obj within it has no field providerId
(see intake frontend<>backend for more info)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working on the changes, I added a providerId which is now included in the provider interface apart of ProviderDetails, so it should work. It's present in this file: .\frontend\src\components\intake\NewProviderModal.tsx
and is defined across all components working with ProviderDetails
@@ -53,13 +59,22 @@ def delete_provider(self, provider_id): | |||
db.session.rollback() | |||
raise error | |||
|
|||
def get_providers_by_child_id(self, child_id): | |||
def get_children_by_provider(self, provider_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it makes more sense to have this function within child_service.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small changes w POST
else: | ||
children_providers[provider["providerId"]] = [child_response.id] | ||
|
||
if not any(x.providerId == provider.providerId for x in all_providers): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider["providerId"]
return jsonify(error), 400 | ||
providers_by_child = child["provider"] | ||
for provider in providers_by_child: | ||
if provider.providerId in children_providers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider["providerId"]
provider_response = provider_service.create_new_provider( | ||
CreateProviderDTO(**provider_obj), | ||
children_providers[provider["providerId"]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, just looked into this—it seems like the create_new_provider
function doesn't work when it takes in children_ids
as a param..
for now (until we fix this), keep the arg for create_new_provider
as
provider_response = provider_service.create_new_provider(
CreateProviderDTO(**provider_obj)
)
you're going to have to change some of your providers_by_child
logic, since atm the POST request doesn't save providers properly
Notion ticket link
Make Providers Children a Many to Many Relationship
Implementation description
Steps to test
What should reviewers focus on?
Checklist