You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: API endpoint for partially updating a task's details using PATCH /tasks/{task_id}/ (#52)
* feat: Implement PATCH /tasks/{task_id} to update tasks
- Added method to handle update requests.
- Introduced for validating incoming update data,
ensuring all fields are optional and is a future date.
- Added method to to perform the MongoDB
operation, ensuring is set.
- Implemented to orchestrate the update logic:
- Fetches the task or raises .
- Processes validated data from the serializer.
- Converts label string IDs to and validates their existence.
- Converts priority and status string names to their enum values for
database storage.
- Sets (currently placeholder).
- Calls the repository to persist changes.
- Corrected an issue where enum objects (Priority, Status) were passed
directly to the database layer, causing a serialization error. Now,
their primitive values are stored.
- Refined construction in to ensure
all valid fields from the serializer are correctly prepared for update.
* refactor(tasks): Standardize error handling in TaskService update
- Removes redundant format validation for label ObjectIds, as this is
already handled by .
- For missing (but validly formatted) label IDs,
now raises instead of a
custom
* rfactor: PATCH /tasks/{task_id} endpoint to have task title blank true
* refactor: improve error handling for task updates and ID validation
centralizes error handling for task update operations:
- Removes specific ObjectId validation from . Invalid ID formats will now correctly raise , which is handled by the global DRF exception handler to return a 400 Bad Request.
- Modifies to raise if the task to be updated is not found. This is also handled by the global exception handler, resulting in a 404 Not Found response
* refactor: Enhance serializer validations and repository clarity
- Implemented validation to ensure `startedAt` cannot be a future date.
- Added `FUTURE_STARTED_AT` to `ValidationErrors` in `constants/messages.py`
for the new validation message.
- Added an explicit type check to ensure `labels` input is a list or tuple.
- Modified to collect all invalid ObjectId formats within the `labels` list
and report them in a single `ValidationError` for better client feedback.
- Moved the "Labels must be a list or tuple..." message to
`ValidationErrors.INVALID_LABELS_STRUCTURE` in `constants/messages.py`
and updated the serializer to use this constant.
- Deleted an unreachable `if not update_data_with_timestamp: pass` block,
as the updatedAt field ensures the dictionary is never empty at that point.
* Update todo/serializers/update_task_serializer.py
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
* Update todo/views/task.py
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
* fix: gramatical errors on the constants
* fix: added missing imports
* fix: used global exception handler for catching errors
* Refactor(TaskRepository): modify update method for input validation and ObjectId handling
* refactor(serializers): align validate_dueAt error handling pattern
-refactors the method in
to collect validation errors in a list and raise a single
with this list.
* refactor(services): reduce complexity of TaskService.update_task
-Refactors the method in to improve
readability and reduce cognitive complexity. The core logic for
processing specific field types (labels, enums) has been extracted
into dedicated helper methods: and
* refactor(services): reduce complexity of TaskService.update_task
-Refactors the method in to improve
readability and reduce cognitive complexity. The core logic for
processing specific field types (labels, enums) has been extracted
into dedicated helper methods: and
* refactor: refactor the code to improve maintainability
---------
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
0 commit comments