- @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
            = form_for match do |f|
              = f.hidden_field :caster_id, {:value => nil}
              = namelink match.caster
              - if match.can_update?(cuser, {:caster_id => nil})
                = link_to "#form_submit" do
                  %i.fa.fa-times
          - elsif match.can_update?(cuser, {:caster_id => cuser.id})
            = form_for match do |f|
              - if cuser.admin?
                = f.collection_select :caster_id, Group.casters, :id, :username, {:include_blank => true}, {:class => "autosubmit"}
              - else
                = f.hidden_field :caster_id, {:value => cuser.id}
                = link_to "Take!", "#form_submit"
        %td
          - if match.referee
            = form_for match do |f|
              = f.hidden_field :referee_id, {:value => nil}
              = namelink match.referee
              - if match.can_update?(cuser, {:referee_id => nil})
                = link_to "#form_submit" do
                  %i.fa.fa-times
          - elsif match.can_update?(cuser, {:referee_id => cuser.id})
            = form_for match do |f|
              - if cuser.admin?
                = f.collection_select :referee_id, User.refadmins, :id, :username, {:include_blank => true}, {:class => "autosubmit"}
              - else
                = f.hidden_field :referee_id, {:value => cuser.id}
                = link_to "Take!", "#form_submit"
        %td.actions
          - if cuser.ref? || cuser.admin?
            = link_to "Admin", "/matches/ref/#{match.id}"