mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 12:30:48 +00:00
Bug fixes, improved consistency & cleanliness
This commit is contained in:
parent
7c1865d8c1
commit
d64d3051dc
3 changed files with 74 additions and 67 deletions
|
@ -17,8 +17,9 @@ class MatchesController < ApplicationController
|
|||
end
|
||||
|
||||
def admin
|
||||
@matches = Match.active.includes(:contest, :contester1, :contester2, :map1, :map2, :referee).all.group_by {|t| t.week.to_s }.to_a.reverse
|
||||
render :layout => "full"
|
||||
@matches = Match.active.includes(:contest, :contester1, :contester2, :map1, :map2, :referee).
|
||||
all.group_by { |t| t.week.to_s }.to_a.reverse
|
||||
render layout: "full"
|
||||
end
|
||||
|
||||
def extra
|
||||
|
@ -39,7 +40,7 @@ class MatchesController < ApplicationController
|
|||
|
||||
if @match.save
|
||||
flash[:notice] = t(:matches_create)
|
||||
redirect_to controller: 'contests', action: 'edit', id: @match.contest
|
||||
redirect_to edit_contest_path(@match.contest)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
@ -49,11 +50,11 @@ class MatchesController < ApplicationController
|
|||
raise AccessError unless @match.can_update? cuser, params[:match]
|
||||
if params[:match][:matchers_attributes]
|
||||
params[:match][:matchers_attributes].each do |key, matcher|
|
||||
matcher['_destroy'] = matcher['_destroy'] == "keep" ? false : true
|
||||
if matcher['user_id'] == ""
|
||||
matcher["_destroy"] = matcher["_destroy"] == "keep" ? false : true
|
||||
if matcher["user_id"] == ""
|
||||
params[:match][:matchers_attributes].delete key
|
||||
elsif matcher['user_id'].to_i == 0
|
||||
matcher['user_id'] = User.find_by_username(matcher['user_id']).id
|
||||
elsif matcher["user_id"].to_i == 0
|
||||
matcher["user_id"] = User.find_by_username(matcher["user_id"]).id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -70,10 +71,15 @@ class MatchesController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if URI(request.referer).path == match_ref_path(@match)
|
||||
ref
|
||||
render :ref
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def hltv
|
||||
raise AccessError unless @match.can_update? cuser, [:hltv]
|
||||
|
@ -90,13 +96,13 @@ class MatchesController < ApplicationController
|
|||
@match.hltv_stop
|
||||
flash[:notice] = t(:hltv_stopped)
|
||||
end
|
||||
redirect_to action: 'show'
|
||||
redirect_to action: "show"
|
||||
end
|
||||
|
||||
def destroy
|
||||
raise AccessError unless @match.can_destroy? cuser
|
||||
@match.destroy
|
||||
redirect_to controller: 'contests', action: 'edit', id: @match.contest
|
||||
redirect_to edit_contest_path(@match.contest)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
4
app/views/matches/show.html.erb
Normal file → Executable file
4
app/views/matches/show.html.erb
Normal file → Executable file
|
@ -117,9 +117,9 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if cuser and @match.can_update? cuser, referee_id: cuser.id %>
|
||||
<% if cuser and @match.can_update? cuser, [:report] %>
|
||||
<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>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
105
config/routes.rb
Normal file → Executable file
105
config/routes.rb
Normal file → Executable file
|
@ -1,6 +1,6 @@
|
|||
Ensl::Application.routes.draw do
|
||||
%w(403 404 422 500).each do |code|
|
||||
get code, to: 'errors#show', code: code
|
||||
get code, to: "errors#show", code: code
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
|
@ -17,12 +17,12 @@ Ensl::Application.routes.draw do
|
|||
resources :versions
|
||||
end
|
||||
|
||||
match 'contests/del_map'
|
||||
match 'contests/scores'
|
||||
match 'contests/historical', to: "contests#historical"
|
||||
match "contests/del_map"
|
||||
match "contests/scores"
|
||||
match "contests/historical", to: "contests#historical"
|
||||
|
||||
resources :contests do
|
||||
get 'current', on: :collection
|
||||
get "current", on: :collection
|
||||
end
|
||||
|
||||
resources :log_events
|
||||
|
@ -30,7 +30,7 @@ Ensl::Application.routes.draw do
|
|||
resources :options
|
||||
resources :polls
|
||||
|
||||
match 'comments/quote'
|
||||
match "comments/quote"
|
||||
|
||||
resources :comments
|
||||
resources :shoutmsgs
|
||||
|
@ -43,8 +43,8 @@ Ensl::Application.routes.draw do
|
|||
resources :forumers
|
||||
resources :topics
|
||||
|
||||
match 'forums/up'
|
||||
match 'forums/down'
|
||||
match "forums/up"
|
||||
match "forums/down"
|
||||
|
||||
resources :forums
|
||||
resources :users
|
||||
|
@ -55,9 +55,10 @@ Ensl::Application.routes.draw do
|
|||
resources :servers
|
||||
resources :predictions
|
||||
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 :ref, to: "matches#ref"
|
||||
end
|
||||
|
||||
resources :maps
|
||||
|
@ -74,65 +75,65 @@ Ensl::Application.routes.draw do
|
|||
resources :tweets
|
||||
resources :issues
|
||||
|
||||
match 'posts/quote'
|
||||
match "posts/quote"
|
||||
|
||||
resources :posts
|
||||
resources :brackets
|
||||
|
||||
match 'about/action'
|
||||
match 'about/staff'
|
||||
match 'about/statistics'
|
||||
match "about/action"
|
||||
match "about/staff"
|
||||
match "about/statistics"
|
||||
|
||||
match 'refresh', to: "application#refresh"
|
||||
match 'search', to: "application#search"
|
||||
match "refresh", to: "application#refresh"
|
||||
match "search", to: "application#search"
|
||||
|
||||
match 'news', to: "articles#news_index"
|
||||
match 'news/archive', to: "articles#news_archive"
|
||||
match 'news/admin', to: "articles#admin"
|
||||
match 'articles/cleanup'
|
||||
match "news", to: "articles#news_index"
|
||||
match "news/archive", to: "articles#news_archive"
|
||||
match "news/admin", to: "articles#admin"
|
||||
match "articles/cleanup"
|
||||
|
||||
match 'data_files/admin'
|
||||
match 'data_files/addFile'
|
||||
match 'data_files/delFile'
|
||||
match 'data_files/trash'
|
||||
match "data_files/admin"
|
||||
match "data_files/addFile"
|
||||
match "data_files/delFile"
|
||||
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/latest/:game', to: "gathers#latest", via: :get
|
||||
match 'gather', to: "gathers#latest", game: "ns2", via: :get
|
||||
match "gathers/refresh"
|
||||
match "gathers/latest/:game", to: "gathers#latest", 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/delUser'
|
||||
match "groups/addUser"
|
||||
match "groups/delUser"
|
||||
|
||||
match 'movies/download'
|
||||
match 'movies/preview'
|
||||
match 'movies/snapshot'
|
||||
match "movies/download"
|
||||
match "movies/preview"
|
||||
match "movies/snapshot"
|
||||
|
||||
match 'plugin/user'
|
||||
match "plugin/user"
|
||||
|
||||
match 'users/forgot'
|
||||
match 'users/recover'
|
||||
match 'users/agenda'
|
||||
match 'users/logout'
|
||||
match 'users/login'
|
||||
match "users/forgot"
|
||||
match "users/recover"
|
||||
match "users/agenda"
|
||||
match "users/logout"
|
||||
match "users/login"
|
||||
|
||||
match 'users/agenda'
|
||||
match 'users/login'
|
||||
match 'users/logout'
|
||||
match 'users/popup'
|
||||
match 'users/forgot', to: "users#forgot"
|
||||
match "users/agenda"
|
||||
match "users/login"
|
||||
match "users/logout"
|
||||
match "users/popup"
|
||||
match "users/forgot", to: "users#forgot"
|
||||
|
||||
match 'votes/create'
|
||||
match "votes/create"
|
||||
|
||||
match ':controller/:action', requirements: { action: /A-Za-z/ }
|
||||
match ':controller/:action/:id'
|
||||
match ':controller/:action/:id.:format'
|
||||
match ':controller/:action/:id/:id2'
|
||||
match ":controller/:action", requirements: { action: /A-Za-z/ }
|
||||
match ":controller/:action/:id"
|
||||
match ":controller/:action/:id.:format"
|
||||
match ":controller/:action/:id/:id2"
|
||||
|
||||
match 'teamers/replace', to: 'teamers#replace', as: 'teamers_replace'
|
||||
match "teamers/replace", to: "teamers#replace", as: "teamers_replace"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue