Fixed formatting and ruby hash syntax

This commit is contained in:
Callum Barratt 2014-03-31 22:33:16 +01:00
parent 8836bc49f2
commit fbd6ad4ac6
42 changed files with 170 additions and 166 deletions

View file

@ -38,6 +38,7 @@ group :development do
gem 'capistrano-rails', '~> 1.1' gem 'capistrano-rails', '~> 1.1'
gem 'capistrano3-unicorn', '~> 0.1.1' gem 'capistrano3-unicorn', '~> 0.1.1'
gem 'annotate', '~> 2.6.2' gem 'annotate', '~> 2.6.2'
gem 'quiet_assets'
end end
group :test do group :test do

View file

@ -147,6 +147,8 @@ GEM
pry-debugger (0.2.2) pry-debugger (0.2.2)
debugger (~> 1.3) debugger (~> 1.3)
pry (~> 0.9.10) pry (~> 0.9.10)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.4.5) rack (1.4.5)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
@ -275,6 +277,7 @@ DEPENDENCIES
oj (~> 2.5.5) oj (~> 2.5.5)
poltergeist (~> 1.5.0) poltergeist (~> 1.5.0)
pry-debugger (~> 0.2.2) pry-debugger (~> 0.2.2)
quiet_assets
rails (~> 3.2.17) rails (~> 3.2.17)
rmagick (~> 2.13.2) rmagick (~> 2.13.2)
rspec-rails (~> 2.14.1) rspec-rails (~> 2.14.1)

View file

@ -1,5 +1,5 @@
class ArticlesController < ApplicationController class ArticlesController < ApplicationController
before_filter :get_article, :only => [:show, :edit, :update, :cleanup, :destroy] before_filter :get_article, only: [:show, :edit, :update, :cleanup, :destroy]
def index def index
@categories = Category.ordered.nospecial.domain Category::DOMAIN_ARTICLES @categories = Category.ordered.nospecial.domain Category::DOMAIN_ARTICLES
@ -49,7 +49,7 @@ class ArticlesController < ApplicationController
flash[:notice] = t(:articles_create) flash[:notice] = t(:articles_create)
redirect_to @article redirect_to @article
else else
render :action => "new" render :new
end end
end end
@ -59,7 +59,7 @@ class ArticlesController < ApplicationController
flash[:notice] = t(:articles_update) flash[:notice] = t(:articles_update)
redirect_to @article redirect_to @article
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class BansController < ApplicationController class BansController < ApplicationController
before_filter :get_ban, :only => [:show, :edit, :update, :destroy] before_filter :get_ban, only: [:show, :edit, :update, :destroy]
def index def index
@bans = Ban.ordered @bans = Ban.ordered
@ -29,7 +29,7 @@ class BansController < ApplicationController
flash[:notice] = t(:bans_create) flash[:notice] = t(:bans_create)
redirect_to(@ban) redirect_to(@ban)
else else
render :action => "new" render :new
end end
end end
@ -39,7 +39,7 @@ class BansController < ApplicationController
flash[:notice] = t(:bans_update) flash[:notice] = t(:bans_update)
redirect_to(@ban) redirect_to(@ban)
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class BracketsController < ApplicationController class BracketsController < ApplicationController
before_filter :get_bracket, :only => [:show, :edit, :update, :destroy] before_filter :get_bracket, only: [:show, :edit, :update, :destroy]
def edit def edit
raise AccessError unless @bracket.can_update? cuser raise AccessError unless @bracket.can_update? cuser
@ -23,7 +23,7 @@ class BracketsController < ApplicationController
flash[:notice] = t(:brackets_update) flash[:notice] = t(:brackets_update)
end end
render :action => "edit" render :edit
end end
def destroy def destroy

View file

@ -1,11 +1,11 @@
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
before_filter :get_category, :except => [:index, :new, :create] before_filter :get_category, except: [:index, :new, :create]
def show def show
if [Category::DOMAIN_ARTICLES, Category::DOMAIN_NEWS].include? @category.domain if [Category::DOMAIN_ARTICLES, Category::DOMAIN_NEWS].include? @category.domain
@articles = Article.with_comments.ordered.limited.nodrafts.category params[:id] @articles = Article.with_comments.ordered.limited.nodrafts.category params[:id]
Category.find(params[:id]).read_by! cuser if cuser Category.find(params[:id]).read_by! cuser if cuser
render :partial => "articles/article", :collection => @articles.to_a render partial: 'articles/article', collection: @articles.to_a
end end
end end

View file

@ -1,5 +1,5 @@
class ChallengesController < ApplicationController class ChallengesController < ApplicationController
before_filter :get_challenge, :only => ['show', 'edit', 'update', 'destroy'] before_filter :get_challenge, only: [:show, :edit, :update, :destroy]
def index def index
@challenges = Challenge.all @challenges = Challenge.all
@ -14,7 +14,7 @@ class ChallengesController < ApplicationController
c.destroy c.destroy
end end
render :text => t(:challenges_cleared) render text: t(:challenges_cleared)
end end
def new def new
@ -34,7 +34,7 @@ class ChallengesController < ApplicationController
flash[:notice] = t(:challenges_create) flash[:notice] = t(:challenges_create)
redirect_to @challenge redirect_to @challenge
else else
render :action => "new" render :new
end end
end end
@ -56,7 +56,7 @@ class ChallengesController < ApplicationController
flash[:notice] = t(:challenges_update) flash[:notice] = t(:challenges_update)
end end
render :action => "show" render :show
end end
def destroy def destroy

View file

@ -1,5 +1,5 @@
class CommentsController < ApplicationController class CommentsController < ApplicationController
before_filter :get_comment, :only => [:raw, 'edit', 'update', 'destroy'] before_filter :get_comment, only: [:raw, :edit, :update, :destroy]
respond_to :html, :js respond_to :html, :js
def index def index
@ -7,8 +7,8 @@ class CommentsController < ApplicationController
end end
def show def show
@comments = Comment.recent5.all :conditions => {:commentable_id => params[:id2], :commentable_type => params[:id]} @comments = Comment.recent5.all conditions: {commentable_id: params[:id2], commentable_type: params[:id]}
render :partial => 'list', :layout => false render partial: 'list', layout: false
end end
def edit def edit
@ -37,7 +37,7 @@ class CommentsController < ApplicationController
flash[:notice] = t(:comments_update) flash[:notice] = t(:comments_update)
return_to return_to
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class ContestersController < ApplicationController class ContestersController < ApplicationController
before_filter :get_contester, :only => ['show', 'edit', 'update', :recover, :destroy, :recalc] before_filter :get_contester, only: [:show, :edit, :update, :recover, :destroy, :recalc]
def show def show
@matches = Match.future.unfinished.ordered.of_contester @contester @matches = Match.future.unfinished.ordered.of_contester @contester
@ -38,7 +38,7 @@ class ContestersController < ApplicationController
flash[:notice] = t(:contests_contester_update) flash[:notice] = t(:contests_contester_update)
redirect_to @contester redirect_to @contester
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class ContestsController < ApplicationController class ContestsController < ApplicationController
before_filter :get_contest, :only => ['show', 'edit', 'update', 'destroy', 'del_map', 'scores', 'recalc'] before_filter :get_contest, only: [:show, :edit, :update, :destroy, :del_map, :scores, :recalc]
def index def index
# @contests = Contest.all # @contests = Contest.all
@ -60,7 +60,7 @@ class ContestsController < ApplicationController
flash[:notice] = t(:contests_create) flash[:notice] = t(:contests_create)
redirect_to @contest redirect_to @contest
else else
render :action => "new" render :new
end end
end end
@ -71,11 +71,11 @@ class ContestsController < ApplicationController
flash[:notice] = t(:contests_update) flash[:notice] = t(:contests_update)
redirect_to @contest redirect_to @contest
else else
render :action => "edit" render :edit
end end
elsif params[:commit] == "Add map" elsif params[:commit] == "Add map"
@contest.maps << Map.find(params[:map]) @contest.maps << Map.find(params[:map])
render :action => "edit" render :edit
elsif params[:commit] == "Add team" elsif params[:commit] == "Add team"
contester = Contester.new contester = Contester.new
contester.team = Team.find params[:team] contester.team = Team.find params[:team]
@ -86,14 +86,14 @@ class ContestsController < ApplicationController
else else
@contest.errors.add_to_base contester.errors.full_messages.to_s @contest.errors.add_to_base contester.errors.full_messages.to_s
end end
render :action => "edit" render :edit
end end
end end
def del_map def del_map
raise AccessError unless @contest.can_update? cuser raise AccessError unless @contest.can_update? cuser
@contest.maps.delete(Map.find(params[:id2])) @contest.maps.delete(Map.find(params[:id2]))
render :action => "edit" render :edit
end end
def destroy def destroy

View file

@ -1,5 +1,5 @@
class DataFilesController < ApplicationController class DataFilesController < ApplicationController
before_filter :get_file, :only => ['show', 'edit', 'update', 'destroy', 'rate', :addFile, :delFile] before_filter :get_file, only: [:show, :edit, :update, :destroy, :rate, :addFile, :delFile]
def show def show
end end
@ -41,7 +41,7 @@ class DataFilesController < ApplicationController
redirect_to @file redirect_to @file
end end
else else
render :action => "new" render :new
end end
end end
@ -51,7 +51,7 @@ class DataFilesController < ApplicationController
flash[:notice] = t(:files_update) flash[:notice] = t(:files_update)
redirect_to(@file) redirect_to(@file)
else else
render :action => "edit" render :edit
end end
end end
@ -94,7 +94,7 @@ class DataFilesController < ApplicationController
@result << file.to_s + "<br />" @result << file.to_s + "<br />"
end end
end end
render :text => @result, :layout => true render text: @result, layout: true
end end
private private

View file

@ -1,12 +1,12 @@
class DirectoriesController < ApplicationController class DirectoriesController < ApplicationController
before_filter :get_directory, :except => [:new, :create] before_filter :get_directory, except: [:new, :create]
def show def show
if @directory.hidden if @directory.hidden
@files = @directory.files @files = @directory.files
render :partial => "data_files/list", :layout => true render partial: 'data_files/list', layout: true
else else
@directories = Directory.ordered.filtered.all :conditions => {:parent_id => 1} @directories = Directory.ordered.filtered.all conditions: { parent_id: 1 }
end end
end end
@ -22,7 +22,7 @@ class DirectoriesController < ApplicationController
def refresh def refresh
@directory.process_dir @directory.process_dir
render :text => t(:directories_update) render text: t(:directories_update)
end end
def create def create
@ -33,7 +33,7 @@ class DirectoriesController < ApplicationController
flash[:notice] = t(:directories_create) flash[:notice] = t(:directories_create)
redirect_to(@directory) redirect_to(@directory)
else else
render :action => "new" render :new
end end
end end
@ -43,7 +43,7 @@ class DirectoriesController < ApplicationController
flash[:notice] = t(:directories_update) flash[:notice] = t(:directories_update)
redirect_to @directory redirect_to @directory
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class ForumsController < ApplicationController class ForumsController < ApplicationController
before_filter :get_forum, :only => [:show, :edit, :update, :up, :down, :destroy] before_filter :get_forum, only: [:show, :edit, :update, :up, :down, :destroy]
def index def index
@categories = Category.domain(Category::DOMAIN_FORUMS).ordered @categories = Category.domain(Category::DOMAIN_FORUMS).ordered
@ -30,7 +30,7 @@ class ForumsController < ApplicationController
flash[:notice] = t(:forums_create) flash[:notice] = t(:forums_create)
redirect_to(@forum) redirect_to(@forum)
else else
render :action => "new" render :new
end end
end end
@ -40,7 +40,7 @@ class ForumsController < ApplicationController
flash[:notice] = t(:forums_update) flash[:notice] = t(:forums_update)
redirect_to(@forum) redirect_to(@forum)
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class GatherersController < ApplicationController class GatherersController < ApplicationController
before_filter :get_gatherer, :except => [:create] before_filter :get_gatherer, except: [:create]
def create def create
Gather.transaction do Gather.transaction do

View file

@ -1,5 +1,5 @@
class GathersController < ApplicationController class GathersController < ApplicationController
before_filter :get_gather, :except => [:latest, :index, :create] before_filter :get_gather, except: [:latest, :index, :create]
respond_to :html, :js respond_to :html, :js
def index def index

View file

@ -1,5 +1,5 @@
class GroupsController < ApplicationController class GroupsController < ApplicationController
before_filter :get_group, :except => [:index, :new, :create] before_filter :get_group, except: [:index, :new, :create]
def index def index
@groups = Group.all @groups = Group.all
@ -26,7 +26,7 @@ class GroupsController < ApplicationController
flash[:notice] = t(:groups_create) flash[:notice] = t(:groups_create)
redirect_to @group redirect_to @group
else else
render :action => "new" render :new
end end
end end
@ -36,7 +36,7 @@ class GroupsController < ApplicationController
flash[:notice] = t(:groups_update) flash[:notice] = t(:groups_update)
redirect_to @group redirect_to @group
else else
render :action => "edit" render :edit
end end
end end
@ -47,12 +47,12 @@ class GroupsController < ApplicationController
end end
def addUser def addUser
@user = User.first :conditions => {:username => params[:username]} @user = User.first conditions: {username: params[:username]}
raise AccessError unless @group.can_update? cuser raise AccessError unless @group.can_update? cuser
raise Error, t(:duplicate_user) if @group.users.include? @user raise Error, t(:duplicate_user) if @group.users.include? @user
@group.users << @user if @user @group.users << @user if @user
redirect_to edit_group_url(@group, :groupTab => "groupTabMembers") redirect_to edit_group_url(@group, groupTab: "groupTabMembers")
end end
def delUser def delUser
@ -60,7 +60,7 @@ class GroupsController < ApplicationController
raise AccessError unless @group.can_update? cuser raise AccessError unless @group.can_update? cuser
@group.users.delete @user @group.users.delete @user
redirect_to edit_group_url(@group, :groupTab => "groupTabMembers") redirect_to edit_group_url(@group, groupTab: "groupTabMembers")
end end
private private

View file

@ -1,5 +1,5 @@
class IssuesController < ApplicationController class IssuesController < ApplicationController
before_filter :get_issue, :only => [:show, :edit, :update, :destroy] before_filter :get_issue, only: [:show, :edit, :update, :destroy]
def index def index
raise AccessError unless cuser and cuser.admin? raise AccessError unless cuser and cuser.admin?
@ -12,9 +12,9 @@ class IssuesController < ApplicationController
else "created_at DESC" else "created_at DESC"
end end
@open = Issue.with_status(Issue::STATUS_OPEN).all :order => sort @open = Issue.with_status(Issue::STATUS_OPEN).all order: sort
@solved = Issue.with_status(Issue::STATUS_SOLVED).all :order => sort @solved = Issue.with_status(Issue::STATUS_SOLVED).all order: sort
@rejected = Issue.with_status(Issue::STATUS_REJECTED).all :order => sort @rejected = Issue.with_status(Issue::STATUS_REJECTED).all order: sort
end end
def show def show
@ -44,7 +44,7 @@ class IssuesController < ApplicationController
redirect_to_home redirect_to_home
end end
else else
render :action => "new" render :new
end end
end end
@ -54,7 +54,7 @@ class IssuesController < ApplicationController
flash[:notice] = t(:issues_update) flash[:notice] = t(:issues_update)
redirect_to(@issue) redirect_to(@issue)
else else
render :action => "edit" render :edit
end end
end end

View file

@ -6,7 +6,7 @@ class LogEventsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.xml { render :xml => @log_events } format.xml { render xml: @log_events }
end end
end end
@ -17,7 +17,7 @@ class LogEventsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb
format.xml { render :xml => @log_event } format.xml { render xml: @log_event }
end end
end end
@ -28,7 +28,7 @@ class LogEventsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.xml { render :xml => @log_event } format.xml { render xml: @log_event }
end end
end end
@ -46,10 +46,10 @@ class LogEventsController < ApplicationController
if @log_event.save if @log_event.save
flash[:notice] = t(:logevent_create) flash[:notice] = t(:logevent_create)
format.html { redirect_to(@log_event) } format.html { redirect_to(@log_event) }
format.xml { render :xml => @log_event, :status => :created, :location => @log_event } format.xml { render xml: @log_event, :status => :created, :location => @log_event }
else else
format.html { render :action => "new" } format.html { render :new }
format.xml { render :xml => @log_event.errors, :status => :unprocessable_entity } format.xml { render xml: @log_event.errors, :status => :unprocessable_entity }
end end
end end
end end
@ -65,8 +65,8 @@ class LogEventsController < ApplicationController
format.html { redirect_to(@log_event) } format.html { redirect_to(@log_event) }
format.xml { head :ok } format.xml { head :ok }
else else
format.html { render :action => "edit" } format.html { render :edit }
format.xml { render :xml => @log_event.errors, :status => :unprocessable_entity } format.xml { render xml: @log_event.errors, :status => :unprocessable_entity }
end end
end end
end end

View file

@ -1,12 +1,12 @@
class LogFilesController < ApplicationController class LogFilesController < ApplicationController
def index def index
LogFile.process LogFile.process
render :text => "Ok" render text: 'Ok'
end end
def handle def handle
LogFile.find(params[:id]).deal LogFile.find(params[:id]).deal
render :text => "Ok" render text: 'Ok'
end end
def refresh def refresh
@ -16,7 +16,7 @@ class LogFilesController < ApplicationController
end end
def fix def fix
Rounder.find_in_batches(:batch_size => 100) do |rounders| Rounder.find_in_batches(batch_size: 100) do |rounders|
rounders.each do |r| rounders.each do |r|
r.team_id = nil r.team_id = nil
if r.user and t = Teamer.historic(r.user, r.round.start).first if r.user and t = Teamer.historic(r.user, r.round.start).first

View file

@ -1,5 +1,5 @@
class MapsController < ApplicationController class MapsController < ApplicationController
before_filter :get_map, :only => [:show, :edit, :update, :destroy] before_filter :get_map, only: [:show, :edit, :update, :destroy]
def index def index
@maps = Map.basic @maps = Map.basic
@ -25,7 +25,7 @@ class MapsController < ApplicationController
flash[:notice] = t(:maps_create) flash[:notice] = t(:maps_create)
redirect_to @map redirect_to @map
else else
render :action => "new" render :new
end end
end end
@ -35,7 +35,7 @@ class MapsController < ApplicationController
flash[:notice] = t(:maps_update) flash[:notice] = t(:maps_update)
redirect_to @map redirect_to @map
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,12 +1,12 @@
class MatchesController < ApplicationController class MatchesController < ApplicationController
before_filter :get_match, :except => [:index, :new, :create] before_filter :get_match, except: [:index, :new, :create]
def index def index
@matches = Match.active @matches = Match.active
end end
def show def show
@ownpred = @match.predictions.first :conditions => {:user_id => cuser.id} if cuser @ownpred = @match.predictions.first conditions: {user_id: cuser.id} if cuser
@newpred = @match.predictions.build @newpred = @match.predictions.build
end end
@ -40,9 +40,9 @@ class MatchesController < ApplicationController
if @match.save if @match.save
flash[:notice] = t(:matches_create) flash[:notice] = t(:matches_create)
redirect_to :controller => "contests", :action => "edit", :id => @match.contest redirect_to controller: 'contests', action: 'edit', id: @match.contest
else else
render :action => "new" render :new
end end
end end
@ -69,7 +69,7 @@ class MatchesController < ApplicationController
end end
end end
else else
render :action => "edit" render :edit
end end
end end
@ -88,13 +88,13 @@ class MatchesController < ApplicationController
@match.hltv_stop @match.hltv_stop
flash[:notice] = t(:hltv_stopped) flash[:notice] = t(:hltv_stopped)
end end
redirect_to :action => "show" redirect_to action: 'show'
end end
def destroy def destroy
raise AccessError unless @match.can_destroy? cuser raise AccessError unless @match.can_destroy? cuser
@match.destroy @match.destroy
redirect_to :controller => "contests", :action => "edit", :id => @match.contest redirect_to controller: 'contests', action: 'edit', id: @match.contest
end end
private private

View file

@ -1,5 +1,5 @@
class MessagesController < ApplicationController class MessagesController < ApplicationController
before_filter :get_message, :only => [:show, :edit, :update, :destroy] before_filter :get_message, only: [:show, :edit, :update, :destroy]
def index def index
raise AccessError unless cuser raise AccessError unless cuser
@ -37,7 +37,7 @@ class MessagesController < ApplicationController
flash[:notice] = t(:message_create) flash[:notice] = t(:message_create)
redirect_to(@message) redirect_to(@message)
else else
render :action => "new" render :new
end end
end end

View file

@ -1,5 +1,5 @@
class MoviesController < ApplicationController class MoviesController < ApplicationController
before_filter :get_movie, :except => [:index, :new, :create] before_filter :get_movie, except: [:index, :new, :create]
def index def index
@movies = [] @movies = []
@ -48,7 +48,7 @@ class MoviesController < ApplicationController
flash[:notice] = t(:movies_create) flash[:notice] = t(:movies_create)
redirect_to(@movie) redirect_to(@movie)
else else
render :action => "new" render :new
end end
end end
@ -59,7 +59,7 @@ class MoviesController < ApplicationController
flash[:notice] = t(:movies_update) flash[:notice] = t(:movies_update)
redirect_to(@movie) redirect_to(@movie)
else else
render :action => "edit" render :edit
end end
end end
@ -67,20 +67,20 @@ class MoviesController < ApplicationController
raise AccessError unless @movie.can_update? cuser raise AccessError unless @movie.can_update? cuser
x = params[:x].to_i <= 1280 ? params[:x].to_i : 800 x = params[:x].to_i <= 1280 ? params[:x].to_i : 800
y = params[:y].to_i <= 720 ? params[:y].to_i : 600 y = params[:y].to_i <= 720 ? params[:y].to_i : 600
render :text => t(:executed) + "<br />" + @movie.make_preview(x, y), :layout => true render text: t(:executed) + "<br />" + @movie.make_preview(x, y), layout: true
end end
def snapshot def snapshot
raise AccessError unless @movie.can_update? cuser raise AccessError unless @movie.can_update? cuser
secs = params[:secs].to_i > 0 ? params[:secs].to_i : 5 secs = params[:secs].to_i > 0 ? params[:secs].to_i : 5
render :text => t(:executed) + "<br />" + @movie.make_snapshot(secs), :layout => true render text: t(:executed) + "<br />" + @movie.make_snapshot(secs), layout: true
end end
def download def download
raise AccessError unless cuser.admin? raise AccessError unless cuser.admin?
@movie.stream_ip = params[:ip] @movie.stream_ip = params[:ip]
@movie.stream_port = params[:port] @movie.stream_port = params[:port]
render :text => t(:executed) + "<br />" + @movie.make_stream, :layout => true render text: t(:executed) + "<br />" + @movie.make_stream, layout: true
end end
def destroy def destroy

View file

@ -1,5 +1,5 @@
class PollsController < ApplicationController class PollsController < ApplicationController
before_filter :get_poll, :except => [:index, :new, :create] before_filter :get_poll, except: [:index, :new, :create]
respond_to :js respond_to :js
def add def add
@ -14,7 +14,7 @@ class PollsController < ApplicationController
flash[:notice] = t(:polls_create) flash[:notice] = t(:polls_create)
redirect_to @poll redirect_to @poll
else else
render :action => "new" render :new
end end
end end
@ -25,7 +25,7 @@ class PollsController < ApplicationController
flash[:notice] = t(:polls_update) flash[:notice] = t(:polls_update)
redirect_to @poll redirect_to @poll
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class PollsController < ApplicationController class PollsController < ApplicationController
before_filter :get_poll, :except => [:index, :new, :create] before_filter :get_poll, except: [:index, :new, :create]
def index def index
@polls = Poll.all @polls = Poll.all
@ -27,7 +27,7 @@ class PollsController < ApplicationController
flash[:notice] = t(:polls_create) flash[:notice] = t(:polls_create)
redirect_to @poll redirect_to @poll
else else
render :action => "new" render :new
end end
end end
@ -38,7 +38,7 @@ class PollsController < ApplicationController
flash[:notice] = t(:polls_update) flash[:notice] = t(:polls_update)
redirect_to @poll redirect_to @poll
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,5 +1,5 @@
class PostsController < ApplicationController class PostsController < ApplicationController
before_filter :get_post, :except => [:new, :create] before_filter :get_post, except: [:new, :create]
respond_to :html, :js respond_to :html, :js
def quote def quote
@ -10,12 +10,12 @@ class PostsController < ApplicationController
@post = Post.new @post = Post.new
@post.topic = Topic.find(params[:id]) @post.topic = Topic.find(params[:id])
raise AccessError unless @post.can_create? cuser raise AccessError unless @post.can_create? cuser
render :layout => "forums" render layout: 'forums'
end end
def edit def edit
raise AccessError unless @post.can_update? cuser raise AccessError unless @post.can_update? cuser
render :layout => "forums" render layout: 'forums'
end end
def create def create
@ -40,7 +40,7 @@ class PostsController < ApplicationController
flash[:notice] = t(:posts_update) flash[:notice] = t(:posts_update)
redirect_to @post.topic redirect_to @post.topic
else else
render :action => "edit" render :edit
end end
end end

View file

@ -10,12 +10,12 @@ class RoundsController < ApplicationController
end end
@rounds = Round.basic.paginate \ @rounds = Round.basic.paginate \
:order => sort, order: sort,
:page => params[:page], page: params[:page],
:per_page => 30 per_page: 30
if params[:ajax] if params[:ajax]
render :partial => "list", :layout => false render partial: 'list', layout: false
return return
end end
end end

View file

@ -1,5 +1,5 @@
class ServersController < ApplicationController class ServersController < ApplicationController
before_filter :get_server, :except => [:index, :refresh, :new, :create] before_filter :get_server, except: [:index, :refresh, :new, :create]
def refresh def refresh
Server.refresh Server.refresh
@ -30,7 +30,7 @@ class ServersController < ApplicationController
raise AccessError unless @server.can_update? cuser raise AccessError unless @server.can_update? cuser
if request.xhr? if request.xhr?
render :partial => "response", :layout => false render partial: 'response', layout: false
end end
end end
@ -43,7 +43,7 @@ class ServersController < ApplicationController
flash[:notice] = t(:server_create) flash[:notice] = t(:server_create)
redirect_to @server redirect_to @server
else else
render :action => "new" render :new
end end
end end
@ -54,14 +54,14 @@ class ServersController < ApplicationController
flash[:notice] = t(:server_update) flash[:notice] = t(:server_update)
redirect_to @server redirect_to @server
else else
render :action => "edit" render :edit
end end
end end
def default def default
raise AccessError unless @server.can_update? cuser raise AccessError unless @server.can_update? cuser
@server.default_record @server.default_record
render :text => "Ok" render text: 'Ok'
end end
def destroy def destroy

View file

@ -1,5 +1,5 @@
class TeamsController < ApplicationController class TeamsController < ApplicationController
before_filter :get_team, :only => ['show', 'edit', 'update', 'destroy', 'recover'] before_filter :get_team, only: [:show, :edit, :update, :destroy, :recover]
def index def index
@teams = Team.with_teamers_num(0).ordered @teams = Team.with_teamers_num(0).ordered
@ -26,7 +26,7 @@ class TeamsController < ApplicationController
flash[:notice] = t(:teams_create) flash[:notice] = t(:teams_create)
redirect_to @team redirect_to @team
else else
render :action => "new" render :new
end end
end end
@ -48,7 +48,7 @@ class TeamsController < ApplicationController
flash[:notice] = t(:teams_update) flash[:notice] = t(:teams_update)
redirect_to edit_team_path(@team) redirect_to edit_team_path(@team)
else else
render :action => "edit" render :edit
end end
end end

View file

@ -1,8 +1,8 @@
class TopicsController < ApplicationController class TopicsController < ApplicationController
before_filter :get_topic, :only => [:show, :reply, :edit, :update, :destroy] before_filter :get_topic, only: [:show, :reply, :edit, :update, :destroy]
def index def index
render :partial => true, :locals => {:page => params[:p].to_i} render partial: true, locals: {page: params[:p].to_i}
end end
def show def show
@ -18,16 +18,16 @@ class TopicsController < ApplicationController
@newpost.topic = @topic @newpost.topic = @topic
@newpost.user = cuser @newpost.user = cuser
@lock = (@topic.lock ? @topic.lock : Lock.new(:lockable => @topic)) @lock = (@topic.lock ? @topic.lock : Lock.new(:lockable => @topic))
render :layout => "forums" render layout: 'forums'
end end
def reply def reply
@post = @topic.posts.build @post = @topic.posts.build
raise AccessError unless @post.can_create? cuser raise AccessError unless @post.can_create? cuser
if request.xhr? if request.xhr?
render "quickreply", :layout => false render 'quickreply', layout: false
else else
render :layout => "forums" render layout: 'forums'
end end
end end
@ -35,12 +35,12 @@ class TopicsController < ApplicationController
@topic = Topic.new @topic = Topic.new
@topic.forum = Forum.find(params[:id]) @topic.forum = Forum.find(params[:id])
raise AccessError unless @topic.can_create? cuser raise AccessError unless @topic.can_create? cuser
render :layout => "forums" render layout: 'forums'
end end
def edit def edit
raise AccessError unless @topic.can_update? cuser raise AccessError unless @topic.can_update? cuser
render :layout => "forums" render layout: 'forums'
end end
def create def create
@ -52,7 +52,7 @@ class TopicsController < ApplicationController
flash[:notice] = t(:topics_create) flash[:notice] = t(:topics_create)
redirect_to(@topic) redirect_to(@topic)
else else
render :action => "new" render :new
end end
end end
@ -62,7 +62,7 @@ class TopicsController < ApplicationController
flash[:notice] = t(:topics_update) flash[:notice] = t(:topics_update)
redirect_to(@topic) redirect_to(@topic)
else else
render :action => "edit" render :edit
end end
end end

View file

@ -3,7 +3,7 @@ require 'open-uri'
class TweetsController < ApplicationController class TweetsController < ApplicationController
def index def index
@tweets = Tweet.all :order => "created_at DESC" @tweets = Tweet.all order: "created_at DESC"
@nobody = true @nobody = true
end end
@ -24,6 +24,6 @@ class TweetsController < ApplicationController
end end
end end
render :text => t(:tweets_refresh) render text: t(:tweets_refresh)
end end
end end

View file

@ -1,9 +1,9 @@
class UsersController < ApplicationController class UsersController < ApplicationController
before_filter :get_user, :only => [:show, :history, :popup, :agenda, :edit, :update, :destroy] before_filter :get_user, only: [:show, :history, :popup, :agenda, :edit, :update, :destroy]
respond_to :html, :js respond_to :html, :js
def index def index
@users = User.search(params[:search]).paginate(:per_page => 40, :page => params[:page]) @users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
end end
def show def show
@ -29,7 +29,7 @@ class UsersController < ApplicationController
end end
def popup def popup
render :layout => false render layout: false
end end
def new def new
@ -54,10 +54,10 @@ class UsersController < ApplicationController
@user.profile = Profile.new @user.profile = Profile.new
@user.profile.user = @user @user.profile.user = @user
@user.profile.save() @user.profile.save()
redirect_to :action => :show, :id => @user.id redirect_to action: :show, id: @user.id
save_session @user save_session @user
else else
render :action => "new" render :new
end end
end end
@ -67,7 +67,7 @@ class UsersController < ApplicationController
flash[:notice] = t(:users_update) flash[:notice] = t(:users_update)
redirect_to_back redirect_to_back
else else
render :action => "edit" render :edit
end end
end end

View file

@ -3,13 +3,13 @@ class VersionsController < ApplicationController
def index def index
@versions = @article.versions @versions = @article.versions
render "articles/history" render 'articles/history'
end end
def show def show
@version = @article.versions.find params[:id] @version = @article.versions.find params[:id]
@nobody = true @nobody = true
render "articles/version" render 'articles/version'
end end
def update def update

View file

@ -1,6 +1,6 @@
class VotesController < ApplicationController class VotesController < ApplicationController
def create def create
@vote = Vote.new params[:vote] @vote = Vote.new(params[:vote])
@vote.user = cuser @vote.user = cuser
raise AccessError unless @vote.can_create? cuser raise AccessError unless @vote.can_create? cuser

View file

@ -1,9 +1,9 @@
class WeeksController < ApplicationController class WeeksController < ApplicationController
before_filter :get_week, :except => [:new, :create] before_filter :get_week, except: [:new, :create]
def new def new
@week = Week.new @week = Week.new
@week.contest = Contest.find params[:id] @week.contest = Contest.find(params[:id])
raise AccessError unless @week.can_create? cuser raise AccessError unless @week.can_create? cuser
end end
@ -19,7 +19,7 @@ class WeeksController < ApplicationController
flash[:notice] = t(:weeks_create) flash[:notice] = t(:weeks_create)
redirect_to @week.contest redirect_to @week.contest
else else
render :action => "new" render :new
end end
end end
@ -30,7 +30,7 @@ class WeeksController < ApplicationController
flash[:notice] = t(:weeks_update) flash[:notice] = t(:weeks_update)
redirect_to @week.contest redirect_to @week.contest
else else
render :action => "edit" render :edit
end end
end end
@ -43,6 +43,6 @@ class WeeksController < ApplicationController
private private
def get_week def get_week
@week = Week.find params[:id] @week = Week.find(params[:id])
end end
end end

View file

@ -37,26 +37,26 @@ class Article < ActiveRecord::Base
attr_protected :id, :updated_at, :created_at, :user_id, :version attr_protected :id, :updated_at, :created_at, :user_id, :version
scope :recent, :order => "created_at DESC", :limit => 8 scope :recent, order: 'created_at DESC', limit: 8
scope :with_comments, scope :with_comments,
:select => "articles.*, COUNT(C.id) AS comment_num", select: "articles.*, COUNT(C.id) AS comment_num",
:joins => "LEFT JOIN comments C ON C.commentable_type = 'Article' AND C.commentable_id = articles.id", joins: "LEFT JOIN comments C ON C.commentable_type = 'Article' AND C.commentable_id = articles.id",
:group => "articles.id" group: "articles.id"
scope :ordered, :order => "articles.created_at DESC" scope :ordered, order: 'articles.created_at DESC'
scope :limited, :limit => 5 scope :limited, limit: 5
scope :nodrafts, :conditions => {:status => STATUS_PUBLISHED} scope :nodrafts, conditions: { status: STATUS_PUBLISHED }
scope :drafts, :conditions => {:status => STATUS_DRAFT} scope :drafts, conditions: { status: STATUS_DRAFT }
scope :articles, :conditions => ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_ARTICLES] scope :articles, conditions: ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_ARTICLES]
scope :onlynews, :conditions => ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_NEWS] scope :onlynews, conditions: ["category_id IN (SELECT id FROM categories WHERE domain = ?)", Category::DOMAIN_NEWS]
scope :category, lambda { |cat| {:conditions => {:category_id => cat}} } scope :category, lambda { |cat| { conditions: { category_id: cat } } }
scope :domain, lambda { |domain| {:include => "category", :conditions => {"categories.domain" => domain}} } scope :domain, lambda { |domain| { includes: 'category', conditions: { "categories.domain" => domain } } }
scope :nospecial, :conditions => ["category_id != ?", Category::SPECIAL] scope :nospecial, conditions: ["category_id != ?", Category::SPECIAL]
scope :interviews, :conditions => ["category_id = ?", Category::INTERVIEWS] scope :interviews, conditions: ["category_id = ?", Category::INTERVIEWS]
belongs_to :user belongs_to :user
belongs_to :category belongs_to :category
has_many :comments, :as => :commentable, :order => "created_at ASC", :dependent => :destroy has_many :comments, as: :commentable, order: 'created_at ASC', dependent: :destroy
has_many :files, :class_name => "DataFile", :order => "created_at DESC", :dependent => :destroy has_many :files, class_name: 'DataFile', order: 'created_at DESC', dependent: :destroy
validates_length_of :title, :in => 1..50 validates_length_of :title, :in => 1..50
validates_length_of :text, :in => 1..16000000 validates_length_of :text, :in => 1..16000000
@ -82,11 +82,11 @@ class Article < ActiveRecord::Base
end end
def previous_article def previous_article
category.articles.nodrafts.first(:conditions => ["id < ?", self.id], :order => "id DESC") category.articles.nodrafts.first(conditions: ["id < ?", self.id], order: "id DESC")
end end
def next_article def next_article
category.articles.nodrafts.first(:conditions => ["id > ?", self.id], :order => "id ASC") category.articles.nodrafts.first(conditions: ["id > ?", self.id], order: "id ASC")
end end
def statuses def statuses
@ -114,11 +114,11 @@ class Article < ActiveRecord::Base
if (new_record? or status_changed?) and status == STATUS_PUBLISHED if (new_record? or status_changed?) and status == STATUS_PUBLISHED
case category.domain case category.domain
when Category::DOMAIN_NEWS when Category::DOMAIN_NEWS
Profile.all(:include => :user, :conditions => "notify_news = 1").each do |p| Profile.all(includes: :user, conditions: "notify_news = 1").each do |p|
Notifications.news p.user, self if p.user Notifications.news p.user, self if p.user
end end
when Category::DOMAIN_ARTICLES when Category::DOMAIN_ARTICLES
Profile.all(:include => :user, :conditions => "notify_articles = 1").each do |p| Profile.all(includes: :user, conditions: "notify_articles = 1").each do |p|
Notifications.article p.user, self if p.user Notifications.article p.user, self if p.user
end end
end end

View file

@ -29,16 +29,16 @@ class Ban < ActiveRecord::Base
attr_protected :id, :created_at, :updated_at attr_protected :id, :created_at, :updated_at
attr_accessor :ts, :sign, :len, :user_name attr_accessor :ts, :sign, :len, :user_name
scope :ordered, :order => "created_at DESC" scope :ordered, order: "created_at DESC"
scope :effective, :conditions => "expiry > UTC_TIMESTAMP()" scope :effective, conditions: "expiry > UTC_TIMESTAMP()"
scope :ineffective, :conditions => "expiry < UTC_TIMESTAMP()" scope :ineffective, conditions: "expiry < UTC_TIMESTAMP()"
validate :validate_ts validate :validate_ts
validate :validate_type validate :validate_type
validate :validate_ventban validate :validate_ventban
validates_format_of :steamid, :with => /\A([0-9]{1,10}:){2}[0-9]{1,10}\Z/, :allow_blank => true validates_format_of :steamid, with: /\A([0-9]{1,10}:){2}[0-9]{1,10}\Z/, allow_blank: true
validates_format_of :addr, :with => /\A([0-9]{1,3}\.){3}[0-9]{1,3}:?[0-9]{0,5}\z/, :allow_blank => true validates_format_of :addr, with: /\A([0-9]{1,3}\.){3}[0-9]{1,3}:?[0-9]{0,5}\z/, allow_blank: true
validates_length_of :reason, :maximum => 255, :allow_nil => true, :allow_blank => true validates_length_of :reason, maximum: 255, allow_nil: true, allow_blank: true
before_validation :check_user before_validation :check_user
@ -78,8 +78,8 @@ class Ban < ActiveRecord::Base
if user_name if user_name
self.user = User.find_by_username(user_name) self.user = User.find_by_username(user_name)
else else
self.user = User.first(:conditions => {:steamid => steamid}) self.user = User.first(conditions: { steamid: steamid })
self.server = Server.first(:conditions => ["CONCAT(ip, ':', port) = ?", addr]) self.server = Server.first(conditions: ["CONCAT(ip, ':', port) = ?", addr])
end end
end end