KyivKrishnaAcademy/ved_akadem_students

View on GitHub
app/views/courses/index.html.haml

Summary

Maintainability
Test Coverage
- provide(:title, t('.title'))

.row
  .col-xs-12
    %h1.text-center=t('.title')

  - if current_person.can_act?('course:new')
    .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1.vert-offset-bottom-1.text-right
      = link_to_new(true, new_course_path)

  .col-xs-12.col-sm-8.col-sm-offset-2
    .table-responsive
      %table.table.table-condensed.table-striped
        %thead
          %tr
            %th.text-top= t('.course_title')
            %th.text-top= t('.course_variant')
            %th.text-top= t('.course_examination_results_count')
            %th.text-top= t('.course_class_schedules_count')

            - if @courses.any? { |c| policy(c).tap { |p| break p.edit? || p.destroy? } }
              %th.text-top.text-right= t('.actions')

        %tbody
          - @courses.each do |course|
            %tr
              %td
                = link_to_if policy(course).show?, course.title, course_path(course) do
                  = course.title

              %td= course.variant
              %td= course.examination_results_count
              %td= course.class_schedules_count

              - if policy(course).tap { |p| break p.edit? || p.destroy? }
                %td.col-xs-2.col-sm-3.col-md-2.text-right
                  = link_to_edit(policy(course).edit?, edit_course_path(course))
                  = link_to_destroy_course(course)