diff --git a/.ruby-version b/.ruby-version index 2972947..7213b44 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.1 +ruby-2.6.10 diff --git a/Dockerfile b/Dockerfile index 0eebe61..96f9a26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.3 +FROM ruby:2.6.10 MAINTAINER Pete Holiday RUN mkdir -p /var/app diff --git a/Dockerfile.production b/Dockerfile.production index 521dbb6..772ad7f 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,4 +1,4 @@ -FROM ruby:2.3 +FROM ruby:2.6.10 MAINTAINER Pete Holiday RUN mkdir -p /var/app diff --git a/Gemfile b/Gemfile index 95f102d..1c03a60 100644 --- a/Gemfile +++ b/Gemfile @@ -1,86 +1,74 @@ source 'https://rubygems.org' -gem 'rails', '~> 3.2.22' +gem 'rails', '~> 4.2' gem 'mimemagic', git: 'https://github.com/mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f' # Backend -# gem 'airbrake' -# gem 'newrelic_rpm' gem 'json' -gem 'multi_json' -gem 'mongoid' +gem 'mongoid', '~> 4.0.0' gem 'declarative_authorization' -gem 'mongoid-paperclip', require: 'mongoid_paperclip' -gem 'strong_parameters' +gem 'mongoid-paperclip', '~> 0.0.11', require: 'mongoid_paperclip' gem 'ruby_parser' gem 'smarter_csv' gem 'actionmailer' -gem 'bcrypt-ruby', '~> 3.0.0' +gem 'bcrypt' gem 'dalli' gem 'premailer-rails' gem 'nokogiri' -gem 'braintree' +gem 'braintree', '~> 2.101.0' gem 'twilio-ruby', '~> 5.10.7' gem 'puma' -gem 'bugsnag' -gem 'test-unit', '~> 3.0' +gem 'bugsnag', '~> 5.1.0' gem 'gibbon', '~> 3.0' # Job Processing -gem 'sidekiq' -gem 'sidekiq-cron' -gem 'kiqstand', '~> 1.1.0' -gem 'sinatra', require: false -gem 'slim' -gem 'whenever' +gem 'sidekiq', '~> 4.2.10' +gem 'sidekiq-cron', '~> 0.4.5' +gem 'sinatra', '~> 1.4.4', require: false +gem 'slim', '~> 2.0.2' +gem 'whenever', '~> 0.9.4' # Frontend -gem 'active_link_to' -gem 'bootstrap-sass' -gem 'bootstrap-will_paginate' -gem 'bootstrap_form' -gem 'haml' -gem 'jquery-rails' -gem 'will_paginate' +gem 'active_link_to', '~> 1.0.0' +gem 'bootstrap-sass', '~> 2.3.1.0' +gem 'bootstrap-will_paginate', '~> 1.0.0' +gem 'bootstrap_form', '~> 2.1.1' +gem 'haml', '~> 4.0.1' +gem 'jquery-rails', '~> 2.2.1' +gem 'will_paginate', '~> 3.1.6' gem "font-awesome-rails", '~> 3.2.1.0' -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' -# gem 'coffee-rails', '~> 3.2.1' -# gem 'uglifier', '>= 1.0.3' - gem 'mini_racer' -end group :development, :test do - gem 'faker' - gem 'guard-rspec' - gem 'guard-spork' - gem 'rspec-rails' - gem 'better_errors' - gem 'binding_of_caller' + gem 'sass-rails' + gem 'faker', '~> 1.1.2' + gem 'rspec-rails', '~> 4.1.2' + gem 'better_errors', '~> 1.1.0' + gem 'binding_of_caller', '~> 1.0.0' + gem 'dotenv', require: 'dotenv/load' end group :development do - gem 'annotate' - gem 'haml-rails' - gem 'rb-inotify', require: false - gem 'rb-fsevent', require: false - gem 'rb-fchange', require: false - gem 'terminal-notifier-guard' - gem 'thin' + gem "web-console", "~> 2.0" + gem 'annotate', '~> 2.5.0' + gem 'haml-rails', '~> 0.4' + gem 'rb-inotify', '~> 0.9.0', require: false + gem 'rb-fsevent', '~> 0.9.3', require: false + gem 'rb-fchange', '~> 0.0.6', require: false + gem 'terminal-notifier-guard', '~> 1.5.3' + gem 'thin', '~> 1.8.2' end group :test do - gem 'factory_girl_rails' - gem 'spork' + gem 'factory_girl_rails', '~> 4.2.1' + gem 'spork', '~> 0.9.2' + gem 'test-unit' end group :ops do - gem 'pry' + gem 'pry', '~> 0.9.12' end # To use ActiveModel has_secure_password diff --git a/Gemfile.lock b/Gemfile.lock index cfe114f..f80fe57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,71 +8,83 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.22.5) - actionpack (= 3.2.22.5) - mail (~> 2.5.4) - actionpack (3.2.22.5) - activemodel (= 3.2.22.5) - activesupport (= 3.2.22.5) - builder (~> 3.0.0) + actionmailer (4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.11.3) + actionview (= 4.2.11.3) + activesupport (= 4.2.11.3) + rack (~> 1.6) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.11.3) + activesupport (= 4.2.11.3) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - active_link_to (1.0.0) - activemodel (3.2.22.5) - activesupport (= 3.2.22.5) - builder (~> 3.0.0) - activerecord (3.2.22.5) - activemodel (= 3.2.22.5) - activesupport (= 3.2.22.5) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.22.5) - activemodel (= 3.2.22.5) - activesupport (= 3.2.22.5) - activesupport (3.2.22.5) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - addressable (2.3.5) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + active_link_to (1.0.5) + actionpack + addressable + activejob (4.2.11.3) + activesupport (= 4.2.11.3) + globalid (>= 0.3.0) + activemodel (4.2.11.3) + activesupport (= 4.2.11.3) + builder (~> 3.1) + activerecord (4.2.11.3) + activemodel (= 4.2.11.3) + activesupport (= 4.2.11.3) + arel (~> 6.0) + activesupport (4.2.11.3) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) annotate (2.5.0) rake - arel (3.0.3) - bcrypt-ruby (3.0.1) + arel (6.0.4) + bcrypt (3.1.20) better_errors (1.1.0) coderay (>= 1.0.0) erubis (>= 2.6.6) - binding_of_caller (1.0.0) - debug_inspector (>= 0.0.1) - bootstrap-sass (2.3.1.0) + binding_of_caller (1.0.1) + debug_inspector (>= 1.2.0) + bootstrap-sass (2.3.1.3) sass (~> 3.2) bootstrap-will_paginate (1.0.0) will_paginate - bootstrap_form (0.3.2) + bootstrap_form (2.1.1) braintree (2.101.0) builder (>= 2.0.0) + bson (3.2.7) bugsnag (5.1.0) - builder (3.0.4) - childprocess (0.3.9) - ffi (~> 1.0, >= 1.0.11) + builder (3.2.4) chronic (0.10.2) climate_control (0.2.0) - cocaine (0.5.8) - climate_control (>= 0.0.3, < 1.0) - coderay (1.0.9) - concurrent-ruby (1.1.9) - connection_pool (2.2.1) - css_parser (1.3.5) + coderay (1.1.3) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) + crass (1.0.6) + css_parser (1.12.0) addressable - daemons (1.1.9) - dalli (2.7.0) - debug_inspector (1.1.0) + daemons (1.4.1) + dalli (3.2.8) + date (3.3.4) + debug_inspector (1.2.0) declarative_authorization (0.5.7) - diff-lcs (1.3) + diff-lcs (1.5.1) + dotenv (2.8.1) erubis (2.7.0) - eventmachine (1.0.4) + et-orbi (1.2.11) + tzinfo + eventmachine (1.2.7) factory_girl (4.2.0) activesupport (>= 3.0.0) factory_girl_rails (4.2.1) @@ -82,150 +94,183 @@ GEM i18n (~> 0.5) faraday (0.17.6) multipart-post (>= 1.2, < 3) - ffi (1.6.0) + ffi (1.16.3) font-awesome-rails (3.2.1.3) railties (>= 3.2, < 5.0) - formatador (0.2.4) - gibbon (3.1.1) - faraday (>= 0.9.1) + fugit (1.10.1) + et-orbi (~> 1, >= 1.2.7) + raabro (~> 1.4) + gibbon (3.4.0) + faraday (>= 0.16.0) multi_json (>= 1.11.0) - guard (1.7.0) - formatador (>= 0.2.4) - listen (>= 0.6.0) - lumberjack (>= 1.0.2) - pry (>= 0.9.10) - thor (>= 0.14.6) - guard-rspec (2.5.1) - guard (>= 1.1) - rspec (~> 2.11) - guard-spork (1.5.0) - childprocess (>= 0.2.3) - guard (>= 1.1) - spork (>= 0.8.4) - haml (4.0.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + haml (4.0.7) tilt - haml-rails (0.4) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (>= 3.1, < 4.1) - railties (>= 3.1, < 4.1) - hike (1.2.3) - htmlentities (4.3.1) + haml-rails (0.9.0) + actionpack (>= 4.0.1) + activesupport (>= 4.0.1) + haml (>= 4.0.6, < 5.0) + html2haml (>= 1.0.1) + railties (>= 4.0.1) + html2haml (2.3.0) + erubis (~> 2.7.0) + haml (>= 4.0) + nokogiri (>= 1.6.0) + ruby_parser (~> 3.5) + htmlentities (4.3.4) i18n (0.9.5) concurrent-ruby (~> 1.0) - journey (1.0.4) - jquery-rails (2.2.1) + jquery-rails (2.2.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.8.6) - jwt (2.3.0) - kiqstand (1.1.0) - mongoid (~> 3.1) - moped (~> 1.4) - libv8-node (15.14.0.1) - listen (0.7.3) - lumberjack (1.0.3) - mail (2.5.5) - mime-types (~> 1.16) - treetop (~> 1.4.8) - method_source (0.8.1) - mime-types (1.25.1) - mini_portile2 (2.4.0) - mini_racer (0.4.0) - libv8-node (~> 15.14.0.0) - mongoid (3.1.7) - activemodel (~> 3.2) - moped (~> 1.4) - origin (~> 1.0) - tzinfo (~> 0.3.29) + json (2.7.1) + jwt (2.5.0) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + method_source (0.9.2) + mime-types (3.5.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2024.0305) + mini_mime (1.1.5) + mini_portile2 (2.8.5) + minitest (5.22.3) + mongoid (4.0.2) + activemodel (~> 4.0) + moped (~> 2.0.0) + origin (~> 2.1) + tzinfo (>= 0.3.37) mongoid-paperclip (0.0.11) mongoid paperclip (>= 2.3.6, != 4.3.0) - moped (1.5.3) + moped (2.0.7) + bson (~> 3.0) + connection_pool (~> 2.0) + optionable (~> 0.2.0) multi_json (1.15.0) - multipart-post (2.2.0) - nokogiri (1.9.1) - mini_portile2 (~> 2.4.0) - origin (1.1.0) - paperclip (4.2.4) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - cocaine (~> 0.5.5) + multipart-post (2.4.0) + net-imap (0.3.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0.1) + net-protocol + nio4r (2.7.1) + nokogiri (1.13.10) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + optionable (0.2.0) + origin (2.3.1) + paperclip (6.1.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) mime-types - polyglot (0.3.5) + mimemagic (~> 0.3.0) + terrapin (~> 0.6.0) power_assert (2.0.3) - premailer (1.8.0) - css_parser (>= 1.3.5) + premailer (1.15.0) + addressable + css_parser (>= 1.6.0) htmlentities (>= 4.0.0) - premailer-rails (1.6.1) - actionmailer (>= 3, < 5) + premailer-rails (1.12.0) + actionmailer (>= 3) + net-smtp premailer (~> 1.7, >= 1.7.9) - pry (0.9.12) - coderay (~> 1.0.5) + pry (0.9.12.6) + coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) - puma (3.6.2) - rack (1.4.7) - rack-cache (1.7.1) - rack (>= 0.4) - rack-protection (1.5.3) - rack - rack-ssl (1.3.4) + public_suffix (5.0.4) + puma (6.4.2) + nio4r (~> 2.0) + raabro (1.4.0) + racc (1.7.3) + rack (1.6.13) + rack-protection (1.5.5) rack rack-test (0.6.3) rack (>= 1.0) - rails (3.2.22.5) - actionmailer (= 3.2.22.5) - actionpack (= 3.2.22.5) - activerecord (= 3.2.22.5) - activeresource (= 3.2.22.5) - activesupport (= 3.2.22.5) - bundler (~> 1.0) - railties (= 3.2.22.5) - railties (3.2.22.5) - actionpack (= 3.2.22.5) - activesupport (= 3.2.22.5) - rack-ssl (~> 1.3.2) + rails (4.2.11.3) + actionmailer (= 4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) + activemodel (= 4.2.11.3) + activerecord (= 4.2.11.3) + activesupport (= 4.2.11.3) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.11.3) + sprockets-rails + rails-deprecated_sanitizer (1.0.4) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) + nokogiri (~> 1.6) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (4.2.11.3) + actionpack (= 4.2.11.3) + activesupport (= 4.2.11.3) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.5.0) + thor (>= 0.18.1, < 2.0) + rake (13.1.0) rb-fchange (0.0.6) ffi - rb-fsevent (0.9.3) - rb-inotify (0.9.0) - ffi (>= 0.5.0) - rdoc (3.12.2) - json (~> 1.4) - redis (3.3.3) - redis-namespace (1.5.3) - redis (~> 3.0, >= 3.0.4) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) - rspec-rails (2.13.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - ruby_parser (3.2.2) - sexp_processor (~> 4.1) - rufus-scheduler (3.3.4) - tzinfo - sass (3.2.7) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sexp_processor (4.4.0) - sidekiq (4.2.9) + rb-fsevent (0.9.8) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + redis (3.3.5) + redis-namespace (1.8.2) + redis (>= 3.0.4) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (4.1.2) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.13.1) + ruby_parser (3.21.0) + racc (~> 1.5) + sexp_processor (~> 4.16) + rufus-scheduler (3.9.1) + fugit (~> 1.1, >= 1.1.6) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + sexp_processor (4.17.1) + sidekiq (4.2.10) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) @@ -234,104 +279,105 @@ GEM redis-namespace (>= 1.5.2) rufus-scheduler (>= 2.0.24) sidekiq (>= 4.2.1) - sinatra (1.4.4) - rack (~> 1.4) + sinatra (1.4.8) + rack (~> 1.5) rack-protection (~> 1.4) - tilt (~> 1.3, >= 1.3.4) - slim (2.0.2) + tilt (>= 1.3, < 3) + slim (2.0.3) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) - slop (3.4.4) - smarter_csv (1.0.17) + slop (3.6.0) + smarter_csv (1.10.3) spork (0.9.2) - sprockets (2.2.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - strong_parameters (0.2.1) - actionpack (~> 3.0) - activemodel (~> 3.0) - railties (~> 3.0) - temple (0.6.7) + sprockets (4.1.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + temple (0.6.10) terminal-notifier-guard (1.5.3) - test-unit (3.6.1) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) + test-unit (3.6.2) power_assert - thin (1.5.1) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - thor (0.20.0) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) + thin (1.8.2) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0, >= 1.0.4) + rack (>= 1, < 3) + thor (1.3.1) + thread_safe (0.3.6) + tilt (2.0.11) + timeout (0.4.1) twilio-ruby (5.10.7) faraday (~> 0.9) jwt (>= 1.5, <= 2.5) nokogiri (>= 1.6, < 2.0) - tzinfo (0.3.60) - whenever (0.9.4) + tzinfo (1.2.11) + thread_safe (~> 0.1) + web-console (2.3.0) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) + whenever (0.9.7) chronic (>= 0.6.3) - will_paginate (3.1.6) + will_paginate (3.1.8) PLATFORMS ruby DEPENDENCIES actionmailer - active_link_to - annotate - bcrypt-ruby (~> 3.0.0) - better_errors - binding_of_caller - bootstrap-sass - bootstrap-will_paginate - bootstrap_form - braintree - bugsnag + active_link_to (~> 1.0.0) + annotate (~> 2.5.0) + bcrypt + better_errors (~> 1.1.0) + binding_of_caller (~> 1.0.0) + bootstrap-sass (~> 2.3.1.0) + bootstrap-will_paginate (~> 1.0.0) + bootstrap_form (~> 2.1.1) + braintree (~> 2.101.0) + bugsnag (~> 5.1.0) dalli declarative_authorization - factory_girl_rails - faker + dotenv + factory_girl_rails (~> 4.2.1) + faker (~> 1.1.2) font-awesome-rails (~> 3.2.1.0) gibbon (~> 3.0) - guard-rspec - guard-spork - haml - haml-rails - jquery-rails + haml (~> 4.0.1) + haml-rails (~> 0.4) + jquery-rails (~> 2.2.1) json - kiqstand (~> 1.1.0) mimemagic! - mini_racer - mongoid - mongoid-paperclip - multi_json + mongoid (~> 4.0.0) + mongoid-paperclip (~> 0.0.11) nokogiri premailer-rails - pry + pry (~> 0.9.12) puma - rails (~> 3.2.22) - rb-fchange - rb-fsevent - rb-inotify - rspec-rails + rails (~> 4.2) + rb-fchange (~> 0.0.6) + rb-fsevent (~> 0.9.3) + rb-inotify (~> 0.9.0) + rspec-rails (~> 4.1.2) ruby_parser - sass-rails (~> 3.2.3) - sidekiq - sidekiq-cron - sinatra - slim + sass-rails + sidekiq (~> 4.2.10) + sidekiq-cron (~> 0.4.5) + sinatra (~> 1.4.4) + slim (~> 2.0.2) smarter_csv - spork - strong_parameters - terminal-notifier-guard - test-unit (~> 3.0) - thin + spork (~> 0.9.2) + terminal-notifier-guard (~> 1.5.3) + test-unit + thin (~> 1.8.2) twilio-ruby (~> 5.10.7) - whenever - will_paginate + web-console (~> 2.0) + whenever (~> 0.9.4) + will_paginate (~> 3.1.6) BUNDLED WITH 1.17.3 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 88e5947..f53cce8 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -34,7 +34,7 @@ def update_score if params['forfeit'] new_score_report[:forfeit] = true - @game.winner = Moped::BSON::ObjectId.from_string(params['forfeit']) + @game.winner = BSON::ObjectId.from_string(params['forfeit']) end if params['score'] @@ -44,7 +44,7 @@ def update_score new_score_report[team_id] = this_score if this_score > top_score top_score = this_score - @game.winner = Moped::BSON::ObjectId.from_string(team_id) + @game.winner = BSON::ObjectId.from_string(team_id) elsif this_score == top_score @game.winner = nil end diff --git a/app/controllers/leagues_controller.rb b/app/controllers/leagues_controller.rb index c08dda3..d9af964 100644 --- a/app/controllers/leagues_controller.rb +++ b/app/controllers/leagues_controller.rb @@ -105,16 +105,19 @@ def cancel_registration def add_player_to_team respond_to do |format| format.json do - team = Team.find(params["team_id"]) + team = nil + if params["team_id"] != 'NONE' + team = Team.find(params["team_id"]) - if team.nil? - render json: {msg: "Team not found."}, status: 404 - return - end - - if team.league != @league - render json: {msg: "Team does not belong to the correct league."}, status: 400 - return + if team.nil? + render json: {msg: "Team not found."}, status: 404 + return + end + + if team.league != @league + render json: {msg: "Team does not belong to the correct league."}, status: 400 + return + end end params["registration_id_list"].each do |reg_id| @@ -144,12 +147,20 @@ def add_player_to_team reg = Registration.find(reg_id) u = reg.user - @league.add_player_to_team(u, team, false) + if team.nil? + @league.remove_player_from_teams(u) + else + @league.add_player_to_team(u, team, false) + end user_list << u.name end @league.touch + if team.nil? + render json: {msg: "#{user_list.join(" & ")} removed from team."} + return + end render json: {msg: "#{user_list.join(" & ")} added to #{team.name}."} end end @@ -157,7 +168,7 @@ def add_player_to_team def update_invites new_invites_list = params[:invited_player_ids].reject { |id| id.blank? } - new_invites_list = new_invites_list.map {|id| Moped::BSON::ObjectId.from_string(id)} + new_invites_list = new_invites_list.map {|id| BSON::ObjectId.from_string(id)} players_to_remove = @league.invited_player_ids - new_invites_list players_to_add = new_invites_list - @league.invited_player_ids @@ -305,9 +316,9 @@ def reg_list core_status = 'active' core_status = 'incomplete' if non_active_statuses > 0 - core_gender = 'Mixed' - core_gender = 'Man-matching' if wm_players == 0 - core_gender = 'Woman-matching' if mm_players == 0 + core_gender = 'mixed' + core_gender = 'man-matching' if wm_players == 0 + core_gender = 'woman-matching' if mm_players == 0 team_name = "unassigned" if team_counts.count == 1 @@ -368,10 +379,10 @@ def reg_list end end - pairs.keys.each do |pair_type| - pairs[pair_type].each do |pair| - pair_gender = pair[0][:matchup] - pair_gender = "Mixed" if pair_type == :mw + pairs.keys.each do |pair_type| + pairs[pair_type].each do |pair| + pair_gender = pair[0][:matchup] + pair_gender = "mixed" if pair_type == :mw pair_name = "#{pair[0][:name].split(' ')[0]} & #{pair[1][:name].split(' ')[0]}" @@ -460,7 +471,7 @@ def reg_data(reg) team_name = "unassigned" end team_name = team.name unless team.nil? - team_id = team.id unless team.nil? + team_id = team.id.to_s unless team.nil? grank = {}; if @league.require_grank? && reg.g_rank_result @@ -468,6 +479,12 @@ def reg_data(reg) grank[:answers] = GRank.convert_answers_to_text(reg.g_rank_result.answers) # grank[:history] = reg.user.g_rank_results.map(&:score).slice(0,12).reverse end + + reg_url = nil + if reg.new_record? == false + reg_url = registration_path(reg) + end + { id: reg._id.to_s, @@ -475,7 +492,7 @@ def reg_data(reg) name_without_pronouns: u.name, email: u.email_address, profile_url: user_path(u), - registration_url: registration_path(reg), + registration_url: reg_url, status: reg.status, rank: reg.rank.to_s.gsub(/\.0$/,''), grank: grank, @@ -957,7 +974,8 @@ def league_params :female_registration_open, :female_registration_close, :male_registration_open, :male_registration_close, :description, {commissioner_ids: []}, :male_limit, :female_limit, :max_grank_age, :allow_pairs, :covid_vax_required, :track_spirit_scores, :display_spirit_scores, :self_rank_type, :eos_tourney, :mst_tourney, :eos_champion_id, :mst_champion_id, - {core_options: [:type, :male_limit, :female_limit, :rank_limit, :male_rank_constant, :female_rank_constant]} + {core_options: [:type, :male_limit, :female_limit, :rank_limit, :male_rank_constant, :female_rank_constant]}, + :solicit_donations, :donation_earmark, :donation_pitch ] if permitted_to? :assign_comps, self diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 807071b..f28520f 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -10,17 +10,27 @@ def create return end - price = registration.price + price = registration.price + donation_amount = 0 + + donation = Donation.new(amount: params[:donation_amount]) + + if registration.league.solicit_donations? && donation.valid? + donation_amount = donation.amount + donation.user = registration.user + donation.registration = registration + end # COPIED TO league.rb result = Braintree::Transaction.sale( - amount: price, + amount: price + donation_amount, payment_method_nonce: params['payment_method_nonce'], channel: 'leagues.afdc.com', options: { submit_for_settlement: true }, custom_fields: { + donation_amount: donation_amount, registration_id: registration._id.to_s, league_id: registration.league._id.to_s, user_id: registration.user._id.to_s @@ -30,7 +40,7 @@ def create ) if result.success? - PaymentTransaction.create({ + pt = PaymentTransaction.create({ transaction_id: result.transaction.id, payment_method: result.transaction.payment_instrument_type, amount: result.transaction.amount, @@ -39,6 +49,13 @@ def create user: registration.user, league: registration.league }) + + if donation_amount > 0 + donation.payment_transaction = pt + donation.save + log_audit('Donate', league: registration.league, registration: registration) + end + registration.paid = true registration.activate! diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 9de4aab..f9ca1c6 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,5 +1,5 @@ class RegistrationsController < ApplicationController - before_filter :load_registration_from_params, only: [:cancel, :edit, :update, :checkout, :approved, :canceled, :show, :pay, :waitlist_authorize] + before_filter :load_registration_from_params, only: [:cancel, :edit, :update, :checkout, :approved, :canceled, :show, :pay, :donate, :waitlist_authorize] filter_access_to [:edit, :update, :show, :checkout, :cancel, :pay], attribute_check: true def create @@ -112,6 +112,11 @@ def update return end + if @registration.league.comped?(@registration.user) == false && @registration.league.solicit_donations? + redirect_to donate_registration_path(@registration) + return + end + # If we get here, the user has successfully registered and now just needs to pay redirect_to pay_registration_path(@registration) end @@ -175,8 +180,10 @@ def populate_registration @registration.notes = reg_params[:notes] @registration.shirt_size = reg_params[:shirt_size] - if reg_params[:pair_id] - @registration.pair_id = reg_params[:pair_id].first + if reg_params[:pair_requested_user_id] + pair_user_id = reg_params[:pair_requested_user_id].reject {|x| x.blank?}.first + pc = PairingCoordinator.new(@registration.league) + pc.request_pair(@registration.user, pair_user_id) end if permitted_to? :manage, @registration.league @@ -187,6 +194,7 @@ def populate_registration def load_registration_from_params begin @registration = Registration.find(params[:id]) + @league = @registration.league rescue redirect_to registrations_user_path(current_user), flash: {error: "Could not load registration for ID '#{params[:id]}'."} end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 56c146d..1d99f4d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -14,9 +14,12 @@ def search format.json do results = { :suggestions => [], :data => [], :query => params[:query] } user_search(params[:query]).each do |user| + if params[:exclude] && params[:exclude].include?(user._id.to_s) + next + end results[:suggestions] << "#{user.firstname} #{user.lastname} [#{user.email_address}]" results[:data] << { - '_id' => user._id, + '_id' => user._id.to_s, 'firstname' => user.firstname, 'lastname' => user.lastname, 'email_address' => user.email_address, diff --git a/app/models/audit_log.rb b/app/models/audit_log.rb index 596717d..09af2d0 100644 --- a/app/models/audit_log.rb +++ b/app/models/audit_log.rb @@ -11,7 +11,7 @@ class AuditLog field :action, type: String field :target_class, type: String - field :target_id, type: Moped::BSON::ObjectId + field :target_id, type: BSON::ObjectId field :details, type: Hash, default: {} diff --git a/app/models/donation.rb b/app/models/donation.rb new file mode 100644 index 0000000..9ee2ee6 --- /dev/null +++ b/app/models/donation.rb @@ -0,0 +1,14 @@ +class Donation + include Mongoid::Document + include Mongoid::Timestamps + + belongs_to :user + belongs_to :registration + + belongs_to :payment_transaction + + field :amount, type: Float + field :earmark, type: String + + validates :amount, :numericality => { integer_only: false, greater_than: 0 } +end \ No newline at end of file diff --git a/app/models/game.rb b/app/models/game.rb index b272343..9ffb73a 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -3,7 +3,7 @@ class Game field :game_time, type: DateTime field :field field :round_number - field :winner, type: Moped::BSON::ObjectId + field :winner, type: BSON::ObjectId field :scores, type: Hash, default: {} field :old_scores, type: Array, default: [] belongs_to :league, index: true diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 870309a..82a575c 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -5,7 +5,7 @@ class Invitation field :type field :handler_class - field :handler_id, type: Moped::BSON::ObjectId + field :handler_id, type: BSON::ObjectId field :data, type: Hash, default: {} field :accept_key, default: ->{SecureRandom.hex(10)} field :status, default: 'new' @@ -15,7 +15,7 @@ class Invitation after_create :send_invite - scope :outstanding, where(:status.nin => %w(accepted declined canceled)) + scope :outstanding, -> {where(:status.nin => %w(accepted declined canceled))} validates :type, :inclusion => { in: %w(pair), message: "Unknown invitation type: %{value}", allow_blank: false } validates :status, :inclusion => { in: %w(new sent accepted declined canceled), message: "Unknown invitation status: %{value}", allow_blank: false } @@ -53,7 +53,7 @@ def decline self[:status] = 'declined' save! - InvitationMailer.delay.pair_request_result(self._id.to_s) + #InvitationMailer.delay.pair_request_result(self._id.to_s) end def cancel diff --git a/app/models/league.rb b/app/models/league.rb index 44990b8..0e074b6 100644 --- a/app/models/league.rb +++ b/app/models/league.rb @@ -35,6 +35,10 @@ class League field :invited_player_ids, type: Array, default: [] field :covid_vax_required, type: Boolean, default: false embeds_one :core_options, class_name: 'LeagueCoreOptions' + field :solicit_donations, type: Boolean, default: false + + field :donation_earmark, type: String, default: nil + field :donation_pitch, type: String, default: nil after_initialize :build_options_if_nil after_find :migrate_self_rank_opts @@ -145,6 +149,14 @@ def update_standings! end end + def remove_player_from_teams(user) + # remove user from all teams in the league + Team.collection.find(_id: {'$in' => self.team_ids}).update({"$pull" => {players: user._id}}, {multi: true}) + + # remove all league teams from player + User.collection.find(_id: user._id).update({"$pullAll" => {teams: self.team_ids}}) + end + def add_player_to_team(user,team,send_mail=true) raise ArgumentError.new "Must supply a user account to add" unless user.instance_of?(User) raise ArgumentError.new "Must supply a team to be added to" unless team.instance_of?(Team) @@ -152,11 +164,7 @@ def add_player_to_team(user,team,send_mail=true) return true if self.team_for(user) == team - # remove user from all teams in the league - Team.collection.find(_id: {'$in' => self.team_ids}).update({"$pull" => {players: user._id}}, {multi: true}) - - # remove all league teams from player - User.collection.find(_id: user._id).update({"$pullAll" => {teams: self.team_ids}}) + remove_player_from_teams(user) # add player to team Team.collection.find({_id: team._id}).update({"$addToSet" => {players: user._id}}, {multi: false}) @@ -184,8 +192,10 @@ def handle_accepted_invite(invitation) sender_reg.pair = invitation.recipient recipient_reg.pair = invitation.sender - sender_reg.save! - recipient_reg.save! + + # We ignore validation errors because pairs can be confirmed before registation is complete which can lead to some odd errors + sender_reg.save(validate: false) + recipient_reg.save(validate: false) end end @@ -351,6 +361,10 @@ def self.expire_stale_registrations end end + def invitations + Invitation.where(handler_class: "League", handler_id: _id) + end + private def build_options_if_nil @@ -358,6 +372,7 @@ def build_options_if_nil end def migrate_self_rank_opts + return if self.attributes.count <= 30 return unless self_rank_type.nil? self["self_rank_type"] = "simple" if allow_self_rank == true self["self_rank_type"] = "none" if allow_self_rank == false diff --git a/app/models/notification_method.rb b/app/models/notification_method.rb index 0b0eec0..da8622d 100644 --- a/app/models/notification_method.rb +++ b/app/models/notification_method.rb @@ -47,7 +47,7 @@ def downcase_target end def initialize_confirmation - if target == @user.email_address + if target == user.email_address self.confirmed = true self.enabled = true return diff --git a/app/models/payment_transaction.rb b/app/models/payment_transaction.rb index dfe479a..e9a10cd 100644 --- a/app/models/payment_transaction.rb +++ b/app/models/payment_transaction.rb @@ -11,4 +11,5 @@ class PaymentTransaction belongs_to :user belongs_to :league belongs_to :registration + has_one :donation end \ No newline at end of file diff --git a/app/models/registration.rb b/app/models/registration.rb index 3a38cd3..9652611 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -4,6 +4,8 @@ class Registration field :paid, type: Boolean field :status field :player_strength + field :pre_authorization + field :waitlist_timestamp, type: DateTime field :signup_timestamp, type: DateTime field :payment_timestamps, type: Hash, default: {} field :pair, type: Hash @@ -29,7 +31,7 @@ class Registration field :payment_id - field :pair_id, type: Moped::BSON::ObjectId + field :pair_id, type: BSON::ObjectId validates :commish_rank, :numericality => { integer_only: false, greater_than: 0, less_than: 10, allow_blank: true } validate :has_valid_attendance_value, :has_valid_self_rank, :has_valid_primary_role, :has_signed_waiver @@ -39,22 +41,23 @@ class Registration belongs_to :g_rank_result belongs_to :pair, class_name: "User" has_many :payment_transactions + has_one :donation before_save :ensure_price after_save :bust_league_cache after_initialize :load_user_info, if: :new_record? - scope :active, where(status: 'active') - scope :registering, where(status: 'registering', :expires_at.gt => Time.now) - scope :pending, where(status: 'pending') - scope :canceled, where(status: 'canceled') - scope :waitlisted, where(status: 'waitlisted') - scope :registering_waitlisted, where(status: 'registering_waitlisted') - scope :queued, where(status: 'queued', :expires_at.gt => Time.now) - scope :expired, any_of( {status: 'expired'}, {:status.in => ['registering','registering_waitlisted'], :expires_at.lte => Time.now} ) + scope :active, -> { where(status: 'active') } + scope :registering, -> { where(status: 'registering', :expires_at.gt => Time.now) } + scope :pending, -> { where(status: 'pending') } + scope :canceled, -> { where(status: 'canceled') } + scope :waitlisted, -> { where(status: 'waitlisted') } + scope :registering_waitlisted, -> { where(status: 'registering_waitlisted') } + scope :queued, -> { where(status: 'queued', :expires_at.gt => Time.now) } + scope :expired, -> { any_of( {status: 'expired'}, {:status.in => ['registering','registering_waitlisted'], :expires_at.lte => Time.now} ) } - scope :male, where(gender: 'male') - scope :female, where(gender: 'female') + scope :male, -> { where(gender: 'male') } + scope :female, -> { where(gender: 'female') } def gen_availability availability['general'] if availability @@ -346,6 +349,14 @@ def has_signed_waiver end end + def sent_invitations + league.invitations.where(sender: user) + end + + def received_invitations + league.invitations.where(recipient: user) + end + private def load_user_info diff --git a/app/models/user.rb b/app/models/user.rb index 7984573..3927eb1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -38,6 +38,7 @@ class User has_many :g_rank_results, order: :_id.desc has_many :registrations + has_many :donations has_many :payment_transactions has_many :notification_methods has_and_belongs_to_many :teams, foreign_key: :teams @@ -200,7 +201,7 @@ def self.find_by_email_address(email_address) end def create_initial_notification_method - notification_methods.create(label: "Account email notifier", method: "email", target: email_address) + NotificationMethod.create(user: self, method: "email", target: email_address, label: "Account email notifier") end def email_md5 diff --git a/app/views/_user_multiselect.html.haml b/app/views/_user_multiselect.html.haml index 0fb094c..9d04e3a 100644 --- a/app/views/_user_multiselect.html.haml +++ b/app/views/_user_multiselect.html.haml @@ -16,8 +16,14 @@ %input.span3.new-user{type: 'text'} %i.icon-plus +- user_search_params = {} +- if local_assigns[:exclude].nil? == false + - user_search_params["exclude"] = exclude + - content_for :page_scripts do + :javascript + var user_search_params = #{user_search_params.to_json}; = javascript_include_tag '/javascripts/jquery.autocomplete.js' = javascript_include_tag '/javascripts/userSelector.js' diff --git a/app/views/dashboard/_tutorials.html.haml b/app/views/dashboard/_tutorials.html.haml index 2c42b20..12af2af 100644 --- a/app/views/dashboard/_tutorials.html.haml +++ b/app/views/dashboard/_tutorials.html.haml @@ -3,9 +3,11 @@ %p If you're new around here, things might be a bit confusing the first time you register. Rest assured that any problem you are facing, someone has likely experienced before. + %p + Email help@afdc.com if you need assistance. %ul - # %li= link_to 'Tutorial: Signing up for leagues.afdc.com', 'http://toomuchpete.clarify-it.com/d/fvm4pl' - # %li= link_to 'Tutorial: Reset or change your password', 'http://toomuchpete.clarify-it.com/d/dh9xta' - # %li= link_to 'Tutorial: Updating your gRank', 'http://toomuchpete.clarify-it.com/d/ddna6c' - # %li= link_to 'Tutorial: Registering for a league', 'http://toomuchpete.clarify-it.com/d/9lhk4h' - %li= link_to 'Tutorial: Pairing with another player', 'https://docs.google.com/document/d/1SMOyrNxigKO__k5eSKrKo9DJ0W3YBEVHHbwnZAuSTrE/edit?usp=sharing' + - # %li= link_to 'Tutorial: Pairing with another player', 'https://docs.google.com/document/d/1SMOyrNxigKO__k5eSKrKo9DJ0W3YBEVHHbwnZAuSTrE/edit?usp=sharing' diff --git a/app/views/dashboard/homepage.html.haml b/app/views/dashboard/homepage.html.haml index 65598c3..2b4f01c 100644 --- a/app/views/dashboard/homepage.html.haml +++ b/app/views/dashboard/homepage.html.haml @@ -6,7 +6,6 @@ = render 'games' .col-md-4 = render 'leagues' - = render 'tutorials' %hr = render 'sponsors' - else diff --git a/app/views/invitation_mailer/pair_request.html.haml b/app/views/invitation_mailer/pair_request.html.haml index d754052..e3ba704 100644 --- a/app/views/invitation_mailer/pair_request.html.haml +++ b/app/views/invitation_mailer/pair_request.html.haml @@ -4,11 +4,18 @@ You have received a request to pair with #{link_to(@invite.sender.name, user_url(@invite.sender))} for #{link_to(@league.name, league_url(@league))}. -%p In order for this request to be honored by the league, you must confirm that you're okay with it. - -%p If you'd rather not pair with this person, you can ignore or decline the invite. +%p + In order for this request to be honored by the league, you must also choose to pair with them. + If you'd rather not pair with this person, you can ignore or decline the invite. - content_for :callout_box do - Click - =link_to "here", invitations_url - to manage your existing invitations + - if recipient_reg = @league.registration_for(@invite.recipient) + Click + =link_to "here", edit_registration_url(recipient_reg) + to edit your registration for + =@league.name + - else + Click + =link_to "here", register_league_url(@league) + to register for + =@league.name diff --git a/app/views/invitation_mailer/pair_request_result.html.haml b/app/views/invitation_mailer/pair_request_result.html.haml index b9b530c..fbbf005 100644 --- a/app/views/invitation_mailer/pair_request_result.html.haml +++ b/app/views/invitation_mailer/pair_request_result.html.haml @@ -1,10 +1,10 @@ -%p #{@invite.sender.name}: +%p #{@invite.sender.name} & #{@invite.recipient.name}: %p - Your request to pair with #{link_to(@invite.recipient.name, user_url(@invite.recipient))} - for #{link_to(@league.name, league_url(@league))} has been #{@invite.status}. + Nice job! You're paired up for #{link_to(@league.name, league_url(@league))}! - content_for :callout_box do - Click - =link_to "here", invitations_url - to manage your existing invitations + %b REMEMBER: + %p + Pairing only counts if both players are in the league. Pairing with someone + on the waitlist does not guarantee that person a spot in the league. \ No newline at end of file diff --git a/app/views/leagues/_form.html.haml b/app/views/leagues/_form.html.haml index b7e6fff..ca91e82 100644 --- a/app/views/leagues/_form.html.haml +++ b/app/views/leagues/_form.html.haml @@ -136,14 +136,7 @@ = f.check_box :allow_pairs Allow Pairs - .control-group - %label.control-label Vaccination - .controls - %label.checkbox - = f.check_box :covid_vax_required - COVID Vaccine Required - - .control-group + .control-group.hide %label.control-label Spirit .controls %label.checkbox @@ -153,6 +146,28 @@ = f.check_box :display_spirit_scores Display Spirit Scores + %h4 Donations at Registration + %p.muted + This determines whether or not donations are permitted with league registration. + In order to advertise a specific use for donations from this leauge (e.g. YCC fundraising), + place a descriptive identifier in the Earmark field (this is for internal/accounting use). + Then, describe what the donations will be used for in the large text area. This text will + be visible to users who click to see more information about where their donation goes. If + the pitch field is left blank, a default message will be added about the donation going to + the AFDC's general budget. + + .control-group + .controls + %label.checkbox + = f.check_box :solicit_donations + Enable Donations + %label.control-label Earmark + .controls + =f.text_field :donation_earmark + %label.control-label Pitch + .controls + =f.text_area :donation_pitch, class: "span4", rows: 6 + %h4 Gender-based Registration %p.muted These dates will be used in addition to the general registrationdates diff --git a/app/views/leagues/players.html.erb b/app/views/leagues/players.html.erb index 5e62084..48c3689 100644 --- a/app/views/leagues/players.html.erb +++ b/app/views/leagues/players.html.erb @@ -205,7 +205,7 @@ formatterParams: { "man-matching": "MM", "woman-matching": "WM", - "Mixed": "MX" + "mixed": "MX" }, headerFilter:"list", headerFilterParams:{valuesLookup: "all", valuesLookupField:"matchup", clearable: true}, @@ -216,6 +216,7 @@ }); function render_team_updater(team_id, reg_ids) { + var setTeamPath = "<%=add_player_to_team_league_path(@league, :json)%>"; var team_updater = _.template($("#team-selection-template").html()); var teamUpdaterDomTarget = $("#team-selection-container"); @@ -223,10 +224,35 @@ teamUpdaterDomTarget.html(team_updater()); if (team_id) { $("#team-selector").val(team_id); + + var remove_button = $("#remove-team-button"); + remove_button.show(); + remove_button.on('click', function(){ + var xhr = $.ajax({ + headers: { 'X-CSRF-Token': CSRF_TOKEN }, + url: setTeamPath, + method: "POST", + data: { + registration_id_list: reg_ids, + team_id: "NONE" + } + }).done(function(data) { + successMessageElement.html(data["msg"]) + successMessageElement.show(); + errorMessageElement.hide(); + reg_table.setData(ajaxURL); + team_table.setData(teamDataURL); + remove_button.hide(); + $("#team-selector option:selected").prop("selected", false) + }).fail(function(jqXHR,textStatus,errorThrown){ + errorMessageElement.html(jqXHR.responseJSON["msg"]); + errorMessageElement.show(); + successMessageElement.hide(); + }); + }); } } - var setTeamPath = "<%=add_player_to_team_league_path(@league, :json)%>"; var setTeamButton = $("#update-team-button"); var errorMessageElement = $("#registrant-error-message"); @@ -248,6 +274,8 @@ errorMessageElement.hide(); reg_table.setData(ajaxURL); team_table.setData(teamDataURL); + var remove_button = $("#remove-team-button"); + remove_button.show(); }).fail(function(jqXHR,textStatus,errorThrown){ errorMessageElement.html(jqXHR.responseJSON["msg"]); errorMessageElement.show(); @@ -448,6 +476,7 @@ <% end %> + <% end %> diff --git a/app/views/leagues/show.html.haml b/app/views/leagues/show.html.haml index 0b4cc77..b01fce2 100644 --- a/app/views/leagues/show.html.haml +++ b/app/views/leagues/show.html.haml @@ -13,6 +13,19 @@ .span5 = render :partial => '/league_summary', :locals => {league: @league} - if permitted_to? :manage, @league + - if @league.solicit_donations? + %hr + - registration_id_list = @league.registrations.active.to_a.map(&:_id) + - donation_list = Donation.where(registration_id: {'$in': registration_id_list}) + .row + .span2{style: 'font-weight: bold;'} Donations: + .span3 + %strong Number: + =donation_list.count + %br + %strong Total: + =number_to_currency donation_list.to_a.inject(0){|sum,d| sum+d.amount} + %hr %h4 League Comps = render partial: 'comps', locals: {league: @league} diff --git a/app/views/registration_mailer/registration_active.html.haml b/app/views/registration_mailer/registration_active.html.haml index 7e8d13b..92cee45 100644 --- a/app/views/registration_mailer/registration_active.html.haml +++ b/app/views/registration_mailer/registration_active.html.haml @@ -17,5 +17,5 @@ - content_for :callout_box do %strong A note about pairs: This league allows players to pair up to guarantee that they will be on the same team. The only way to ensure that your pair - request will be respected is if you use the official pairing system. - Requests made to the commissioner or in the notes field of your registration cannot be guaranteed. + request will be respected is if you use the official pairing system. Requests made to the commissioner or in the notes field + of your registration cannot be guaranteed. diff --git a/app/views/registrations/_form.html.haml b/app/views/registrations/_form.html.haml index 0543e73..121ae9a 100644 --- a/app/views/registrations/_form.html.haml +++ b/app/views/registrations/_form.html.haml @@ -7,7 +7,7 @@ = f.select :gen_availability, [nil, '25%', '50%', '75%', '100%'], label: 'Availability' - if @registration.league.created_at > Date.new(2019, 4, 11) = f.select :shirt_size, [nil, 'XXL', 'XL', 'Large', 'Medium', 'Small', 'XS', 'XXS'], label: 'Unisex Shirt Size' - .control-group + .form-group .controls = f.check_box :eos_availability, value: 1, label: "Will attend end of season tourney" - rank_max = 6 if (@registration.league.sport == 'goaltimate' && @registration.user.gender == 'female') @@ -20,6 +20,39 @@ - if permitted_to?(:manage, @registration.league) && @registration.persisted? = f.text_field :commish_rank, label: 'League Rank' = f.select :player_strength, [nil, 'Runner', 'Thrower', 'Both'] + - if @league.allow_pairs? && !@registration.linked? + - received_invites = @registration.received_invitations.outstanding + - if received_invites.count > 0 + .form-group + %label.control-label Accept Pair Invite + .controls + - received_invites.each do |inv| + %label.radio + %input{type: 'radio', name: 'registration[pair_requested_user_id][]', class: 'received_invite_radio', value: inv.sender._id.to_s } + =inv.sender.name + .checkbox + %label{for: 'ignore_received_invites'} + %input{type: 'checkbox', id: 'ignore_received_invites', value: nil, checked: true} + None of the Above + + - invited_user = @registration.sent_invitations.outstanding.first&.recipient + - exclusion_list = PairingCoordinator.new(@league).excluded_players + - exclusion_list.append(current_user._id.to_s) + = render partial: '/user_multiselect', locals: {form: f, fieldname: 'pair_requested_user_id', label: "Invite Pair", users: [invited_user], limit: 1, exclude: exclusion_list} + + - if @registration.linked? + .form-group + %label.control-label Current Pair + - if @registration.cored? + %span.span3.uneditable-input n/a + .controls + %span.help-inline Cored Players Cannot Pair + - else + %span.span3.uneditable-input + = @registration.pair.name + .controls + %span.form-control.help-inline To remove a confirmed pair, email help@afdc.com + = f.text_area :notes, rows: 5 - if @registration.new_record? .control-group @@ -34,8 +67,27 @@ = f.check_box :waiver_accepted, value: 1, label: raw('I have read, understand, and accept the
AFDC\'s liability waiver and refund policy.') - if @registration.errors[:waiver_accepted].any? = f.alert_message @registration.errors[:waiver_accepted].first - = f.actions do - - if @registration.new_record? - = f.primary "Register", disable_with: 'Registering...' - - else - = f.primary "Update", disable_with: 'Updating...' + - if @registration.status == 'registering' || @registration.status == 'registering_waitlisted' + = f.submit "Register", disable_with: 'Registering...', class: "btn btn-primary" + - else + = f.submit "Update", disable_with: 'Updating...', class: "btn btn-primary" + + +- content_for :page_scripts do + :javascript + $(function(){ + $('#ignore_received_invites').on('change', function(e){ + if ($('#ignore_received_invites').is(':checked')) { + $('.received_invite_radio').prop('checked', false); + $('.user-multi-select .new-user').prop( "disabled", false); + } + }); + + $('.received_invite_radio').on('change', function(e){ + if ($(e.target).is(':checked')) { + $('#ignore_received_invites').prop('checked', false); + $('.user-multi-select a.remove').click(); + $('.user-multi-select .new-user').prop( "disabled", true); + } + }); + }); diff --git a/app/views/registrations/donate.html.erb b/app/views/registrations/donate.html.erb new file mode 100644 index 0000000..b3d2fce --- /dev/null +++ b/app/views/registrations/donate.html.erb @@ -0,0 +1,42 @@ +
+

Boost Your Impact

+

Add a donation with your registration and become a game-changer!

+

+ By stepping onto the field, you're already supporting Ultimate in Atlanta. But here's a + chance to have an even greater impact. When you add a donation with your registration, + you're not just a player - you're a pillar of our community. Your tax-deductible donation + expands the reach of our programs, empowering youth development, fostering diversity and inclusivity, + and amplifying our mission to teach and celebrate the games of Ultimate and Goaltimate. + It's like adding a strategic play to your game; your contribution helps us build a stronger, + more vibrant community for everyone who steps onto the field. +

+

Ready to be more than a player? Be a game-changer with us!

+

+ <%=link_to "$5", pay_registration_path(@registration, donation_amount: 5), class: "btn btn-primary btn-large"%> + <%=link_to "$10", pay_registration_path(@registration, donation_amount: 10), class: "btn btn-primary btn-large"%> + <%=link_to "$25", pay_registration_path(@registration, donation_amount: 25), class: "btn btn-primary btn-large"%> + <%=link_to "$50", pay_registration_path(@registration, donation_amount: 50), class: "btn btn-primary btn-large"%> +

+
+ <%= form_tag(pay_registration_path(@registration), method: "GET", class: "form-inline") do %> +
+
+ $ + <%=text_field_tag :donation_amount, "", class: "input-medium", placeholder: "amount" %> +
+ <%=submit_tag "Pay", class: "btn btn-primary"%> +
+ <% end %> +
+

+ <%=link_to "No thanks, Maybe Next Time", pay_registration_path(@registration)%> +

+
+ +<% if @registration.league.donation_pitch.present? %> +
+

Heads Up! Donations made via this league may be reserved for a specific purpose

+
A message from your commissioner:
+ <%= @registration.league.donation_pitch.html_safe %> +
+<% end %> diff --git a/app/views/registrations/pay.html.erb b/app/views/registrations/pay.html.erb new file mode 100644 index 0000000..55f5c7d --- /dev/null +++ b/app/views/registrations/pay.html.erb @@ -0,0 +1,82 @@ +<% content_for :title, @registration.league.name %> +<%= render :partial => '/pageheader', :locals => {subtitle: 'Join the League', breadcrumbs: {'Leagues' => leagues_path, @registration.league.name => league_path(@registration.league), "Registration for #{@registration.user.name}" => nil}}%> +<% + donation = Donation.new(amount: params[:donation_amount], user: @registration.user, registration: @registration) + if @registration.league.solicit_donations? == false || donation.valid? == false + donation = nil + end +%> + +
+
+
+ + + Relax! Your connection to our payment processor is secure. + +

Your payment details will be submitted directly from your browser to our payment processor over a secure connection; the AFDC will never see your credit card information.

+
+ <%= form_tag payments_path, id: "payment_form" do %> +
+
+ League Registration + <%= @registration.league.name %> +
+
<%= number_to_currency @registration.price %> +
+
+ <% if donation %> +
+
+ Tax-deductible Donation + NON-REFUNDABLE +
+
<%= number_to_currency donation.amount %>
+
+ <%= hidden_field_tag 'donation_amount', donation.amount %> + <% end %> +
+
+

Total: <%= number_to_currency(@registration.price + donation&.amount.to_f) %>

+
+
+ <%= hidden_field_tag 'payment_method_nonce', '' %> + <%= hidden_field_tag 'registration_id', @registration._id %> + <%= button_tag "Pay now to join the league!", type: :submit, class: "btn btn-block btn-success btn-large", id: "submit_button" do %> + + Pay now to join the league! + <% end %> + <% end %> +
+
+ +<% content_for :page_scripts do %> + + +<% end %> \ No newline at end of file diff --git a/app/views/registrations/pay.html.haml b/app/views/registrations/pay.html.haml deleted file mode 100644 index 8ab3cf1..0000000 --- a/app/views/registrations/pay.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -- content_for :title, @registration.league.name -= render :partial => '/pageheader', :locals => {subtitle: 'Join the League', breadcrumbs: {'Leagues' => leagues_path, @registration.league.name => league_path(@registration.league), "Registration for #{@registration.user.name}" => nil}} - -.row - .span6.offset3 - .alert.alert-success - %strong{style: 'color: #222'} - %i.icon-lock - Relax! This transaction is secured by a 128 Bit SSL connection - %p{style: 'font-size: 80%'} Your payment details will be submitted directly from your browser to our payment processor over a secure connection; the AFDC will never see your credit card information. - = form_tag payments_path, id: "payment_form" do - %p.lead - #{@registration.user.name}'s registration for #{@registration.league.name}: - %p.lead{style: 'font-size: 400%; font-weight: bold; text-align: center'}=number_to_currency @registration.price - #braintree_dropin - =hidden_field_tag 'payment_method_nonce', '' - =hidden_field_tag 'registration_id', @registration._id - %button.btn.btn-block.btn-success.btn-large{type: :submit, id: :submit_button} - %i.icon-lock - Pay now to join the league! - -- content_for :page_scripts do - = javascript_include_tag "https://js.braintreegateway.com/web/dropin/1.40.2/js/dropin.min.js" - :javascript - $(function(){ - form = $("#payment_form"); - braintree.dropin.create({ - container: document.getElementById('braintree_dropin'), - authorization: "#{current_user.braintree_token}", - }, (error, dropinInstance) => { - if (error) { - console.error(error); - return; - } - - form.on('submit', function (e) { - e.preventDefault(); - dropinInstance.requestPaymentMethod(function (requestPaymentMethodErr, payload) { - if (requestPaymentMethodErr) { - console.error(requestPaymentMethodErr); - return; - } - - $("#payment_method_nonce").val(payload["nonce"]); - form.off().submit(); - }); - }); - }); - }); \ No newline at end of file diff --git a/app/views/registrations/show.html.haml b/app/views/registrations/show.html.haml index 50b9eee..2ab9c19 100644 --- a/app/views/registrations/show.html.haml +++ b/app/views/registrations/show.html.haml @@ -97,12 +97,16 @@ %hr - %dt Pair: - %dd - - if @registration.pair_id + - if @registration.pair_id + %dt Pair: + %dd = @registration.pair.name - - else - n/a + - elsif invite = Invitation.where(handler_id: @registration.league._id, sender: @registration.user, type: "pair", status: "new").first + %dt Requested Pair: + %dd + = invite.recipient.name + + %dt Signup Time: %dd= @registration.formatted_signup_timestamp diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index 6b54749..1d16f39 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -56,8 +56,7 @@ COVID Admin - = f.actions do - - if @user.new_record? - = f.primary "Create my Account" - - else - = f.primary "Update Account" + - if @user.new_record? + = f.submit "Create my Account", class: "btn btn-primary" + - else + = f.submit "Update Account", class: "btn btn-primary" diff --git a/app/views/users/edit_avatar.html.haml b/app/views/users/edit_avatar.html.haml index f7c2f09..9a94d25 100644 --- a/app/views/users/edit_avatar.html.haml +++ b/app/views/users/edit_avatar.html.haml @@ -19,6 +19,5 @@ = bootstrap_form_for(@user, html: { class: 'form-horizontal' }, url: update_avatar_user_path(@user), method: 'PUT', help: :block) do |f| = f.alert_message "Please fix the errors below." = f.file_field :avatar, label: 'Upload file' - = f.actions do - = f.primary "Upload Image", disable_with: 'Uploading...' + = f.submit "Upload Image", disable_with: 'Uploading...', class: "btn btn-primary" diff --git a/config/application.rb b/config/application.rb index 6193060..629005e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,9 +1,8 @@ require File.expand_path('../boot', __FILE__) -#require 'rails/all' +# require 'rails/all' require "action_controller/railtie" require "action_mailer/railtie" -require "active_resource/railtie" require "rails/test_unit/railtie" require "sprockets/railtie" # Uncomment this line for Rails 3.1+ require "csv" @@ -12,7 +11,7 @@ if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) + Bundler.require(*Rails.groups) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end diff --git a/config/authorization_rules.rb b/config/authorization_rules.rb index 7648431..c66426a 100644 --- a/config/authorization_rules.rb +++ b/config/authorization_rules.rb @@ -24,7 +24,6 @@ # Things all users can do: has_permission_on :users, to: [:index, :search, :show] - has_permission_on :invitations, to: [:index] has_permission_on :teams, to: [:index, :search, :show, :view_roster] has_permission_on :registration_groups, to: [:index] has_permission_on :registrations, to: [:create] @@ -38,15 +37,7 @@ if_attribute :_id => is { user._id } end - has_permission_on :invitations, to: [:show, :accept, :decline] do - if_attribute recipient_id: is { user._id } - end - - has_permission_on :invitations, to: [:show, :cancel] do - if_attribute sender_id: is { user._id } - end - - has_permission_on :registrations, to: [:checkout, :show, :pay, :waitlist_authorize, :edit, :update, :cancel] do + has_permission_on :registrations, to: [:checkout, :show, :pay, :donate, :waitlist_authorize, :edit, :update, :cancel] do if_attribute user_id: is { user._id } end @@ -116,6 +107,16 @@ includes :'spirit-manager' includes :'covid-admin' + has_permission_on :invitations, to: [:index] + + has_permission_on :invitations, to: [:show, :accept, :decline] do + if_attribute recipient_id: is { user._id } + end + + has_permission_on :invitations, to: [:show, :cancel] do + if_attribute sender_id: is { user._id } + end + has_permission_on :global, :to => [:see_debug] has_permission_on :users, :to => [:edit_avatar, :update_avatar, :destroy_avatar, :login_as, :edit_permissions] diff --git a/config/environments/development.rb b/config/environments/development.rb index 6b36e3a..7ebabdb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -35,9 +35,11 @@ # Expands the lines which load the assets config.assets.debug = true + config.eager_load = false + config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { address: 'mailhog', port: 1025 } + config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 } - config.cache_store = :dalli_store, 'memcached', { :namespace => 'platinum', :expires_in => 1.day, :compress => true } - config.action_mailer.default_url_options = { :host => "localhost:3000" } + config.cache_store = :mem_cache_store, ENV['MEMCACHE_HOST'], { :namespace => 'platinum_r4', :expires_in => 1.day, :compress => true } + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } end \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 97c2000..9e718dd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -9,7 +9,7 @@ config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + config.serve_static_files = true # Compress JavaScripts and CSS config.assets.compress = false @@ -65,6 +65,8 @@ # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 + config.eager_load = true + config.action_mailer.smtp_settings = { :address => "smtp.mailgun.org", :port => 587, @@ -75,6 +77,8 @@ :domain => 'leagues.afdc.com', } - config.cache_store = :dalli_store, 'memcached', { :namespace => 'platinum', :expires_in => 1.day, :compress => true } + config.log_level = :info + + config.cache_store = :mem_cache_store, 'memcached', { :namespace => 'platinum_r4', :expires_in => 1.day, :compress => true } config.action_mailer.default_url_options = { :host => "leagues.afdc.com" } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 4f9e1cf..9006c2b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,7 +8,7 @@ config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = "public, max-age=3600" # Log error messages when you accidentally call methods on nil @@ -35,5 +35,7 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + config.eager_load = false + config.secret_token = SecureRandom.hex(64) end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index ffed5da..330595a 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -5,3 +5,4 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Platinum::Application.config.secret_token = ENV['secret_token'] +Platinum::Application.config.secret_key_base = ENV['secret_key_base'] diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index a4e0a04..d2b58cd 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -Platinum::Application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes +Platinum::Application.config.session_store :cookie_store, key: '_afdc_platinum_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information diff --git a/config/mongoid.yml b/config/mongoid.yml index 35b96d7..41f52f0 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -9,7 +9,7 @@ development: # Provides the hosts the default session can connect to. Must be an array # of host:port pairs. (required) hosts: - - mongodb:27017 + - localhost:27017 options: # Change whether the session persists in safe mode by default. # (default: false) @@ -84,7 +84,6 @@ test: hosts: - mongodb:27017 options: - consistency: :strong # In the test environment we lower the retries and retry interval to # low amounts for fast failures. max_retries: 1 diff --git a/config/routes.rb b/config/routes.rb index 8900743..b1d8850 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ require 'sidekiq/web' Platinum::Application.routes.draw do - match '/users/search' => 'users#search' + match '/users/search' => 'users#search', via: :get resources :fields, :schedules, :comp_groups, :payments, :spirit_reports resources :invitations do @@ -21,6 +21,7 @@ resources :registrations do member do put 'cancel' + get 'donate' get 'pay' get 'waitlist_authorize' end diff --git a/lib/afdc/pairing_coordinator.rb b/lib/afdc/pairing_coordinator.rb new file mode 100644 index 0000000..313a4a1 --- /dev/null +++ b/lib/afdc/pairing_coordinator.rb @@ -0,0 +1,68 @@ +# TODO: Exclude already-paired players from search results + +class PairingCoordinator + attr_reader :league + + def initialize(league) + @league = league + end + + def request_pair(source_player, target_player) + # puts "Requesting pair..." + src_user = load_user(source_player) + # puts "\t Source user loaded (#{source_player} => #{src_user&.name})" + tgt_user = load_user(target_player) + # puts "\t Source user loaded (#{target_player} => #{tgt_user&.name})" + + return false if src_user.nil? + + src_reg = @league.registration_for(src_user) + tgt_reg = @league.registration_for(tgt_user) + + # Check if either player is already paired + return false if src_reg&.linked? + return false if tgt_reg&.linked? + # puts "\t Neither user is paired/cored yet" + + # Cancel all outstanding sent pair requests: + src_reg.sent_invitations.outstanding.update_all(status: "canceled") + return true if tgt_user.nil? + + # Accept outstanding pair invite from the target player, if it exists + if tgt_reg.present? && tgt_reg.sent_invitations.outstanding.where(recipient: src_user).exists? + tgt_reg.sent_invitations.outstanding.where(recipient: src_user).first.accept + # puts "\t Pair Successful!" + return true + end + + if src_reg.sent_invitations.where(recipient: tgt_user).exists? + src_reg.sent_invitations.where(recipient: tgt_user).update(status: "sent") + # puts "\t Reusing old Invite" + return true + end + Invitation.create!(type: "pair", sender: src_user, recipient: tgt_user, handler: @league) + end + + def excluded_players + cored_list = RegistrationGroup.where(league: @league).all.inject([]) {|list, grp| list + grp.member_ids} + captain_list = Team.where(league: @league).all.inject([]) {|list, team| list + team.captains.map(&:id)} + paired_list = @league.registrations.where(:pair_id.exists => true).all.inject([]) {|list, reg| list.append(reg.user_id)} + (cored_list + captain_list + paired_list).to_set.to_a.map(&:to_s) + end + + private + + def load_user(identifier) + if identifier.is_a?(User) + return identifier + end + + if identifier.is_a?(Registration) + return identifier.user + end + + if identifier.is_a?(String) or identifier.is_a?(BSON::ObjectId) + return User.find(identifier) + end + end +end \ No newline at end of file diff --git a/mongo_import/download_backup.sh b/mongo_import/download_backup.sh old mode 100644 new mode 100755 diff --git a/mongo_import/native_mongo_restore.sh b/mongo_import/native_mongo_restore.sh new file mode 100755 index 0000000..5bf8d82 --- /dev/null +++ b/mongo_import/native_mongo_restore.sh @@ -0,0 +1,4 @@ +#!/bin/bash +tar -xzf platypus_dump.tar.gz +mongorestore --drop +rm -rf dump diff --git a/mongo_import/restore_mongo.sh b/mongo_import/restore_mongo.sh old mode 100644 new mode 100755 diff --git a/mongo_import/restore_mongo_linux.sh b/mongo_import/restore_mongo_linux.sh old mode 100644 new mode 100755 diff --git a/public/javascripts/userSelector.js b/public/javascripts/userSelector.js index b43f271..294d25a 100644 --- a/public/javascripts/userSelector.js +++ b/public/javascripts/userSelector.js @@ -1,9 +1,13 @@ $(function(){ // Autocomplete $(".user-multi-select").each(function(){ + if (typeof user_search_params !== 'undefined') { + console.log(user_search_params); + } var ums = $(this); var userAutocomplete = ums.find("input.new-user").autocomplete({ serviceUrl:'/users/search.json', + params: user_search_params, minChars: 3, maxHeight: 400, width: 350, diff --git a/spec/factories.rb b/spec/factories.rb index aff247d..b4bfcb8 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,12 +1,15 @@ FactoryGirl.define do + sequence :email do |n| + "johndoe#{n}@email.net" + end + factory :user do firstname 'John' lastname 'Doe' birthdate '1980-01-01' - sequence(:email_address) {|n| "johndoe#{n}@email.net"} + email_address { generate(:email) } gender 'male' - password 'pw' - password_confirmation 'pw' + password_digest "xxx" end end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0a1d588..0830882 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -85,6 +85,8 @@ # --seed 1234 config.order = "random" + config.include FactoryGirl::Syntax::Methods + config.before(:suite) do Mongoid.default_session.drop end