1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Merge branch 'development'

This commit is contained in:
2017-11-18 19:38:32 -05:00
146 changed files with 848 additions and 4135 deletions

View File

@@ -1,6 +1,6 @@
language: ruby
rvm:
- 2.3.0
- 2.4.0
env:
- DB=sqlite
script:
@@ -14,3 +14,4 @@ deploy:
on:
repo: jcwimer/wrestlingApp
branch: master
run: "rake db:migrate RAILS_ENV=production"

24
Gemfile
View File

@@ -1,15 +1,15 @@
source 'https://rubygems.org'
ruby '2.3.0'
ruby '2.4.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
gem 'rails', '5.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', :group => :development
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
gem 'uglifier'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
gem 'coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
@@ -18,9 +18,9 @@ gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
gem 'jbuilder'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', :group => :doc
gem 'sdoc', :group => :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', :group => :development
@@ -39,26 +39,24 @@ gem 'spring', :group => :development
#Installed by me
#For Heroku
group :production do
gem 'rails_12factor'
gem 'mysql2'
gem 'passenger'
gem 'therubyracer'
gem 'newrelic_rpm'
gem 'dalli'
end
#Other
gem 'devise'
gem 'cancancan'
gem 'round_robin_tournament'
gem 'rb-readline'
gem 'delayed_job_active_record'
gem 'puma'
gem 'brakeman'
gem 'rails-lineman'
group :development do
#gem 'bullet'
group :development do
gem 'rubocop'
gem 'bullet'
gem 'brakeman'
end

View File

@@ -1,227 +1,220 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
actioncable (5.1.1)
actionpack (= 5.1.1)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.1)
actionpack (= 5.1.1)
actionview (= 5.1.1)
activejob (= 5.1.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5)
actionview (= 4.2.5)
activesupport (= 4.2.5)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.1.1)
actionview (= 5.1.1)
activesupport (= 5.1.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5)
activesupport (= 4.2.5)
actionview (5.1.1)
activesupport (= 5.1.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5)
activesupport (= 4.2.5)
globalid (>= 0.3.0)
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activerecord (4.2.5)
activemodel (= 4.2.5)
activesupport (= 4.2.5)
arel (~> 6.0)
activesupport (4.2.5)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.1)
activesupport (= 5.1.1)
globalid (>= 0.3.6)
activemodel (5.1.1)
activesupport (= 5.1.1)
activerecord (5.1.1)
activemodel (= 5.1.1)
activesupport (= 5.1.1)
arel (~> 8.0)
activesupport (5.1.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
bcrypt (3.1.10)
brakeman (3.1.5)
erubis (~> 2.6)
fastercsv (~> 1.5)
haml (>= 3.0, < 5.0)
highline (>= 1.6.20, < 2.0)
multi_json (~> 1.2)
ruby2ruby (>= 2.1.1, < 2.3.0)
ruby_parser (~> 3.7.0)
safe_yaml (>= 1.0)
sass (~> 3.0)
slim (>= 1.3.6, < 4.0)
terminal-table (~> 1.4)
builder (3.2.2)
cancancan (1.10.1)
coffee-rails (4.0.1)
arel (8.0.0)
ast (2.3.0)
bcrypt (3.1.11)
brakeman (3.7.2)
builder (3.2.3)
bullet (5.6.1)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.10.0)
cancancan (2.0.0)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
concurrent-ruby (1.0.0)
dalli (2.7.5)
delayed_job (4.1.1)
activesupport (>= 3.0, < 5.0)
delayed_job_active_record (4.1.0)
activerecord (>= 3.0, < 5)
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
dalli (2.7.6)
delayed_job (4.1.3)
activesupport (>= 3.0, < 5.2)
delayed_job_active_record (4.1.2)
activerecord (>= 3.0, < 5.2)
delayed_job (>= 3.0, < 5)
devise (3.4.1)
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0, < 5.2)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.5.2)
fastercsv (1.5.5)
globalid (0.3.6)
activesupport (>= 4.1.0)
haml (4.0.7)
tilt
highline (1.7.8)
i18n (0.7.0)
jbuilder (2.2.13)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
rails-dom-testing (~> 1.0)
erubi (1.6.1)
execjs (2.7.0)
globalid (0.4.0)
activesupport (>= 4.2.0)
i18n (0.8.6)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
libv8 (3.16.14.7)
json (1.8.6)
libv8 (3.16.14.19)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.3)
multi_json (1.11.0)
mysql2 (0.3.18)
newrelic_rpm (3.13.2.302)
nokogiri (1.6.7)
mini_portile2 (~> 2.0.0.rc2)
mail (2.6.6)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.3)
multi_json (1.12.2)
mysql2 (0.4.9)
newrelic_rpm (4.4.0.336)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
orm_adapter (0.5.0)
passenger (5.0.7)
rack
rake (>= 0.8.1)
puma (2.11.2)
rack (>= 1.1, < 2.0)
rack (1.6.4)
parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
powerpack (0.1.1)
puma (3.10.0)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5)
actionmailer (= 4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
activemodel (= 4.2.5)
activerecord (= 4.2.5)
activesupport (= 4.2.5)
rails (5.1.1)
actioncable (= 5.1.1)
actionmailer (= 5.1.1)
actionpack (= 5.1.1)
actionview (= 5.1.1)
activejob (= 5.1.1)
activemodel (= 5.1.1)
activerecord (= 5.1.1)
activesupport (= 5.1.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
railties (= 5.1.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-lineman (0.3.0)
rake
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.3)
railties (4.2.5)
actionpack (= 4.2.5)
activesupport (= 4.2.5)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (5.1.1)
actionpack (= 5.1.1)
activesupport (= 5.1.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rb-readline (0.5.2)
rdoc (4.2.0)
json (~> 1.4)
ref (1.0.5)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rainbow (2.2.2)
rake
rake (12.1.0)
rb-readline (0.5.5)
rdoc (4.3.0)
ref (2.0.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
round_robin_tournament (0.0.1)
ruby2ruby (2.2.0)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
ruby_parser (3.7.3)
sexp_processor (~> 4.1)
safe_yaml (1.0.4)
sass (3.4.21)
sdoc (0.4.1)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sexp_processor (4.6.1)
slim (3.0.6)
temple (~> 0.7.3)
tilt (>= 1.3.3, < 2.1)
spring (1.3.5)
sprockets (3.5.0)
spring (2.0.2)
activesupport (>= 4.2)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
temple (0.7.6)
terminal-table (1.5.2)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.2)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thor (0.20.0)
thread_safe (0.3.6)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.0)
uniform_notifier (1.10.0)
warden (1.2.7)
rack (>= 1.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
PLATFORMS
ruby
DEPENDENCIES
brakeman
bullet
cancancan
coffee-rails (~> 4.0.0)
coffee-rails
dalli
delayed_job_active_record
devise
jbuilder (~> 2.0)
jbuilder
jquery-rails
mysql2
newrelic_rpm
passenger
puma
rails (= 4.2.5)
rails-lineman
rails (= 5.1.1)
rails_12factor
rb-readline
round_robin_tournament
sdoc (~> 0.4.0)
rubocop
sdoc
spring
sqlite3
therubyracer
turbolinks
uglifier (>= 1.3.0)
uglifier
RUBY VERSION
ruby 2.3.0p0
ruby 2.4.0p0
BUNDLED WITH
1.13.5
1.15.4

View File

@@ -1,2 +1,2 @@
worker: bundle exec rake jobs:work
web: bundle exec passenger start -p $PORT --max-pool-size 3
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}

View File

@@ -16,9 +16,9 @@ MIT License
<b>Development details:</b>
* Ruby 2.3.0
* Ruby 2.4.0
* Rails 4.2.5
* Rails 5.1.1
* Install gems without production <tt>bundle install --without production</tt>

View File

@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
after_filter :set_csrf_cookie_for_ng
after_action :set_csrf_cookie_for_ng
def set_csrf_cookie_for_ng
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?

View File

@@ -1,7 +1,7 @@
class MatsController < ApplicationController
before_action :set_mat, only: [:show, :edit, :update, :destroy]
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit,:show]
before_filter :check_for_matches, only: [:show]
before_action :check_access, only: [:new,:create,:update,:destroy,:edit,:show]
before_action :check_for_matches, only: [:show]
# GET /mats/1
# GET /mats/1.json

View File

@@ -1,7 +1,7 @@
class SchoolsController < ApplicationController
before_action :set_school, only: [:show, :edit, :update, :destroy]
before_filter :check_access_director, only: [:new,:create,:destroy]
before_filter :check_access_delegate, only: [:update,:edit]
before_action :check_access_director, only: [:new,:create,:destroy]
before_action :check_access_delegate, only: [:update,:edit]
# GET /schools/1

View File

@@ -1,9 +1,9 @@
class TournamentsController < ApplicationController
before_action :set_tournament, only: [:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
before_filter :check_access_manage, only: [:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
before_filter :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
before_filter :check_tournament_errors, only: [:generate_matches]
before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
before_action :check_access_manage, only: [:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
before_action :check_tournament_errors, only: [:generate_matches]
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
def weigh_in_sheet
@@ -195,7 +195,7 @@ class TournamentsController < ApplicationController
end
def show
@schools = @tournament.schools(:delegates)
@schools = @tournament.schools.includes(:delegates)
@weights = @tournament.weights.sort_by{|x|[x.max]}
@mats = @tournament.mats
end

View File

@@ -1,6 +1,6 @@
class WeightsController < ApplicationController
before_action :set_weight, only: [:show, :edit, :update, :destroy,:re_gen]
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit, :re_gen]
before_action :check_access, only: [:new,:create,:update,:destroy,:edit, :re_gen]
# GET /weights/1

View File

@@ -1,6 +1,6 @@
class WrestlersController < ApplicationController
before_action :set_wrestler, only: [:show, :edit, :update, :destroy]
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit]
before_action :set_wrestler, only: [:show, :edit, :update, :destroy, :update_pool]
before_action :check_access, only: [:new,:create,:update,:destroy,:edit,:update_pool]
@@ -69,6 +69,25 @@ class WrestlersController < ApplicationController
end
end
def update_pool
@tournament = @wrestler.tournament
@weight = @wrestler.weight
@weights = @tournament.weights.sort_by{|w| w.max}
@school = @wrestler.school
if params[:wrestler]['pool']
@wrestler.pool = params[:wrestler]['pool']
respond_to do |format|
if @wrestler.update(wrestler_params)
format.html { redirect_to "/weights/#{@wrestler.weight.id}/", notice: 'Wrestler was successfully updated. Please re-generate this weight classes matches.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @wrestler.errors, status: :unprocessable_entity }
end
end
end
end
# DELETE /wrestlers/1
# DELETE /wrestlers/1.json
def destroy
@@ -88,14 +107,19 @@ class WrestlersController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def wrestler_params
params.require(:wrestler).permit(:name, :school_id, :weight_id, :seed, :original_seed, :season_win, :season_loss,:criteria,:extra,:offical_weight)
params.require(:wrestler).permit(:name, :school_id, :weight_id, :seed, :original_seed, :season_win, :season_loss,:criteria,:extra,:offical_weight,:pool)
end
def check_access
if params[:school]
@school = School.find(params[:school])
#@tournament = Tournament.find(@school.tournament.id)
elsif params[:wrestler]
if params[:wrestler]["school_id"]
@school = School.find(params[:wrestler]["school_id"])
else
@wrestler = Wrestler.find(params[:wrestler]["id"])
@school = @wrestler.school
end
#@tournament = Tournament.find(@school.tournament.id)
elsif @wrestler
@school = @wrestler.school

View File

@@ -130,9 +130,15 @@ class Match < ActiveRecord::Base
end
def poolNumber
if self.w1?
wrestler1.generatePoolNumber
wrestler1.pool
end
end
def list_w2_stats
"#{w2_name}: #{w2_stat}"
end
def list_w1_stats
"#{w1_name}: #{w1_stat}"
end
end

View File

@@ -17,8 +17,25 @@ class Weight < ActiveRecord::Base
# self.tournament.destroyAllMatches
end
def wrestlersForPool(pool)
self.wrestlers.select{|w| w.generatePoolNumber == pool}
def pools_with_bye
pool = 1
pools_with_a_bye = []
until pool > self.pools do
if wrestlersForPool(pool).first.hasAPoolBye
pools_with_a_bye << pool
end
pool = pool + 1
end
pools_with_a_bye
end
def wrestlersForPool(poolNumber)
#For some reason this does not work
# wrestlers.select{|w| w.pool == poolNumber}
#This does...
weightWrestlers = Wrestler.where(:weight_id => self.id)
weightWrestlers.select{|w| w.pool == poolNumber}
end
def allPoolMatchesFinished(pool)
@@ -43,7 +60,8 @@ class Weight < ActiveRecord::Base
end
def poolSeedOrder(pool)
wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
# wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
return wrestlersForPool(pool).sort_by{|w|w.seed}
end
@@ -51,79 +69,6 @@ class Weight < ActiveRecord::Base
SwapWrestlers.new.swapWrestlers(wrestler1_id,wrestler2_id)
end
def returnPoolNumber(wrestler)
if self.pools == 4
@wrestlers = fourPoolNumbers(self.wrestlers)
elsif self.pools == 2
@wrestlers = twoPoolNumbers(self.wrestlers)
elsif self.pools == 1
@wrestlers = onePoolNumbers(self.wrestlers)
end
@wrestler = @wrestlers.select{|w| w.id == wrestler.id}.first
return @wrestler.poolNumber
end
def onePoolNumbers(poolWrestlers)
poolWrestlers.sort_by{|x| x.seed }.each do |w|
w.poolNumber = 1
end
return poolWrestlers
end
def twoPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.poolNumber = 1
elsif w.seed == 2
w.poolNumber = 2
elsif w.seed == 3
w.poolNumber = 2
elsif w.seed == 4
w.poolNumber = 1
else
w.poolNumber = pool
end
if pool < 2
pool = pool + 1
else
pool = 1
end
end
return poolWrestlers
end
def fourPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.poolNumber = 1
elsif w.seed == 2
w.poolNumber = 2
elsif w.seed == 3
w.poolNumber = 3
elsif w.seed == 4
w.poolNumber = 4
elsif w.seed == 8
w.poolNumber = 1
elsif w.seed == 7
w.poolNumber = 2
elsif w.seed == 6
w.poolNumber = 3
elsif w.seed == 5
w.poolNumber = 4
else
w.poolNumber = pool
end
if pool < 4
pool = pool + 1
else
pool = 1
end
end
return poolWrestlers
end
def bracket_size
wrestlers.size
@@ -165,4 +110,8 @@ class Weight < ActiveRecord::Base
PoolOrder.new(wrestlersForPool(pool)).getPoolOrder
end
def wrestlersWithoutPool
wrestlers.select{|w| w.pool == nil}
end
end

View File

@@ -4,7 +4,7 @@ class Wrestler < ActiveRecord::Base
has_one :tournament, through: :weight
has_many :matches, through: :weight
has_many :deductedPoints, class_name: "Teampointadjust"
attr_accessor :poolNumber, :poolAdvancePoints, :originalId, :swapId
attr_accessor :poolAdvancePoints, :originalId, :swapId
validates :name, :weight_id, :school_id, presence: true
@@ -103,10 +103,6 @@ class Wrestler < ActiveRecord::Base
end
end
def generatePoolNumber
self.weight.returnPoolNumber(self)
end
def boutByRound(round)
round_match = allMatches.select{|m| m.round == round}.first
if round_match.blank?
@@ -122,7 +118,7 @@ class Wrestler < ActiveRecord::Base
def poolMatches
pool_matches = allMatches.select{|m| m.bracket_position == "Pool"}
pool_matches.select{|m| m.poolNumber == self.generatePoolNumber}
pool_matches.select{|m| m.poolNumber == self.pool}
end
def hasAPoolBye

View File

@@ -6,7 +6,7 @@ class PoolAdvance
end
def advanceWrestler
if @wrestler.weight.allPoolMatchesFinished(@wrestler.generatePoolNumber) && @wrestler.finishedBracketMatches.size == 0
if @wrestler.weight.allPoolMatchesFinished(@wrestler.pool) && @wrestler.finishedBracketMatches.size == 0
poolToBracketAdvancment
end
if @wrestler.finishedBracketMatches.size > 0
@@ -15,7 +15,7 @@ class PoolAdvance
end
def poolToBracketAdvancment
pool = @wrestler.generatePoolNumber
pool = @wrestler.pool
if @wrestler.weight.wrestlers.size > 6
poolOrder = @wrestler.weight.poolOrder(pool)
#Take pool order and move winner and runner up to correct match based on w1_name and w2_name
@@ -67,7 +67,7 @@ class PoolAdvance
def loserAdvance
bout = @wrestler.lastMatch.bout_number
next_match = Match.where("loser1_name = ? OR loser2_name = ? AND weight_id = ?","Loser of #{bout}","Loser of #{bout}",@wrestler.weight_id)
next_match = Match.where("(loser1_name = ? OR loser2_name = ?) AND weight_id = ?","Loser of #{bout}","Loser of #{bout}",@wrestler.weight_id)
if next_match.size > 0
next_match.first.replaceLoserNameWithWrestler(@wrestler,"Loser of #{bout}")
end

View File

@@ -6,6 +6,7 @@ class PoolGeneration
end
def generatePools
GeneratePoolNumbers.new(@weight).savePoolNumbers
pools = @weight.pools
while @pool <= pools
roundRobin

View File

@@ -0,0 +1,77 @@
class GeneratePoolNumbers
def initialize( weight )
@weight = weight
end
def savePoolNumbers
if @weight.pools == 4
saveFourPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 2
saveTwoPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 1
saveOnePoolNumbers(@weight.wrestlersWithoutPool)
end
end
def saveOnePoolNumbers(poolWrestlers)
poolWrestlers.sort_by{|x| x.seed }.each do |w|
w.pool = 1
w.save
end
end
def saveTwoPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.pool = 1
elsif w.seed == 2
w.pool = 2
elsif w.seed == 3
w.pool = 2
elsif w.seed == 4
w.pool = 1
else
w.pool = pool
end
if pool < 2
pool = pool + 1
else
pool = 1
end
w.save
end
end
def saveFourPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.pool = 1
elsif w.seed == 2
w.pool = 2
elsif w.seed == 3
w.pool = 3
elsif w.seed == 4
w.pool = 4
elsif w.seed == 8
w.pool = 1
elsif w.seed == 7
w.pool = 2
elsif w.seed == 6
w.pool = 3
elsif w.seed == 5
w.pool = 4
else
w.pool = pool
end
if pool < 4
pool = pool + 1
else
pool = 1
end
w.save
end
end
end

View File

@@ -11,15 +11,18 @@ class SwapWrestlers
w3.weight_id = w1.weight_id
w3.original_seed = w1.original_seed
w3.seed = w1.seed
w3.pool = w1.pool
swapWrestlerMatches(w1.allMatches,w1.id,w3.id)
#Swap wrestler 1 and wrestler 2
swapWrestlerMatches(w2.allMatches,w2.id,w1.id)
w1.seed = w2.seed
w1.pool = w2.pool
swapWrestlerMatches(w3.allMatches,w3.id,w2.id)
w2.seed = w3.seed
w2.pool = w3.pool
w1.save

View File

@@ -10,15 +10,15 @@
</ul>
</div>
<% end %>
<h4>Bout <%= @match.bout_number %></h4>
<h4>Bout: <%= @match.bout_number %> </h4><h4>Round: <%= @match.round %></h4><h4>Weight: <%= @match.weight_max %> lbs</h4>
<table class="table">
<thead>
<tr>
<th><%= @w1.name %> <select id="w1-color" onchange="changeW1Color(this)">
<th><%= @w1.name %> - <%= @w1.school.name %> <select id="w1-color" onchange="changeW1Color(this)">
<option value="green">Green</option>
<option value="red">Red</option>
</select><br>Last Match: <%= if @w1.lastMatch != nil then time_ago_in_words(@w1.lastMatch.updated_at) end%></th>
<th><%= @w2.name %> <select id="w2-color" onchange="changeW2Color(this)">
<th><%= @w2.name %> - <%= @w2.school.name %> <select id="w2-color" onchange="changeW2Color(this)">
<option value="red">Red</option>
<option value="green">Green</option>
</select><br>Last Match: <%= if @w2.lastMatch != nil then time_ago_in_words(@w2.lastMatch.updated_at) end%></th>

View File

@@ -26,6 +26,7 @@
<li>Win by major: 1pt extra</li>
<li>Win by tech fall: 1.5pt extra</li>
<li>Win by fall, default, dq: 2pt extra</li>
<li>BYE points: 2pt (if you win at least 1 match in a pool with a BYE)</li>
<li>1st place: 16pt</li>
<li>2nd place: 12pt</li>
<li>3rd place: 10pt</li>

View File

@@ -1,4 +1 @@
<% if Rails.env.production? %>
<script type='text/javascript' src='//eclkmpbn.com/adServe/banners?tid=85597_138467_5&type=shadowbox&size=800x440'></script>
<% end %>
You do not have permissions to go there.

View File

@@ -1,6 +1,6 @@
<% @round = 1 %>
<% @pool = 1 %>
<% until @wrestlers.select{|w| w.generatePoolNumber == @pool}.blank? %>
<% until @wrestlers.select{|w| w.pool == @pool}.blank? %>
<h5>Pool <%= @pool %></h5>
<table class="table table-striped table-bordered table-condensed">
<thead>
@@ -15,7 +15,7 @@
</tr>
</thead>
<tbody>
<% @wrestlers.select{|w| w.generatePoolNumber == @pool}.sort_by{|w| w.seed}.each do |w| %>
<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.seed}.each do |w| %>
<tr>
<td><%= w.original_seed %> <%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %></td>
<% @round = 1 %>

View File

@@ -104,3 +104,19 @@ li:first-child,li:last-child {
<%= submit_tag "Swap", :class=>"btn btn-success"%>
<% end %>
<% end %>
<% if can? :manage, @tournament %>
<br><br>
<h3>Move wrestler to pool with a bye</h3>
<%= form_tag '/wrestlers/update_pool' do %>
<div class="field">
<%= label_tag 'Wrestler to move' %><br>
<%= collection_select(:wrestler, :id, @weight.wrestlers, :id, :name) %>
</div>
<div class="field">
<%= label_tag 'Pool to move to' %><br>
<%= select :wrestler, :pool, @weight.pools_with_bye %>
</div>
<br>
<%= submit_tag "Move", :class=>"btn btn-success"%>
<% end %>
<% end %>

View File

@@ -1,6 +1,3 @@
<% if Rails.env.production? %>
<script type='text/javascript' src='//eclkmpbn.com/adServe/banners?tid=85597_138467_5&type=shadowbox&size=800x440'></script>
<% end %>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<br>
<br>

View File

@@ -1,6 +1,3 @@
<% if Rails.env.production? %>
<script type='text/javascript' src='//eclkmpbn.com/adServe/banners?tid=85597_138467_5&type=shadowbox&size=800x440'></script>
<% end %>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<br>
<br>

View File

@@ -1,6 +1,3 @@
<% if params[:print] == nil && Rails.env.production? %>
<script type='text/javascript' src='//eclkmpbn.com/adServe/banners?tid=85597_138467_5&type=shadowbox&size=800x440'></script>
<% end %>
<% cache ["#{@tournament.id}_up_matches", @tournament] do %>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default"%>
<script>
@@ -32,10 +29,10 @@
<% @mats.each.map do |m| %>
<tr>
<td><%= m.name %></td>
<td><% if m.unfinishedMatches.first %><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.second %><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.third %><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.fourth %><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.first %><strong><%=m.unfinishedMatches.first.bout_number%></strong> - <%= m.unfinishedMatches.first.weight_max %> lbs<br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.second %><strong><%=m.unfinishedMatches.second.bout_number%></strong> - <%= m.unfinishedMatches.second.weight_max %> lbs<br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.third %><strong><%=m.unfinishedMatches.third.bout_number%></strong> - <%= m.unfinishedMatches.third.weight_max %> lbs<br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.fourth %><strong><%=m.unfinishedMatches.fourth.bout_number%></strong> - <%= m.unfinishedMatches.fourth.weight_max %> lbs<br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %><% end %></td>
</tr>
<% end %>
</tbody>

View File

@@ -40,5 +40,11 @@
<br>
<% @wrestler.allMatches.each do |m| %>
<div> Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %></div>
<% if m.w1_stat || m.w2_stat %>
<div>Stats:</div>
<div><%= m.list_w1_stats %></div>
<div><%= m.list_w2_stats %></div>
</br>
<% end %>
<% end %>
<% end %>

View File

@@ -29,14 +29,13 @@ module Wrestling
config.active_job.queue_adapter = :delayed_job
config.rails_lineman.lineman_project_location = "frontend"
config.to_prepare do
DeviseController.respond_to :html, :json
end
config.autoload_paths += %W(#{config.root}/app/services/tournament_services)
config.autoload_paths += %W(#{config.root}/app/services/wrestler_services)
config.autoload_paths += %W(#{config.root}/app/services/weight_services)
config.autoload_paths += %W(#{config.root}/app/services/bracket_advancement)
end

View File

@@ -90,7 +90,7 @@ Wrestling::Application.configure do
#THESE ADDED BY ME TO GET RAILS 4 WORKING IN HEROKU
config.cache_classes = true
config.serve_static_files = true
config.public_file_server.enabled = true
config.assets.compile = true
config.assets.digest = true
@@ -111,6 +111,4 @@ Wrestling::Application.configure do
#Devise needs origin of email
Rails.application.routes.default_url_options[:host] = 'https://wrestlingdev.com'
#For lineman creating assets
config.serve_static_files = true
end

View File

@@ -13,8 +13,8 @@ Wrestling::Application.configure do
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
config.public_file_server.enabled = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
# Show full error reports and disable caching.
config.consider_all_requests_local = true

View File

@@ -4,7 +4,11 @@ Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
config.secret_key = ENV['WRESTLINGDEV_DEVISE_SECRET_KEY'] if Rails.env.production?
if Rails.env.production?
config.secret_key = ENV['WRESTLINGDEV_DEVISE_SECRET_KEY']
else
config.secret_key = "2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa"
end
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,

View File

@@ -9,4 +9,8 @@
# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
if Rails.env.production?
Wrestling::Application.config.secret_key_base = ENV['WRESTLINGDEV_SECRET_KEY_BASE']
else
Wrestling::Application.config.secret_key_base = "077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2"
end

View File

@@ -52,6 +52,7 @@ Wrestling::Application.routes.draw do
post "/tournaments/:id/swap" => "tournaments#swap", :as => :swap_wrestlers
post 'weights/:id/re_gen' => 'weights#re_gen', :as => :regen_weight
post "/wrestlers/update_pool" => "wrestlers#update_pool"
#API
get "/api/tournaments" => "api#tournaments"

View File

@@ -1,4 +1,4 @@
class CreateSchools < ActiveRecord::Migration
class CreateSchools < ActiveRecord::Migration[4.2][4.2]
def change
create_table :schools do |t|
t.string :name

View File

@@ -1,4 +1,4 @@
class CreateWeights < ActiveRecord::Migration
class CreateWeights < ActiveRecord::Migration[4.2]
def change
create_table :weights do |t|
t.integer :max

View File

@@ -1,4 +1,4 @@
class CreateWrestlers < ActiveRecord::Migration
class CreateWrestlers < ActiveRecord::Migration[4.2]
def change
create_table :wrestlers do |t|
t.string :name

View File

@@ -1,4 +1,4 @@
class CreateTournaments < ActiveRecord::Migration
class CreateTournaments < ActiveRecord::Migration[4.2]
def change
create_table :tournaments do |t|
t.string :name

View File

@@ -1,4 +1,4 @@
class SchoolAddTournamentId < ActiveRecord::Migration
class SchoolAddTournamentId < ActiveRecord::Migration[4.2]
def change
add_column :schools, :tournament_id, :integer
end

View File

@@ -1,4 +1,4 @@
class DeviseCreateUsers < ActiveRecord::Migration
class DeviseCreateUsers < ActiveRecord::Migration[4.2]
def change
create_table(:users) do |t|
## Database authenticatable

View File

@@ -1,4 +1,4 @@
class WeightAddTournamentId < ActiveRecord::Migration
class WeightAddTournamentId < ActiveRecord::Migration[4.2]
def change
add_column :weights, :tournament_id, :integer
end

View File

@@ -1,4 +1,4 @@
class WrestlerAddWinLossColumn < ActiveRecord::Migration
class WrestlerAddWinLossColumn < ActiveRecord::Migration[4.2]
def change
add_column :wrestlers, :season_win, :integer
add_column :wrestlers, :season_loss, :integer

View File

@@ -1,4 +1,4 @@
class DropSchoolScore < ActiveRecord::Migration
class DropSchoolScore < ActiveRecord::Migration[4.2]
def change
remove_column :schools, :score
end

View File

@@ -1,4 +1,4 @@
class AddSchoolScore < ActiveRecord::Migration
class AddSchoolScore < ActiveRecord::Migration[4.2]
def change
add_column :schools, :score, :integer
end

View File

@@ -1,4 +1,4 @@
class CreateMatches < ActiveRecord::Migration
class CreateMatches < ActiveRecord::Migration[4.2]
def change
create_table :matches do |t|
t.integer :r_id

View File

@@ -1,4 +1,4 @@
class AddTournamentIdToMatches < ActiveRecord::Migration
class AddTournamentIdToMatches < ActiveRecord::Migration[4.2]
def change
add_column :matches, :tournament_id, :integer
end

View File

@@ -1,4 +1,4 @@
class AddRoundToMatch < ActiveRecord::Migration
class AddRoundToMatch < ActiveRecord::Migration[4.2]
def change
add_column :matches, :round, :integer
end

View File

@@ -1,4 +1,4 @@
class CreateMats < ActiveRecord::Migration
class CreateMats < ActiveRecord::Migration[4.2]
def change
create_table :mats do |t|
t.string :name

View File

@@ -1,4 +1,4 @@
class AddMatIdToWeights < ActiveRecord::Migration
class AddMatIdToWeights < ActiveRecord::Migration[4.2]
def change
add_column :weights, :mat_id, :integer
end

View File

@@ -1,4 +1,4 @@
class AddFinishedFieldToMatches < ActiveRecord::Migration
class AddFinishedFieldToMatches < ActiveRecord::Migration[4.2]
def change
add_column :matches, :finished, :integer
end

View File

@@ -1,4 +1,4 @@
class DropWeightMatId < ActiveRecord::Migration
class DropWeightMatId < ActiveRecord::Migration[4.2]
def change
remove_column :weights, :mat_id
end

View File

@@ -1,4 +1,4 @@
class AddSeedCriteriaToWrestler < ActiveRecord::Migration
class AddSeedCriteriaToWrestler < ActiveRecord::Migration[4.2]
def change
add_column :wrestlers, :criteria, :string
end

View File

@@ -1,4 +1,4 @@
class AssignWrestlerPoolNumber < ActiveRecord::Migration
class AssignWrestlerPoolNumber < ActiveRecord::Migration[4.2]
def change
add_column :wrestlers, :poolNumber, :integer
end

View File

@@ -1,4 +1,4 @@
class AddBoutNumberToMatch < ActiveRecord::Migration
class AddBoutNumberToMatch < ActiveRecord::Migration[4.2]
def change
add_column :matches, :boutNumber, :integer
end

View File

@@ -1,4 +1,4 @@
class AddExtraFlagForWrestler < ActiveRecord::Migration
class AddExtraFlagForWrestler < ActiveRecord::Migration[4.2]
def change
add_column :wrestlers, :extra, :boolean
end

View File

@@ -1,4 +1,4 @@
class DropPoolNumber < ActiveRecord::Migration
class DropPoolNumber < ActiveRecord::Migration[4.2]
def change
remove_column :wrestlers, :poolNumber
end

View File

@@ -1,4 +1,4 @@
class AddMatchupsToTournament < ActiveRecord::Migration
class AddMatchupsToTournament < ActiveRecord::Migration[4.2]
def change
add_column :tournaments, :matchups, :text
end

View File

@@ -1,4 +1,4 @@
class RenameTournamentMatchups < ActiveRecord::Migration
class RenameTournamentMatchups < ActiveRecord::Migration[4.2]
def change
rename_column :tournaments, :matchups, :matchups_array
end

View File

@@ -1,4 +1,4 @@
class DropSchoolScoreAgain < ActiveRecord::Migration
class DropSchoolScoreAgain < ActiveRecord::Migration[4.2]
def change
remove_column :schools, :score
end

View File

@@ -1,4 +1,4 @@
class MatchupToMatch < ActiveRecord::Migration
class MatchupToMatch < ActiveRecord::Migration[4.2]
def change
add_column :matches, :weight_id, :integer
add_column :matches, :bracket_position, :string

View File

@@ -1,4 +1,4 @@
class AddWNamesToMatch < ActiveRecord::Migration
class AddWNamesToMatch < ActiveRecord::Migration[4.2]
def change
add_column :matches, :w1_name, :string
add_column :matches, :w2_name, :string

View File

@@ -1,4 +1,4 @@
class ChangeWNameToLoserName < ActiveRecord::Migration
class ChangeWNameToLoserName < ActiveRecord::Migration[4.2]
def change
rename_column :matches, :w1_name, :loser1_name
rename_column :matches, :w2_name, :loser2_name

View File

@@ -1,4 +1,4 @@
class DropMatchupsArray < ActiveRecord::Migration
class DropMatchupsArray < ActiveRecord::Migration[4.2]
def change
remove_column :tournaments, :matchups_array
end

View File

@@ -1,4 +1,4 @@
class AddTypeToTournament < ActiveRecord::Migration
class AddTypeToTournament < ActiveRecord::Migration[4.2]
def change
add_column :tournaments, :type, :text
end

View File

@@ -1,4 +1,4 @@
class RenameTypeToTournamentType < ActiveRecord::Migration
class RenameTypeToTournamentType < ActiveRecord::Migration[4.2]
def change
end
end

View File

@@ -1,4 +1,4 @@
class RenameTypeToTournamentTypeForReal < ActiveRecord::Migration
class RenameTypeToTournamentTypeForReal < ActiveRecord::Migration[4.2]
def change
rename_column :tournaments, :type, :tournament_type
end

View File

@@ -1,4 +1,4 @@
class RenameBoutNumber < ActiveRecord::Migration
class RenameBoutNumber < ActiveRecord::Migration[4.2]
def change
rename_column :matches, :boutNumber, :bout_number
end

View File

@@ -1,4 +1,4 @@
class IntroduceIndexes < ActiveRecord::Migration
class IntroduceIndexes < ActiveRecord::Migration[4.2]
def change
add_index :weights, :tournament_id
add_index :schools, :tournament_id

View File

@@ -1,4 +1,4 @@
class AddMatIdToMatch < ActiveRecord::Migration
class AddMatIdToMatch < ActiveRecord::Migration[4.2]
def change
add_column :matches, :mat_id, :integer
add_index :matches, :mat_id

View File

@@ -1,4 +1,4 @@
class AddOfficalWeightWrestlers < ActiveRecord::Migration
class AddOfficalWeightWrestlers < ActiveRecord::Migration[4.2]
def change
add_column :tournaments, :weigh_in_ref, :text
add_column :wrestlers, :offical_weight, :decimal

View File

@@ -1,4 +1,4 @@
class AddUserIdToTournaments < ActiveRecord::Migration
class AddUserIdToTournaments < ActiveRecord::Migration[4.2]
def change
add_column :tournaments, :user_id, :integer
add_index :tournaments, :user_id

View File

@@ -1,4 +1,4 @@
class CreateTeampointadjusts < ActiveRecord::Migration
class CreateTeampointadjusts < ActiveRecord::Migration[4.2]
def change
create_table :teampointadjusts do |t|
t.integer :points

View File

@@ -1,4 +1,4 @@
class AddScoreBackToSchool < ActiveRecord::Migration
class AddScoreBackToSchool < ActiveRecord::Migration[4.2]
def change
add_column :schools, :score, :decimal
end

View File

@@ -1,4 +1,4 @@
class RenameStats < ActiveRecord::Migration
class RenameStats < ActiveRecord::Migration[4.2]
def change
rename_column :matches, :g_stat, :w1_stat
rename_column :matches, :r_stat, :w2_stat

View File

@@ -1,4 +1,4 @@
class CreateDelayedJobs < ActiveRecord::Migration
class CreateDelayedJobs < ActiveRecord::Migration[4.2]
def self.up
create_table :delayed_jobs, force: true do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue

View File

@@ -1,4 +1,4 @@
class GeneratingMatches < ActiveRecord::Migration
class GeneratingMatches < ActiveRecord::Migration[4.2]
def change
add_column :tournaments, :curently_generating_matches, :integer
end

View File

@@ -1,4 +1,4 @@
class TournamentDate < ActiveRecord::Migration
class TournamentDate < ActiveRecord::Migration[4.2]
def change
add_column :tournaments, :date, :date
end

View File

@@ -1,4 +1,4 @@
class CreateTournamentDelegates < ActiveRecord::Migration
class CreateTournamentDelegates < ActiveRecord::Migration[4.2]
def change
create_table :tournament_delegates do |t|
t.integer :user_id

View File

@@ -1,4 +1,4 @@
class CreateSchoolDelegates < ActiveRecord::Migration
class CreateSchoolDelegates < ActiveRecord::Migration[4.2]
def change
create_table :school_delegates do |t|
t.integer :user_id

View File

@@ -1,4 +1,4 @@
class AddSchoolIdToTeampointsadjust < ActiveRecord::Migration
class AddSchoolIdToTeampointsadjust < ActiveRecord::Migration[4.2]
def change
add_column :teampointadjusts, :school_id, :integer
end

View File

@@ -0,0 +1,5 @@
class AddPoolColumn < ActiveRecord::Migration[4.2]
def change
add_column :wrestlers, :pool, :integer
end
end

View File

@@ -1,4 +1,3 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -11,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160126173424) do
ActiveRecord::Schema.define(version: 20170301174920) do
create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
@@ -25,10 +24,9 @@ ActiveRecord::Schema.define(version: 20160126173424) do
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
end
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority"
create_table "matches", force: :cascade do |t|
t.integer "w1"
t.integer "w2"
@@ -49,21 +47,19 @@ ActiveRecord::Schema.define(version: 20160126173424) do
t.string "loser1_name"
t.string "loser2_name"
t.integer "mat_id"
t.index ["mat_id"], name: "index_matches_on_mat_id"
t.index ["tournament_id"], name: "index_matches_on_tournament_id"
t.index ["w1", "w2"], name: "index_matches_on_w1_and_w2"
end
add_index "matches", ["mat_id"], name: "index_matches_on_mat_id"
add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id"
add_index "matches", ["w1", "w2"], name: "index_matches_on_w1_and_w2"
create_table "mats", force: :cascade do |t|
t.string "name"
t.integer "tournament_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["tournament_id"], name: "index_mats_on_tournament_id"
end
add_index "mats", ["tournament_id"], name: "index_mats_on_tournament_id"
create_table "school_delegates", force: :cascade do |t|
t.integer "user_id"
t.integer "school_id"
@@ -77,20 +73,18 @@ ActiveRecord::Schema.define(version: 20160126173424) do
t.datetime "updated_at"
t.integer "tournament_id"
t.decimal "score"
t.index ["tournament_id"], name: "index_schools_on_tournament_id"
end
add_index "schools", ["tournament_id"], name: "index_schools_on_tournament_id"
create_table "teampointadjusts", force: :cascade do |t|
t.integer "points"
t.integer "wrestler_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "school_id"
t.index ["wrestler_id"], name: "index_teampointadjusts_on_wrestler_id"
end
add_index "teampointadjusts", ["wrestler_id"], name: "index_teampointadjusts_on_wrestler_id"
create_table "tournament_delegates", force: :cascade do |t|
t.integer "user_id"
t.integer "tournament_id"
@@ -110,10 +104,9 @@ ActiveRecord::Schema.define(version: 20160126173424) do
t.integer "user_id"
t.integer "curently_generating_matches"
t.date "date"
t.index ["user_id"], name: "index_tournaments_on_user_id"
end
add_index "tournaments", ["user_id"], name: "index_tournaments_on_user_id"
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
@@ -127,20 +120,18 @@ ActiveRecord::Schema.define(version: 20160126173424) do
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
create_table "weights", force: :cascade do |t|
t.integer "max"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "tournament_id"
t.index ["tournament_id"], name: "index_weights_on_tournament_id"
end
add_index "weights", ["tournament_id"], name: "index_weights_on_tournament_id"
create_table "wrestlers", force: :cascade do |t|
t.string "name"
t.integer "school_id"
@@ -154,8 +145,8 @@ ActiveRecord::Schema.define(version: 20160126173424) do
t.string "criteria"
t.boolean "extra"
t.decimal "offical_weight"
t.integer "pool"
t.index ["weight_id"], name: "index_wrestlers_on_weight_id"
end
add_index "wrestlers", ["weight_id"], name: "index_wrestlers_on_weight_id"
end

View File

@@ -22,4 +22,4 @@ memcached:
worker:
image: wrestlingdev
command: /bin/bash -c "cd /var/www && bundle exec rake jobs:work RAILS_ENV=production"
command: /bin/bash -c "cd /rails && bundle exec rake jobs:work RAILS_ENV=production"

View File

@@ -1,4 +1,5 @@
app:
image: registry:5000/wrestlingdev:dev
extends:
file: docker-compose-common.yml
service: app
@@ -27,6 +28,7 @@ db:
restart: always
worker:
image: registry:5000/wrestlingdev:dev
extends:
file: docker-compose-common.yml
service: worker

9
frontend/.gitignore vendored
View File

@@ -1,9 +0,0 @@
.DS_Store
#ignore node_modules, as the node project is not "deployed" per se: http://www.mikealrogers.com/posts/nodemodules-in-git.html
/node_modules
/dist
/generated
.sass-cache

View File

@@ -1,9 +0,0 @@
.DS_Store
#ignore node_modules, as the node project is not "deployed" per se: http://www.mikealrogers.com/posts/nodemodules-in-git.html
/node_modules
/dist
/generated
.sass-cache

View File

@@ -1,4 +0,0 @@
language: node_js
node_js:
- 0.10
script: "lineman spec-ci"

View File

@@ -1,4 +0,0 @@
/*global module:false*/
module.exports = function(grunt) {
require('./config/lineman').config.grunt.run(grunt);
};

View File

@@ -1 +0,0 @@
web: npm run production

View File

@@ -1 +0,0 @@
# My Lineman Application

View File

@@ -1,4 +0,0 @@
.hello {
background-color: #efefef;
border: 1px solid #dedede;
}

View File

View File

View File

@@ -1,11 +0,0 @@
var app = angular.module("wrestlingdev", ["ngRoute","Devise"]).run(function($rootScope) {
// adds some basic utilities to the $rootScope for debugging purposes
$rootScope.log = function(thing) {
console.log(thing);
};
$rootScope.alert = function(thing) {
alert(thing);
};
});

View File

@@ -1,51 +0,0 @@
'use strict';
app.controller("loginController", function($scope, $routeParams, Auth, $rootScope) {
$scope.credentials = {
email: '',
password: ''
};
var config = {
headers: {
'X-HTTP-Method-Override': 'POST'
}
};
$scope.login = function(){
Auth.login($scope.credentials, config).then(function(user) {
console.log(user); // => {id: 1, ect: '...'}
$rootScope.user = user;
$rootScope.alertClass = "alert alert-success";
$rootScope.alertMessage = "Logged in successfully";
}, function(error) {
console.log(error);
$rootScope.alertClass = "alert alert-danger";
$rootScope.alertMessage = "Username and/or password is incorrect";
});
};
$scope.logout = function(){
Auth.logout(config).then(function(oldUser) {
// alert(oldUser.name + "you're signed out now.");
$rootScope.user = null;
$rootScope.alertClass = "alert alert-success";
$rootScope.alertMessage = "Logged out successfully";
}, function(error) {
// An error occurred logging out.
$rootScope.alertClass = "alert alert-danger";
$rootScope.alertMessage = "There was an error logging out";
});
};
Auth.currentUser().then(function(user) {
// User was logged in, or Devise returned
// previously authenticated session.
$rootScope.user = user;
}, function(error) {
// unauthenticated error
$rootScope.user = null;
});
});

View File

@@ -1,11 +0,0 @@
'use strict';
app.controller("myTournamentsController", function($scope, tournamentsService, $rootScope) {
tournamentsService.getMyTournaments().then(function(data) {
//this will execute when the
//AJAX call completes.
$scope.allTournaments = data;
});
});

View File

@@ -1,86 +0,0 @@
'use strict';
app.controller("tournamentController", function($scope, tournamentsService, $routeParams, Wrestler, Auth, $rootScope) {
$scope.message = "Test message in scope.";
// $scope.tournamentData = "test";
tournamentsService.tournamentDetails($routeParams.id).then(function(data) {
//this will execute when the
//AJAX call completes.
$scope.tournament = data;
});
$scope.refreshTournamentData = function(){
tournamentsService.tournamentDetails($routeParams.id).then(function(data) {
//this will execute when the
//AJAX call completes.
$scope.tournament = data;
});
};
// refresh tournament data every 10 seconds
// setInterval(function(){
// tournamentsService.tournamentDetails($routeParams.id).then(function(data) {
// //this will execute when the
// //AJAX call completes.
// $scope.tournament = data;
// });
// }, 10000);
$scope.wrestler = Wrestler;
$scope.showSchools = false;
$scope.toggleSchools = function(){
$scope.showSchools = !$scope.showSchools;
};
$scope.showWeightSeeds = false;
$scope.toggleWeightSeeds = function(){
$scope.showWeightSeeds = !$scope.showWeightSeeds;
};
$scope.showBoutBoard = false;
$scope.toggleBoutBoard = function(){
$scope.showBoutBoard = !$scope.showBoutBoard;
};
$scope.isTournamentOwner = function(tournamentId,userId){
if(userId == tournamentId){
return true;
} else {
return false;
}
};
$scope.newSchool = null;
$scope.saveNewSchool = function(){
$scope.newSchool.tournament_id = $scope.tournament.id;
tournamentsService.saveNewSchool($scope.newSchool).then(function(data) {
$scope.tournament.schools.push(data);
});
$scope.newSchool = null;
$('#NewSchool').modal('hide');
};
$scope.deleteSchool = function(school){
if (confirm('Are you sure you want to delete ' + school.name + '?')) {
tournamentsService.deleteSchool(school).then(function(data) {
$scope.tournament.schools.splice( $scope.tournament.schools.indexOf(school), 1 );
});
}
};
$scope.updateSchool = function(school){
tournamentsService.updateSchool(school);
$('#EditSchool' + school.id).modal('hide');
};
});

View File

@@ -1,19 +0,0 @@
'use strict';
app.controller("tournamentsController", function($scope, tournamentsService) {
tournamentsService.getAllTournaments().then(function(data) {
//this will execute when the
//AJAX call completes.
$scope.allTournaments = data;
});
$scope.searchTournaments = function (){
tournamentsService.searchTournaments($scope.searchTerms).then(function(data) {
//this will execute when the
//AJAX call completes.
$scope.allTournaments = data;
});
};
});

View File

@@ -1,24 +0,0 @@
(function(){
app.directive('usSpinner', ['$http', '$rootScope' ,function ($http, $rootScope){
return {
link: function (scope, elm, attrs)
{
$rootScope.spinnerActive = false;
scope.isLoading = function () {
return $http.pendingRequests.length > 0;
};
scope.$watch(scope.isLoading, function (loading)
{
$rootScope.spinnerActive = loading;
if(loading){
elm.removeClass('ng-hide');
}else{
elm.addClass('ng-hide');
}
});
}
};
}]);
}).call(this);

View File

@@ -1,18 +0,0 @@
'use strict';
app.factory('Wrestler', function Wrestler(){
var vm = this;
vm.matches = function(wrestler,matches){
console.log(matches);
return _.filter(matches, function(match){
return match.w1 == wrestler.id || match.w2 == wrestler.id;
});
};
return vm;
});

View File

@@ -1,49 +0,0 @@
// $routeProvider.when('/list-of-books', {
// templateUrl: 'angular/books.html',
// controller: 'BooksController'
// // uncomment if you want to see an example of a route that resolves a request prior to rendering
// // resolve: {
// // books : function(BookService) {
// // return BookService.get();
// // }
// // }
// });
app.config(['$routeProvider', '$locationProvider', function($routeProvider,$locationProvider) {
$routeProvider.when('/', {
templateUrl: 'home.html',
});
$routeProvider.when('/tournaments', {
templateUrl: 'tournaments-search.html',
controller: 'tournamentsController'
});
$routeProvider.when('/tournaments/user', {
templateUrl: 'my-tournaments.html',
controller: 'myTournamentsController'
});
$routeProvider.when('/tournaments/:id', {
templateUrl: 'tournaments-show.html',
controller: 'tournamentController'
});
$routeProvider.when('/about', {
templateUrl: 'about.html',
});
$routeProvider.when('/tutorials', {
templateUrl: 'tutorials.html',
});
$routeProvider.otherwise({redirectTo: '/'});
//this give me normal routes instead of /#/
// $locationProvider.html5Mode(true);
}]);

Some files were not shown because too many files have changed in this diff Show More