Bug fixes, improved consistency & cleanliness

This commit is contained in:
Prommah 2015-11-08 09:02:13 +00:00
parent 7c1865d8c1
commit d64d3051dc
3 changed files with 74 additions and 67 deletions

View file

@ -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.first conditions: { user_id: cuser.id } if cuser
@newpred = @match.predictions.build @newpred = @match.predictions.build
end end
@ -17,8 +17,9 @@ class MatchesController < ApplicationController
end end
def admin def admin
@matches = Match.active.includes(:contest, :contester1, :contester2, :map1, :map2, :referee).all.group_by {|t| t.week.to_s }.to_a.reverse @matches = Match.active.includes(:contest, :contester1, :contester2, :map1, :map2, :referee).
render :layout => "full" all.group_by { |t| t.week.to_s }.to_a.reverse
render layout: "full"
end end
def extra def extra
@ -39,7 +40,7 @@ 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 edit_contest_path(@match.contest)
else else
render :new render :new
end end
@ -49,11 +50,11 @@ class MatchesController < ApplicationController
raise AccessError unless @match.can_update? cuser, params[:match] raise AccessError unless @match.can_update? cuser, params[:match]
if params[:match][:matchers_attributes] if params[:match][:matchers_attributes]
params[:match][:matchers_attributes].each do |key, matcher| params[:match][:matchers_attributes].each do |key, matcher|
matcher['_destroy'] = matcher['_destroy'] == "keep" ? false : true matcher["_destroy"] = matcher["_destroy"] == "keep" ? false : true
if matcher['user_id'] == "" if matcher["user_id"] == ""
params[:match][:matchers_attributes].delete key params[:match][:matchers_attributes].delete key
elsif matcher['user_id'].to_i == 0 elsif matcher["user_id"].to_i == 0
matcher['user_id'] = User.find_by_username(matcher['user_id']).id matcher["user_id"] = User.find_by_username(matcher["user_id"]).id
end end
end end
end end
@ -71,7 +72,12 @@ class MatchesController < ApplicationController
end end
end end
else else
render :edit if URI(request.referer).path == match_ref_path(@match)
ref
render :ref
else
render :edit
end
end end
end end
@ -90,13 +96,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 edit_contest_path(@match.contest)
end end
private private

4
app/views/matches/show.html.erb Normal file → Executable file
View file

@ -117,9 +117,9 @@
</div> </div>
<% end %> <% end %>
<% if cuser and @match.can_update? cuser, referee_id: cuser.id %> <% if cuser and @match.can_update? cuser, [:report] %>
<div class="referee"> <div class="referee">
<%= link_to "Referee Admin", { controller: :matches, action: 'ref', id: @match }, class: 'button' %> <%= link_to "Referee Admin", match_ref_path(@match), class: 'button' %>
</div> </div>
<% end %> <% end %>
</div> </div>

109
config/routes.rb Normal file → Executable file
View file

@ -1,6 +1,6 @@
Ensl::Application.routes.draw do Ensl::Application.routes.draw do
%w(403 404 422 500).each do |code| %w(403 404 422 500).each do |code|
get code, to: 'errors#show', code: code get code, to: "errors#show", code: code
end end
namespace :api do namespace :api do
@ -17,12 +17,12 @@ Ensl::Application.routes.draw do
resources :versions resources :versions
end end
match 'contests/del_map' match "contests/del_map"
match 'contests/scores' match "contests/scores"
match 'contests/historical', to: "contests#historical" match "contests/historical", to: "contests#historical"
resources :contests do resources :contests do
get 'current', on: :collection get "current", on: :collection
end end
resources :log_events resources :log_events
@ -30,7 +30,7 @@ Ensl::Application.routes.draw do
resources :options resources :options
resources :polls resources :polls
match 'comments/quote' match "comments/quote"
resources :comments resources :comments
resources :shoutmsgs resources :shoutmsgs
@ -43,8 +43,8 @@ Ensl::Application.routes.draw do
resources :forumers resources :forumers
resources :topics resources :topics
match 'forums/up' match "forums/up"
match 'forums/down' match "forums/down"
resources :forums resources :forums
resources :users resources :users
@ -55,9 +55,10 @@ Ensl::Application.routes.draw do
resources :servers resources :servers
resources :predictions resources :predictions
resources :rounds resources :rounds
resources :matches do |m|
get "matches/ref/:id" => "matches#ref", as: :match_ref
resources :matches do
get :admin, to: "matches#admin", on: :collection get :admin, to: "matches#admin", on: :collection
get :ref, to: "matches#ref"
end end
resources :maps resources :maps
@ -73,66 +74,66 @@ Ensl::Application.routes.draw do
resources :bans resources :bans
resources :tweets resources :tweets
resources :issues resources :issues
match 'posts/quote' match "posts/quote"
resources :posts resources :posts
resources :brackets resources :brackets
match 'about/action' match "about/action"
match 'about/staff' match "about/staff"
match 'about/statistics' match "about/statistics"
match 'refresh', to: "application#refresh" match "refresh", to: "application#refresh"
match 'search', to: "application#search" match "search", to: "application#search"
match 'news', to: "articles#news_index" match "news", to: "articles#news_index"
match 'news/archive', to: "articles#news_archive" match "news/archive", to: "articles#news_archive"
match 'news/admin', to: "articles#admin" match "news/admin", to: "articles#admin"
match 'articles/cleanup' match "articles/cleanup"
match 'data_files/admin' match "data_files/admin"
match 'data_files/addFile' match "data_files/addFile"
match 'data_files/delFile' match "data_files/delFile"
match 'data_files/trash' match "data_files/trash"
match 'contesters/recalc' match "contesters/recalc"
match 'directories', to: "directories#show", id: 1 match "directories", to: "directories#show", id: 1
match 'gathers/refresh' match "gathers/refresh"
match 'gathers/latest/:game', to: "gathers#latest", via: :get match "gathers/latest/:game", to: "gathers#latest", via: :get
match 'gather', to: "gathers#latest", game: "ns2", via: :get match "gather", to: "gathers#latest", game: "ns2", via: :get
match 'gatherers/:id/status', to: "gatherers#status", via: :post match "gatherers/:id/status", to: "gatherers#status", via: :post
match 'groups/addUser' match "groups/addUser"
match 'groups/delUser' match "groups/delUser"
match 'movies/download' match "movies/download"
match 'movies/preview' match "movies/preview"
match 'movies/snapshot' match "movies/snapshot"
match 'plugin/user' match "plugin/user"
match 'users/forgot' match "users/forgot"
match 'users/recover' match "users/recover"
match 'users/agenda' match "users/agenda"
match 'users/logout' match "users/logout"
match 'users/login' match "users/login"
match 'users/agenda' match "users/agenda"
match 'users/login' match "users/login"
match 'users/logout' match "users/logout"
match 'users/popup' match "users/popup"
match 'users/forgot', to: "users#forgot" match "users/forgot", to: "users#forgot"
match 'votes/create' match "votes/create"
match ':controller/:action', requirements: { action: /A-Za-z/ } match ":controller/:action", requirements: { action: /A-Za-z/ }
match ':controller/:action/:id' match ":controller/:action/:id"
match ':controller/:action/:id.:format' match ":controller/:action/:id.:format"
match ':controller/:action/:id/:id2' match ":controller/:action/:id/:id2"
match 'teamers/replace', to: 'teamers#replace', as: 'teamers_replace' match "teamers/replace", to: "teamers#replace", as: "teamers_replace"
end end