Skip to content

PR 6: (#98) Unscheduled Tasks Management for Calendar#186

Merged
cj-ballesteros merged 5 commits intomainfrom
Calendar_Unscheduled_Tasks
Apr 30, 2025
Merged

PR 6: (#98) Unscheduled Tasks Management for Calendar#186
cj-ballesteros merged 5 commits intomainfrom
Calendar_Unscheduled_Tasks

Conversation

@EthanZ23
Copy link
Contributor

@EthanZ23 EthanZ23 commented Apr 29, 2025

Unscheduled Tasks Management for Calendar Integration

Added UnscheduledTask model to apps.planner, alongside API endpoints to fetch, create, update, and delete unscheduled tasks. Also added a comprehensive test suite covering all CRUD operations and edge cases.


Overview

What does this PR do?

This PR introduces a new planner model, named UnscheduledTask, which allows tracking and organization of tasks that have not yet been assigned to specific time slots or calendar events. This PR also involves:

  • A DRF ViewSet for full CRUD on /api/unscheduled-tasks/
  • A serializer to validate and (de)serialize JSON payloads
  • Router entries to wire up those endpoints
  • A suite of APITestCase tests that verify list, create, update, delete, plus unauthorized access and missing‐field edge cases

Key Features & Changes

What has been added or changed?

New model creation in apps/planner/models.py

  • UnscheduledTask: Stores tasks that have not been assigned to specific times
  • Fields: title, description, due_date, assigned_assignment (has a relationship with the assignments model), plus timestamps

Admin

  • Registered UnscheduledTask with list display & filters in apps/planner/admin.py

Serializer

  • UnscheduledTaskSerializer in apps/planner/serializers.py

API endpoint Implementation (views & URLs)

  • API endpoint to fetch, create, update, and delete unscheduled tasks:
    - GET /api/unscheduled-tasks/: List all unscheduled tasks
    - POST /api/unscheduled-tasks/: Create a new unscheduled task
    - PATCH /api/unscheduled-tasks/{id}/: Update an existing unscheduled task
    - DELETE /api/unscheduled-tasks/{id}/: Delete an unscheduled task

API endpoint testing

  • Implemented and tested the API endpoints. These tests test for the functionality of unscheduled tasks management.

Why This Is Needed

What problem does this solve?

Before this change, there was no way to track tasks that didn’t yet have a calendar slot or to manage them via API. Adding model, endpoints, and tests:

  • Ensures no regressions when iterating on scheduling features
  • Gives tutors/students a central API for to-do items
  • Provides test coverage for maintenance and future refactors

Related Issue

🔗 This PR addresses [Issue #98 - Implement management for unscheduled tasks to allow tracking and organization of tasks that have not yet been assigned to specific time slots or calendar events.]


Implementation Details

How was this feature developed?

  • Django REST Framework: Implemented ViewSets for all CRUD operations with proper authentication and permissions
  • Testing: APITestCase with JWT auth, reverse‐routed URLs, and edge‐case assertions
  • Added complete endpoint testing using DRF reverse routing and bearer token auth
  • DRF Permission: IsAuthenticated on all endpoints

Design Documentation (If Applicable)

Diagrams & Visuals


How to Test This PR

Step-by-step testing guide

  1. Ensure you're on the Calendar_Unscheduled_Tasks branch
  2. Run virtual environment
  3. Apply migrations: Run make migrations and migrate
python manage.py makemigrations

python manage.py migrate
  1. Run the backend test suite:
python manage.py test apps.planner
# or 
coverage run manage.py test apps.planner
coverage report
  1. Confirm all (25 planner) tests pass

Files Added/Modified

📂 List of important files changed in this PR

File Name Description
apps/planner/models.py Defines UnscheduledTask model with fields.
apps/planner/admin.py Registers UnscheduledTask in Django admin.
apps/planner/serializers.py Implements UnscheduledTaskSerializer for (de)serialization of task data.
apps/planner/views.py Adds UnscheduledTaskViewSet with full CRUD and IsAuthenticated permission.
apps/planner/urls.py Registers the viewset under /api/unscheduled-tasks/ via DRF router.
apps/planner/tests.py Appended UnscheduledTaskAPITestCase covering list/create/update/delete and few edge cases.

AI Code Usage

🤖 Was AI-generated code used in this PR?

  • Yes (AI was used to help draft test logic, and come up with edge cases.)
  • No

Checklist for Reviewers

Things to check before approving this PR:

  • Does the feature work as expected?
  • Is the models code clean, modular, and well-documented?
  • Is the test code clean, reusable, and easy to follow?
  • Are all CRUD endpoints for UnscheduledTask fully tested?
  • Do all tests pass successfully when run locally?

Next Steps & Future Enhancements

What improvements can be made after merging?

  • Cover more edge cases
  • Update CalendarEvent model to accommodate Assignment and UnscheduledTask models.
  • Enforce ownership so only task owners (or tutors) can view/modify their tasks

Final Notes

Thank you for reviewing! Any feedback or suggestions are greatly appreciated.

-- Ethan

@EthanZ23 EthanZ23 added enhancement New feature or request Backend Issue is primarily backend related Calendar labels Apr 29, 2025
@EthanZ23 EthanZ23 self-assigned this Apr 29, 2025
@EthanZ23 EthanZ23 linked an issue Apr 29, 2025 that may be closed by this pull request
Copy link
Contributor

@alliekameda alliekameda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Peer Review: Great Job on This PR!

Hey Ethan 👋 — just finished reviewing your PR titled "PR 6: (#98) Unscheduled Tasks Management for Calendar #186". Here’s my feedback:


✅ What Looks Great

  • The core feature has been implemented cleanly.
  • Your model, views, serializers, and tests follow best practices — everything is logically structured and readable.
  • The test coverage is excellent, with edge case handling and authentication scenarios well considered.

💡 Suggestions for Improvement

Not super urgent!

  • Consider adding a clean() method to UnscheduledTask if you foresee future validation needs (e.g., due_date should not be in the past).

  • If event_type values are reused in views or serializers, moving the EVENT_TYPE_CHOICES into a shared constant or enum might be beneficial long-term.

  • Adding test coverage for admin interfaces (optional but nice-to-have) could round out the suite.

  • Consider adding edge case tests for time-sensitive queries (e.g., what counts as "recent" when dealing with timezone offsets or year boundaries).

  • Could use factory methods or factories (e.g., AchievementFactory) for cleaner, DRYer test setup as the test suite grows.


🧪 Tested This Feature

I ran the following test steps:

  • ✅ Verified migrations apply cleanly.
  • ✅ Ran the planner test suite — all 25 tests passed.
  • ✅ Skimmed the code for edge-case and permission logic.
    Screenshot 2025-04-29 143137

🔄 Next Steps

  • Consider edge cases and then merge :)

🚀 Final Thoughts

Everything looks good, great work Ethan! ᕙ( * •̀ ᗜ •́ * )ᕗ

Copy link
Contributor

@cj-ballesteros cj-ballesteros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Ethan 👋 — just finished reviewing your PR titled "PR 6: (#98) Unscheduled Tasks Management for Calendar #186". Here’s my feedback:


✅ What Looks Great

  • The primary functionality is implemented in a clear and organized manner.
  • Your models, views, serializers, and tests are well-structured and adhere to best practices, making the code easy to follow.
  • The test coverage is thorough, effectively accounting for edge cases and authentication workflows.

🧪 Tested This Feature

Screenshot 2025-04-29 at 18 28 34

🔄 Next Steps

  • Consider edge cases and then merge :)

🚀 Final Thoughts

nice work Ethan!

@cj-ballesteros cj-ballesteros merged commit fb4fd65 into main Apr 30, 2025
3 checks passed
@codecov
Copy link

codecov bot commented Apr 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.16%. Comparing base (fa41293) to head (e4efb81).
Report is 21 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #186   +/-   ##
=======================================
  Coverage   81.16%   81.16%           
=======================================
  Files          17       17           
  Lines         775      775           
  Branches       51       51           
=======================================
  Hits          629      629           
  Misses        123      123           
  Partials       23       23           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Issue is primarily backend related Calendar enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task: Unscheduled Tasks Management for Calendar

3 participants