Skip to content

feat(dashboard): owner calendar booking with fixed time slots#77

Merged
robert197 merged 4 commits into
mainfrom
feat/66-owner-calendar-booking
Apr 2, 2026
Merged

feat(dashboard): owner calendar booking with fixed time slots#77
robert197 merged 4 commits into
mainfrom
feat/66-owner-calendar-booking

Conversation

@robert197

Copy link
Copy Markdown
Owner

Summary

  • Add owner-facing calendar booking system for scheduling inspection appointments
  • 3 fixed daily time slots (Vormittag 08:00-10:30, Mittag 10:30-13:00, Nachmittag 13:30-16:00)
  • Business hours changed from 8-18 to 8-16 per customer feedback
  • HTMX-powered weekly calendar with mobile-first responsive design

Closes #66

Changes

  • Model: Add TimeSlot choices, SLOT_TIMES constant, time_slot field. Make inspector FK nullable (SET_NULL) for owner-booked inspections. Add apartment-day duplicate validation.
  • Subscription counting: Fix get_inspections_used_this_month() to count all non-cancelled inspections (SCHEDULED + IN_PROGRESS + COMPLETED), not just COMPLETED
  • Views: booking_calendar (weekly grid with HTMX navigation), book_slot (HTMX POST endpoint)
  • Templates: Calendar with desktop 7-column grid and mobile vertical day list, success/error partials
  • Navigation: "Termin buchen" added to sidebar and bottom nav (replaces disabled placeholder)
  • Notifications: Admin email on new booking via background task
  • Safety: All inspector references audited for None safety across admin, tasks, templates, emails

Validation

  • make lint passes
  • make test passes (931 tests, 34 new)
  • make manage CMD="check" passes
  • Code review via /ce:review (all findings resolved)

Review Notes

  • No Critical findings. Addressed Important findings: batched per-day queries, capped week_offset, used enum for SLOT_TIMES lookup.
  • TOCTOU race on same-day duplicate check accepted for MVP (subscription limit is natural cap). Can add DB constraint in v2.
  • Inspector assignment remains manual (admin assigns via Django Admin). Auto-assignment deferred to v2.

Co-Authored-By: Claude noreply@anthropic.com

Robert added 4 commits April 2, 2026 10:46
… subscription counting

- Change BUSINESS_HOURS_END from 18 to 16 (customer requirement)
- Add TimeSlot choices (MORNING/MIDDAY/AFTERNOON) with SLOT_TIMES mapping
- Add time_slot field to Inspection model
- Make inspector FK nullable (null=True, blank=True, on_delete=SET_NULL)
  for owner-booked inspections where inspector is assigned later
- Add apartment-day duplicate validation (no two inspections same apt same day)
- Fix get_inspections_used_this_month() to count all non-cancelled inspections
  (SCHEDULED + IN_PROGRESS + COMPLETED) instead of only COMPLETED
- Audit all inspector references for None safety across admin, tasks, templates
- Update scheduling tests for new business hours and same-day validation
- Add BookingApartmentForm for apartment selection
- Add booking_calendar view with weekly grid and HTMX week navigation
- Add book_slot view for creating inspections from slot selection
- Add URL routes: /dashboard/buchen/ and /dashboard/buchen/slot/
- Add booking_calendar.html with desktop grid and mobile vertical layout
- Add _calendar_week.html HTMX partial for week navigation
- Add _booking_success.html and _booking_error.html response partials
- Add send_booking_notification task and admin email templates
- Update sidebar and bottom nav with "Termin buchen" link
- Fix test_cascade_delete_inspector for SET_NULL behavior
- 34 new tests covering auth, validation, slot times, subscription limits
- Batch per-day booking queries into single query with __date__in
- Cap week_offset to max 52 weeks ahead
- Use Inspection.TimeSlot enum for SLOT_TIMES lookup instead of raw string
@robert197 robert197 merged commit 070d1f8 into main Apr 2, 2026
@robert197 robert197 deleted the feat/66-owner-calendar-booking branch April 2, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Owner-facing calendar booking with fixed time slots

1 participant