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

@ -163,6 +163,23 @@ class Program < ApplicationRecord
(!conference.email_settings.program_schedule_public_subject.blank? && !conference.email_settings.program_schedule_public_body.blank?)
end
##
# Checks if there is a published schedule that should be displayed.
# A schedule is displayable only when the admin has enabled the
# +schedule_public+ flag *and* there is at least one event scheduled,
# either on the conference-wide selected schedule or on the selected
# schedule of any confirmed self-organized track.
#
# ====Returns
# * +true+ -> When the schedule is public and contains at least one event
# * +false+ -> Otherwise
def any_published_schedule?
return false unless schedule_public
return true if selected_schedule&.event_schedules&.exists?
tracks.self_organized.confirmed.any? { |track| track.selected_schedule&.event_schedules&.exists? }
end
def languages_list
languages.split(',').map {|l| ISO_639.find(l).english_name} if languages.present?
end