Add match admin page and casting

This commit is contained in:
Ari Timonen 2014-05-10 11:44:48 +03:00
parent faa895b3f0
commit d91a2eae52
17 changed files with 126 additions and 61 deletions

View file

@ -35,6 +35,7 @@ gem 'sass-rails', '~> 3.2.6'
gem 'font-awesome-sass', '~> 4.0.3.1'
gem 'bourbon', '~> 3.1.8'
gem 'neat', '~> 1.6.0'
gem 'haml'
group :assets do
gem 'uglifier', '~> 2.5.0'

View file

@ -114,6 +114,8 @@ GEM
font-awesome-sass (4.0.3.1)
sass (~> 3.2)
gruff (0.3.7)
haml (4.0.5)
tilt
hike (1.2.3)
i18n (0.6.9)
journey (1.0.4)
@ -277,6 +279,7 @@ DEPENDENCIES
faraday (~> 0.9.0)
font-awesome-sass (~> 4.0.3.1)
gruff (~> 0.3.6)
haml
jquery-rails (~> 2.0.2)
mysql2 (~> 0.3.15)
neat (~> 1.6.0)

View file

@ -27,4 +27,8 @@ $ ->
$select.trigger 'DOMSubtreeModified'
$('a[href=#form_submit]').click ->
$(this).closest('form').submit()
return false
$('#notification').delay(3000).fadeOut()

View file

@ -1,5 +1,5 @@
class MatchesController < ApplicationController
before_filter :get_match, except: [:index, :new, :create]
before_filter :get_match, except: [:index, :new, :create, :admin]
def index
@matches = Match.active
@ -16,6 +16,11 @@ class MatchesController < ApplicationController
raise AccessError unless @match.can_create? cuser
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"
end
def extra
end
@ -64,8 +69,11 @@ class MatchesController < ApplicationController
format.xml { head :ok }
format.html do
flash[:notice] = t(:matches_update)
#redirect_to_back
redirect_to @match
if URI(request.referer).path.include?("admin")
redirect_to_back
else
redirect_to @match
end
end
end
else

View file

@ -17,7 +17,7 @@ class Group < ActiveRecord::Base
MOVIES = 3
DONORS = 4
MOVIEMAKERS = 5
SHOUTCASTERS = 6
CASTERS = 6
CHAMPIONS = 7
PREDICTORS = 8
STAFF = 10
@ -48,7 +48,7 @@ class Group < ActiveRecord::Base
def self.staff
staff = []
(find(ADMINS).groupers + find(PREDICTORS).groupers + find(SHOUTCASTERS).groupers + find(STAFF).groupers + find(REFEREES).groupers).each do |g|
(find(ADMINS).groupers + find(PREDICTORS).groupers + find(CASTERS).groupers + find(STAFF).groupers + find(REFEREES).groupers).each do |g|
staff << g unless staff.include? g
end
staff
@ -78,11 +78,11 @@ class Group < ActiveRecord::Base
extras
end
def self.shoutcasters
shoutcasters = []
(find(SHOUTCASTERS).groupers).each do |g|
shoutcasters << g unless shoutcasters.include? g
def self.casters
casters = []
(find(CASTERS).groupers).each do |g|
casters << g unless casters.include? g
end
shoutcasters
casters
end
end

View file

@ -54,6 +54,7 @@ class Match < ActiveRecord::Base
belongs_to :week
belongs_to :hltv, :class_name => "Server"
belongs_to :stream, :class_name => "Movie"
belongs_to :caster, :class_name => "User"
scope :future, :conditions => ["match_time > UTC_TIMESTAMP()"]
scope :future5, :conditions => ["match_time > UTC_TIMESTAMP()"], :limit => 5
@ -293,6 +294,7 @@ class Match < ActiveRecord::Base
def can_update? cuser, params = {}
return false unless cuser
return true if cuser.admin?
return true if cuser.caster? and Verification.contain params, [:caster_id]
return true if cuser.ref? and !referee and Verification.contain params, [:referee_id]
return true if cuser.ref? and referee == cuser \
and Verification.contain params, [:score1, :score2, :forfeit, :report, :demo_id, :motm_name, :matchers_attributes, :server_id]

View file

@ -74,6 +74,8 @@ class Profile < ActiveRecord::Base
validates_length_of :achievements, :maximum => 65000
validates_format_of :steam_profile, :with => /\A[A-Za-z0-9_\-\+]{1,40}\z/, :allow_blank => true
validates :stream, :length => {:maximum => 30}
before_validation :init_steam_profile
before_save :parse_text

View file

@ -193,6 +193,10 @@ class User < ActiveRecord::Base
groups.exists? :id => Group::REFEREES
end
def caster?
group.exists? :id => Group::CASTERS
end
def verified?
# created_at < DateTime.now.ago(VERIFICATION_TIME)
true

View file

@ -80,7 +80,7 @@
</table>
</div>
<div class="tab" id="casters">
<h3>Shoutcasters</h3>
<h3>CASTERS</h3>
<table class="striped staff">
<tr>
<th></th>
@ -89,7 +89,7 @@
<th>Task</th>
<th>Age</th>
</tr>
<% Group.shoutcasters.each do |grouper| %>
<% Group.casters.each do |grouper| %>
<tr>
<td class="country"><%= flag grouper.user.country %></td>
<td class="username"><%= namelink grouper.user %></td>

View file

@ -0,0 +1,42 @@
- @matches.each do |week, matches|
%h2=week
%table.striped#matches
%tr
%th.opponent Teams
%th.date Date
%th.maps Maps
%th Score
%th Caster
%th Referee
%th.actions Actions
- matches.each do |match|
%tr
%td
= namelink match.contester1.team
vs
= namelink match.contester2.team
%td
= shorttime match.match_time
%td
= match.map1.to_s + " " + match.map2.to_s
%td
= link_to match, :class => "bold #{match.score_color}" do
= h match.score1
\- #{h match.score2}
%td
- if match.caster
= namelink match.caster
- elsif match.can_update?(cuser, {:caster_id => 1})
= form_for match do |f|
= f.hidden_field :caster_id, {:value => cuser.id}
= link_to "Take!", "#form_submit"
%td
- if match.referee
= namelink match.referee
- elsif match.can_update?(cuser, {:referee_id => 1})
= form_for match do |f|
= f.hidden_field :referee_id, {:value => cuser.id}
= link_to "Take!", "#form_submit"
%td.actions
- if cuser.ref? || cuser.admin?
= link_to "Admin", match_ref_path(match)

View file

@ -99,6 +99,15 @@
<%= cascade @match, [:server, :demo, :referee] %>
<strong>Maps</strong><br>
<%= namelink @match.map1 %>, <%= namelink @match.map2 %>
<% if @match.caster && @match.caster.profile.stream %>
<dl>
<dt>Stream</dt>
<dd>
<%= link_to @match.caster.profile.stream, @match.caster.profile.stream %>
</dd>
</dl>
<% end %>
</div>
<% unless @match.report.nil? or @match.report.empty? %>

View file

@ -84,6 +84,11 @@
<label>Avatar</label>
<%= p.file_field :avatar %>
</div>
<div class="fields horizontal">
<%= p.label :stream %>
<%= p.text_field :stream %>
</div>
</div>
<div class="tab" id="country">

View file

@ -47,7 +47,10 @@ Ensl::Application.routes.draw do
resources :servers
resources :predictions
resources :rounds
resources :matches
resources :matches do |m|
get :admin, :to => "matches#admin", :on => :collection
get :ref, :to => "matches#ref"
end
resources :maps
resources :logs
resources :log_files

View file

@ -0,0 +1,7 @@
class AddStream < ActiveRecord::Migration
def change
change_table :profiles do |p|
p.string :stream
end
end
end

View file

@ -0,0 +1,7 @@
class AddCaster < ActiveRecord::Migration
def change
change_table :matches do |m|
m.string :caster_id
end
end
end

View file

@ -11,21 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140330152235) do
create_table "admin_requests", :force => true do |t|
t.string "addr"
t.string "pwd"
t.integer "server_id"
t.string "player"
t.integer "user_id"
t.string "msg"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "admin_requests", ["server_id"], :name => "index_admin_requests_on_server_id"
add_index "admin_requests", ["user_id"], :name => "index_admin_requests_on_user_id"
ActiveRecord::Schema.define(:version => 20140510080652) do
create_table "article_versions", :force => true do |t|
t.integer "article_id"
@ -214,16 +200,6 @@ ActiveRecord::Schema.define(:version => 20140330152235) do
add_index "data_files", ["directory_id"], :name => "index_data_files_on_directory_id"
add_index "data_files", ["related_id"], :name => "index_data_files_on_related_id"
create_table "deleteds", :force => true do |t|
t.integer "deletable_id"
t.string "deletable_type"
t.integer "user_id"
t.text "reason"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "related_id"
end
create_table "directories", :force => true do |t|
t.string "name"
t.string "description"
@ -236,21 +212,6 @@ ActiveRecord::Schema.define(:version => 20140330152235) do
add_index "directories", ["parent_id"], :name => "index_directories_on_parent_id"
create_table "firms", :force => true do |t|
t.string "name"
t.string "y_code"
t.string "email"
t.string "website"
t.string "phone"
t.string "address"
t.integer "zipcode"
t.string "town"
t.integer "owner"
t.string "opentime"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "forumers", :force => true do |t|
t.integer "forum_id"
t.integer "group_id"
@ -462,6 +423,7 @@ ActiveRecord::Schema.define(:version => 20140330152235) do
t.integer "points1"
t.integer "points2"
t.integer "hltv_id"
t.string "caster_id"
end
add_index "matches", ["challenge_id"], :name => "index_matches_on_challenge_id"
@ -516,13 +478,6 @@ ActiveRecord::Schema.define(:version => 20140330152235) do
add_index "movies", ["status"], :name => "index_movies_on_status"
add_index "movies", ["user_id"], :name => "index_movies_on_user_id"
create_table "nodes", :force => true do |t|
t.string "name"
t.integer "foreign_key"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "options", :force => true do |t|
t.string "option"
t.integer "poll_id"
@ -631,6 +586,7 @@ ActiveRecord::Schema.define(:version => 20140330152235) do
t.string "steam_profile"
t.string "achievements_parsed"
t.string "signature_parsed"
t.string "stream"
end
add_index "profiles", ["user_id"], :name => "index_profiles_on_user_id"
@ -755,6 +711,18 @@ ActiveRecord::Schema.define(:version => 20140330152235) do
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
create_table "shoutmsg_archive", :force => true do |t|
t.integer "user_id"
t.string "text"
t.datetime "created_at"
t.datetime "updated_at"
t.string "shoutable_type"
t.integer "shoutable_id"
end
add_index "shoutmsg_archive", ["shoutable_type", "shoutable_id"], :name => "index_shoutmsgs_on_shoutable_type_and_shoutable_id"
add_index "shoutmsg_archive", ["user_id"], :name => "index_shoutmsgs_on_user_id"
create_table "shoutmsgs", :force => true do |t|
t.integer "user_id"
t.string "text"

View file

@ -10,7 +10,7 @@ Group.create!(id: Group::REFEREES, name: "Referees", founder: User.first)
Group.create!(id: Group::MOVIES, name: "Movies", founder: User.first)
Group.create!(id: Group::DONORS, name: "Donors", founder: User.first)
Group.create!(id: Group::MOVIEMAKERS, name: "Movie Makers", founder: User.first)
Group.create!(id: Group::SHOUTCASTERS, name: "Casters", founder: User.first)
Group.create!(id: Group::CASTERS, name: "Streamers", founder: User.first)
Group.create!(id: Group::CHAMPIONS, name: "Champions", founder: User.first)
Group.create!(id: Group::PREDICTORS, name: "Predictors", founder: User.first)
Group.create!(id: Group::STAFF, name: "Staff", founder: User.first)