[refractor]Use ? methods instead of boolean variables; rename happening_next? to happening_later?

This commit is contained in:
Jimmy 2021-04-17 08:30:07 +08:00
parent 59c5d432ed
commit ab15a3fb10
No known key found for this signature in database
GPG key ID: FAE75C760A4A5CC6
6 changed files with 18 additions and 18 deletions

View file

@ -40,7 +40,7 @@ class ConferencesController < ApplicationController
@image_url = "#{request.protocol}#{request.host}#{@conference.picture}"
if splashpage.include_cfp
if splashpage.include_cfp?
cfps = @conference.program.cfps
@call_for_events = cfps.find { |call| call.cfp_type == 'events' }
if @call_for_events.try(:open?)
@ -50,27 +50,27 @@ class ConferencesController < ApplicationController
@call_for_tracks = cfps.find { |call| call.cfp_type == 'tracks' }
@call_for_booths = cfps.find { |call| call.cfp_type == 'booths' }
end
if splashpage.include_program
if splashpage.include_program?
@highlights = @conference.highlighted_events.eager_load(:speakers)
if splashpage.include_tracks
if splashpage.include_tracks?
@tracks = @conference.confirmed_tracks.eager_load(
:room
).order('tracks.name')
end
if splashpage.include_booths
if splashpage.include_booths?
@booths = @conference.confirmed_booths.order('title')
end
if splashpage.include_happening_now
if splashpage.include_happening_now?
load_happening_now
end
end
if splashpage.include_registrations || splashpage.include_tickets
if splashpage.include_registrations? || splashpage.include_tickets?
@tickets = @conference.tickets.visible.order('price_cents')
end
if splashpage.include_lodgings
if splashpage.include_lodgings?
@lodgings = @conference.lodgings.order('id')
end
if splashpage.include_sponsors
if splashpage.include_sponsors?
@sponsorship_levels = @conference.sponsorship_levels.eager_load(
:sponsors
).order('sponsorship_levels.position ASC', 'sponsors.name')

View file

@ -89,7 +89,7 @@ module ConferenceHelper
def get_happening_next_events_schedules(conference)
events_schedules = conference.program.selected_event_schedules(
includes: [:room, { event: %i[track event_type speakers submitter] }]
).select(&:happening_next?)
).select(&:happening_later?)
if events_schedules.empty?
return []

View file

@ -70,7 +70,7 @@ class EventSchedule < ApplicationRecord
event_time_range.overlaps?(now_range)
end
def happening_next?
def happening_later?
# TODO: Save start_time with local timezone info when making an event schedule
in_tz_start = start_time.in_time_zone(timezone)
in_tz_start -= in_tz_start.utc_offset

View file

@ -51,7 +51,7 @@
- if @conference.program.schedule_public
%td {schedule_link}
%td The link to complete schedule of the conference
- if @conference.splashpage && @conference.splashpage.public
- if @conference.splashpage && @conference.splashpage.public?
%tr
%td {conference_splash_link}
%td The link to conference splash page

View file

@ -49,7 +49,7 @@
%i{ class: "fa-li #{icon_for_todo @splashpage.include_social_media?}" }
Display social media links
%li
- if @conference.splashpage && @conference.splashpage.public
- if @conference.splashpage && @conference.splashpage.public?
%i{ class: "fa-li #{icon_for_todo @splashpage.public?}" }
%text-muted.publicorprivate Public
- else

View file

@ -53,18 +53,18 @@
is_happening_next: @is_happening_next
-# calls for content, or program
- if @conference.splashpage.include_cfp
- if @conference.splashpage.include_cfp?
= render 'call_for_content', conference: @conference,
call_for_events: @call_for_events, call_for_tracks: @call_for_tracks,
call_for_booths: @call_for_booths,
event_types: @event_types, tracks: @track_names
- if @conference.splashpage.include_program
- if @conference.splashpage.include_program?
= render 'program', conference: @conference, tracks: @tracks,
highlights: @highlights, booths: @booths
-# attendance/registration
- if @conference.splashpage.include_registrations
- if @conference.splashpage.include_registrations?
- if @conference.registration_open?
= render 'registration', conference: @conference,
registration_period: @conference.registration_period,
@ -73,20 +73,20 @@
= render 'tickets', conference: @conference, tickets: @tickets
-# geo
- if @conference.splashpage.include_venue && @conference.venue
- if @conference.splashpage.include_venue? && @conference.venue
= render 'venue', conference: @conference, venue: @conference.venue,
commercial: @conference.venue.commercial
- if @conference.splashpage.include_lodgings && @conference.lodgings.any?
= render 'lodging', venue: @conference.venue, lodgings: @lodgings
-# sponsorship
- if @conference.splashpage.include_sponsors
- if @conference.splashpage.include_sponsors?
= render 'sponsors', conference: @conference,
sponsorship_levels: @sponsorship_levels,
sponsors: @sponsors
-# footer
- if @conference.splashpage.include_social_media
- if @conference.splashpage.include_social_media?
- if @conference.contact.has_social_media?
= render 'social_media', contact: @conference.contact
= render 'footer'