mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 21:31:28 +00:00
Fix models and views related to matches/contets
This commit is contained in:
parent
6c780c84db
commit
56303d39ba
7 changed files with 8 additions and 5 deletions
|
@ -48,6 +48,7 @@ class MatchesController < ApplicationController
|
|||
|
||||
def update
|
||||
raise AccessError unless @match.can_update? cuser, params[:match]
|
||||
# FIXME: better implementation
|
||||
if params[:match][:matchers_attributes]
|
||||
params[:match][:matchers_attributes].each do |key, matcher|
|
||||
matcher["_destroy"] = matcher["_destroy"] == "keep" ? false : true
|
||||
|
|
|
@ -59,6 +59,8 @@ class Match < ActiveRecord::Base
|
|||
has_many :users, :through => :matchers
|
||||
has_many :predictions, :dependent => :destroy
|
||||
has_many :comments, -> { order("created_at") }, :as => :commentable, :dependent => :destroy
|
||||
has_many :match_proposals, inverse_of: :match, dependent: :destroy
|
||||
|
||||
belongs_to :challenge
|
||||
belongs_to :contest
|
||||
belongs_to :contester1, -> { includes('team') }, :class_name => "Contester"
|
||||
|
|
|
@ -244,7 +244,7 @@
|
|||
<%= namelink match.contester2.team %>
|
||||
</td>
|
||||
<td>
|
||||
<%= longtime match.match_time %>
|
||||
<%= link_to (longtime match.match_time), match %>
|
||||
</td>
|
||||
<td>
|
||||
<% link_to match do %>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<div class="fields horizontal">
|
||||
<%= f.label :referee_id %>
|
||||
<%= f.select :referee_id, Group.find(Group::REFEREES).users.collect{|u| [u, u.id]}, {:include_blank => true} %>
|
||||
<%= f.select :referee_id, Group.referees.collect{|u| [u, u.id]}, {:include_blank => true} %>
|
||||
</div>
|
||||
<div class="fields horizontal">
|
||||
<%= f.label :week_id %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="players">
|
||||
<% contester.lineup.each do |teamer| %>
|
||||
<div class="player fields">
|
||||
<% if matcher = @match.matchers.first(conditions: { user_id: teamer.user_id, contester_id: contester.id }) %>
|
||||
<% if matcher = @match.matchers.where(user_id: teamer.user_id, contester_id: contester.id).first %>
|
||||
<%= hidden_field_tag "match[matchers_attributes][#{@n}][id]", matcher.id %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<th class="maps">Maps</th>
|
||||
<% end %>
|
||||
<th class="score">Score</th>
|
||||
<% if matches&.first.contest.contest_type == Contest::TYPE_LADDER %>
|
||||
<% if matches.first&.contest&.contest_type == Contest::TYPE_LADDER %>
|
||||
<th class="points">Points</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
|
||||
<% if cuser and @match.can_update? cuser, [:report] %>
|
||||
<div class="referee">
|
||||
<%= link_to "Referee Admin", match_ref_path(@match), class: 'button' %>
|
||||
<%= link_to "Referee Admin", ref_match_path(@match), class: 'button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if cuser and @match.referee.nil? and cuser.ref? %>
|
||||
|
|
Loading…
Reference in a new issue