KyivKrishnaAcademy/ved_akadem_students

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

Summary

Maintainability
Test Coverage
- provide(:title, @course.title)

.row
  .col-xs-12.text-center
    %h1
      = @course.title

  .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1.text-right
    = link_to_new policy(Course).new?, new_course_path
    = link_to_index policy(Course).index?, courses_path
    = link_to_edit(policy(@course).edit?, edit_course_path(@course))
    = link_to_destroy_course(@course)

  .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
    %h5
      = t('.course_description')
      = inline_info(t('.course_description_help'))
  .col-xs-12.col-sm-8.col-sm-offset-2
    = @course.description

  .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
    %h5
      = t('.course_variant')
      = inline_info(t('.course_variant_help'))
  .col-xs-12.col-sm-8.col-sm-offset-2
    = @course.variant

  .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
    %h5
      = t('.class_schedules_count')
  .col-xs-12.col-sm-8.col-sm-offset-2
    = @class_schedules_count

  .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
    %h5
      = t('.total_examination_results_count')
  .col-xs-12.col-sm-8.col-sm-offset-2
    = @course.examination_results_count

  - if @course.teacher_profiles.any?
    .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
      %h5
        = t('.associated_teachers')
    .col-xs-12.col-sm-8.col-sm-offset-2
      %ul
        - @course.teacher_profiles.each do |profile|
          %li
            = link_to_show_person_or_name(profile.person)

  .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
    %h5
      = t('.associated_academic_groups')
  .col-xs-12.col-sm-8.col-sm-offset-2
    .table-responsive
      %table.table.table-condensed.table-striped
        %thead
          %tr
            %th= t('.academic_group_title')

        %tbody
          - @academic_groups.each do |group|
            %tr
              %td.nowrap
                = link_to_show_academic_group_or_title(group)

  - if policy(Examination).index?
    .col-xs-12.col-sm-8.col-sm-offset-2.vert-offset-top-1
      %h5.clearfix
        = t('.examinations')

        .pull-right
          = link_to_new(current_person.can_act?('examination:new'), new_course_examination_path(@course))

    .col-xs-12.col-sm-8.col-sm-offset-2
      .table-responsive
        %table.table.table-condensed.table-striped
          %thead
            %tr
              %th.text-top= t('.examination_title')
              %th.text-top= t('.min_result')
              %th.text-top= t('.max_result')
              %th.text-top= t('.passing_score')
              %th.text-top= t('.results_per_examination')

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

          %tbody
            - @examinations.each do |examination|
              %tr
                %td= examination.title
                %td.col-xs-1= examination.min_result
                %td.col-xs-1= examination.max_result
                %td.col-xs-1= examination.passing_score
                %td= examination.examination_results_count

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