Skip to content

Calendar events (backend) - #381

Open
jzgom067 wants to merge 18 commits into
v1.0.0from
calendar-events-backend
Open

Calendar events (backend)#381
jzgom067 wants to merge 18 commits into
v1.0.0from
calendar-events-backend

Conversation

@jzgom067

@jzgom067 jzgom067 commented Jul 17, 2026

Copy link
Copy Markdown
Member

This PR adds the backend implementation for date-only events, referred to as a "calendar" event on the backend.

New Database Tables

Two new tables were added to the database, EventCalendarTimeslot and EventCalendarAvailability. These are structurally about the same as their respective tables for the other event types. The only difference is that the timeslots store just dates, not datetimes.

New Endpoints

  • /event/calendar-create/
  • /event/calendar-edit/

These endpoints take the same data as their respective endpoints for the other event types.

It's worth noting that this identical data format means that the backend accepts datetimes for timeslots for calendar events, instead of only dates. This should make it much easier to implement on the frontend with the existing logic, instead of having to adapt the logic to convert to dates.

  • If only dates are supplied anyway (in ISO format, just like the datetimes) they will be converted by the serializers to datetimes, which the backend can then use.

Updated Endpoints

  • /event/get-details/
  • /availability/add/
  • /availability/get-self/
  • /availability/get-all/
  • /dashboard/get/

The logic in these endpoints was extended to support calendar type events. It was mostly reused logic, just leveraging different fields on the database tables.

Fixed Error Logging Issue

Apparently I never noticed that I was trying to access UserEvent.id when logging an error for missing timeslots. The correct field is UserEvent.user_event_id, and that has been fixed in the relevant locations.

New Util Function

to_datetime was created to convert date objects into datetime objects at midnight, making it much easier to convert data between the database format and format used by the existing API logic.

A Note on Testing

If you migrate your database to this new version when testing, you will need to delete any calendar events you create before unapplying the migrations to go back to other versions. You can do this from the dashboard on the frontend, as the events display there, albeit not with the correct data. Otherwise, you can just call the event deletion endpoint,

@jzgom067 jzgom067 added this to the v1.0.0 milestone Jul 17, 2026
@jzgom067
jzgom067 marked this pull request as draft July 17, 2026 20:08
@jzgom067 jzgom067 added enhancement New feature or request cleanup Involves refactoring or small changes backend Related to backend stuff labels Jul 17, 2026
@jzgom067
jzgom067 marked this pull request as ready for review July 17, 2026 20:22
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds calendar events backed by dated timeslots and participant availability records. Backend serializers, validation, creation/editing endpoints, event details, bounds, dashboard queries, and availability APIs now recognize the Calendar event type. New routes expose calendar creation and editing. Frontend API types and endpoint definitions include calendar events, while database migrations add the calendar timeslot and availability models with uniqueness constraints.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 109c07dd-667a-42f0-baad-ff1b6962c654

📥 Commits

Reviewing files that changed from the base of the PR and between 1c91c59 and 7e224d4.

📒 Files selected for processing (12)
  • backend/api/availability/utils.py
  • backend/api/availability/views.py
  • backend/api/dashboard/views.py
  • backend/api/event/serializers.py
  • backend/api/event/urls.py
  • backend/api/event/utils.py
  • backend/api/event/views.py
  • backend/api/migrations/0034_alter_userevent_date_type_eventcalendartimeslot_and_more.py
  • backend/api/models.py
  • backend/api/utils.py
  • frontend/src/lib/utils/api/endpoints.ts
  • frontend/src/lib/utils/api/types.ts

Comment thread backend/api/dashboard/views.py
Comment thread backend/api/event/views.py Outdated
@jzgom067
jzgom067 requested a review from mirmirmirr July 17, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Related to backend stuff cleanup Involves refactoring or small changes enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant