diff --git a/Gemfile b/Gemfile index 565cbfd..e5f811a 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 960f152..91e8fde 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index dd04dd1..fa73e42 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -27,4 +27,8 @@ $ -> $select.trigger 'DOMSubtreeModified' + $('a[href=#form_submit]').click -> + $(this).closest('form').submit() + return false + $('#notification').delay(3000).fadeOut() \ No newline at end of file diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 9827dfe..5066916 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -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 diff --git a/app/models/group.rb b/app/models/group.rb index df76445..734ea38 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -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 diff --git a/app/models/match.rb b/app/models/match.rb index c49c468..8e453d3 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -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] diff --git a/app/models/profile.rb b/app/models/profile.rb index 20c5178..194e0f8 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index f56319e..1f06540 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/about/staff.html.erb b/app/views/about/staff.html.erb index bad9e40..ae75282 100644 --- a/app/views/about/staff.html.erb +++ b/app/views/about/staff.html.erb @@ -80,7 +80,7 @@
@@ -89,7 +89,7 @@ | Task | Age |
---|---|---|
<%= flag grouper.user.country %> | <%= namelink grouper.user %> | diff --git a/app/views/matches/admin.html.haml b/app/views/matches/admin.html.haml new file mode 100644 index 0000000..66dfd63 --- /dev/null +++ b/app/views/matches/admin.html.haml @@ -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) \ No newline at end of file diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 8907892..0bd455b 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -99,6 +99,15 @@ <%= cascade @match, [:server, :demo, :referee] %> Maps