is_current method added to check an event is current and function addded to refresh conference_wide_information
This commit is contained in:
parent
35afdcead4
commit
febd3451ad
8 changed files with 74 additions and 2 deletions
|
|
@ -45,6 +45,7 @@
|
||||||
//= require osem-commercials
|
//= require osem-commercials
|
||||||
//= require unobtrusive_flash
|
//= require unobtrusive_flash
|
||||||
//= require unobtrusive_flash_bootstrap
|
//= require unobtrusive_flash_bootstrap
|
||||||
|
//= require refresh_current_events
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('a[disabled=disabled]').click(function(event){
|
$('a[disabled=disabled]').click(function(event){
|
||||||
|
|
|
||||||
10
app/assets/javascripts/refresh_current_events.js
Normal file
10
app/assets/javascripts/refresh_current_events.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
// will call refreshCurrentEvents every 15 minutes
|
||||||
|
setInterval(refreshCurrentEvents, 900000)
|
||||||
|
});
|
||||||
|
|
||||||
|
function refreshCurrentEvents(){
|
||||||
|
$.ajax({
|
||||||
|
url: "conference_wide_screen.js"
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -177,6 +177,13 @@ module Admin
|
||||||
#To display sponsors in the conference wide information page
|
#To display sponsors in the conference wide information page
|
||||||
@conference = Conference.find_by(short_title: params[:id])
|
@conference = Conference.find_by(short_title: params[:id])
|
||||||
@sponsors = @conference.sponsors
|
@sponsors = @conference.sponsors
|
||||||
|
@program = @conference.program
|
||||||
|
@current_events = @conference.program.events.confirmed.select{ |event| event.is_current?}
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js {render :action=>"conference_wide_screen.js.haml"}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ class Event < ActiveRecord::Base
|
||||||
scope :canceled, -> { where(state: 'canceled') }
|
scope :canceled, -> { where(state: 'canceled') }
|
||||||
scope :withdrawn, -> { where(state: 'withdrawn') }
|
scope :withdrawn, -> { where(state: 'withdrawn') }
|
||||||
scope :highlighted, -> { where(is_highlight: true) }
|
scope :highlighted, -> { where(is_highlight: true) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
state_machine initial: :new do
|
state_machine initial: :new do
|
||||||
state :new
|
state :new
|
||||||
|
|
@ -247,6 +249,13 @@ class Event < ActiveRecord::Base
|
||||||
event_schedules.find_by(schedule_id: program.selected_schedule_id).try(:start_time)
|
event_schedules.find_by(schedule_id: program.selected_schedule_id).try(:start_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
#Compares event start_time, end_with with current time to predict current events
|
||||||
|
#
|
||||||
|
def is_current?
|
||||||
|
Time.current >= self.start_time && Time.current <= end_time
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -294,4 +303,12 @@ class Event < ActiveRecord::Base
|
||||||
def conference_id
|
def conference_id
|
||||||
program.conference_id
|
program.conference_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
#Compares event start_time, end_with with current time to predict current events
|
||||||
|
#
|
||||||
|
def is_current?
|
||||||
|
Time.current >= self.start_time && Time.current <= end_time
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
9
app/views/admin/conference/_current_events.html.haml
Normal file
9
app/views/admin/conference/_current_events.html.haml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
.text-center
|
||||||
|
%h2 Upcoming Events
|
||||||
|
- @current_events.each do |event|
|
||||||
|
%div
|
||||||
|
%h3
|
||||||
|
= link_to event.title, conference_program_proposal_path(@conference.short_title, event.id)
|
||||||
|
%h4
|
||||||
|
presented by
|
||||||
|
= event.speaker_names
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
.container
|
.container
|
||||||
- if @conference.present?
|
- if @conference.present?
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-center
|
.col-md-12
|
||||||
%h2 Upcoming Events
|
- if @program.present?
|
||||||
|
%section#program#current-events
|
||||||
|
= render 'current_events'
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-center
|
.col-md-12.text-center
|
||||||
%h2 Tweets About Conference
|
%h2 Tweets About Conference
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
$('#current-events').html("#{escape_javascript(render 'current_events', data: @current_events)}");
|
||||||
|
|
@ -327,4 +327,29 @@ describe Event do
|
||||||
expect(other_event.week).to eq 48
|
expect(other_event.week).to eq 48
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe 'is_current?' do
|
||||||
|
let(:past_event) { create(:event, program: conference.program) }
|
||||||
|
let(:future_event) { create(:event, program: conference.program) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
event.update_attributes(start_time: "#{Time.current}")
|
||||||
|
past_event.update_attributes(start_time: "#{Time.current - 2.days}")
|
||||||
|
future_event.update_attributes(start_time: "#{Time.current + 2.days}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false for a completed event' do
|
||||||
|
expect(past_event.is_current?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false for a future event' do
|
||||||
|
expect(future_event.is_current?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true for a current event' do
|
||||||
|
expect(event.is_current?).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue