Merge branch 'master' into 176895077-Google-Calendar-Link-Should-Be-Visible-only-with-registration

This commit is contained in:
Rajavi Mishra 2021-04-29 13:34:24 -07:00 committed by GitHub
commit 42882d852b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 166 additions and 35 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -1,7 +1,7 @@
.row
.col-md-12
.page-header
%h1 Session Materials
%h1 #{@conference.title} Materials
%p.text-muted
Conference materials will be displayed on the events in the
= link_to 'schedule,', conference_schedule_path(@conference.short_title)

View file

@ -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

View file

@ -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.

View file

@ -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'));

View file

@ -52,7 +52,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
@ -139,3 +139,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

View 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'));

View file

@ -10,11 +10,18 @@ feature Commercial do
let!(:participant) { create(:user) }
context 'in admin area' do
scenario 'adds, updates, deletes of a conference', feature: true, js: true do
before do
sign_in organizer
visit admin_conference_commercials_path(conference.short_title)
end
scenario 'contains the conference name in the title', feature: true, js: true do
header = conference.title + ' Materials'
expect(page).to have_content(header)
end
scenario 'adds, updates, deletes of a conference', feature: true, js: true do
# Create valid commercial
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
click_button 'Save Materials'

View file

@ -213,6 +213,7 @@ feature Event do
end
end
context 'as a user, looking at a conference with scheduled events' do
before(:each) do
@user = create(:user)
@ -234,4 +235,109 @@ feature Event do
expect(page).not_to have_content('Add to Google Calendar (beta)')
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