Browse Source

Fixed NPE on schedule

development
Godwin 8 years ago
parent
commit
b89fa43b0e
  1. 76
      Gemfile
  2. 18
      app/controllers/application_controller.rb
  3. 6
      app/views/application/500.html.haml
  4. 22
      app/views/application/_contact.html.haml

76
Gemfile

@ -11,9 +11,9 @@ gem 'haml'
gem 'nokogiri', '~> 1.6.8.rc2'
if Dir.exists?('../lingua_franca')
gem 'lingua_franca', :path => '../lingua_franca'
gem 'lingua_franca', path: '../lingua_franca'
else
gem 'lingua_franca', :git => 'git://github.com/lingua-franca/lingua_franca.git'
gem 'lingua_franca', git: 'git://github.com/lingua-franca/lingua_franca.git'
end
gem 'tzinfo-data'
@ -21,15 +21,15 @@ gem 'sass'
gem 'sass-rails'
if Dir.exists?('../bumbleberry')
gem 'bumbleberry', :path => "../bumbleberry"
gem 'bumbleberry', path: "../bumbleberry"
else
gem 'bumbleberry', :git => 'git://github.com/bumbleberry/bumbleberry.git'
gem 'bumbleberry', git: 'git://github.com/bumbleberry/bumbleberry.git'
end
if Dir.exists?('../paypal-express')
gem 'paypal-express', :path => "../paypal-express"
gem 'paypal-express', path: "../paypal-express"
else
gem 'paypal-express', :git => 'git://github.com/bikebike/paypal-express.git'
gem 'paypal-express', git: 'git://github.com/bikebike/paypal-express.git'
end
gem 'uglifier', '>= 1.3.0'
@ -48,55 +48,55 @@ gem 'redcarpet'
gem 'sidekiq'
gem 'letter_opener'
gem 'launchy'
gem 'to_spreadsheet', :git => 'git://github.com/glebm/to_spreadsheet.git'
gem 'to_spreadsheet', git: 'git://github.com/glebm/to_spreadsheet.git'
group :test do
gem 'rspec'
gem 'rspec-rails'
gem 'rspec'
gem 'rspec-rails'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-faster-assets', '~> 1.0'
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-faster-assets', '~> 1.0'
gem 'eventmachine', :github => 'krzcho/eventmachine', :branch => 'master'
gem 'thin', :github => 'krzcho/thin', :branch => 'master'
gem 'eventmachine'#, :github => 'krzcho/eventmachine', :branch => 'master'
gem 'thin'#, :github => 'krzcho/thin', :branch => 'master'
end
group :test do
gem 'gherkin3', '>= 3.1.0'
gem 'cucumber'
gem 'cucumber-core'
gem 'cucumber-rails'
gem 'poltergeist'
gem 'guard-rspec'
gem 'factory_girl_rails'
gem 'coveralls', require: false
gem 'selenium-webdriver'
gem 'simplecov', require: false
gem 'webmock', require: false
gem 'database_cleaner'
gem 'mocha'
gem 'gherkin3', '>= 3.1.0'
gem 'cucumber'
gem 'cucumber-core'
gem 'cucumber-rails'
gem 'poltergeist'
gem 'guard-rspec'
gem 'factory_girl_rails'
gem 'coveralls', require: false
gem 'selenium-webdriver'
gem 'simplecov', require: false
gem 'webmock', require: false
gem 'database_cleaner'
gem 'mocha'
end
group :staging, :production, :preview do
gem 'rails_12factor'
gem 'rails_12factor'
end
group :production, :preview do
gem 'unicorn'
gem 'daemon-spawn'
gem 'daemons'
gem 'unicorn'
gem 'daemon-spawn'
gem 'daemons'
end
platforms 'mswin', 'mingw' do
group :test do
gem 'wdm', '>= 0.1.0'
end
group :test do
gem 'wdm', '>= 0.1.0'
end
end

18
app/controllers/application_controller.rb

@ -586,14 +586,16 @@ class ApplicationController < LinguaFrancaApplicationController
end
@events.each do | event |
day = event.start_time.midnight.to_date
time = event.start_time.hour.to_f + (event.start_time.min / 60.0)
@schedule[day] ||= {}
@schedule[day][:times] ||= {}
@schedule[day][:times][time] ||= {}
@schedule[day][:times][time][:type] = :event
@schedule[day][:times][time][:length] = (event.end_time - event.start_time) / 3600.0
@schedule[day][:times][time][:item] = event
if event.present? && event.start_time.present? && event.end_time.present?
day = event.start_time.midnight.to_date
time = event.start_time.hour.to_f + (event.start_time.min / 60.0)
@schedule[day] ||= {}
@schedule[day][:times] ||= {}
@schedule[day][:times][time] ||= {}
@schedule[day][:times][time][:type] = :event
@schedule[day][:times][time][:length] = (event.end_time - event.start_time) / 3600.0
@schedule[day][:times][time][:item] = event
end
end
@schedule = @schedule.sort.to_h

6
app/views/application/500.html.haml

@ -1,6 +1,6 @@
= render :partial => 'application/header', :locals => {:image_file => 'parts.jpg'}
= row do
= columns(medium: 12) do
%p= _'error.500.description', :p
= render 'contact', cancel_btn: false, contact_reason: :website
= columns(medium: 12) do
%p= _'error.500.description', :p
= render 'contact', cancel_btn: false, contact_reason: :website

22
app/views/application/_contact.html.haml

@ -1,14 +1,14 @@
- contact_reason ||= nil
- locale ||= nil
= form_tag (locale.present? ? contact_send_url : url_for_locale(locale, contact_send_path)), class: 'contact-form' do
= emailfield :email, nil, big: true, required: true unless logged_in?
- if contact_reason.present?
= hidden_field_tag :reason, contact_reason
- else
= contact_reason_select
= textfield :subject, nil, required: true, big: true
= textarea :message, nil, required: true, plain: true
.actions
= button_tag :send, value: :send
- if cancel_btn
%button.close.subdued=_'forms.actions.generic.cancel'
= emailfield :email, nil, big: true, required: true unless logged_in?
- if contact_reason.present?
= hidden_field_tag :reason, contact_reason
- else
= contact_reason_select
= textfield :subject, nil, required: true, big: true
= textarea :message, nil, required: true, plain: true
.actions
= button_tag :send, value: :send
- if cancel_btn
%button.close.subdued=_'forms.actions.generic.cancel'

Loading…
Cancel
Save