Add a Happening Now View
This commit is contained in:
parent
0d4733b130
commit
70bde86dd6
8 changed files with 80 additions and 9 deletions
|
|
@ -60,6 +60,14 @@ class SchedulesController < ApplicationController
|
||||||
@tag = day.strftime('%Y-%m-%d') if day
|
@tag = day.strftime('%Y-%m-%d') if day
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def happening_now
|
||||||
|
@events_schedules = @program.selected_event_schedules(
|
||||||
|
includes: [:room, { event: %i[track event_type speakers submitter] }]
|
||||||
|
).select(&:happening_now?)
|
||||||
|
@events_schedules = [] unless @events_schedules
|
||||||
|
@current_time = Time.now.in_time_zone(@conference.timezone)
|
||||||
|
end
|
||||||
|
|
||||||
def app
|
def app
|
||||||
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11)
|
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -177,14 +177,14 @@ module EventsHelper
|
||||||
return unless event.url.present? && current_user
|
return unless event.url.present? && current_user
|
||||||
|
|
||||||
conference = event.conference
|
conference = event.conference
|
||||||
is_today = event.time&.in_time_zone(conference.timezone).to_date == conference.current_conference_day
|
is_now = event.happening_now?
|
||||||
|
|
||||||
if current_user.roles.where(id: conference.roles).any?
|
if current_user.roles.where(id: conference.roles).any?
|
||||||
# Show Pre-Event links for any memeber of the conference team.
|
# Show Pre-Event links for any memeber of the conference team.
|
||||||
link_to("Join Live Event #{'(Pre-Event)' unless is_today}",
|
link_to("Join Live Event #{'(Pre-Event)' unless is_now}",
|
||||||
event.url, target: '_blank')
|
event.url, target: '_blank')
|
||||||
elsif current_user.registered_to_event?(conference)
|
elsif current_user.registered_to_event?(conference)
|
||||||
if is_today
|
if is_now
|
||||||
link_to('Join Live Event', event.url, target: '_blank')
|
link_to('Join Live Event', event.url, target: '_blank')
|
||||||
else
|
else
|
||||||
link_to('Live Event Link Coming Soon', '#')
|
link_to('Live Event Link Coming Soon', '#')
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class Ability
|
||||||
event.state == 'confirmed'
|
event.state == 'confirmed'
|
||||||
end
|
end
|
||||||
|
|
||||||
can [:show, :events, :app], Schedule do |schedule|
|
can [:show, :events, :happening_now, :app], Schedule do |schedule|
|
||||||
schedule.program.schedule_public
|
schedule.program.schedule_public
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,14 @@ class Event < ApplicationRecord
|
||||||
event_schedules.find_by(schedule_id: selected_schedule_id).try(:start_time)
|
event_schedules.find_by(schedule_id: selected_schedule_id).try(:start_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns the start time at which this event is scheduled
|
||||||
|
#
|
||||||
|
def happening_now?
|
||||||
|
event_schedules.find_by(schedule_id: selected_schedule_id).try(:happening_now?)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns true or false, if the event is already over or not
|
# Returns true or false, if the event is already over or not
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,21 @@ class EventSchedule < ApplicationRecord
|
||||||
|
|
||||||
delegate :guid, to: :room, prefix: true
|
delegate :guid, to: :room, prefix: true
|
||||||
|
|
||||||
delegate :timezone, to: :event
|
def timezone
|
||||||
|
event.conference.timezone
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# True within 1 hour before and after the event.
|
# True within `threshold` before and after the event.
|
||||||
#
|
#
|
||||||
def happening_now?(threshold=30.minutes)
|
def happening_now?(threshold=30.minutes)
|
||||||
pre_start_time = (start_time - threshold).in_time_zone(timezone)
|
in_tz_start = start_time.in_time_zone(timezone)
|
||||||
end_time_with_threshold = (end_time + threshold).in_time_zone(timezone)
|
in_tz_end = start_time.in_time_zone(timezone)
|
||||||
(pre_start_time..end_time_with_threshold).cover?(Time.now.in_time_zone(timezone))
|
in_tz_start -= in_tz_start.utc_offset
|
||||||
|
in_tz_end -= in_tz_end.utc_offset
|
||||||
|
begin_range = Time.now - threshold
|
||||||
|
end_range = Time.now + threshold + 1.minute # The range is exclusive.
|
||||||
|
(begin_range..end_range).cover?(in_tz_start) || (begin_range..end_range).cover?(in_tz_end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.withdrawn_or_canceled_event_schedules(schedule_ids)
|
def self.withdrawn_or_canceled_event_schedules(schedule_ids)
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,7 @@
|
||||||
%ul.nav.nav-tabs{ role: "tablist" }
|
%ul.nav.nav-tabs{ role: "tablist" }
|
||||||
%li{ class: "program #{ 'active' if active == 'program' }", role: "presentation" }
|
%li{ class: "program #{ 'active' if active == 'program' }", role: "presentation" }
|
||||||
= link_to('All events', events_conference_schedule_path(@conference.short_title))
|
= link_to('All events', events_conference_schedule_path(@conference.short_title))
|
||||||
|
%li{ class: "program #{ 'active' if active == 'now' }", role: "presentation" }
|
||||||
|
= link_to('Happening Now', happening_now_conference_schedule_path(@conference.short_title))
|
||||||
%li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" }
|
%li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" }
|
||||||
= link_to('Schedule', conference_schedule_path(@conference.short_title))
|
= link_to('Schedule', conference_schedule_path(@conference.short_title))
|
||||||
|
|
|
||||||
46
app/views/schedules/happening_now.haml
Normal file
46
app/views/schedules/happening_now.haml
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
.container#program
|
||||||
|
= render partial: 'schedule_tabs', locals: { active: 'now' }
|
||||||
|
|
||||||
|
%h1.text-center
|
||||||
|
Happening Now at
|
||||||
|
= @conference.title
|
||||||
|
-# .dropdown.program-dropdown
|
||||||
|
-# %button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" }
|
||||||
|
-# Dates
|
||||||
|
-# %span.caret
|
||||||
|
-# %ul.dropdown-menu
|
||||||
|
-# - @dates.each do |date|
|
||||||
|
-# %li.li-dropdown-program
|
||||||
|
-# = link_to date, "##{date}", class: "program-selector#{ ' no-events-day' unless @conference.program.any_event_for_this_date?(date) }"
|
||||||
|
-# - if @unscheduled_events.any?
|
||||||
|
-# %li.li-dropdown-program
|
||||||
|
-# = link_to('Unscheduled', "#unscheduled", class: 'program-selector')
|
||||||
|
|
||||||
|
.row
|
||||||
|
%h2
|
||||||
|
#{pluralize(@events_schedules.count, 'Event')} Occurring Within The Next 30 minutes.
|
||||||
|
%h3
|
||||||
|
This page was loaded at #{Time.now.strftime('%Y-%m-%d at %H:%M %P')}
|
||||||
|
%p
|
||||||
|
P.S. This page is in beta, and if it doesn't make sense, we're sorry.
|
||||||
|
%small
|
||||||
|
Times & Timezones...only of the many 2 hard problems in computer science.
|
||||||
|
|
||||||
|
.row
|
||||||
|
/ scheduled events
|
||||||
|
- @events_schedules.each do |event_schedule|
|
||||||
|
.col-xs-12.col-md-11.col-md-offset-1
|
||||||
|
= render partial: 'event', locals: { event: event_schedule.event, event_schedule: event_schedule }
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$('.program-selector').on('click', function(e) {
|
||||||
|
$('.li-dropdown-program').removeClass('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Go to current date and time
|
||||||
|
$(document).ready(function(){
|
||||||
|
tag = "#{ @tag }";
|
||||||
|
if(tag !== ""){
|
||||||
|
document.getElementById(tag).scrollIntoView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -204,6 +204,7 @@ Osem::Application.routes.draw do
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
get :events
|
get :events
|
||||||
|
get :happening_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue