mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-27 03:30:54 +00:00
Lots of rails 4 updates
- Add .params to models and update controllers - Add afk time to gather - Reannotate models - Fix rspec problem by using latest rspec plugins from github
This commit is contained in:
parent
76faa4d18c
commit
e59e8ac8e7
89 changed files with 991 additions and 453 deletions
10
Gemfile
10
Gemfile
|
@ -38,6 +38,7 @@ gem 'dynamic_form'
|
||||||
gem 'public_suffix'
|
gem 'public_suffix'
|
||||||
gem 'sanitize'
|
gem 'sanitize'
|
||||||
gem 'will_paginate'
|
gem 'will_paginate'
|
||||||
|
gem 'time_difference'
|
||||||
|
|
||||||
# External APIs
|
# External APIs
|
||||||
gem 'google-api-client', '~> 0.10.3'
|
gem 'google-api-client', '~> 0.10.3'
|
||||||
|
@ -94,8 +95,6 @@ group :test do
|
||||||
gem 'factory_bot_rails', '4.10.0'
|
gem 'factory_bot_rails', '4.10.0'
|
||||||
gem 'phantomjs', require: 'phantomjs/poltergeist'
|
gem 'phantomjs', require: 'phantomjs/poltergeist'
|
||||||
gem 'poltergeist'
|
gem 'poltergeist'
|
||||||
gem 'rspec'
|
|
||||||
gem 'rspec-rails'
|
|
||||||
gem 'selenium-webdriver'
|
gem 'selenium-webdriver'
|
||||||
# Fix FF issue
|
# Fix FF issue
|
||||||
gem 'geckodriver-helper'
|
gem 'geckodriver-helper'
|
||||||
|
@ -104,6 +103,13 @@ group :test do
|
||||||
gem 'simplecov', require: false
|
gem 'simplecov', require: false
|
||||||
gem 'test-unit'
|
gem 'test-unit'
|
||||||
gem 'timecop'
|
gem 'timecop'
|
||||||
|
|
||||||
|
# Use dev versions because of rspec bug
|
||||||
|
gem 'rspec-core', git: 'https://github.com/rspec/rspec-core'
|
||||||
|
gem 'rspec-expectations', git: 'https://github.com/rspec/rspec-expectations'
|
||||||
|
gem 'rspec-mocks', git: 'https://github.com/rspec/rspec-mocks'
|
||||||
|
gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails'
|
||||||
|
gem 'rspec-support', git: 'https://github.com/rspec/rspec-support'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
73
Gemfile.lock
73
Gemfile.lock
|
@ -6,6 +6,48 @@ GIT
|
||||||
multi_json (~> 1.6)
|
multi_json (~> 1.6)
|
||||||
multi_xml (~> 0.5)
|
multi_xml (~> 0.5)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/rspec/rspec-core
|
||||||
|
revision: 725b0d2eadaa9ac9f816a6d2d7ef1e507a6705cd
|
||||||
|
specs:
|
||||||
|
rspec-core (3.10.0.pre)
|
||||||
|
rspec-support (= 3.10.0.pre)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/rspec/rspec-expectations
|
||||||
|
revision: 3c997d98f49731b2d28d01e070b88aef6bb3c68b
|
||||||
|
specs:
|
||||||
|
rspec-expectations (3.10.0.pre)
|
||||||
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
rspec-support (= 3.10.0.pre)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/rspec/rspec-mocks
|
||||||
|
revision: 81c17e89b2722cb225d602e08b600e4a4f6148a4
|
||||||
|
specs:
|
||||||
|
rspec-mocks (3.10.0.pre)
|
||||||
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
rspec-support (= 3.10.0.pre)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/rspec/rspec-rails
|
||||||
|
revision: 84e79259c8978fdff34ea2a327316b638ff00b85
|
||||||
|
specs:
|
||||||
|
rspec-rails (4.0.0.pre)
|
||||||
|
actionpack (>= 4.2)
|
||||||
|
activesupport (>= 4.2)
|
||||||
|
railties (>= 4.2)
|
||||||
|
rspec-core (= 3.10.0.pre)
|
||||||
|
rspec-expectations (= 3.10.0.pre)
|
||||||
|
rspec-mocks (= 3.10.0.pre)
|
||||||
|
rspec-support (= 3.10.0.pre)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/rspec/rspec-support
|
||||||
|
revision: 9cec8e858228ee1d1395e4e6186ac39c2a83d705
|
||||||
|
specs:
|
||||||
|
rspec-support (3.10.0.pre)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -306,27 +348,6 @@ GEM
|
||||||
retriable (3.1.2)
|
retriable (3.1.2)
|
||||||
rexml (3.2.4)
|
rexml (3.2.4)
|
||||||
rmagick (4.0.0)
|
rmagick (4.0.0)
|
||||||
rspec (3.9.0)
|
|
||||||
rspec-core (~> 3.9.0)
|
|
||||||
rspec-expectations (~> 3.9.0)
|
|
||||||
rspec-mocks (~> 3.9.0)
|
|
||||||
rspec-core (3.9.1)
|
|
||||||
rspec-support (~> 3.9.1)
|
|
||||||
rspec-expectations (3.9.1)
|
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
|
||||||
rspec-support (~> 3.9.0)
|
|
||||||
rspec-mocks (3.9.1)
|
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
|
||||||
rspec-support (~> 3.9.0)
|
|
||||||
rspec-rails (3.9.1)
|
|
||||||
actionpack (>= 3.0)
|
|
||||||
activesupport (>= 3.0)
|
|
||||||
railties (>= 3.0)
|
|
||||||
rspec-core (~> 3.9.0)
|
|
||||||
rspec-expectations (~> 3.9.0)
|
|
||||||
rspec-mocks (~> 3.9.0)
|
|
||||||
rspec-support (~> 3.9.0)
|
|
||||||
rspec-support (3.9.2)
|
|
||||||
rubocop (0.80.1)
|
rubocop (0.80.1)
|
||||||
jaro_winkler (~> 1.5.1)
|
jaro_winkler (~> 1.5.1)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
|
@ -384,6 +405,8 @@ GEM
|
||||||
thor (1.0.1)
|
thor (1.0.1)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.10)
|
tilt (2.0.10)
|
||||||
|
time_difference (0.5.0)
|
||||||
|
activesupport
|
||||||
timecop (0.9.1)
|
timecop (0.9.1)
|
||||||
tinymce-rails (5.2.0)
|
tinymce-rails (5.2.0)
|
||||||
railties (>= 3.1.1)
|
railties (>= 3.1.1)
|
||||||
|
@ -454,8 +477,11 @@ DEPENDENCIES
|
||||||
rake (< 11.0)
|
rake (< 11.0)
|
||||||
responders
|
responders
|
||||||
rmagick
|
rmagick
|
||||||
rspec
|
rspec-core!
|
||||||
rspec-rails
|
rspec-expectations!
|
||||||
|
rspec-mocks!
|
||||||
|
rspec-rails!
|
||||||
|
rspec-support!
|
||||||
rubocop
|
rubocop
|
||||||
sanitize
|
sanitize
|
||||||
sass-rails (~> 5.0.3)
|
sass-rails (~> 5.0.3)
|
||||||
|
@ -465,6 +491,7 @@ DEPENDENCIES
|
||||||
spring (= 2.0.2)
|
spring (= 2.0.2)
|
||||||
steam-condenser!
|
steam-condenser!
|
||||||
test-unit
|
test-unit
|
||||||
|
time_difference
|
||||||
timecop
|
timecop
|
||||||
tinymce-rails
|
tinymce-rails
|
||||||
uglifier (~> 2.5.0)
|
uglifier (~> 2.5.0)
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ArticlesController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @article.can_update? cuser, Article.article_params(params, cuser)
|
raise AccessError unless @article.can_update? cuser, Article.article_params(params, cuser)
|
||||||
if @article.update_attributes(article_params)
|
if @article.update_attributes(Article.article_params(params, cuser))
|
||||||
flash[:notice] = t(:articles_update)
|
flash[:notice] = t(:articles_update)
|
||||||
redirect_to @article
|
redirect_to @article
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,7 +18,7 @@ class BansController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@ban = Ban.new(params[:ban])
|
@ban = Ban.new(Ban.params(params, cuser))
|
||||||
raise AccessError unless @ban.can_create? cuser
|
raise AccessError unless @ban.can_create? cuser
|
||||||
@ban.creator = cuser
|
@ban.creator = cuser
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BansController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @ban.can_update? cuser
|
raise AccessError unless @ban.can_update? cuser
|
||||||
if @ban.update_attributes(ban_params(ban_params))
|
if @ban.update_attributes(Ban.params(params, cuser))
|
||||||
flash[:notice] = t(:bans_update)
|
flash[:notice] = t(:bans_update)
|
||||||
redirect_to(@ban)
|
redirect_to(@ban)
|
||||||
else
|
else
|
||||||
|
@ -51,8 +51,4 @@ class BansController < ApplicationController
|
||||||
def get_ban
|
def get_ban
|
||||||
@ban = Ban.find(params[:id])
|
@ban = Ban.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def ban_params
|
|
||||||
params.permit(:steamid, :user_id, :addr, :server_id, :expiry, :reason, :ban_type, :ip)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ class BracketsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@bracket = Bracket.new params[:bracket]
|
@bracket = Bracket.new Bracket.params(params, cuser)
|
||||||
raise AccessError unless @bracket.can_create? cuser
|
raise AccessError unless @bracket.can_create? cuser
|
||||||
|
|
||||||
if @bracket.save
|
if @bracket.save
|
||||||
|
@ -20,7 +20,7 @@ class BracketsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @bracket.can_update? cuser
|
raise AccessError unless @bracket.can_update? cuser
|
||||||
|
|
||||||
if @bracket.update_attributes params[:bracket] and @bracket.update_cells(params[:cell])
|
if @bracket.update_attributes(Bracket.params(params, cuser)) and @bracket.update_cells(params.permit(:cell)[:cell])
|
||||||
flash[:notice] = t(:brackets_update)
|
flash[:notice] = t(:brackets_update)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,11 @@ class CategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@category = Category.new params[:category]
|
@category = Category.new Category.params(params, cuser)
|
||||||
raise AccessError unless @category.can_create? cuser
|
raise AccessError unless @category.can_create? cuser
|
||||||
|
|
||||||
if @category.save
|
if @category.save
|
||||||
|
# FIXME: move to model
|
||||||
@category.update_attribute :sort, @category.id
|
@category.update_attribute :sort, @category.id
|
||||||
flash[:notice] = t(:articles_category)
|
flash[:notice] = t(:articles_category)
|
||||||
redirect_to :categories
|
redirect_to :categories
|
||||||
|
@ -37,7 +38,7 @@ class CategoriesController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @category.can_update? cuser
|
raise AccessError unless @category.can_update? cuser
|
||||||
if @category.update_attributes params[:category]
|
if @category.update_attributes Category.params(params, cuser)
|
||||||
flash[:notice] = t(:articles_category_update)
|
flash[:notice] = t(:articles_category_update)
|
||||||
redirect_to :categories
|
redirect_to :categories
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ChallengesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@challenge = Challenge.new params[:challenge]
|
@challenge = Challenge.new(Challenge.params(params, cuser))
|
||||||
@challenge.user = cuser
|
@challenge.user = cuser
|
||||||
raise AccessError unless @challenge.can_create? cuser
|
raise AccessError unless @challenge.can_create? cuser
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class ChallengesController < ApplicationController
|
||||||
@challenge.status = Challenge::STATUS_DECLINED
|
@challenge.status = Challenge::STATUS_DECLINED
|
||||||
end
|
end
|
||||||
|
|
||||||
if @challenge.update_attributes params[:challenge]
|
if @challenge.update_attributes(Challenge.params(params, cuser))
|
||||||
flash[:notice] = t(:challenges_update)
|
flash[:notice] = t(:challenges_update)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class CommentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@comment = Comment.new params[:comment]
|
@comment = Comment.new Comment.params(parmas, cuser)
|
||||||
@comment.user = cuser
|
@comment.user = cuser
|
||||||
raise AccessError unless @comment.can_create? cuser
|
raise AccessError unless @comment.can_create? cuser
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class CommentsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @comment.can_update? cuser
|
raise AccessError unless @comment.can_update? cuser
|
||||||
if @comment.update_attributes params[:comment]
|
if @comment.update_attributes(Comment.params(parmas, cuser))
|
||||||
flash[:notice] = t(:comments_update)
|
flash[:notice] = t(:comments_update)
|
||||||
return_to
|
return_to
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ContestersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@contester = Contester.new params[:contester]
|
@contester = Contester.new(Contester.params(params, cuser))
|
||||||
@contester.user = cuser
|
@contester.user = cuser
|
||||||
raise AccessError unless @contester.can_create? cuser
|
raise AccessError unless @contester.can_create? cuser
|
||||||
if @contester.contest.contest_type == Contest::TYPE_LADDER
|
if @contester.contest.contest_type == Contest::TYPE_LADDER
|
||||||
|
@ -48,7 +48,7 @@ class ContestersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @contester.update_attributes params[:contester]
|
if @contester.update_attributes(Contester.params(params, cuser))
|
||||||
flash[:notice] = t(:contests_contester_update)
|
flash[:notice] = t(:contests_contester_update)
|
||||||
redirect_to @contester.contest
|
redirect_to @contester.contest
|
||||||
else
|
else
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ContestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@contest = Contest.new params[:contest]
|
@contest = Contest.new(Contest.params(params, cuser))
|
||||||
raise AccessError unless @contest.can_create? cuser
|
raise AccessError unless @contest.can_create? cuser
|
||||||
|
|
||||||
if @contest.save
|
if @contest.save
|
||||||
|
@ -67,7 +67,7 @@ class ContestsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @contest.can_update? cuser
|
raise AccessError unless @contest.can_update? cuser
|
||||||
if update_type == "contest"
|
if update_type == "contest"
|
||||||
if @contest.update_attributes(params[:contest])
|
if @contest.update_attributes(Contest.params(params, cuser))
|
||||||
flash[:notice] = t(:contests_update)
|
flash[:notice] = t(:contests_update)
|
||||||
redirect_to @contest
|
redirect_to @contest
|
||||||
else
|
else
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DataFilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@file = DataFile.new params[:data_file]
|
@file = DataFile.new(DataFile.params(params, cuser))
|
||||||
@file.size = 0
|
@file.size = 0
|
||||||
raise AccessError unless @file.can_create? cuser
|
raise AccessError unless @file.can_create? cuser
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class DataFilesController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @file.can_update? cuser
|
raise AccessError unless @file.can_update? cuser
|
||||||
if @file.update_attributes params[:data_file]
|
if @file.update_attributes(DataFile.params(params, cuser))
|
||||||
flash[:notice] = t(:files_update)
|
flash[:notice] = t(:files_update)
|
||||||
redirect_to(@file)
|
redirect_to(@file)
|
||||||
else
|
else
|
||||||
|
|
|
@ -26,7 +26,7 @@ class DirectoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@directory = Directory.new params[:directory]
|
@directory = Directory.new(Directory.params(params, cuser))
|
||||||
raise AccessError unless @directory.can_create? cuser
|
raise AccessError unless @directory.can_create? cuser
|
||||||
|
|
||||||
if @directory.save
|
if @directory.save
|
||||||
|
@ -39,7 +39,7 @@ class DirectoriesController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @directory.can_update? cuser
|
raise AccessError unless @directory.can_update? cuser
|
||||||
if @directory.update_attributes(params[:directory])
|
if @directory.update_attributes(Directory.params(params, cuser))
|
||||||
flash[:notice] = t(:directories_update)
|
flash[:notice] = t(:directories_update)
|
||||||
redirect_to @directory
|
redirect_to @directory
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class ForumersController < ApplicationController
|
class ForumersController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@forumer = Forumer.new params[:forumer]
|
@forumer = Forumer.new(Forumer.params(params, cuser))
|
||||||
raise AccessError unless @forumer.can_create? cuser
|
raise AccessError unless @forumer.can_create? cuser
|
||||||
|
|
||||||
if @forumer.save
|
if @forumer.save
|
||||||
|
@ -16,7 +16,7 @@ class ForumersController < ApplicationController
|
||||||
@forumer = Forumer.find params[:id]
|
@forumer = Forumer.find params[:id]
|
||||||
raise AccessError unless @forumer.can_update? cuser
|
raise AccessError unless @forumer.can_update? cuser
|
||||||
|
|
||||||
if @forumer.update_attributes params[:forumer]
|
if @forumer.update_attributes(Forumer.params(params, cuser))
|
||||||
flash[:notice] = t(:groups_acl_update)
|
flash[:notice] = t(:groups_acl_update)
|
||||||
else
|
else
|
||||||
flash[:error] = @forumer.errors.full_messages.to_s
|
flash[:error] = @forumer.errors.full_messages.to_s
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ForumsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@forum = Forum.new(params[:forum])
|
@forum = Forum.new(Forum.params(params, cuser))
|
||||||
raise AccessError unless @forum.can_create? cuser
|
raise AccessError unless @forum.can_create? cuser
|
||||||
|
|
||||||
if @forum.save
|
if @forum.save
|
||||||
|
@ -44,7 +44,7 @@ class ForumsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @forum.can_update? cuser
|
raise AccessError unless @forum.can_update? cuser
|
||||||
if @forum.update_attributes(params[:forum])
|
if @forum.update_attributes(Forum.params(params, cuser))
|
||||||
flash[:notice] = t(:forums_update)
|
flash[:notice] = t(:forums_update)
|
||||||
redirect_to(@forum)
|
redirect_to(@forum)
|
||||||
else
|
else
|
||||||
|
|
|
@ -4,9 +4,9 @@ class GatherersController < ApplicationController
|
||||||
def create
|
def create
|
||||||
Gather.transaction do
|
Gather.transaction do
|
||||||
Gatherer.transaction do
|
Gatherer.transaction do
|
||||||
@gatherer = Gatherer.new params[:gatherer]
|
@gatherer = Gatherer.new(Gatherer.params(params, cuser))
|
||||||
@gatherer.gather.lock!
|
@gatherer.gather.lock!
|
||||||
raise AccessError unless @gatherer.can_create? cuser, params[:gatherer]
|
raise AccessError unless @gatherer.can_create?(cuser, Gatherer.params(params, cuser))
|
||||||
|
|
||||||
if @gatherer.save
|
if @gatherer.save
|
||||||
flash[:notice] = t(:gathers_join)
|
flash[:notice] = t(:gathers_join)
|
||||||
|
@ -21,9 +21,9 @@ class GatherersController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@gatherer = Gatherer.find params[:gatherer][:id]
|
@gatherer = Gatherer.find params[:gatherer][:id]
|
||||||
raise AccessError unless @gatherer.can_update? cuser, params[:gatherer]
|
raise AccessError unless @gatherer.can_update?(cuser, Gatherer.params(params, cuser))
|
||||||
|
|
||||||
if @gatherer.update_attributes params[:gatherer]
|
if @gatherer.update_attributes(Gatherer.params(params, cuser))
|
||||||
flash[:notice] = t(:gatherers_update)
|
flash[:notice] = t(:gatherers_update)
|
||||||
else
|
else
|
||||||
flash[:error] = @gatherer.errors.full_messages.to_s
|
flash[:error] = @gatherer.errors.full_messages.to_s
|
||||||
|
|
|
@ -37,7 +37,7 @@ class GathersController < ApplicationController
|
||||||
|
|
||||||
Gatherer.transaction do
|
Gatherer.transaction do
|
||||||
Gather.transaction do
|
Gather.transaction do
|
||||||
if @gather.update_attributes params[:gather]
|
if @gather.update_attributes(Gather.params(params, cuser))
|
||||||
flash[:notice] = 'Gather was successfully updated.'
|
flash[:notice] = 'Gather was successfully updated.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class GroupersController < ApplicationController
|
class GroupersController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@grouper = Grouper.new params[:grouper]
|
@grouper = Grouper.new(Grouper.params(params, cuser))
|
||||||
raise AccessError unless @grouper.can_create? cuser
|
raise AccessError unless @grouper.can_create? cuser
|
||||||
|
|
||||||
if @grouper.save
|
if @grouper.save
|
||||||
|
@ -16,7 +16,7 @@ class GroupersController < ApplicationController
|
||||||
@grouper = Grouper.find params[:id]
|
@grouper = Grouper.find params[:id]
|
||||||
raise AccessError unless @grouper.can_update? cuser
|
raise AccessError unless @grouper.can_update? cuser
|
||||||
|
|
||||||
if @grouper.update_attributes params[:grouper]
|
if @grouper.update_attributes(Grouper.params(params, cuser))
|
||||||
flash[:notice] = t(:groups_user_update)
|
flash[:notice] = t(:groups_user_update)
|
||||||
else
|
else
|
||||||
flash[:error] = @grouper.errors.full_messages.to_s
|
flash[:error] = @grouper.errors.full_messages.to_s
|
||||||
|
|
|
@ -19,7 +19,7 @@ class GroupsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@group = Group.new params[:group]
|
@group = Group.new(Group.params(params, cuser))
|
||||||
@group.founder = cuser
|
@group.founder = cuser
|
||||||
raise AccessError unless @group.can_create? cuser
|
raise AccessError unless @group.can_create? cuser
|
||||||
if @group.save
|
if @group.save
|
||||||
|
@ -32,7 +32,7 @@ class GroupsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @group.can_update? cuser
|
raise AccessError unless @group.can_update? cuser
|
||||||
if @group.update_attributes params[:group]
|
if @group.update_attributes(Group.params(params, cuser))
|
||||||
flash[:notice] = t(:groups_update)
|
flash[:notice] = t(:groups_update)
|
||||||
redirect_to @group
|
redirect_to @group
|
||||||
else
|
else
|
||||||
|
|
|
@ -36,7 +36,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@issue = Issue.new(params[:issue])
|
@issue = Issue.new(Issue.params(params, cuser))
|
||||||
@issue.author = cuser if cuser
|
@issue.author = cuser if cuser
|
||||||
raise AccessError unless @issue.can_create? cuser
|
raise AccessError unless @issue.can_create? cuser
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @issue.can_update?(cuser, params[:issue])
|
raise AccessError unless @issue.can_update?(cuser, params[:issue])
|
||||||
if @issue.update_attributes(params[:issue])
|
if @issue.update_attributes(Issue.params(params, cuser))
|
||||||
flash[:notice] = t(:issues_update)
|
flash[:notice] = t(:issues_update)
|
||||||
redirect_to(@issue)
|
redirect_to(@issue)
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class LocksController < ApplicationController
|
class LocksController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@lock = Lock.new params[:lock]
|
@lock = Lock.new(Lock.params(params, cuser))
|
||||||
raise AccessError unless @lock.can_create? cuser
|
raise AccessError unless @lock.can_create? cuser
|
||||||
|
|
||||||
if @lock.save
|
if @lock.save
|
||||||
|
|
|
@ -18,7 +18,7 @@ class MapsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@map = Map.new params[:map]
|
@map = Map.new(Map.params(params, cuser))
|
||||||
raise AccessError unless @map.can_create? cuser
|
raise AccessError unless @map.can_create? cuser
|
||||||
|
|
||||||
if @map.save
|
if @map.save
|
||||||
|
@ -31,7 +31,7 @@ class MapsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @map.can_update? cuser
|
raise AccessError unless @map.can_update? cuser
|
||||||
if @map.update_attributes(params[:map])
|
if @map.update_attributes(Map.params(params, cuser))
|
||||||
flash[:notice] = t(:maps_update)
|
flash[:notice] = t(:maps_update)
|
||||||
redirect_to @map
|
redirect_to @map
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class MatchProposalsController < ApplicationController
|
class MatchProposalsController < ApplicationController
|
||||||
before_action :get_match
|
before_action :get_match
|
||||||
|
|
||||||
def index
|
def index
|
||||||
raise AccessError unless cuser.admin? || @match.user_in_match?(cuser)
|
raise AccessError unless cuser.admin? || @match.user_in_match?(cuser)
|
||||||
end
|
end
|
||||||
|
@ -19,7 +20,7 @@ class MatchProposalsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@proposal = MatchProposal.new(params[:match_proposal])
|
@proposal = MatchProposal.new(MatchProposal.params(params, cuser))
|
||||||
@proposal.match = @match
|
@proposal.match = @match
|
||||||
raise AccessError unless @proposal.can_create? cuser
|
raise AccessError unless @proposal.can_create? cuser
|
||||||
@proposal.team = cuser.team
|
@proposal.team = cuser.team
|
||||||
|
@ -49,7 +50,7 @@ class MatchProposalsController < ApplicationController
|
||||||
}
|
}
|
||||||
render(json: rjson, status: :not_found) && return
|
render(json: rjson, status: :not_found) && return
|
||||||
end
|
end
|
||||||
unless proposal.can_update?(cuser, params[:match_proposal])
|
unless proposal.can_update?(cuser, MatchProposal.params(params, cuser))
|
||||||
rjson[:error] = {
|
rjson[:error] = {
|
||||||
code: 403,
|
code: 403,
|
||||||
message: "You are not allowed to update the state to #{MatchProposal.status_strings[params[:match_proposal][:status].to_i]}"
|
message: "You are not allowed to update the state to #{MatchProposal.status_strings[params[:match_proposal][:status].to_i]}"
|
||||||
|
|
|
@ -6,7 +6,7 @@ class MatchesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ownpred = @match.predictions.first conditions: { user_id: cuser.id } if cuser
|
@ownpred = @match.predictions.where(user_id: cuser.id) if cuser
|
||||||
@newpred = @match.predictions.build
|
@newpred = @match.predictions.build
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class MatchesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@match = Match.new params[:match]
|
@match = Match.new(Match.params(params, cuser))
|
||||||
raise AccessError unless @match.can_create? cuser
|
raise AccessError unless @match.can_create? cuser
|
||||||
|
|
||||||
if @match.save
|
if @match.save
|
||||||
|
@ -59,7 +59,7 @@ class MatchesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @match.update_attributes params[:match]
|
if @match.update_attributes(Match.params(params, cuser))
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
format.html do
|
format.html do
|
||||||
|
|
|
@ -29,7 +29,7 @@ class MessagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@message = Message.new(params[:message])
|
@message = Message.new(Message.params(params, cuser))
|
||||||
@message.sender = @message.sender_raw == "" ? cuser : cuser.active_teams.find(@message.sender_raw)
|
@message.sender = @message.sender_raw == "" ? cuser : cuser.active_teams.find(@message.sender_raw)
|
||||||
raise AccessError unless @message.can_create? cuser
|
raise AccessError unless @message.can_create? cuser
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class MoviesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@movie = Movie.new(params[:movie])
|
@movie = Movie.new(Movie.params(params, cuser))
|
||||||
raise AccessError unless @movie.can_create? cuser
|
raise AccessError unless @movie.can_create? cuser
|
||||||
|
|
||||||
if @movie.save
|
if @movie.save
|
||||||
|
@ -39,7 +39,7 @@ class MoviesController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @movie.can_update? cuser
|
raise AccessError unless @movie.can_update? cuser
|
||||||
|
|
||||||
if @movie.update_attributes(params[:movie])
|
if @movie.update_attributes(Movie.params(params, cuser))
|
||||||
flash[:notice] = t(:movies_update)
|
flash[:notice] = t(:movies_update)
|
||||||
redirect_to(@movie)
|
redirect_to(@movie)
|
||||||
else
|
else
|
||||||
|
|
|
@ -6,7 +6,7 @@ class PollsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@poll = Poll.new params[:poll]
|
@poll = Poll.new(Poll.params(params, cuser))
|
||||||
@poll.user = cuser
|
@poll.user = cuser
|
||||||
raise AccessError unless @poll.can_create? cuser
|
raise AccessError unless @poll.can_create? cuser
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class PollsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @poll.can_update? cuser
|
raise AccessError unless @poll.can_update? cuser
|
||||||
|
|
||||||
if @poll.update_attributes params[:poll]
|
if @poll.update_attributes(Poll.params(params, cuser))
|
||||||
flash[:notice] = t(:polls_update)
|
flash[:notice] = t(:polls_update)
|
||||||
redirect_to @poll
|
redirect_to @poll
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,7 @@ class PollsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@poll = Poll.new params[:poll]
|
@poll = Poll.new(Poll.params(params, cuser))
|
||||||
@poll.user = cuser
|
@poll.user = cuser
|
||||||
raise AccessError unless @poll.can_create? cuser
|
raise AccessError unless @poll.can_create? cuser
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class PollsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @poll.can_update? cuser
|
raise AccessError unless @poll.can_update? cuser
|
||||||
|
|
||||||
if @poll.update_attributes params[:poll]
|
if @poll.update_attributes(Poll.params(params, cuser))
|
||||||
flash[:notice] = t(:polls_update)
|
flash[:notice] = t(:polls_update)
|
||||||
redirect_to @poll
|
redirect_to @poll
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,7 @@ class PostsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@post = Post.new(params[:post])
|
@post = Post.new(Post.params(params, cuser))
|
||||||
@post.user = cuser
|
@post.user = cuser
|
||||||
raise AccessError unless @post.can_create? cuser
|
raise AccessError unless @post.can_create? cuser
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class PostsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @post.can_update? cuser, params[:post]
|
raise AccessError unless @post.can_update? cuser, params[:post]
|
||||||
if @post.update_attributes(params[:post])
|
if @post.update_attributes(Post.params(params, cuser))
|
||||||
flash[:notice] = t(:posts_update)
|
flash[:notice] = t(:posts_update)
|
||||||
redirect_to @post.topic
|
redirect_to @post.topic
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class PredictionsController < ApplicationController
|
class PredictionsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@prediction = Prediction.new params[:prediction]
|
@prediction = Prediction.new(Prediction.params(params, cuser))
|
||||||
@prediction.user = cuser
|
@prediction.user = cuser
|
||||||
raise AccessError unless @prediction.can_create? cuser
|
raise AccessError unless @prediction.can_create? cuser
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ServersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@server = Server.new params[:server]
|
@server = Server.new(Server.params(params, cuser))
|
||||||
@server.user = cuser
|
@server.user = cuser
|
||||||
raise AccessError unless @server.can_create? cuser
|
raise AccessError unless @server.can_create? cuser
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class ServersController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @server.can_update? cuser
|
raise AccessError unless @server.can_update? cuser
|
||||||
|
|
||||||
if @server.update_attributes params[:server]
|
if @server.update_attributes(Server.params(params, cuser))
|
||||||
flash[:notice] = t(:server_update)
|
flash[:notice] = t(:server_update)
|
||||||
redirect_to @server
|
redirect_to @server
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,7 +14,7 @@ class ShoutmsgsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@shoutmsg = Shoutmsg.new params[:shoutmsg]
|
@shoutmsg = Shoutmsg.new(Shoutmsg.params(params, cuser))
|
||||||
@shoutmsg.user = cuser
|
@shoutmsg.user = cuser
|
||||||
raise AccessError unless @shoutmsg.can_create? cuser
|
raise AccessError unless @shoutmsg.can_create? cuser
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ class TeamersController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@old_application = (cuser.teamers.joining.count == 0) ? nil : cuser.teamers.joining.first
|
@old_application = (cuser.teamers.joining.count == 0) ? nil : cuser.teamers.joining.first
|
||||||
@teamer = Teamer.new params[:teamer]
|
@teamer = Teamer.new(Teamer.params(params, cuser))
|
||||||
raise AccessError unless @teamer.can_create? cuser, params[:teamer]
|
raise AccessError unless @teamer.can_create?(cuser, Teamer.params(params, cuser))
|
||||||
@teamer.user = cuser unless cuser.admin?
|
@teamer.user = cuser unless cuser.admin?
|
||||||
|
|
||||||
if @teamer.save
|
if @teamer.save
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TeamsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@team = Team.new params[:team]
|
@team = Team.new(Team.params(params, cuser))
|
||||||
@team.founder = cuser
|
@team.founder = cuser
|
||||||
raise AccessError unless @team.can_create? cuser
|
raise AccessError unless @team.can_create? cuser
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class TeamsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @team.can_update? cuser
|
raise AccessError unless @team.can_update? cuser
|
||||||
if @team.update_attributes params[:team]
|
if @team.update_attributes(Team.params(params, cuser))
|
||||||
if params[:rank]
|
if params[:rank]
|
||||||
@team.teamers.present.each do |member|
|
@team.teamers.present.each do |member|
|
||||||
# Contains new rank as given by submitted parameters
|
# Contains new rank as given by submitted parameters
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@topic = Topic.new(params[:topic])
|
@topic = Topic.new(Topic.params(params, cuser))
|
||||||
@topic.user = cuser
|
@topic.user = cuser
|
||||||
raise AccessError unless @topic.can_create? cuser
|
raise AccessError unless @topic.can_create? cuser
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,8 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@user = User.new params[:user]
|
@user = User.new(User.params(params, cuser))
|
||||||
|
# FIXME: move to model
|
||||||
@user.lastvisit = Date.today
|
@user.lastvisit = Date.today
|
||||||
@user.lastip = request.env['REMOTE_ADDR']
|
@user.lastip = request.env['REMOTE_ADDR']
|
||||||
|
|
||||||
|
@ -72,8 +73,9 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @user.can_update? cuser
|
raise AccessError unless @user.can_update? cuser
|
||||||
|
# FIXME: use permit
|
||||||
params[:user].delete(:username) unless @user.can_change_name? cuser
|
params[:user].delete(:username) unless @user.can_change_name? cuser
|
||||||
if @user.update_attributes params[:user]
|
if @user.update_attributes(User.params(params, cuser))
|
||||||
flash[:notice] = t(:users_update)
|
flash[:notice] = t(:users_update)
|
||||||
redirect_to_back
|
redirect_to_back
|
||||||
else
|
else
|
||||||
|
@ -127,10 +129,6 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def user_params
|
|
||||||
params.require(:user).permit(:raw_password, :firstname, :lastname, :email, :steamid, :country, :birthdate, :timezone, :public_email, :filter)
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_user
|
def get_user
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class VotesController < ApplicationController
|
class VotesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@vote = Vote.new(params[:vote])
|
@vote = Vote.new(Vote.params(params, cuser))
|
||||||
@vote.user = cuser
|
@vote.user = cuser
|
||||||
raise AccessError unless @vote.can_create? cuser
|
raise AccessError unless @vote.can_create? cuser
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class WeeksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@week = Week.new(params[:week])
|
@week = Week.new(Weeks.params(params, cuser))
|
||||||
raise AccessError unless @week.can_create? cuser
|
raise AccessError unless @week.can_create? cuser
|
||||||
|
|
||||||
if @week.save
|
if @week.save
|
||||||
|
@ -26,7 +26,7 @@ class WeeksController < ApplicationController
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @week.can_update? cuser
|
raise AccessError unless @week.can_update? cuser
|
||||||
|
|
||||||
if @week.update_attributes(params[:week])
|
if @week.update_attributes(Week.params(params, cuser))
|
||||||
flash[:notice] = t(:weeks_update)
|
flash[:notice] = t(:weeks_update)
|
||||||
redirect_to @week.contest
|
redirect_to @week.contest
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,16 +3,23 @@
|
||||||
# Table name: articles
|
# Table name: articles
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# title :string(255)
|
|
||||||
# status :integer not null
|
# status :integer not null
|
||||||
# category_id :integer
|
|
||||||
# text :text(16777215)
|
# text :text(16777215)
|
||||||
# user_id :integer
|
# text_coding :integer default("0"), not null
|
||||||
|
# text_parsed :text(16777215)
|
||||||
|
# title :string(255)
|
||||||
|
# version :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# version :integer
|
# category_id :integer
|
||||||
# text_parsed :text(16777215)
|
# user_id :integer
|
||||||
# text_coding :integer default(0), not null
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_articles_on_category_id (category_id)
|
||||||
|
# index_articles_on_created_at (created_at)
|
||||||
|
# index_articles_on_created_at_and_status (created_at,status)
|
||||||
|
# index_articles_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Article < ActiveRecord::Base
|
class Article < ActiveRecord::Base
|
||||||
|
|
|
@ -3,17 +3,24 @@
|
||||||
# Table name: bans
|
# Table name: bans
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# steamid :string(255)
|
|
||||||
# user_id :integer
|
|
||||||
# addr :string(255)
|
# addr :string(255)
|
||||||
# server_id :integer
|
# ban_type :integer
|
||||||
# expiry :datetime
|
# expiry :datetime
|
||||||
|
# ip :string(255)
|
||||||
# reason :string(255)
|
# reason :string(255)
|
||||||
|
# steamid :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# ban_type :integer
|
|
||||||
# ip :string(255)
|
|
||||||
# creator_id :integer
|
# creator_id :integer
|
||||||
|
# server_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_bans_on_creator_id (creator_id)
|
||||||
|
# index_bans_on_server_id (server_id)
|
||||||
|
# index_bans_on_user_id (user_id)
|
||||||
|
#
|
||||||
|
|
||||||
class Ban < ActiveRecord::Base
|
class Ban < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
@ -96,4 +103,8 @@ class Ban < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and (cuser.admin? or (self.creator == cuser and cuser.allowed_to_ban?))
|
cuser and (cuser.admin? or (self.creator == cuser and cuser.allowed_to_ban?))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params params, cuser
|
||||||
|
params.require(:ban).permit(:steamid, :user_id, :addr, :server_id, :expiry, :reason, :ban_type, :ip)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,15 @@
|
||||||
# Table name: brackets
|
# Table name: brackets
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# contest_id :integer
|
# name :string(255)
|
||||||
# slots :integer
|
# slots :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# name :string(255)
|
# contest_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_brackets_on_contest_id (contest_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Bracket < ActiveRecord::Base
|
class Bracket < ActiveRecord::Base
|
||||||
|
@ -78,4 +82,8 @@ class Bracket < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params params, cuser
|
||||||
|
params.require(:bracket).permit(:contest_id, :slots, :name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,13 +3,18 @@
|
||||||
# Table name: bracketers
|
# Table name: bracketers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# bracket_id :integer
|
|
||||||
# column :integer
|
# column :integer
|
||||||
# row :integer
|
# row :integer
|
||||||
# match_id :integer
|
|
||||||
# team_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# bracket_id :integer
|
||||||
|
# match_id :integer
|
||||||
|
# team_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_bracketers_on_match_id (match_id)
|
||||||
|
# index_bracketers_on_team_id (team_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Bracketer < ActiveRecord::Base
|
class Bracketer < ActiveRecord::Base
|
||||||
|
|
|
@ -3,11 +3,16 @@
|
||||||
# Table name: categories
|
# Table name: categories
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
|
# domain :integer
|
||||||
# name :string(255)
|
# name :string(255)
|
||||||
# sort :integer
|
# sort :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# domain :integer
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_categories_on_domain (domain)
|
||||||
|
# index_categories_on_sort (sort)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Category < ActiveRecord::Base
|
class Category < ActiveRecord::Base
|
||||||
|
@ -79,4 +84,8 @@ class Category < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:ban).permit(:name, :sort, :domain)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,20 +3,29 @@
|
||||||
# Table name: challenges
|
# Table name: challenges
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# contester1_id :integer
|
|
||||||
# contester2_id :integer
|
|
||||||
# match_time :datetime
|
|
||||||
# default_time :datetime
|
# default_time :datetime
|
||||||
# mandatory :boolean
|
|
||||||
# server_id :integer
|
|
||||||
# user_id :integer
|
|
||||||
# details :string(255)
|
# details :string(255)
|
||||||
|
# mandatory :boolean
|
||||||
|
# match_time :datetime
|
||||||
# response :string(255)
|
# response :string(255)
|
||||||
|
# status :integer default("0"), not null
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# contester1_id :integer
|
||||||
|
# contester2_id :integer
|
||||||
# map1_id :string(255)
|
# map1_id :string(255)
|
||||||
# map2_id :string(255)
|
# map2_id :string(255)
|
||||||
# status :integer default(0), not null
|
# server_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_challenges_on_contester1_id (contester1_id)
|
||||||
|
# index_challenges_on_contester2_id (contester2_id)
|
||||||
|
# index_challenges_on_map1_id (map1_id)
|
||||||
|
# index_challenges_on_map2_id (map2_id)
|
||||||
|
# index_challenges_on_server_id (server_id)
|
||||||
|
# index_challenges_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Challenge < ActiveRecord::Base
|
class Challenge < ActiveRecord::Base
|
||||||
|
@ -256,4 +265,8 @@ class Challenge < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and (contester1.team.is_leader? cuser or cuser.admin?) and status == STATUS_PENDING# and autodefault.future?
|
cuser and (contester1.team.is_leader? cuser or cuser.admin?) and status == STATUS_PENDING# and autodefault.future?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params params, cuser
|
||||||
|
params.require(:challenge).permit(:contester1_id, :contester2_id, :match_time, :mandatory, :server_id, :details, :response, :map1_id, :map2_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,13 +3,20 @@
|
||||||
# Table name: comments
|
# Table name: comments
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# text :text
|
|
||||||
# user_id :integer
|
|
||||||
# commentable_type :string(255)
|
# commentable_type :string(255)
|
||||||
# commentable_id :integer
|
# text :text(65535)
|
||||||
|
# text_parsed :text(65535)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# text_parsed :text
|
# commentable_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_comments_on_commentable_type (commentable_type)
|
||||||
|
# index_comments_on_commentable_type_and_commentable_id (commentable_type,commentable_id)
|
||||||
|
# index_comments_on_commentable_type_and_id (commentable_type,id)
|
||||||
|
# index_comments_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Comment < ActiveRecord::Base
|
class Comment < ActiveRecord::Base
|
||||||
|
@ -58,4 +65,8 @@ class Comment < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params params, cuser
|
||||||
|
params.require(:ban).permit(:text, :user_id, :commentable_type, :commentable_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,23 +3,30 @@
|
||||||
# Table name: contests
|
# Table name: contests
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
# contest_type :integer default("0"), not null
|
||||||
# start :datetime
|
# default_time :time
|
||||||
# end :datetime
|
# end :datetime
|
||||||
|
# modulus_3to1 :float(24)
|
||||||
|
# modulus_4to0 :float(24)
|
||||||
|
# modulus_base :integer
|
||||||
|
# modulus_even :float(24)
|
||||||
|
# name :string(255)
|
||||||
|
# short_name :string(255)
|
||||||
|
# start :datetime
|
||||||
# status :integer
|
# status :integer
|
||||||
|
# weight :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# default_time :time
|
|
||||||
# contest_type :integer default(0), not null
|
|
||||||
# winner_id :integer
|
|
||||||
# demos_id :integer
|
# demos_id :integer
|
||||||
# short_name :string(255)
|
|
||||||
# weight :integer
|
|
||||||
# modulus_base :integer
|
|
||||||
# modulus_even :float
|
|
||||||
# modulus_3to1 :float
|
|
||||||
# modulus_4to0 :float
|
|
||||||
# rules_id :integer
|
# rules_id :integer
|
||||||
|
# winner_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_contests_on_demos_id (demos_id)
|
||||||
|
# index_contests_on_rules_id (rules_id)
|
||||||
|
# index_contests_on_status (status)
|
||||||
|
# index_contests_on_winner_id (winner_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Contest < ActiveRecord::Base
|
class Contest < ActiveRecord::Base
|
||||||
|
@ -139,4 +146,11 @@ class Contest < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params params, cuser
|
||||||
|
params.require(:contest).permit(:name, :start, :end, :status, :default_time,
|
||||||
|
:contest_type, :winner_id, :demos_id, :short_name,
|
||||||
|
:weight, :modulus_base, :modulus_even,
|
||||||
|
:modulus_3to1, :modulus_4to0, :rules_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,17 +3,22 @@
|
||||||
# Table name: contesters
|
# Table name: contesters
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# team_id :integer
|
# active :boolean default("1"), not null
|
||||||
|
# draw :integer default("0"), not null
|
||||||
|
# extra :integer not null
|
||||||
|
# loss :integer default("0"), not null
|
||||||
|
# score :integer default("0"), not null
|
||||||
|
# trend :integer not null
|
||||||
|
# win :integer default("0"), not null
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# score :integer default(0), not null
|
|
||||||
# win :integer default(0), not null
|
|
||||||
# loss :integer default(0), not null
|
|
||||||
# draw :integer default(0), not null
|
|
||||||
# contest_id :integer
|
# contest_id :integer
|
||||||
# trend :integer not null
|
# team_id :integer
|
||||||
# extra :integer not null
|
#
|
||||||
# active :boolean default(TRUE), not null
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_contesters_on_contest_id (contest_id)
|
||||||
|
# index_contesters_on_team_id (team_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Contester < ActiveRecord::Base
|
class Contester < ActiveRecord::Base
|
||||||
|
@ -121,4 +126,8 @@ class Contester < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and team.is_leader? cuser or cuser.admin?
|
cuser and team.is_leader? cuser or cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params params, cuser
|
||||||
|
params.require(:contester).permit(:team_id, :score, :win, :lowss, :draw, :contest_id, :active, :extra)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: custom_urls
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# name :string(255)
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# article_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_custom_urls_on_article_id (article_id)
|
||||||
|
# index_custom_urls_on_name (name)
|
||||||
|
#
|
||||||
|
|
||||||
|
# FIXME: move this to a gem
|
||||||
class CustomUrl < ActiveRecord::Base
|
class CustomUrl < ActiveRecord::Base
|
||||||
belongs_to :article
|
belongs_to :article
|
||||||
# FIXME: attr_accessible :name
|
# FIXME: attr_accessible :name
|
||||||
|
@ -9,4 +26,8 @@ class CustomUrl < ActiveRecord::Base
|
||||||
|
|
||||||
validates :article_id,
|
validates :article_id,
|
||||||
presence: true
|
presence: true
|
||||||
end
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:custom_url).permit(:name, :article_id)
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,16 +3,22 @@
|
||||||
# Table name: data_files
|
# Table name: data_files
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
|
||||||
# description :string(255)
|
# description :string(255)
|
||||||
|
# md5 :string(255)
|
||||||
|
# name :string(255)
|
||||||
# path :string(255)
|
# path :string(255)
|
||||||
# size :integer not null
|
# size :integer not null
|
||||||
# md5 :string(255)
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# article_id :integer
|
||||||
# directory_id :integer
|
# directory_id :integer
|
||||||
# related_id :integer
|
# related_id :integer
|
||||||
# article_id :integer
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_data_files_on_article_id (article_id)
|
||||||
|
# index_data_files_on_directory_id (directory_id)
|
||||||
|
# index_data_files_on_related_id (related_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
@ -150,4 +156,8 @@ class DataFile < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin? or (article and article.can_create? cuser)
|
cuser and cuser.admin? or (article and article.can_create? cuser)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:data_file).permit(:description, :name, :article_id, :related_id, :directory_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: directories
|
# Table name: directories
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
|
||||||
# description :string(255)
|
# description :string(255)
|
||||||
|
# hidden :boolean default("0"), not null
|
||||||
|
# name :string(255)
|
||||||
# path :string(255)
|
# path :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# parent_id :integer
|
# parent_id :integer
|
||||||
# hidden :boolean default(FALSE), not null
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_directories_on_parent_id (parent_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Directory < ActiveRecord::Base
|
class Directory < ActiveRecord::Base
|
||||||
|
@ -59,7 +64,7 @@ class Directory < ActiveRecord::Base
|
||||||
def update_timestamp
|
def update_timestamp
|
||||||
self.created_at = File.mtime(path) if File.exists?(path)
|
self.created_at = File.mtime(path) if File.exists?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_files
|
def remove_files
|
||||||
files.each do |subdir|
|
files.each do |subdir|
|
||||||
subdir.destroy
|
subdir.destroy
|
||||||
|
@ -113,4 +118,8 @@ class Directory < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:directory).permit(:description, :hidden, :name, :parent_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,16 @@
|
||||||
# Table name: forums
|
# Table name: forums
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# title :string(255)
|
|
||||||
# description :string(255)
|
# description :string(255)
|
||||||
# category_id :integer
|
# position :integer
|
||||||
|
# title :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# position :integer
|
# category_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forums_on_category_id (category_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Forum < ActiveRecord::Base
|
class Forum < ActiveRecord::Base
|
||||||
|
@ -78,4 +82,7 @@ class Forum < ActiveRecord::Base
|
||||||
id IN (SELECT q.id from (#{Forum.public_forums.to_sql}) q )")
|
id IN (SELECT q.id from (#{Forum.public_forums.to_sql}) q )")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:data_file).permit(:description, :position, :title, :category_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,16 @@
|
||||||
# Table name: forumers
|
# Table name: forumers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# forum_id :integer
|
|
||||||
# group_id :integer
|
|
||||||
# access :integer
|
# access :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# forum_id :integer
|
||||||
|
# group_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forumers_on_forum_id (forum_id)
|
||||||
|
# index_forumers_on_group_id (group_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Forumer < ActiveRecord::Base
|
class Forumer < ActiveRecord::Base
|
||||||
|
@ -36,4 +41,8 @@ class Forumer < ActiveRecord::Base
|
||||||
def accesses
|
def accesses
|
||||||
{ACCESS_READ => "Read", ACCESS_REPLY => "Reply", ACCESS_TOPIC => "Post a Topic"}
|
{ACCESS_READ => "Read", ACCESS_REPLY => "Reply", ACCESS_TOPIC => "Post a Topic"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:forumer).permit(:access, :forum_id, :group_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,19 +3,27 @@
|
||||||
# Table name: gathers
|
# Table name: gathers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
|
# lastpick1 :datetime
|
||||||
|
# lastpick2 :datetime
|
||||||
# status :integer
|
# status :integer
|
||||||
|
# turn :integer
|
||||||
|
# votes :integer default("0"), not null
|
||||||
|
# created_at :datetime
|
||||||
|
# updated_at :datetime
|
||||||
# captain1_id :integer
|
# captain1_id :integer
|
||||||
# captain2_id :integer
|
# captain2_id :integer
|
||||||
|
# category_id :integer
|
||||||
# map1_id :integer
|
# map1_id :integer
|
||||||
# map2_id :integer
|
# map2_id :integer
|
||||||
# server_id :integer
|
# server_id :integer
|
||||||
# created_at :datetime
|
#
|
||||||
# updated_at :datetime
|
# Indexes
|
||||||
# turn :integer
|
#
|
||||||
# lastpick1 :datetime
|
# index_gathers_on_captain1_id (captain1_id)
|
||||||
# lastpick2 :datetime
|
# index_gathers_on_captain2_id (captain2_id)
|
||||||
# votes :integer default(0), not null
|
# index_gathers_on_map1_id (map1_id)
|
||||||
# category_id :integer
|
# index_gathers_on_map2_id (map2_id)
|
||||||
|
# index_gathers_on_server_id (server_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Gather < ActiveRecord::Base
|
class Gather < ActiveRecord::Base
|
||||||
|
@ -192,4 +200,8 @@ class Gather < ActiveRecord::Base
|
||||||
game.gathers.ordered.first
|
game.gathers.ordered.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:gather).permit(:status, :captain1_id, :captain2_id, :map1_id, :map2_id, :server_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,9 +3,14 @@
|
||||||
# Table name: gather_maps
|
# Table name: gather_maps
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
|
# votes :integer
|
||||||
# gather_id :integer
|
# gather_id :integer
|
||||||
# map_id :integer
|
# map_id :integer
|
||||||
# votes :integer
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_gather_maps_on_gather_id (gather_id)
|
||||||
|
# index_gather_maps_on_map_id (map_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class GatherMap < ActiveRecord::Base
|
class GatherMap < ActiveRecord::Base
|
||||||
|
|
|
@ -3,13 +3,19 @@
|
||||||
# Table name: gatherers
|
# Table name: gatherers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# user_id :integer
|
# status :integer default("0"), not null
|
||||||
# gather_id :integer
|
|
||||||
# team :integer
|
# team :integer
|
||||||
|
# votes :integer default("0"), not null
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# votes :integer default(0), not null
|
# gather_id :integer
|
||||||
# status :integer default(0), not null
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_gatherers_on_gather_id (gather_id)
|
||||||
|
# index_gatherers_on_updated_at_and_gather_id (updated_at,gather_id)
|
||||||
|
# index_gatherers_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Gatherer < ActiveRecord::Base
|
class Gatherer < ActiveRecord::Base
|
||||||
|
@ -163,4 +169,8 @@ class Gatherer < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and ((user == cuser or cuser.admin? or cuser.gather_moderator?) and gather.status == Gather::STATE_RUNNING)
|
cuser and ((user == cuser or cuser.admin? or cuser.gather_moderator?) and gather.status == Gather::STATE_RUNNING)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:gatherer).permit(:status, :user_id, :gather_id, :team, :votes)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# founder_id :integer
|
# founder_id :integer
|
||||||
#
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_groups_on_founder_id (founder_id)
|
||||||
|
#
|
||||||
|
|
||||||
class Group < ActiveRecord::Base
|
class Group < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
@ -24,7 +28,6 @@ class Group < ActiveRecord::Base
|
||||||
GATHER_MODERATORS = 14
|
GATHER_MODERATORS = 14
|
||||||
CONTRIBUTORS = 16
|
CONTRIBUTORS = 16
|
||||||
|
|
||||||
#attr_protected :id, :updated_at, :created_at, :founder_id
|
|
||||||
validates_length_of :name, :maximum => 20
|
validates_length_of :name, :maximum => 20
|
||||||
|
|
||||||
has_and_belongs_to_many :users
|
has_and_belongs_to_many :users
|
||||||
|
@ -118,4 +121,8 @@ class Group < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
contributors
|
contributors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:gather).permit(:task)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,16 @@
|
||||||
# Table name: groupers
|
# Table name: groupers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# group_id :integer
|
|
||||||
# user_id :integer
|
|
||||||
# task :string(255)
|
# task :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# group_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_groupers_on_group_id (group_id)
|
||||||
|
# index_groupers_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Grouper < ActiveRecord::Base
|
class Grouper < ActiveRecord::Base
|
||||||
|
@ -44,4 +49,6 @@ class Grouper < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,16 +3,22 @@
|
||||||
# Table name: issues
|
# Table name: issues
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# title :string(255)
|
# solution :text(65535)
|
||||||
# status :integer
|
# status :integer
|
||||||
# assigned_id :integer
|
# text :text(65535)
|
||||||
# category_id :integer
|
# text_parsed :text(65535)
|
||||||
# text :text
|
# title :string(255)
|
||||||
# author_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# solution :text
|
# assigned_id :integer
|
||||||
# text_parsed :text
|
# author_id :integer
|
||||||
|
# category_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_issues_on_assigned_id (assigned_id)
|
||||||
|
# index_issues_on_author_id (author_id)
|
||||||
|
# index_issues_on_category_id (category_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Issue < ActiveRecord::Base
|
class Issue < ActiveRecord::Base
|
||||||
|
@ -126,5 +132,8 @@ class Issue < ActiveRecord::Base
|
||||||
allowed
|
allowed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:issue).permit(:solution, :status, :text, :title,
|
||||||
|
:assigned_id, :author_id, :category_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,14 @@
|
||||||
# Table name: locks
|
# Table name: locks
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# lockable_id :integer
|
|
||||||
# lockable_type :string(255)
|
# lockable_type :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# lockable_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_locks_on_lockable_id_and_lockable_type (lockable_id,lockable_type)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Lock < ActiveRecord::Base
|
class Lock < ActiveRecord::Base
|
||||||
|
@ -20,4 +24,8 @@ class Lock < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:lock).permit(:lockable_type, :lockable_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
# Table name: maps
|
# Table name: maps
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
# deleted :boolean default("0"), not null
|
||||||
# download :string(255)
|
# download :string(255)
|
||||||
|
# name :string(255)
|
||||||
|
# picture :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# deleted :boolean default(FALSE), not null
|
|
||||||
# picture :string(255)
|
|
||||||
# category_id :integer
|
# category_id :integer
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -50,4 +50,8 @@ class Map < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:map).permit(:name, :download, :picture, :category_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,29 +3,46 @@
|
||||||
# Table name: matches
|
# Table name: matches
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# contester1_id :integer
|
|
||||||
# contester2_id :integer
|
|
||||||
# score1 :integer
|
|
||||||
# score2 :integer
|
|
||||||
# match_time :datetime
|
|
||||||
# challenge_id :integer
|
|
||||||
# contest_id :integer
|
|
||||||
# report :text
|
|
||||||
# created_at :datetime
|
|
||||||
# updated_at :datetime
|
|
||||||
# map1_id :integer
|
|
||||||
# map2_id :integer
|
|
||||||
# server_id :integer
|
|
||||||
# motm_id :integer
|
|
||||||
# demo_id :integer
|
|
||||||
# week_id :integer
|
|
||||||
# referee_id :integer
|
|
||||||
# forfeit :boolean
|
|
||||||
# diff :integer
|
# diff :integer
|
||||||
|
# forfeit :boolean
|
||||||
|
# match_time :datetime
|
||||||
# points1 :integer
|
# points1 :integer
|
||||||
# points2 :integer
|
# points2 :integer
|
||||||
# hltv_id :integer
|
# report :text(65535)
|
||||||
|
# score1 :integer
|
||||||
|
# score2 :integer
|
||||||
|
# created_at :datetime
|
||||||
|
# updated_at :datetime
|
||||||
# caster_id :string(255)
|
# caster_id :string(255)
|
||||||
|
# challenge_id :integer
|
||||||
|
# contest_id :integer
|
||||||
|
# contester1_id :integer
|
||||||
|
# contester2_id :integer
|
||||||
|
# demo_id :integer
|
||||||
|
# hltv_id :integer
|
||||||
|
# map1_id :integer
|
||||||
|
# map2_id :integer
|
||||||
|
# motm_id :integer
|
||||||
|
# referee_id :integer
|
||||||
|
# server_id :integer
|
||||||
|
# week_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_matches_on_challenge_id (challenge_id)
|
||||||
|
# index_matches_on_contest_id (contest_id)
|
||||||
|
# index_matches_on_contester1_id (contester1_id)
|
||||||
|
# index_matches_on_contester2_id (contester2_id)
|
||||||
|
# index_matches_on_demo_id (demo_id)
|
||||||
|
# index_matches_on_hltv_id (hltv_id)
|
||||||
|
# index_matches_on_map1_id (map1_id)
|
||||||
|
# index_matches_on_map2_id (map2_id)
|
||||||
|
# index_matches_on_match_time (match_time)
|
||||||
|
# index_matches_on_motm_id (motm_id)
|
||||||
|
# index_matches_on_referee_id (referee_id)
|
||||||
|
# index_matches_on_score1_and_score2 (score1,score2)
|
||||||
|
# index_matches_on_server_id (server_id)
|
||||||
|
# index_matches_on_week_id (week_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Match < ActiveRecord::Base
|
class Match < ActiveRecord::Base
|
||||||
|
@ -361,4 +378,9 @@ class Match < ActiveRecord::Base
|
||||||
def user_in_match?(user)
|
def user_in_match?(user)
|
||||||
user && (user.team == contester1.team || user.team == contester2.team)
|
user && (user.team == contester1.team || user.team == contester2.team)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
# FIXME: check this
|
||||||
|
params.require(:match).permit(:diff, :forfeit, :match_time, :points1, :points2, :report, :score1, :score2, :caster_id, :challenge_id, :contest_id, :contester1_id, :contester2_id, :demo_id, :hltv_id, :map1_id, :map2_id, :motm_id, :referee_id, :server_Id, :week_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: match_proposals
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# proposed_time :datetime
|
||||||
|
# status :integer
|
||||||
|
# match_id :integer
|
||||||
|
# team_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_match_proposals_on_status (status)
|
||||||
|
#
|
||||||
class MatchProposal < ActiveRecord::Base
|
class MatchProposal < ActiveRecord::Base
|
||||||
|
|
||||||
STATUS_PENDING = 0
|
STATUS_PENDING = 0
|
||||||
|
@ -84,4 +98,7 @@ class MatchProposal < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:match_proposal).permit(:status, :match_id, :team_id, :proposed_time)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,18 @@
|
||||||
# Table name: matchers
|
# Table name: matchers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# match_id :integer not null
|
# merc :boolean not null
|
||||||
# user_id :integer not null
|
|
||||||
# contester_id :integer not null
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# merc :boolean not null
|
# contester_id :integer not null
|
||||||
|
# match_id :integer not null
|
||||||
|
# user_id :integer not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_matchers_on_contester_id (contester_id)
|
||||||
|
# index_matchers_on_match_id (match_id)
|
||||||
|
# index_matchers_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Matcher < ActiveRecord::Base
|
class Matcher < ActiveRecord::Base
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
# Table name: messages
|
# Table name: messages
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# sender_type :string(255)
|
|
||||||
# sender_id :integer
|
|
||||||
# recipient_type :string(255)
|
# recipient_type :string(255)
|
||||||
# recipient_id :integer
|
# sender_type :string(255)
|
||||||
|
# text :text(65535)
|
||||||
|
# text_parsed :text(65535)
|
||||||
# title :string(255)
|
# title :string(255)
|
||||||
# text :text
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# text_parsed :text
|
# recipient_id :integer
|
||||||
|
# sender_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_messages_on_recipient_id_and_recipient_type (recipient_id,recipient_type)
|
||||||
|
# index_messages_on_sender_id_and_sender_type (sender_id,sender_type)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Message < ActiveRecord::Base
|
class Message < ActiveRecord::Base
|
||||||
|
@ -90,4 +95,9 @@ class Message < ActiveRecord::Base
|
||||||
def can_create? cuser
|
def can_create? cuser
|
||||||
cuser and !cuser.banned?(Ban::TYPE_MUTE)
|
cuser and !cuser.banned?(Ban::TYPE_MUTE)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
# FIXME: check this
|
||||||
|
params.require(:message).permit(:recipient_type, :sender_type, :title, :text, :recipient_id, :sender_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,19 +3,27 @@
|
||||||
# Table name: movies
|
# Table name: movies
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
|
||||||
# content :string(255)
|
# content :string(255)
|
||||||
# format :string(255)
|
# format :string(255)
|
||||||
# user_id :integer
|
# length :integer
|
||||||
# file_id :integer
|
# name :string(255)
|
||||||
|
# picture :string(255)
|
||||||
|
# status :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# picture :string(255)
|
|
||||||
# preview_id :integer
|
|
||||||
# length :integer
|
|
||||||
# match_id :integer
|
|
||||||
# status :integer
|
|
||||||
# category_id :integer
|
# category_id :integer
|
||||||
|
# file_id :integer
|
||||||
|
# match_id :integer
|
||||||
|
# preview_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_movies_on_file_id (file_id)
|
||||||
|
# index_movies_on_match_id (match_id)
|
||||||
|
# index_movies_on_preview_id (preview_id)
|
||||||
|
# index_movies_on_status (status)
|
||||||
|
# index_movies_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
# Rails.root.join('lib/plugins/acts_as_rateable/init.rb')
|
# Rails.root.join('lib/plugins/acts_as_rateable/init.rb')
|
||||||
|
@ -100,75 +108,79 @@ class Movie < ActiveRecord::Base
|
||||||
# self.file.save!
|
# self.file.save!
|
||||||
# make_stream
|
# make_stream
|
||||||
#end
|
#end
|
||||||
end
|
|
||||||
|
|
||||||
def make_preview x, y
|
|
||||||
result = file.full_path.gsub(/\.\w{3}$/, "") + "_preview.mp4"
|
|
||||||
params = "-vcodec libx264 -vpre hq -b 1200k -bt 1200k -acodec libmp3lame -ab 128k -ac 2"
|
|
||||||
cmd = "#{SCREEN} -d -m #{FFMPEG} -y -i \"#{file.full_path}\" #{params} \"#{result}\""
|
|
||||||
system cmd
|
|
||||||
cmd
|
|
||||||
end
|
|
||||||
|
|
||||||
def make_snapshot secs
|
|
||||||
image = File.join(Rails.root, "public", "images", MOVIES, id.to_s + ".png")
|
|
||||||
params = "-ss #{secs} -vcodec png -vframes 1 -an -f rawvideo -s 160x120"
|
|
||||||
Movie.update_all({:picture => "#{id}.png"}, {:id => id})
|
|
||||||
cmd = "#{FFMPEG} -y -i \"#{file.full_path}\" #{params} \"#{image}\""
|
|
||||||
system cmd
|
|
||||||
cmd
|
|
||||||
end
|
|
||||||
|
|
||||||
def make_stream
|
|
||||||
ip = stream_ip.match(/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/)[0]
|
|
||||||
port = stream_port.match(/[0-9]{1,5}/)[0]
|
|
||||||
cmd = "#{SCREEN} -d -m #{VLC} http://#{ip}:#{port} --sout \"#duplicate{dst=std{access=file,mux=mp4,dst=#{file.full_path}},dst=std{access=http,mux=ts,dst=#{LOCAL}}}\" vlc://quit"
|
|
||||||
system cmd
|
|
||||||
update_attribute :status, $?.pid
|
|
||||||
cmd
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.filter_or_all order, filter
|
|
||||||
order = case order
|
|
||||||
when "date" then "data_files.created_at DESC"
|
|
||||||
when "author" then "users.username ASC"
|
|
||||||
when "ratings" then "total_ratings DESC"
|
|
||||||
else "total_ratings DESC"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: use new system
|
def make_preview x, y
|
||||||
#movies = []
|
result = file.full_path.gsub(/\.\w{3}$/, "") + "_preview.mp4"
|
||||||
#if filter
|
params = "-vcodec libx264 -vpre hq -b 1200k -bt 1200k -acodec libmp3lame -ab 128k -ac 2"
|
||||||
# Movie.index.order(order).each do |movie|
|
cmd = "#{SCREEN} -d -m #{FFMPEG} -y -i \"#{file.full_path}\" #{params} \"#{result}\""
|
||||||
# if movie.file and movie.file.average_rating_round >= filter.to_i
|
system cmd
|
||||||
# movies << movie
|
cmd
|
||||||
# end
|
end
|
||||||
# end
|
|
||||||
# return movies
|
def make_snapshot secs
|
||||||
#else
|
image = File.join(Rails.root, "public", "images", MOVIES, id.to_s + ".png")
|
||||||
return with_ratings.order(order)
|
params = "-ss #{secs} -vcodec png -vframes 1 -an -f rawvideo -s 160x120"
|
||||||
|
Movie.update_all({:picture => "#{id}.png"}, {:id => id})
|
||||||
|
cmd = "#{FFMPEG} -y -i \"#{file.full_path}\" #{params} \"#{image}\""
|
||||||
|
system cmd
|
||||||
|
cmd
|
||||||
|
end
|
||||||
|
|
||||||
|
def make_stream
|
||||||
|
ip = stream_ip.match(/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/)[0]
|
||||||
|
port = stream_port.match(/[0-9]{1,5}/)[0]
|
||||||
|
cmd = "#{SCREEN} -d -m #{VLC} http://#{ip}:#{port} --sout \"#duplicate{dst=std{access=file,mux=mp4,dst=#{file.full_path}},dst=std{access=http,mux=ts,dst=#{LOCAL}}}\" vlc://quit"
|
||||||
|
system cmd
|
||||||
|
update_attribute :status, $?.pid
|
||||||
|
cmd
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.filter_or_all order, filter
|
||||||
|
order = case order
|
||||||
|
when "date" then "data_files.created_at DESC"
|
||||||
|
when "author" then "users.username ASC"
|
||||||
|
when "ratings" then "total_ratings DESC"
|
||||||
|
else "total_ratings DESC"
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME: use new system
|
||||||
|
#movies = []
|
||||||
|
#if filter
|
||||||
|
# Movie.index.order(order).each do |movie|
|
||||||
|
# if movie.file and movie.file.average_rating_round >= filter.to_i
|
||||||
|
# movies << movie
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# return movies
|
||||||
|
#else
|
||||||
|
return with_ratings.order(order)
|
||||||
|
#end
|
||||||
|
end
|
||||||
|
|
||||||
|
#def update_status
|
||||||
|
# if status and status > 0
|
||||||
|
# begin
|
||||||
|
# Process.getpgid(status) != -1
|
||||||
|
# rescue Errno::ESRCH
|
||||||
|
# update_attribute :status, 0
|
||||||
|
# end
|
||||||
|
# end
|
||||||
#end
|
#end
|
||||||
end
|
|
||||||
|
|
||||||
#def update_status
|
def can_create? cuser
|
||||||
# if status and status > 0
|
cuser and cuser.admin? or cuser.groups.exists? :id => Group::MOVIES
|
||||||
# begin
|
end
|
||||||
# Process.getpgid(status) != -1
|
|
||||||
# rescue Errno::ESRCH
|
|
||||||
# update_attribute :status, 0
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#end
|
|
||||||
|
|
||||||
def can_create? cuser
|
def can_update? cuser
|
||||||
cuser and cuser.admin? or cuser.groups.exists? :id => Group::MOVIES
|
cuser and cuser.admin? or user == cuser
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_update? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin? or user == cuser
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_destroy? cuser
|
def self.params(params, cuser)
|
||||||
cuser and cuser.admin?
|
params.require(:movie).permit(:content, :format, :length, :name, :picture, :status, :category_id, :file_id, :match_id, :preview_id, :user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,14 @@
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# option :string(255)
|
# option :string(255)
|
||||||
# poll_id :integer
|
# votes :integer default("0"), not null
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# votes :integer default(0), not null
|
# poll_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_options_on_poll_id (poll_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Option < ActiveRecord::Base
|
class Option < ActiveRecord::Base
|
||||||
|
@ -23,4 +27,9 @@ class Option < ActiveRecord::Base
|
||||||
def to_s
|
def to_s
|
||||||
self.option
|
self.option
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
# FIXME: check this
|
||||||
|
params.require(:option).permit(:option, :votes, :poll_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,16 @@
|
||||||
# Table name: polls
|
# Table name: polls
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# question :string(255)
|
|
||||||
# end_date :datetime
|
# end_date :datetime
|
||||||
# user_id :integer
|
# question :string(255)
|
||||||
|
# votes :integer default("0"), not null
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# votes :integer default(0), not null
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_polls_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Poll < ActiveRecord::Base
|
class Poll < ActiveRecord::Base
|
||||||
|
@ -42,4 +46,8 @@ class Poll < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:poll).permit(:end_date, :question)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
# Table name: posts
|
# Table name: posts
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# text :text
|
# text :text(65535)
|
||||||
# topic_id :integer
|
# text_parsed :text(65535)
|
||||||
# user_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# text_parsed :text
|
# topic_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_posts_on_topic_id (topic_id)
|
||||||
|
# index_posts_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Post < ActiveRecord::Base
|
class Post < ActiveRecord::Base
|
||||||
|
@ -65,4 +70,9 @@ class Post < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
# FIXME: check this
|
||||||
|
params.require(:post).permit(:text, :topic_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,13 +3,18 @@
|
||||||
# Table name: predictions
|
# Table name: predictions
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# match_id :integer
|
# result :integer
|
||||||
# user_id :integer
|
|
||||||
# score1 :integer
|
# score1 :integer
|
||||||
# score2 :integer
|
# score2 :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# result :integer
|
# match_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_predictions_on_match_id (match_id)
|
||||||
|
# index_predictions_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Prediction < ActiveRecord::Base
|
class Prediction < ActiveRecord::Base
|
||||||
|
@ -30,4 +35,8 @@ class Prediction < ActiveRecord::Base
|
||||||
def can_create? cuser
|
def can_create? cuser
|
||||||
cuser and match.match_time.future? and !match.score1 and !match.score2 and !cuser.predictions.exists?(:match_id => match.id)
|
cuser and match.match_time.future? and !match.score1 and !match.score2 and !cuser.predictions.exists?(:match_id => match.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:prediction).permit(:result, :score1, :score2, :match_id, :user_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,57 +3,61 @@
|
||||||
# Table name: profiles
|
# Table name: profiles
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# user_id :integer
|
# achievements :text(65535)
|
||||||
# msn :string(255)
|
# achievements_parsed :string(400)
|
||||||
|
# avatar :string(255)
|
||||||
|
# beverage :string(255)
|
||||||
|
# book :string(255)
|
||||||
|
# case :string(255)
|
||||||
|
# clan_search :string(255)
|
||||||
|
# cpu :string(255)
|
||||||
|
# food :string(255)
|
||||||
|
# gpu :string(255)
|
||||||
|
# hdd :string(255)
|
||||||
|
# head_phones :string(255)
|
||||||
|
# hobby :string(255)
|
||||||
# icq :string(255)
|
# icq :string(255)
|
||||||
# irc :string(255)
|
# irc :string(255)
|
||||||
# web :string(255)
|
# keyboard :string(255)
|
||||||
# town :string(255)
|
# layout :string(255)
|
||||||
# singleplayer :string(255)
|
|
||||||
# multiplayer :string(255)
|
|
||||||
# food :string(255)
|
|
||||||
# beverage :string(255)
|
|
||||||
# hobby :string(255)
|
|
||||||
# music :string(255)
|
|
||||||
# book :string(255)
|
|
||||||
# movie :string(255)
|
|
||||||
# tvseries :string(255)
|
|
||||||
# res :string(255)
|
|
||||||
# sensitivity :string(255)
|
|
||||||
# monitor_hz :string(255)
|
|
||||||
# scripts :string(255)
|
|
||||||
# cpu :string(255)
|
|
||||||
# gpu :string(255)
|
|
||||||
# ram :string(255)
|
|
||||||
# psu :string(255)
|
|
||||||
# motherboard :string(255)
|
|
||||||
# soundcard :string(255)
|
|
||||||
# hdd :string(255)
|
|
||||||
# case :string(255)
|
|
||||||
# monitor :string(255)
|
# monitor :string(255)
|
||||||
|
# monitor_hz :string(255)
|
||||||
|
# motherboard :string(255)
|
||||||
# mouse :string(255)
|
# mouse :string(255)
|
||||||
# mouse_pad :string(255)
|
# mouse_pad :string(255)
|
||||||
# keyboard :string(255)
|
# movie :string(255)
|
||||||
# head_phones :string(255)
|
# msn :string(255)
|
||||||
# speakers :string(255)
|
# multiplayer :string(255)
|
||||||
# achievements :text
|
# music :string(255)
|
||||||
# updated_at :datetime
|
|
||||||
# signature :string(255)
|
|
||||||
# avatar :string(255)
|
|
||||||
# clan_search :string(255)
|
|
||||||
# notify_news :boolean
|
|
||||||
# notify_articles :boolean
|
|
||||||
# notify_movies :boolean
|
|
||||||
# notify_gather :boolean
|
|
||||||
# notify_own_match :boolean
|
|
||||||
# notify_any_match :boolean
|
# notify_any_match :boolean
|
||||||
# notify_pms :boolean default(TRUE), not null
|
# notify_articles :boolean
|
||||||
# notify_challenge :boolean default(TRUE), not null
|
# notify_challenge :boolean default("1"), not null
|
||||||
|
# notify_gather :boolean
|
||||||
|
# notify_movies :boolean
|
||||||
|
# notify_news :boolean
|
||||||
|
# notify_own_match :boolean
|
||||||
|
# notify_pms :boolean default("1"), not null
|
||||||
|
# psu :string(255)
|
||||||
|
# ram :string(255)
|
||||||
|
# res :string(255)
|
||||||
|
# scripts :string(255)
|
||||||
|
# sensitivity :string(255)
|
||||||
|
# signature :string(255)
|
||||||
|
# signature_parsed :text(65535)
|
||||||
|
# singleplayer :string(255)
|
||||||
|
# soundcard :string(255)
|
||||||
|
# speakers :string(255)
|
||||||
# steam_profile :string(255)
|
# steam_profile :string(255)
|
||||||
# achievements_parsed :string(255)
|
|
||||||
# signature_parsed :string(255)
|
|
||||||
# stream :string(255)
|
# stream :string(255)
|
||||||
# layout :string(255)
|
# town :string(255)
|
||||||
|
# tvseries :string(255)
|
||||||
|
# web :string(255)
|
||||||
|
# updated_at :datetime
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_profiles_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Profile < ActiveRecord::Base
|
class Profile < ActiveRecord::Base
|
||||||
|
@ -97,4 +101,10 @@ class Profile < ActiveRecord::Base
|
||||||
self.achievements_parsed = bbcode_to_html(achievements) if self.achievements
|
self.achievements_parsed = bbcode_to_html(achievements) if self.achievements
|
||||||
self.signature_parsed = bbcode_to_html(signature) if self.signature
|
self.signature_parsed = bbcode_to_html(signature) if self.signature
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
# FIXME: check this, add user_id
|
||||||
|
# TEST
|
||||||
|
params.require(:profile).except!(:id, :updated_at).permit!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,31 +3,37 @@
|
||||||
# Table name: servers
|
# Table name: servers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
# active :boolean default("1"), not null
|
||||||
# description :string(255)
|
# description :string(255)
|
||||||
# dns :string(255)
|
# dns :string(255)
|
||||||
|
# domain :integer default("0"), not null
|
||||||
|
# idle :datetime
|
||||||
# ip :string(255)
|
# ip :string(255)
|
||||||
# port :string(255)
|
|
||||||
# password :string(255)
|
|
||||||
# irc :string(255)
|
# irc :string(255)
|
||||||
# user_id :integer
|
# map :string(255)
|
||||||
|
# max_players :integer
|
||||||
|
# name :string(255)
|
||||||
# official :boolean
|
# official :boolean
|
||||||
|
# password :string(255)
|
||||||
|
# ping :string(255)
|
||||||
|
# players :integer
|
||||||
|
# port :string(255)
|
||||||
|
# recordable_type :string(255)
|
||||||
|
# recording :string(255)
|
||||||
|
# reservation :string(255)
|
||||||
|
# version :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# map :string(255)
|
|
||||||
# players :integer
|
|
||||||
# max_players :integer
|
|
||||||
# ping :string(255)
|
|
||||||
# version :integer
|
|
||||||
# domain :integer default(0), not null
|
|
||||||
# reservation :string(255)
|
|
||||||
# recording :string(255)
|
|
||||||
# idle :datetime
|
|
||||||
# default_id :integer
|
|
||||||
# active :boolean default(TRUE), not null
|
|
||||||
# recordable_type :string(255)
|
|
||||||
# recordable_id :integer
|
|
||||||
# category_id :integer
|
# category_id :integer
|
||||||
|
# default_id :integer
|
||||||
|
# recordable_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_servers_on_default_id (default_id)
|
||||||
|
# index_servers_on_players_and_domain (players,domain)
|
||||||
|
# index_servers_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "yaml"
|
require "yaml"
|
||||||
|
@ -138,4 +144,10 @@ class Server < ActiveRecord::Base
|
||||||
hltv.save!
|
hltv.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
# FIXME: check this, add user_id
|
||||||
|
# TEST
|
||||||
|
params.require(:server).except!(:id, :created_at, :user_id, :map, :players, :maxplayers, :ping, :version, :updated_at).permit!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
# Table name: shoutmsgs
|
# Table name: shoutmsgs
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# user_id :integer
|
# shoutable_type :string(255)
|
||||||
# text :string(255)
|
# text :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# shoutable_type :string(255)
|
|
||||||
# shoutable_id :integer
|
# shoutable_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_shoutmsgs_on_shoutable_type_and_shoutable_id (shoutable_type,shoutable_id)
|
||||||
|
# index_shoutmsgs_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Shoutmsg < ActiveRecord::Base
|
class Shoutmsg < ActiveRecord::Base
|
||||||
|
@ -49,4 +54,8 @@ class Shoutmsg < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:shoutmsg).permit(:shoutable_id, :shoutable_type, :text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,19 +2,24 @@
|
||||||
#
|
#
|
||||||
# Table name: teams
|
# Table name: teams
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
# active :boolean default("1"), not null
|
||||||
# irc :string(255)
|
# comment :string(255)
|
||||||
# web :string(255)
|
# country :string(255)
|
||||||
# tag :string(255)
|
# irc :string(255)
|
||||||
# country :string(255)
|
# logo :string(255)
|
||||||
# comment :string(255)
|
# name :string(255)
|
||||||
# created_at :datetime
|
# recruiting :string(255)
|
||||||
# updated_at :datetime
|
# tag :string(255)
|
||||||
# logo :string(255)
|
# teamers_count :integer
|
||||||
# founder_id :integer
|
# web :string(255)
|
||||||
# active :boolean default(TRUE), not null
|
# created_at :datetime
|
||||||
# recruiting :string(255)
|
# updated_at :datetime
|
||||||
|
# founder_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_teams_on_founder_id (founder_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Team < ActiveRecord::Base
|
class Team < ActiveRecord::Base
|
||||||
|
@ -126,4 +131,8 @@ class Team < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:team).except(:id, :active, :founder_id, :created_at, :updated_at).permit!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
# Table name: teamers
|
# Table name: teamers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# team_id :integer not null
|
|
||||||
# user_id :integer not null
|
|
||||||
# comment :string(255)
|
# comment :string(255)
|
||||||
# rank :integer not null
|
# rank :integer not null
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# team_id :integer not null
|
||||||
|
# user_id :integer not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_teamers_on_team_id (team_id)
|
||||||
|
# index_teamers_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Teamer < ActiveRecord::Base
|
class Teamer < ActiveRecord::Base
|
||||||
|
@ -92,4 +97,8 @@ class Teamer < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and (user == cuser or team.is_leader? cuser or cuser.admin?)
|
cuser and (user == cuser or team.is_leader? cuser or cuser.admin?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:teamer).permit(:comment, :rank, :team_id, :user_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
# Table name: topics
|
# Table name: topics
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
|
# state :integer default("0"), not null
|
||||||
# title :string(255)
|
# title :string(255)
|
||||||
# user_id :integer
|
|
||||||
# forum_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# state :integer default(0), not null
|
# forum_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_topics_on_forum_id (forum_id)
|
||||||
|
# index_topics_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Topic < ActiveRecord::Base
|
class Topic < ActiveRecord::Base
|
||||||
|
@ -122,4 +127,8 @@ class Topic < ActiveRecord::Base
|
||||||
def states
|
def states
|
||||||
{STATE_NORMAL => "Normal", STATE_STICKY => "Sticky"}
|
{STATE_NORMAL => "Normal", STATE_STICKY => "Sticky"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.permit(:state, :title, :forum_id, :user_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,22 +3,27 @@
|
||||||
# Table name: users
|
# Table name: users
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# username :string(255)
|
# birthdate :date
|
||||||
# password :string(255)
|
# country :string(255)
|
||||||
# firstname :string(255)
|
|
||||||
# lastname :string(255)
|
|
||||||
# email :string(255)
|
# email :string(255)
|
||||||
# steamid :string(255)
|
# firstname :string(255)
|
||||||
# team_id :integer
|
# lastip :string(255)
|
||||||
|
# lastname :string(255)
|
||||||
# lastvisit :datetime
|
# lastvisit :datetime
|
||||||
|
# password :string(255)
|
||||||
|
# public_email :boolean default("0"), not null
|
||||||
|
# steamid :string(255)
|
||||||
|
# time_zone :string(255)
|
||||||
|
# username :string(255)
|
||||||
|
# version :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# lastip :string(255)
|
# team_id :integer
|
||||||
# country :string(255)
|
#
|
||||||
# birthdate :date
|
# Indexes
|
||||||
# time_zone :string(255)
|
#
|
||||||
# version :integer
|
# index_users_on_lastvisit (lastvisit)
|
||||||
# public_email :boolean default(FALSE), not null
|
# index_users_on_team_id (team_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
@ -181,6 +186,10 @@ class User < ActiveRecord::Base
|
||||||
a
|
a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def idle
|
||||||
|
"%d m" % [TimeDifference.between(DateTime.now, lastvisit).in_minutes.floor]
|
||||||
|
end
|
||||||
|
|
||||||
def current_layout
|
def current_layout
|
||||||
profile.layout || 'default'
|
profile.layout || 'default'
|
||||||
end
|
end
|
||||||
|
@ -344,4 +353,8 @@ class User < ActiveRecord::Base
|
||||||
def self.casters
|
def self.casters
|
||||||
Group.find(Group::CASTERS).users.order(:username)
|
Group.find(Group::CASTERS).users.order(:username)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:user).permit(:raw_password, :firstname, :lastname, :email, :steamid, :country, :birthdate, :timezone, :public_email, :filter)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,15 @@
|
||||||
# Table name: view_counts
|
# Table name: view_counts
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# viewable_id :integer
|
|
||||||
# viewable_type :string(255)
|
|
||||||
# ip_address :string(255)
|
# ip_address :string(255)
|
||||||
# logged_in :boolean
|
# logged_in :boolean
|
||||||
|
# viewable_type :string(255)
|
||||||
# created_at :date
|
# created_at :date
|
||||||
|
# viewable_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_view_counts_on_viewable_type_and_viewable_id (viewable_type,viewable_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class ViewCount < ActiveRecord::Base
|
class ViewCount < ActiveRecord::Base
|
||||||
|
|
|
@ -3,10 +3,15 @@
|
||||||
# Table name: votes
|
# Table name: votes
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
|
# votable_type :string(255)
|
||||||
|
# poll_id :integer
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# votable_id :integer
|
# votable_id :integer
|
||||||
# poll_id :integer
|
#
|
||||||
# votable_type :string(255)
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_votes_on_user_id (user_id)
|
||||||
|
# index_votes_on_votable_id_and_votable_type (votable_id,votable_type)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Vote < ActiveRecord::Base
|
class Vote < ActiveRecord::Base
|
||||||
|
@ -65,4 +70,8 @@ class Vote < ActiveRecord::Base
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:vote).permit(:votable_type, :votable_id, :poll_id, :user_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,11 +5,17 @@
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
# name :string(255)
|
||||||
# start_date :date
|
# start_date :date
|
||||||
|
# created_at :datetime
|
||||||
|
# updated_at :datetime
|
||||||
# contest_id :integer
|
# contest_id :integer
|
||||||
# map1_id :integer
|
# map1_id :integer
|
||||||
# map2_id :integer
|
# map2_id :integer
|
||||||
# created_at :datetime
|
#
|
||||||
# updated_at :datetime
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_weeks_on_contest_id (contest_id)
|
||||||
|
# index_weeks_on_map1_id (map1_id)
|
||||||
|
# index_weeks_on_map2_id (map2_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class Week < ActiveRecord::Base
|
class Week < ActiveRecord::Base
|
||||||
|
@ -42,4 +48,8 @@ class Week < ActiveRecord::Base
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.params(params, cuser)
|
||||||
|
params.require(:week).permit(:name, :start_date, :contest_id, :map1_id, :map2_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<li<% if gatherer.status > 0 %> class="away"<% end %>>
|
<li<% if gatherer.status > 0 %> class="away"<% end %>>
|
||||||
<%= flag gatherer.user.country %>
|
<%= flag gatherer.user.country %>
|
||||||
<%= namelink gatherer.user %>
|
<%= namelink gatherer.user %>
|
||||||
|
( <%= gatherer.user.idle %> )
|
||||||
<% if cuser and gatherer.can_destroy?(cuser) %>
|
<% if cuser and gatherer.can_destroy?(cuser) %>
|
||||||
<%= link_to gatherer, method: :delete, class: 'delete' do %>
|
<%= link_to gatherer, method: :delete, class: 'delete' do %>
|
||||||
<%= icon 'times' %>
|
<%= icon 'times' %>
|
||||||
|
|
59
lib/tasks/auto_annotate_models.rake
Normal file
59
lib/tasks/auto_annotate_models.rake
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# NOTE: only doing this in development as some production environments (Heroku)
|
||||||
|
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
||||||
|
# NOTE: to have a dev-mode tool do its thing in production.
|
||||||
|
if Rails.env.development?
|
||||||
|
require 'annotate'
|
||||||
|
task :set_annotation_options do
|
||||||
|
# You can override any of these by setting an environment variable of the
|
||||||
|
# same name.
|
||||||
|
Annotate.set_defaults(
|
||||||
|
'active_admin' => 'false',
|
||||||
|
'additional_file_patterns' => [],
|
||||||
|
'routes' => 'false',
|
||||||
|
'models' => 'true',
|
||||||
|
'position_in_routes' => 'before',
|
||||||
|
'position_in_class' => 'before',
|
||||||
|
'position_in_test' => 'before',
|
||||||
|
'position_in_fixture' => 'before',
|
||||||
|
'position_in_factory' => 'before',
|
||||||
|
'position_in_serializer' => 'before',
|
||||||
|
'show_foreign_keys' => 'true',
|
||||||
|
'show_complete_foreign_keys' => 'false',
|
||||||
|
'show_indexes' => 'true',
|
||||||
|
'simple_indexes' => 'false',
|
||||||
|
'model_dir' => 'app/models',
|
||||||
|
'root_dir' => '',
|
||||||
|
'include_version' => 'false',
|
||||||
|
'require' => '',
|
||||||
|
'exclude_tests' => 'false',
|
||||||
|
'exclude_fixtures' => 'false',
|
||||||
|
'exclude_factories' => 'false',
|
||||||
|
'exclude_serializers' => 'false',
|
||||||
|
'exclude_scaffolds' => 'true',
|
||||||
|
'exclude_controllers' => 'true',
|
||||||
|
'exclude_helpers' => 'true',
|
||||||
|
'exclude_sti_subclasses' => 'false',
|
||||||
|
'ignore_model_sub_dir' => 'false',
|
||||||
|
'ignore_columns' => nil,
|
||||||
|
'ignore_routes' => nil,
|
||||||
|
'ignore_unknown_models' => 'false',
|
||||||
|
'hide_limit_column_types' => 'integer,bigint,boolean',
|
||||||
|
'hide_default_column_types' => 'json,jsonb,hstore',
|
||||||
|
'skip_on_db_migrate' => 'false',
|
||||||
|
'format_bare' => 'true',
|
||||||
|
'format_rdoc' => 'false',
|
||||||
|
'format_yard' => 'false',
|
||||||
|
'format_markdown' => 'false',
|
||||||
|
'sort' => 'false',
|
||||||
|
'force' => 'false',
|
||||||
|
'frozen' => 'false',
|
||||||
|
'classified_sort' => 'true',
|
||||||
|
'trace' => 'false',
|
||||||
|
'wrapper_open' => nil,
|
||||||
|
'wrapper_close' => nil,
|
||||||
|
'with_comment' => 'true'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
Annotate.load_tasks
|
||||||
|
end
|
|
@ -3,16 +3,23 @@
|
||||||
# Table name: bans
|
# Table name: bans
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# steamid :string(255)
|
|
||||||
# user_id :integer
|
|
||||||
# addr :string(255)
|
# addr :string(255)
|
||||||
# server_id :integer
|
# ban_type :integer
|
||||||
# expiry :datetime
|
# expiry :datetime
|
||||||
|
# ip :string(255)
|
||||||
# reason :string(255)
|
# reason :string(255)
|
||||||
|
# steamid :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# ban_type :integer
|
# creator_id :integer
|
||||||
# ip :string(255)
|
# server_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_bans_on_creator_id (creator_id)
|
||||||
|
# index_bans_on_server_id (server_id)
|
||||||
|
# index_bans_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,12 +3,16 @@
|
||||||
# Table name: forums
|
# Table name: forums
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# title :string(255)
|
|
||||||
# description :string(255)
|
# description :string(255)
|
||||||
# category_id :integer
|
# position :integer
|
||||||
|
# title :string(255)
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# position :integer
|
# category_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forums_on_category_id (category_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,11 +3,16 @@
|
||||||
# Table name: forumers
|
# Table name: forumers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# forum_id :integer
|
|
||||||
# group_id :integer
|
|
||||||
# access :integer
|
# access :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
|
# forum_id :integer
|
||||||
|
# group_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forumers_on_forum_id (forum_id)
|
||||||
|
# index_forumers_on_group_id (group_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,16 +3,22 @@
|
||||||
# Table name: issues
|
# Table name: issues
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# title :string(255)
|
# solution :text(65535)
|
||||||
# status :integer
|
# status :integer
|
||||||
# assigned_id :integer
|
# text :text(65535)
|
||||||
# category_id :integer
|
# text_parsed :text(65535)
|
||||||
# text :text
|
# title :string(255)
|
||||||
# author_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# solution :text
|
# assigned_id :integer
|
||||||
# text_parsed :text
|
# author_id :integer
|
||||||
|
# category_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_issues_on_assigned_id (assigned_id)
|
||||||
|
# index_issues_on_author_id (author_id)
|
||||||
|
# index_issues_on_category_id (category_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
# Table name: messages
|
# Table name: messages
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# sender_type :string(255)
|
|
||||||
# sender_id :integer
|
|
||||||
# recipient_type :string(255)
|
# recipient_type :string(255)
|
||||||
# recipient_id :integer
|
# sender_type :string(255)
|
||||||
|
# text :text(65535)
|
||||||
|
# text_parsed :text(65535)
|
||||||
# title :string(255)
|
# title :string(255)
|
||||||
# text :text
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# text_parsed :text
|
# recipient_id :integer
|
||||||
|
# sender_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_messages_on_recipient_id_and_recipient_type (recipient_id,recipient_type)
|
||||||
|
# index_messages_on_sender_id_and_sender_type (sender_id,sender_type)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
# Table name: posts
|
# Table name: posts
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# text :text
|
# text :text(65535)
|
||||||
# topic_id :integer
|
# text_parsed :text(65535)
|
||||||
# user_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# text_parsed :text
|
# topic_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_posts_on_topic_id (topic_id)
|
||||||
|
# index_posts_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,31 +3,37 @@
|
||||||
# Table name: servers
|
# Table name: servers
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255)
|
# active :boolean default("1"), not null
|
||||||
# description :string(255)
|
# description :string(255)
|
||||||
# dns :string(255)
|
# dns :string(255)
|
||||||
|
# domain :integer default("0"), not null
|
||||||
|
# idle :datetime
|
||||||
# ip :string(255)
|
# ip :string(255)
|
||||||
# port :string(255)
|
|
||||||
# password :string(255)
|
|
||||||
# irc :string(255)
|
# irc :string(255)
|
||||||
# user_id :integer
|
# map :string(255)
|
||||||
|
# max_players :integer
|
||||||
|
# name :string(255)
|
||||||
# official :boolean
|
# official :boolean
|
||||||
|
# password :string(255)
|
||||||
|
# ping :string(255)
|
||||||
|
# players :integer
|
||||||
|
# port :string(255)
|
||||||
|
# recordable_type :string(255)
|
||||||
|
# recording :string(255)
|
||||||
|
# reservation :string(255)
|
||||||
|
# version :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# map :string(255)
|
|
||||||
# players :integer
|
|
||||||
# max_players :integer
|
|
||||||
# ping :string(255)
|
|
||||||
# version :integer
|
|
||||||
# domain :integer default(0), not null
|
|
||||||
# reservation :string(255)
|
|
||||||
# recording :string(255)
|
|
||||||
# idle :datetime
|
|
||||||
# default_id :integer
|
|
||||||
# active :boolean default(TRUE), not null
|
|
||||||
# recordable_type :string(255)
|
|
||||||
# recordable_id :integer
|
|
||||||
# category_id :integer
|
# category_id :integer
|
||||||
|
# default_id :integer
|
||||||
|
# recordable_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_servers_on_default_id (default_id)
|
||||||
|
# index_servers_on_players_and_domain (players,domain)
|
||||||
|
# index_servers_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
# Table name: topics
|
# Table name: topics
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
|
# state :integer default("0"), not null
|
||||||
# title :string(255)
|
# title :string(255)
|
||||||
# user_id :integer
|
|
||||||
# forum_id :integer
|
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# state :integer default(0), not null
|
# forum_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_topics_on_forum_id (forum_id)
|
||||||
|
# index_topics_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
|
|
@ -3,23 +3,27 @@
|
||||||
# Table name: users
|
# Table name: users
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# username :string(255)
|
# birthdate :date
|
||||||
# password :string(255)
|
# country :string(255)
|
||||||
# firstname :string(255)
|
|
||||||
# lastname :string(255)
|
|
||||||
# email :string(255)
|
# email :string(255)
|
||||||
# steamid :string(255)
|
# firstname :string(255)
|
||||||
# team_id :integer
|
# lastip :string(255)
|
||||||
|
# lastname :string(255)
|
||||||
# lastvisit :datetime
|
# lastvisit :datetime
|
||||||
|
# password :string(255)
|
||||||
|
# public_email :boolean default("0"), not null
|
||||||
|
# steamid :string(255)
|
||||||
|
# time_zone :string(255)
|
||||||
|
# username :string(255)
|
||||||
|
# version :integer
|
||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# lastip :string(255)
|
# team_id :integer
|
||||||
# country :string(255)
|
#
|
||||||
# birthdate :date
|
# Indexes
|
||||||
# time_zone :string(255)
|
#
|
||||||
# version :integer
|
# index_users_on_lastvisit (lastvisit)
|
||||||
# public_email :boolean default(FALSE), not null
|
# index_users_on_team_id (team_id)
|
||||||
# salt :string(255)
|
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
Loading…
Reference in a new issue