-
Notifications
You must be signed in to change notification settings - Fork 5
Add profile management and single opportunity endpoints #340
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
Add profile management and single opportunity endpoints #340
Conversation
new route that queries the database for all opportunities and returns them as a JSON list
test to ensure your new endpoint works correctly
creating a specific backend route to fetch the details of one opportunity by its ID
test verifies that the new endpoint correctly retrieves an opportunity or handle error
Added opportunity_to_dict helper Fix two GET endpoints for better error checks and improved data handling created corresponding tests in test_single_opportunity_routes.py for a smooth experience
GET /profile route to allow users to fetch their own profile data. Added a 'user_to_dict' helper function to consistently serialize user data.
PUT /profile route for user to update their personal details.
PUT /profile route for user to update their majors and department.
GET /profile endpoint: both successful data retrieval and unauthorized access PUT /profile endpoint: ensuring that full updates, partial updates, and unauthorized attempts are handled correctly. ISSUE: Login helper function to streamline authentication within the tests but the tests fail as user not in DB.
|
Here's the code health analysis summary for commits Analysis Summary
|
RafaelCenzano
left a comment
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.
Make sure linting passes on changes. If you are using vscode you can use the ruff extension https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff. Or just call ruff directly as it should be installed.
|
@RafaelCenzano fixed the lint error |
RafaelCenzano
left a comment
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.
LGTM
62dab3c
into
LabConnect-RCOS:Single-Opportunity-and-User-Profile-Management
Description
This pull request introduces two major new features to the backend, complete with testing:
GET /opportunity/<int:opportunity_id>) to fetch all details for a single opportunity. This also includes helper functions to properly serialize the opportunity data for the JSON response.GET /profileandPUT /profile. These endpoints allow an authenticated user to fetch their own profile data and update it, including personal details (name, website, etc.) and their associated majors and departments.These changes provide the core API functionality needed for the frontend to build the individual opportunity view page and the user profile settings page.
Fixes # (issue)
(Please link the relevant issue number here, if one exists)
Type of change
How Has This Been Tested?
This PR has been tested by adding new unit test files for both major features:
Single Opportunity Endpoint:
test_opportunity.pyandtest_single_opportunity_routes.py.User Profile Management:
test_profile_routes.py, was created to provide full coverage for the new endpoints.GET /profilesuccess (for an authenticated user) and failure (for an unauthorized user).PUT /profilesuccess (for both full and partial data updates) and failure (for an unauthorized user).All new and existing unit tests pass locally with these changes. The User Profile Management is not fully passing, as the existing authentication code needs fixes.
Checklist: