Merge pull request #72 from CactusPuppy/177571211-Embed-Happening-Now-Events-in-Event-Page
177571211 embed happening now events in event page
This commit is contained in:
commit
7039bf852e
9 changed files with 155 additions and 32 deletions
|
|
@ -147,16 +147,4 @@ class ConferencesController < ApplicationController
|
|||
def current_user_has_unpaid_tickets?
|
||||
current_user && current_user_tickets.unpaid.any?
|
||||
end
|
||||
|
||||
def load_happening_now
|
||||
events_schedules_list = get_happening_now_events_schedules(@conference)
|
||||
@is_happening_next = false
|
||||
if events_schedules_list.empty?
|
||||
events_schedules_list = get_happening_next_events_schedules(@conference)
|
||||
@is_happening_next = true
|
||||
end
|
||||
@events_schedules_limit = EVENTS_PER_PAGE
|
||||
@events_schedules_length = events_schedules_list.length
|
||||
@pagy, @events_schedules = pagy_array(events_schedules_list, items: @events_schedules_limit, link_extra: 'data-remote="true"')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
EVENTS_PER_PAGE = Rails.configuration.conference[:events_per_page]
|
||||
|
||||
class ProposalsController < ApplicationController
|
||||
include ConferenceHelper
|
||||
before_action :authenticate_user!, except: [:show, :new, :create]
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_resource :program, through: :conference, singleton: true
|
||||
|
|
@ -19,6 +22,7 @@ class ProposalsController < ApplicationController
|
|||
@event_schedule = @event.event_schedules.find_by(schedule_id: @program.selected_schedule_id)
|
||||
@speakers_ordered = @event.speakers_ordered
|
||||
@surveys_after_event = @event.surveys.after_event.select(&:active?)
|
||||
load_happening_now
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
|||
|
|
@ -98,6 +98,18 @@ module ConferenceHelper
|
|||
events_schedules
|
||||
end
|
||||
|
||||
def load_happening_now
|
||||
events_schedules_list = get_happening_now_events_schedules(@conference)
|
||||
@is_happening_next = false
|
||||
if events_schedules_list.empty?
|
||||
events_schedules_list = get_happening_next_events_schedules(@conference)
|
||||
@is_happening_next = true
|
||||
end
|
||||
@events_schedules_limit = EVENTS_PER_PAGE
|
||||
@events_schedules_length = events_schedules_list.length
|
||||
@pagy, @events_schedules = pagy_array(events_schedules_list, items: @events_schedules_limit, link_extra: 'data-remote="true"')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def filter_events_schedules(conference, filter)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
.container
|
||||
.row
|
||||
-# happening now events are displayed second in md or lg view
|
||||
- if conference.splashpage.include_happening_now && conference.splashpage.include_program
|
||||
- if conference.splashpage.include_happening_now? && conference.splashpage.include_program?
|
||||
- if conference.description.present?
|
||||
.col-md-6.col-md-push-6.col-lg-4.col-lg-push-8
|
||||
.col-md-6.col-md-push-6.col-lg-4.col-lg-push-8{ style: 'margin-top: 60px' }
|
||||
= yield :happening_now
|
||||
- else
|
||||
.col-md-12
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
- if conference.splashpage.include_program && conference.splashpage.include_happening_now
|
||||
- if events_schedules.any?
|
||||
.row
|
||||
%h2.text-center{ style: 'margin-bottom:30px' }
|
||||
- if is_happening_next
|
||||
Happening Next
|
||||
- else
|
||||
Happening Now
|
||||
- events_schedules.each do |event_schedule|
|
||||
= render 'schedules/event', conference: conference, event_schedule: event_schedule, event: event_schedule.event, is_brief: true
|
||||
- if events_schedules_length > events_schedules_limit
|
||||
.container{ style: 'width:100%; text-align:center' }
|
||||
!= pagy_bootstrap_nav_js(pagy)
|
||||
- else
|
||||
.row
|
||||
%h3.text-center There are no events scheduled yet.
|
||||
- if events_schedules.present? && events_schedules.any?
|
||||
.row
|
||||
%h3.text-left{ style: 'margin-bottom:30px; padding-left:20px' }
|
||||
- if is_happening_next
|
||||
Events Happening Next
|
||||
- else
|
||||
Events Happening Now
|
||||
- events_schedules.each do |event_schedule|
|
||||
= render 'schedules/event', conference: conference, event_schedule: event_schedule, event: event_schedule.event, is_brief: true
|
||||
- if events_schedules_length > events_schedules_limit
|
||||
.container{ style: 'width:100%; text-align:center' }
|
||||
!= pagy_bootstrap_nav_js(pagy)
|
||||
- else
|
||||
.row
|
||||
%h3.text-center There are no events scheduled yet.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
$('#happening-now').html("<%= j(render 'happening_now', conference: @conference,
|
||||
events_schedules: @events_schedules, pagy: @pagy,
|
||||
events_schedules_length: @events_schedules_length,
|
||||
events_schedules_limit: @events_schedules_limit)%>");
|
||||
events_schedules_limit: @events_schedules_limit,
|
||||
is_happening_next: @is_happening_next) %>");
|
||||
Pagy.init(document.getElementById('happening-now'));
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
- @event.volunteers.each do |volunteer|
|
||||
= render 'volunteer_info', speaker: volunteer, show_bio: false
|
||||
|
||||
.col-md-9
|
||||
.col-md-6
|
||||
.row
|
||||
.col-md-12
|
||||
.lead
|
||||
|
|
@ -138,3 +138,11 @@
|
|||
- if @surveys_after_event.any? && @event.ended?
|
||||
.page-header
|
||||
= render partial: 'surveys/list', locals: { surveys: @surveys_after_event, conference: @conference }
|
||||
.col-md-3
|
||||
#happening-now
|
||||
= render 'conferences/happening_now', conference: @conference,
|
||||
events_schedules: @events_schedules, pagy: @pagy,
|
||||
events_schedules_length: @events_schedules_length,
|
||||
events_schedules_limit: @events_schedules_limit,
|
||||
is_happening_next: @is_happening_next
|
||||
|
||||
|
|
|
|||
6
app/views/proposals/show.js.erb
Normal file
6
app/views/proposals/show.js.erb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
$('#happening-now').html("<%= j(render 'conferences/happening_now', conference: @conference,
|
||||
events_schedules: @events_schedules, pagy: @pagy,
|
||||
events_schedules_length: @events_schedules_length,
|
||||
events_schedules_limit: @events_schedules_limit,
|
||||
is_happening_next: @is_happening_next) %>");
|
||||
Pagy.init(document.getElementById('happening-now'));
|
||||
|
|
@ -212,4 +212,109 @@ feature Event do
|
|||
expect(page.find('#event_submission_text').value).to eq(event_type.submission_instructions)
|
||||
end
|
||||
end
|
||||
|
||||
context 'happening now or next section', feature: true, js: true do
|
||||
let!(:conference1) { create(:full_conference, start_date: 1.day.ago, end_date: 7.days.from_now, start_hour: 0, end_hour: 24) }
|
||||
let!(:program) { conference1.program }
|
||||
let!(:selected_schedule) { create(:schedule, program: program) }
|
||||
let!(:splashpage) { create(:full_splashpage, conference: conference1, public: true) }
|
||||
|
||||
let!(:scheduled_event1) do
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
create(:event, program: program, state: 'confirmed')
|
||||
end
|
||||
let!(:scheduled_event2) do
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
create(:event, program: program, state: 'confirmed')
|
||||
end
|
||||
let!(:scheduled_event3) do
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
create(:event, program: program, state: 'confirmed')
|
||||
end
|
||||
let!(:scheduled_event4) do
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
create(:event, program: program, state: 'confirmed')
|
||||
end
|
||||
let!(:current_time) { Time.now.in_time_zone(conference1.timezone) }
|
||||
|
||||
let!(:events_list) { [scheduled_event1, scheduled_event2, scheduled_event3, scheduled_event4] }
|
||||
|
||||
before :each do
|
||||
sign_in participant
|
||||
end
|
||||
|
||||
scenario 'No events happening now or next' do
|
||||
events_list.each do |event|
|
||||
visit conference_program_proposal_path(conference1.short_title, event.id)
|
||||
happening_now = page.find('#happening-now')
|
||||
expect(happening_now).to have_content('There are no events scheduled yet.')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'shows all events happening next if nothing is happening now' do
|
||||
event_schedule1 = create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: (current_time + 1.hour).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule2 = create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: (current_time + 1.hour).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
|
||||
events_list.each do |event|
|
||||
visit conference_program_proposal_path(conference1.short_title, event.id)
|
||||
happening_now = page.find('#happening-now')
|
||||
expect(happening_now).to have_content(event_schedule1.event.title)
|
||||
expect(happening_now).to have_content(event_schedule2.event.title)
|
||||
expect(happening_now).not_to have_content(scheduled_event3.title)
|
||||
expect(happening_now).not_to have_content(scheduled_event4.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'only shows all events happening now if something is happening now and next' do
|
||||
event_schedule1 = create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: (current_time + 1.hour).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule2 = create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: (current_time + 1.hour).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule3 = create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: current_time.strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
events_list.each do |event|
|
||||
visit conference_program_proposal_path(conference1.short_title, event.id)
|
||||
happening_now = page.find('#happening-now')
|
||||
expect(happening_now).not_to have_content(event_schedule1.event.title)
|
||||
expect(happening_now).not_to have_content(event_schedule2.event.title)
|
||||
expect(happening_now).to have_content(event_schedule3.event.title)
|
||||
expect(happening_now).not_to have_content(scheduled_event4.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'only shows events happening at the earliest time, not at a later time in the future' do
|
||||
event_schedule1 = create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: (current_time + 1.hour).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule2 = create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: (current_time + 1.hour).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule3 = create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: (current_time + 2.hours).strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
events_list.each do |event|
|
||||
visit conference_program_proposal_path(conference1.short_title, event.id)
|
||||
happening_now = page.find('#happening-now')
|
||||
expect(happening_now).to have_content(event_schedule1.event.title)
|
||||
expect(happening_now).to have_content(event_schedule2.event.title)
|
||||
expect(happening_now).not_to have_content(event_schedule3.event.title)
|
||||
expect(happening_now).not_to have_content(scheduled_event4.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'only shows 3 events happening now because of pagination' do
|
||||
event_schedule1 = create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: current_time.strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule2 = create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: current_time.strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule3 = create(:event_schedule, event: scheduled_event3, schedule: selected_schedule, start_time: current_time.strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
event_schedule4 = create(:event_schedule, event: scheduled_event4, schedule: selected_schedule, start_time: current_time.strftime('%a, %d %b %Y %H:%M:%S'))
|
||||
|
||||
events_list.each do |event|
|
||||
visit conference_program_proposal_path(conference1.short_title, event.id)
|
||||
happening_now = page.find('#happening-now')
|
||||
expect(happening_now).to have_content(event_schedule1.event.title)
|
||||
expect(happening_now).to have_content(event_schedule2.event.title)
|
||||
expect(happening_now).to have_content(event_schedule3.event.title)
|
||||
|
||||
visit conference_program_proposal_path(conference1.short_title, event.id, page: 2)
|
||||
happening_now = page.find('#happening-now')
|
||||
expect(happening_now).not_to have_content(event_schedule3.event.title)
|
||||
expect(happening_now).not_to have_content(event_schedule1.event.title)
|
||||
expect(happening_now).not_to have_content(event_schedule2.event.title)
|
||||
|
||||
expect(happening_now).to have_content(event_schedule4.event.title)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue