From d564de7caae65ebeabaa2d464419f6d273e5279d Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 21 Apr 2021 09:01:12 -0700 Subject: [PATCH 01/11] show happening now and happening next on the events page --- app/controllers/proposals_controller.rb | 18 ++++++++++++++++++ app/views/proposals/show.html.haml | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index bf1b3adc..63a2a72c 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -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 @@ -166,6 +170,8 @@ class ProposalsController < ApplicationController def registrations; end + + private def event_params @@ -179,4 +185,16 @@ class ProposalsController < ApplicationController def user_params params.require(:user).permit(:email, :password, :password_confirmation, :username) 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 diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index 5d2dd948..9df7901e 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -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 + From c4920ba85d4d5d9badef5a2a2eb6e577cb13d150 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 22 Apr 2021 00:40:53 +0800 Subject: [PATCH 02/11] [fix]Fix ajax for pagination --- app/views/conferences/show.js.erb | 3 ++- app/views/proposals/show.js.erb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/views/proposals/show.js.erb diff --git a/app/views/conferences/show.js.erb b/app/views/conferences/show.js.erb index fb35b420..61c0a3a3 100644 --- a/app/views/conferences/show.js.erb +++ b/app/views/conferences/show.js.erb @@ -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')); diff --git a/app/views/proposals/show.js.erb b/app/views/proposals/show.js.erb new file mode 100644 index 00000000..53220cb8 --- /dev/null +++ b/app/views/proposals/show.js.erb @@ -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')); From 83e7321b693500dd39ef9b78aee2852d9bc6eacb Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 22 Apr 2021 00:43:27 +0800 Subject: [PATCH 03/11] [style]Fix rubocop --- app/controllers/proposals_controller.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 63a2a72c..97d20787 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -170,8 +170,6 @@ class ProposalsController < ApplicationController def registrations; end - - private def event_params From 74437ab1e50e379e293c0d7a66050f96ef419b32 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 22 Apr 2021 00:59:38 +0800 Subject: [PATCH 04/11] [fix]Remove unnecessary check in happening_now partial --- .../conferences/_about_and_happening_now.haml | 2 +- app/views/conferences/_happening_now.haml | 31 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/views/conferences/_about_and_happening_now.haml b/app/views/conferences/_about_and_happening_now.haml index ead36206..92bd7a6f 100644 --- a/app/views/conferences/_about_and_happening_now.haml +++ b/app/views/conferences/_about_and_happening_now.haml @@ -16,7 +16,7 @@ .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 = yield :happening_now diff --git a/app/views/conferences/_happening_now.haml b/app/views/conferences/_happening_now.haml index 563a4b4f..e5296273 100644 --- a/app/views/conferences/_happening_now.haml +++ b/app/views/conferences/_happening_now.haml @@ -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.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. From 83e4601ddb0316ed411f9ac42847f5fae89c535c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 22 Apr 2021 01:13:56 +0800 Subject: [PATCH 05/11] [fix]Add nil check for happening_now partial --- app/views/conferences/_happening_now.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/conferences/_happening_now.haml b/app/views/conferences/_happening_now.haml index e5296273..4e4c62ae 100644 --- a/app/views/conferences/_happening_now.haml +++ b/app/views/conferences/_happening_now.haml @@ -1,4 +1,4 @@ -- if events_schedules.any? +- if events_schedules.present? && events_schedules.any? .row %h2.text-center{ style: 'margin-bottom:30px' } - if is_happening_next From bafeca7ab934b3f9396abf8bf49d6336c8b6dcd0 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 22 Apr 2021 01:24:14 +0800 Subject: [PATCH 06/11] [fix]Remove duplicate code --- app/controllers/conferences_controller.rb | 12 ------------ app/controllers/proposals_controller.rb | 12 ------------ app/helpers/conference_helper.rb | 12 ++++++++++++ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 529d9fb4..cfd7eafc 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -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 diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 97d20787..b6571b10 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -183,16 +183,4 @@ class ProposalsController < ApplicationController def user_params params.require(:user).permit(:email, :password, :password_confirmation, :username) 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 diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb index 29db24d4..4240ad54 100644 --- a/app/helpers/conference_helper.rb +++ b/app/helpers/conference_helper.rb @@ -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) From 690ea5b2a9c46a0190b243ba930ac28761b4f044 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 21 Apr 2021 10:47:49 -0700 Subject: [PATCH 07/11] [style] changes to styling and wording --- app/views/conferences/_about_and_happening_now.haml | 2 +- app/views/conferences/_happening_now.haml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/conferences/_about_and_happening_now.haml b/app/views/conferences/_about_and_happening_now.haml index 92bd7a6f..82bf4ee3 100644 --- a/app/views/conferences/_about_and_happening_now.haml +++ b/app/views/conferences/_about_and_happening_now.haml @@ -18,7 +18,7 @@ -# happening now events are displayed second in md or lg view - 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 diff --git a/app/views/conferences/_happening_now.haml b/app/views/conferences/_happening_now.haml index 4e4c62ae..ccf0181f 100644 --- a/app/views/conferences/_happening_now.haml +++ b/app/views/conferences/_happening_now.haml @@ -1,10 +1,10 @@ - if events_schedules.present? && events_schedules.any? .row - %h2.text-center{ style: 'margin-bottom:30px' } + %h3.text-left{ style: 'margin-bottom:30px; padding-left:20px' } - if is_happening_next - Happening Next + Events Happening Next - else - Happening Now + 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 From 6fa21fcba5659e1141dee5c23c153329f5952e19 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 21 Apr 2021 21:40:08 -0700 Subject: [PATCH 08/11] testing --- .../conferences/_about_and_happening_now.haml | 2 +- spec/features/proposals_spec.rb | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/app/views/conferences/_about_and_happening_now.haml b/app/views/conferences/_about_and_happening_now.haml index 82bf4ee3..f8518bc8 100644 --- a/app/views/conferences/_about_and_happening_now.haml +++ b/app/views/conferences/_about_and_happening_now.haml @@ -18,7 +18,7 @@ -# happening now events are displayed second in md or lg view - 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{ style: 'margin-top: 60px'} + .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 diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index e7377bb2..42b0112d 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -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 From 6ebfdefbbdd0d3c96670281f9d58113a31bb3c1a Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Sat, 24 Apr 2021 22:19:36 -0700 Subject: [PATCH 09/11] fixed the title --- app/views/admin/commercials/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/commercials/index.html.haml b/app/views/admin/commercials/index.html.haml index 2b91c1a6..d318707c 100644 --- a/app/views/admin/commercials/index.html.haml +++ b/app/views/admin/commercials/index.html.haml @@ -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) From 4307fa9538685aa2aea9cebfdc20f8031c77e5cb Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Sat, 24 Apr 2021 22:33:59 -0700 Subject: [PATCH 10/11] testing --- spec/features/commercials_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index d6fc7f38..e6d4f9ca 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -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' From 4ce418002d81de6e1dbec300ad1fba8a3d28bfb5 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Sat, 24 Apr 2021 22:40:48 -0700 Subject: [PATCH 11/11] rubocop fixed --- spec/features/commercials_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index e6d4f9ca..c9b30a6e 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -10,14 +10,14 @@ feature Commercial do let!(:participant) { create(:user) } context 'in admin area' 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" + header = conference.title + ' Materials' expect(page).to have_content(header) end