diff --git a/INSTALL.md b/INSTALL.md index afd2ded8..95c1cb04 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -52,16 +52,15 @@ There are a couple of environment variables you can set to configure OSEM. | CLOUDINARY_URL | *string* | Configure your cloudinary.com cloud name and api key/secret | STRIPE_PUBLISHABLE_KEY | *string* | Publishable Key for Stripe Gateway | STRIPE_SECRET_KEY | *string* | Secret Key for Stripe Gateway +| OSEM_TWITTER_CONSUMER_KEY | *string* | To embed tweets about the conference in the conference wide page +| OSEM_TWITTER_CONSUMER_SECRET | *string* | To embed tweets about the conference in the conference wide page +| OSEM_TWITTER_ACCESS_TOKEN | *string* | To embed tweets about the conference in the conference wide page +| OSEM_TWITTER_ACCESS_TOKEN_SECRET | *string* | To embed tweets about the conference in the conference wide page ### Online Ticket Payments We use [Stripe](https://stripe.com) for accepting your ticket payments securely over the web. Our application uses iFrame for accepting your user's payment details without storing them, making the application PCI SAQ-A Compliant. Please refer to [PAYMENTS](PAYMENTS.md) documentation file for setting up your stripe account and start accepting payments from your users. -| CLOUDINARY_URL | *string* | Configure your cloudinary.com cloud name and api key/secret -| OSEM_TWITTER_CONSUMER_KEY | *string* | To embed tweets about the conference in the conference wide page -| OSEM_TWITTER_CONSUMER_SECRET | *string* | To embed tweets about the conference in the conference wide page -| OSEM_TWITTER_ACCESS_TOKEN | *string* | To embed tweets about the conference in the conference wide page -| OSEM_TWITTER_ACCESS_TOKEN_SECRET | *string* | To embed tweets about the conference in the conference wide page ## Dependencies diff --git a/app.json b/app.json index f77f6c9c..856766d1 100644 --- a/app.json +++ b/app.json @@ -59,6 +59,18 @@ }, "RAILS_ENV": { "required": false + }, + "OSEM_TWITTER_CONSUMER_KEY": { + "required": true + }, + "OSEM_TWITTER_CONSUMER_SECRET": { + "required": true + }, + "OSEM_TWITTER_ACCESS_TOKEN": { + "required": true + }, + "OSEM_TWITTER_ACCESS_TOKEN_SECRET": { + "required": true } }, "scripts": { diff --git a/app/assets/javascripts/refresh_current_events.js b/app/assets/javascripts/refresh_current_events.js index 2d9ac5e0..a6d050f7 100644 --- a/app/assets/javascripts/refresh_current_events.js +++ b/app/assets/javascripts/refresh_current_events.js @@ -1,21 +1,32 @@ $(document).ready(function() { // will call refreshCurrentEvents every 15 minutes - setInterval(refreshCurrentEvents, 900000) - // To cycle through tweets - var tweets = $('div[id^="tweet"]').hide(); - var i = 0; + setInterval(refreshCurrentEvents,900000); - (function cycle() { - tweets.eq(i).show(0) - .delay(5000) - .hide(0, cycle); - i = ++i % tweets.length; - })(); + // Only show the first child of tweet and sponsor containers on page load + $('#tweet-container').children().hide(); + $('#tweet-container').children().eq(0).show(); + $('#sponsor-container').children().hide(); + $('#sponsor-container').children().eq(0).show(); - }); + setInterval(function(){ cycleVisibleElement($('#tweet-container'))}, 5000) + setInterval(function(){ cycleVisibleElement($('#sponsor-container'))}, 10000) +}); +// Makes an ajax call for fresh data function refreshCurrentEvents(){ $.ajax({ url: "conference_wide_screen.js" }); }; + +// Cycle through children in a container and toggles visibility +function cycleVisibleElement(container){ + var childrens = $(container).children(); + for(var i = 0; i < childrens.length; i++ ){ + if(childrens.eq(i).is(":visible")){ + childrens.eq(i).hide(); + childrens.eq(++i % childrens.length).show(); + return + } + } +}; diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 662ab1cd..ac01136f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -8,7 +8,6 @@ *= require osem-schedule-print *= require osem-dashboard *= require osem-splash - *= require osem-conference-wide-screen *= require font-awesome *= require osem-fonts *= require bootstrap-markdown diff --git a/app/assets/stylesheets/osem-conference-wide-screen.css.scss b/app/assets/stylesheets/osem-conference-wide-screen.css.scss deleted file mode 100644 index 51f43c08..00000000 --- a/app/assets/stylesheets/osem-conference-wide-screen.css.scss +++ /dev/null @@ -1,77 +0,0 @@ -@import "breakpoints.css.scss"; - -html { - position: relative; - min-height: 100%; -} - -body { - /* Margin bottom by 2 times the footer height */ - // margin-bottom: 60px; - /* Margin bottom by navbar height */ - padding-top: 10px; -} - -#main-display { - // Counter the general padding for #content - // margin-bottom: -60px; - section { - padding: 10px; - } - - #main-heading { - position: absolute; - top: 0; - width: 100%; - height: 120px; - background-color: #abcdef; - } - - - #event-display{ - position: absolute; - bottom:480px; - width: 100%; - top: 120px; - background-color: #00FF00; - } - #tweets-display { - position: absolute; - height: 150px; - bottom: 330px; - width: 100%; - background-color: #F63; - } - - #sponsor-display { - position: absolute; - bottom: 0; - width: 100%; - max-height: 330px; - background-color: #FF1493; - .container { - background-color: yellow; - max-height: 310px; - } - - .img-sponsor { - max-height: 50px; - margin: 2% auto; - } - .img-sponsor-1 { - max-height: 90px; - } - .img-sponsor-2 { - max-height: 70px; - } - .img-sponsor-3 { - max-height: 50px; - } - @include breakpoint(xs) { - .img-sponsor, .img-sponsor-1, .img-sponsor-3, .img-sponsor-3{ - max-height: unset; - max-width: 280px; - } - } - } -} diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index f3d87af1..2ad2369a 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -175,10 +175,9 @@ module Admin def conference_wide_screen # To display sponsors in the conference wide information page - @conference = Conference.find_by(short_title: params[:id]) @sponsors = @conference.sponsors @program = @conference.program - @current_events = @conference.program.events.confirmed.select(&:current?) + @current_events = @conference.program.events.current @tweets = twitter_client.search_tweets(15, @conference.contact.social_tag) respond_to do |format| diff --git a/app/models/event.rb b/app/models/event.rb index da7efd0f..652597d0 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -41,6 +41,7 @@ class Event < ActiveRecord::Base scope :canceled, -> { where(state: 'canceled') } scope :withdrawn, -> { where(state: 'withdrawn') } scope :highlighted, -> { where(is_highlight: true) } + scope :current, -> { joins(:event_type).where('start_time <= ? AND state = ?', Time.current, 'confirmed').map { |e| e if e.end_time > Time.current }.compact } state_machine initial: :new do state :new @@ -248,10 +249,10 @@ class Event < ActiveRecord::Base end ## - # Compares event start_time, end_with with current time to predict current events + # Returns end of the event # - def current? - Time.current >= self.start_time && Time.current <= self.end_time + def end_time + self.start_time + self.event_type.length.minutes end private @@ -308,5 +309,4 @@ class Event < ActiveRecord::Base def current? Time.current >= self.start_time && Time.current <= self.end_time end - end diff --git a/app/views/admin/conference/_conference_tweets.html.haml b/app/views/admin/conference/_conference_tweets.html.haml index 83b5168c..58ed4e9e 100644 --- a/app/views/admin/conference/_conference_tweets.html.haml +++ b/app/views/admin/conference/_conference_tweets.html.haml @@ -1,8 +1,14 @@ .container .row .col-md-12.text-center - %h2 Conference Tweets - - @tweets.each do |tweet| - %div#tweet - = tweet.user.name - = tweet.text + %h2 + = "#" + @conference.contact.social_tag + " Tweets" + %div#tweet-container + - @tweets.each do |tweet| + %div#tweet + %blockquote.twitter-tweet + %p{:lang => "en"} + = tweet.text + = link_to "— @" + tweet.user.name, "http://www.twitter.com/#{tweet.user.name}", target: "_blank" + = link_to tweet.url, tweet.url.to_s + diff --git a/app/views/admin/conference/_sponsors.html.haml b/app/views/admin/conference/_sponsors.html.haml index 335eade8..5fb6a8c7 100644 --- a/app/views/admin/conference/_sponsors.html.haml +++ b/app/views/admin/conference/_sponsors.html.haml @@ -2,10 +2,11 @@ .row .col-md-12.text-center %h2 Sponsors - - @conference.sponsorship_levels.each do |sponsorship_level| - -if sponsorship_level.sponsors.any? - - sponsorship_level.sponsors.each_slice(3) do |slice| - .row.row-centered - - slice.each do |sponsor| - .col-md-4.col-sm-4.col-centered.col-top - = image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}" + %div#sponsor-container + - @conference.sponsorship_levels.each do |sponsorship_level| + -if sponsorship_level.sponsors.any? + - sponsorship_level.sponsors.each_slice(3) do |slice| + .row.row-centered#sponsor + - slice.each do |sponsor| + .col-md-4.col-sm-4.col-centered.col-top + = image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}" diff --git a/app/views/admin/conference/conference_wide_screen.html.haml b/app/views/admin/conference/conference_wide_screen.html.haml index 4e2991fe..5f2e7c71 100644 --- a/app/views/admin/conference/conference_wide_screen.html.haml +++ b/app/views/admin/conference/conference_wide_screen.html.haml @@ -6,11 +6,11 @@ - if @conference.description.present? %h3 = @conference.description - - if @program.present? - .row + - if @current_events.present? + .row#current-events = render 'current_events' - if @conference.contact.social_tag.present? && @tweets.present? - .row + .row#conference-tweets = render 'conference_tweets' - if @sponsors.any? = render 'sponsors' diff --git a/app/views/admin/conference/conference_wide_screen.js.haml b/app/views/admin/conference/conference_wide_screen.js.haml index 998342dc..694d5ace 100644 --- a/app/views/admin/conference/conference_wide_screen.js.haml +++ b/app/views/admin/conference/conference_wide_screen.js.haml @@ -1 +1,4 @@ $('#current-events').html("#{escape_javascript(render 'current_events', data: @current_events)}"); +$('#conference-tweets').html("#{escape_javascript(render 'conference_tweets', data: @tweets)}"); +$('#tweet-container').children().hide(); +$('#tweet-container').children().eq(0).show(); diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index ac377a69..eac4c68c 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -165,18 +165,6 @@ describe Admin::ConferencesController do end end - describe 'GET #conference_wide_screen' do - it 'assigns the requested conference to conference' do - get :show, id: conference.short_title - expect(assigns(:conference)).to eq conference - end - - it 'renders the conference_wide_screen page' do - get :conference_wide_screen, id: conference.short_title - expect(response).to render_template :conference_wide_screen - end - end - describe 'GET #index' do context 'with more than 0 conferences' do it 'populates an array with conferences' do @@ -292,18 +280,6 @@ describe Admin::ConferencesController do end end end - - describe 'GET #conference_wide_screen' do - it 'requires organizer privileges' do - get :conference_wide_screen, id: conference.short_title, - conference: attributes_for(:conference, - short_title: 'ExCon') - expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end - end - end end describe 'participant access' do diff --git a/spec/factories/events.rb b/spec/factories/events.rb index c306cdf9..916e840a 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -33,6 +33,19 @@ FactoryGirl.define do event.event_schedules << build(:event_schedule, event: event) end end + + factory :past_event do + after(:build) do |event| + event.start_time = (DateTime.current - 2.days).to_s + event.state = 'confirmed' + end + end + factory :future_event do + after(:build) do |event| + event.start_time = (DateTime.current + 2.days).to_s + event.state = 'confirmed' + end + end end end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 77aa4566..65b73103 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -114,6 +114,14 @@ describe Event do expect(conference.program.events.highlighted).to eq [my_event] end end + context 'current' do + it 'returns only current events' do + current_event = create(:event, start_time: Time.current.to_s, state: 'confirmed', program: conference.program) + create(:past_event, program: conference.program) + create(:future_event, program: conference.program) + expect(conference.program.events.current).to match_array([current_event]) + end + end end describe '#scheduled?' do @@ -327,28 +335,4 @@ describe Event do expect(other_event.week).to eq 48 end end - - describe '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.to_s) - past_event.update_attributes(start_time: (Time.current - 2.days).to_s) - future_event.update_attributes(start_time: (Time.current + 2.days).to_s) - end - - it 'returns false for a completed event' do - expect(past_event.current?).to be_falsey - end - - it 'returns false for a future event' do - expect(future_event.current?).to be_falsey - end - - it 'returns true for a current event' do - expect(event.current?).to be_truthy - end - end - end