created current scope in event_schedule model and conference info link name and path changed

This commit is contained in:
AnithaPal 2016-08-23 10:23:26 -04:00
parent e8d3177ec1
commit e82a3e1727
17 changed files with 53 additions and 65 deletions

View file

@ -75,6 +75,14 @@ $ bundle exec rake logo:reprocess
### openID
In order to use [openID](http://openid.net/) logins for your OSEM installation you need to register your application with the providers ([Google](https://code.google.com/apis/console#:access), [GitHub](https://github.com/settings/applications/new) or [Facebook](https://developers.facebook.com/)) and enter their API keys in `config/secrets.yml` file, changing the existing sample values.
### Twitter
In order to embed conference tweets in the application you need to register your application here [twitter](https://apps.twitter.com/) and get twitter consumer and access keys.
Add your Twitter API keys in `.env` file into these variables:
OSEM_TWITTER_CONSUMER_KEY=""
OSEM_TWITTER_CONSUMER_SECRET=""
OSEM_TWITTER_ACCESS_TOKEN=""
OSEM_TWITTER_ACCESS_TOKEN_SECRET=""
## Recurring Jobs
=======
Open a separate terminal and go into the directory where the rails app is present, and type the following to start the delayed_jobs worker for sending email notifications.

View file

@ -59,18 +59,6 @@
},
"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": {

View file

@ -15,7 +15,7 @@ $(document).ready(function() {
// Makes an ajax call for fresh data
function refreshCurrentEvents(){
$.ajax({
url: "conference_wide_screen.js"
url: "conference_info.js"
});
};

View file

@ -173,16 +173,15 @@ module Admin
end
end
def conference_wide_screen
def conference_info
# To display sponsors in the conference wide information page
@sponsors = @conference.sponsors
@program = @conference.program
@current_events = @conference.program.events.current
@current_event_schedules = @program.selected_schedule.event_schedules.current
@tweets = twitter_client.search_tweets(15, @conference.contact.social_tag)
respond_to do |format|
format.html{render layout: 'conference_wide_screen'}
format.js {render action: 'conference_wide_screen.js.haml'}
format.html{render layout: 'conference_info'}
format.js {render action: 'conference_info.js.haml'}
end
end

View file

@ -41,7 +41,6 @@ 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,13 +247,6 @@ class Event < ActiveRecord::Base
event_schedules.find_by(schedule_id: program.selected_schedule_id).try(:start_time)
end
##
# Returns end of the event
#
def end_time
self.start_time + self.event_type.length.minutes
end
private
##
@ -302,11 +294,4 @@ class Event < ActiveRecord::Base
def conference_id
program.conference_id
end
##
# Compares event start_time, end_with with current time to predict current events
#
def current?
Time.current >= self.start_time && Time.current <= self.end_time
end
end

View file

@ -12,6 +12,7 @@ class EventSchedule < ActiveRecord::Base
scope :confirmed, -> { joins(:event).where('state = ?', 'confirmed') }
scope :canceled, -> { joins(:event).where('state = ?', 'canceled') }
scope :withdrawn, -> { joins(:event).where('state = ?', 'withdrawn') }
scope :current, -> { where('start_time <= ?', Time.current).select{ |es| es.end_time >= Time.current }}
delegate :guid, to: :room, prefix: true

View file

@ -2,12 +2,12 @@
.row
.col-md-12.text-center
%h2 Current Events
- @current_events.each do |event|
- @current_event_schedules.each do |es|
%div
%h3
= event.title
= es.event.title
%h4
presented by
= event.speaker_names
= es.event.speaker_names
in
= event.room.name
= es.event.room.name

View file

@ -6,10 +6,10 @@
- if @conference.description.present?
%h3
= @conference.description
- if @current_events.present?
- if @current_event_schedules.present?
.row#current-events
= render 'current_events'
- if @conference.contact.social_tag.present? && @tweets.present?
- if @conference.contact.social_tag.present? && @tweets.any?
.row#conference-tweets
= render 'conference_tweets'
- if @sponsors.any?

View file

@ -138,7 +138,7 @@
Roles
- if can? :show, @conference
%li{:class=> active_nav_li(conference_wide_screen_admin_conference_path(@conference.short_title))}
= link_to(conference_wide_screen_admin_conference_path(@conference.short_title)) do
%li{:class=> active_nav_li(conference_info_admin_conference_path(@conference.short_title))}
= link_to(conference_info_admin_conference_path(@conference.short_title)) do
%span.fa.fa-expand
Conference Wide Information
Conference Info

View file

@ -27,7 +27,7 @@ Osem::Application.routes.draw do
resources :comments, only: [:index]
resources :conferences do
member do
get :conference_wide_screen
get :conference_info
end
resource :contact, except: [:index, :new, :create, :show, :destroy]
resources :schedules, only: [:index, :create, :show, :update, :destroy]

View file

@ -20,5 +20,20 @@ FactoryGirl.define do
event_schedule.schedule = program.selected_schedule
end
end
factory :current_event_schedule do
after(:build) do |event_schedule|
event_schedule.start_time = DateTime.current
end
end
factory :past_event_schedule do
after(:build) do |event_schedule|
event_schedule.start_time = (DateTime.current - 2.days).to_s
end
end
factory :future_event_schedule do
after(:build) do |event_schedule|
event_schedule.start_time = (DateTime.current + 2.days).to_s
end
end
end
end

View file

@ -33,19 +33,6 @@ 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

View file

@ -1,6 +1,12 @@
require 'spec_helper'
describe EventSchedule do
subject { create(:event_schedule) }
let(:schedule) { create(:schedule) }
let(:program) { create(:program, selected_schedule: schedule) }
let!(:current_event_schedule) { create(:current_event_schedule, schedule: program.selected_schedule) }
let!(:past_event_schedule) { create(:past_event_schedule) }
let!(:future_event_schedule) { create(:future_event_schedule) }
describe 'association' do
it { should belong_to(:schedule) }
@ -18,4 +24,12 @@ describe EventSchedule do
it { is_expected.to validate_presence_of(:room) }
it { is_expected.to validate_presence_of(:start_time) }
end
describe 'scope' do
context 'current' do
it 'returns only current events' do
expect(program.selected_schedule.event_schedules.current).to match_array([current_event_schedule])
end
end
end
end

View file

@ -114,14 +114,6 @@ 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

View file

@ -1,7 +1,6 @@
require 'spec_helper'
describe Schedule do
describe 'association' do
it { should belong_to(:program) }
it { should have_many(:event_schedules).dependent(:destroy) }