noesya/osuny

View on GitHub
app/views/admin/education/programs/parts/admission.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, @l10n %>

<p class="lead mb-5"><%= t('education.program.parts.admission.hint') %>

<div class="row">
  <%
  [
    :prerequisites,
    :registration,
    :other,
    :pricing,
    :pricing_initial,
    :pricing_continuing,
    :pricing_apprenticeship,
    :accessibility,
    :contacts
  ].each do |property| %>
    <div class="col-xxl-4 col-md-6 mb-4">
      <%= render 'admin/application/property/text', object: @l10n, property: property %>
    </div>
  <% end %>
  <div class="col-xxl-4 col-md-6 mb-4">
    <% if @l10n.registration_url.present? %>
      <%= osuny_label Education::Program::Localization.human_attribute_name(:registration_url) %>
      <p><%= link_to @l10n.registration_url, @l10n.registration_url, target: :_blank %></p>
    <% end %>
  </div>
</div>

<%
action = ''
if !current_user.program_manager? || current_user.programs_to_manage.pluck(:education_program_id).include?(@program.id)
action += link_to t('education.manage_roles'),
                  admin_education_program_roles_path(program_id: @program.id),
                  class: 'action' if can?(:update, University::Role)
end
%>
<%= osuny_panel Education::Program.human_attribute_name('roles'), action: action, classes: 'mt-5' do %>
  <% if @roles.any? %>
    <div class="table-responsive">
      <table class="<%= table_classes %>">
        <thead>
          <tr>
            <th class="ps-0"><%= University::Role.model_name.human %></th>
            <th><%= University::Role.human_attribute_name('people') %></th>
          </tr>
        </thead>
        <tbody>
          <% @roles.each do |role| %>
            <tr>
              <td class="ps-0">
                <%= osuny_link_localized_if can?(:update, role),
                                            role,
                                            edit_admin_education_program_role_path(role, { program_id: @program.id }) %>
              </td>
              <td>
                <%= role.involvements.includes(:person).ordered.map { |involvement|
                  person = involvement.person
                  link_to_if  can?(:read, person),
                              person.best_localization_for(current_language).to_s,
                              admin_university_person_path(person)
                }.to_sentence.html_safe %>
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  <% end %>
<% end %>

<% content_for :action_bar_right do %>
  <%= link_to_if  can?(:edit, @program),
                  t('edit'),
                  edit_admission_admin_education_program_path(@program),
                  class: button_classes %>
<% end %>