Stop offering the schedule page when no schedule is published

The home and splash page render a link to the schedule based purely on
the `schedule_public` flag, even when an admin has not yet selected a
schedule or scheduled any events. Following that link rendered the
schedule view, which then failed inside `_carousel.html.haml` because
`@rooms` (and the selected schedule) had no data — a 500 error instead
of a graceful response.

Treat `schedule_public` as an allowance rather than an unchecked
control: introduce `Program#any_published_schedule?` (true only when
the flag is on *and* there is at least one event in a selected
schedule) and use it to decide whether to render the link from the
home and splash pages. The schedule controller now returns 404 when no
event has been scheduled, so bookmarked URLs surface as "not found"
instead of an internal server error.
This commit is contained in:
Asish Kumar 2026-05-14 09:23:06 +05:30
parent c8e6fabed1
commit fae6332c36
6 changed files with 57 additions and 6 deletions

View file

@ -12,10 +12,11 @@ class SchedulesController < ApplicationController
includes: [{ event: %i[event_type speakers submitter] }]
)
unless event_schedules
redirect_to events_conference_schedule_path(@conference.short_title)
return
end
# The +schedule_public+ flag opts a conference into displaying a schedule,
# but the schedule itself only exists once an admin has selected a schedule
# and at least one event has been scheduled. Return 404 to avoid rendering
# a broken page (or crashing) when the schedule has not yet been published.
return not_found if event_schedules.empty?
respond_to do |format|
format.xml do