-
Notifications
You must be signed in to change notification settings - Fork 213
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
feat: add testimonial update endpoint #1216
base: dev
Are you sure you want to change the base?
feat: add testimonial update endpoint #1216
Conversation
Signed-off-by: Henrietta Onoge <[email protected]>
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.
Why is your virtual environment here??
Please remove
alembic.ini
Outdated
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.
Revert this back to the way it was
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.
Done! please review
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'm sorry about that. It's off now. Thank You
On it boss |
You want me to merge your virtual environment too?? |
api/v1/models/activity_logs.py
Outdated
user_id = Column(String, ForeignKey("users.id", ondelete="CASCADE"), nullable=False) | ||
user_id = Column(String, ForeignKey("users.id"), nullable=False) |
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.
Why did you touch this line of code?
How is it related to your issue?
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.
It gave some errors while testing and a mentor said i could adjust it. Reverted back now.
api/v1/services/testimonial.py
Outdated
db.commit() | ||
db.refresh(testimonial) | ||
return testimonial |
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.
Move line 48-50 outside the loop
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 have done that now
Description
This pull request introduces a new API endpoint that allows users to update their testimonials. It enhances the testimonial system by allowing users to update their own testimonials securely while maintaining a structured response
New Endpoint
🔹 Method: PUT /api/v1/testimonials/{id}
🔹 Description: Allows users to update testimonials they created.
🔹 Authorization: Only the testimonial's owner can update it.
Example Request:
Example Success Response:
Example Failure Response (Unauthorized User):
Link to Issue
Closes [#776] (#776)
Motivation and Context
✔️ Enables users to modify testimonials they previously created.
✔️ Ensures only authorized users can update their own testimonials.
✔️ Provides a structured and consistent API response.
Changes Implemented
🔹 Added the PUT /api/v1/testimonials/{id} endpoint.
🔹 Implemented logic to restrict updates to the testimonial's creator.
🔹 Standardized the API response to return the updated testimonial.
🔹 Wrote unit tests to verify success and failure scenarios.
How Has This Been Tested?
✔️ Unit Tests:
Tested successful updates for authorized users.
Tested failure responses for unauthorized users.
✔️ Manual Testing:
Verified the endpoint using Postman with valid and invalid users.
✔️ Automated Tests:
Ran pytest to confirm all tests pass.
Files Updated
📂 api/v1/routes/testimonials.py
📂 api/v1/services/testimonial_service.py
📂 tests/v1/testimonial/test_testimonial_updates.py
Screenshots (if appropriate - Postman, etc):
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
[x] My code follows the code style of this project.
[x] My change requires a change to the documentation.
[x] I have updated the documentation accordingly.
[x] I have read the CONTRIBUTING document.
[x] I have added tests to cover my changes.
[x] All new and existing tests passed.