ozfortress/citadel

View on GitHub
app/views/leagues/matches/show.html.haml

Summary

Maintainability
Test Coverage
- match_p = present(@match)

- content_for(:title) { safe_join([match_p, @league.name], ' | ') }

- if user_can_edit_league?
  = link_to edit_match_path(@match), class: 'btn btn-secondary pull-right' do
    Edit
    = inline_svg_tag 'open_iconic/pencil.svg', class: 'icon ml-1'

%h1= present(@league).link
%h2
  - if @league.divisions.size > 1
    #{@match.division.name} -
  = match_p.round_s

- if @match.bye?
  %br

  This match is counted as a win for #{match_p.home_team.link}.
  = @league.points_per_match_win
  - if @league.points_per_match_win == 1
    point has been awarded
  - else
    points have been awarded

- else
  %table.table.mb-2
    %thead
      %tr
        %th
          %h5.mb-0= present(@match.home_team).link
          %small Home Team
        %th.text-center.align-middle vs
        %th
          %h5.mb-0= present(@match.away_team).link
          %small Away Team
    %tbody
      - match_p.players do |home_user, away_user|
        %tr
          %td= render 'users/listing', user: home_user, team: @match.home_team.team if home_user
          %td
          %td= render 'users/listing', user: away_user, team: @match.away_team.team if away_user


  .card.mb-3
    .card-header Results #{match_p.status}

    - can_view_scores = !@match.confirmed? && user_can_either_teams? && @league.matches_submittable?
    - if can_view_scores || user_can_edit_league?
      = render 'leagues/matches/match_scores', match: @match, pick_bans: @pick_bans
    - else
      = render 'leagues/matches/match_results',
               match: @match, pick_bans: @pick_bans

  - if @match.notice.present? && (user_on_either_teams? || user_can_edit_league?)
    .card.mb-3
      .card-header Match Notice
      .card-body.markdown= match_p.notice

  - if @match.home_team.schedule_data && @match.away_team.schedule_data
    = render 'leagues/matches/schedule', match: @match, league: @league

  = render 'leagues/matches/match_comms', league: @league, match: @match, comm: @comm, comms: @comms