Browse Source

Fixed NPE on schedule

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

80
Gemfile

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

18
app/controllers/application_controller.rb

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

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

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

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

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

Loading…
Cancel
Save