diff --git a/app/models/education/diploma.rb b/app/models/education/diploma.rb index 8f6763d8e6113de84755aa6b6b256991a8a1db7d..dc0913ddd905e2dedf1396c3abc34f33fc27733a 100644 --- a/app/models/education/diploma.rb +++ b/app/models/education/diploma.rb @@ -41,6 +41,17 @@ class Education::Diploma < ApplicationRecord doctor: 800 } + def websites + @websites ||= university.websites.reject { |website| + !for_website?(website) + } + end + + # We need to send the diplomas only to the websites that need them + def for_website?(website) + website.education_programs.published.where(diploma: self).any? + end + def git_path(website) "content/diplomas/#{slug}/_index.html" end diff --git a/app/views/admin/education/diplomas/_form.html.erb b/app/views/admin/education/diplomas/_form.html.erb index 04f3a2d6e22b9fb6e10d16319036b092dd606b0d..a7580255abfc90ef1ccce28db929001cd6085f57 100644 --- a/app/views/admin/education/diplomas/_form.html.erb +++ b/app/views/admin/education/diplomas/_form.html.erb @@ -1,19 +1,27 @@ <%= simple_form_for [:admin, diploma] do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> - <div class="row"> - <div class="col-lg-6"> - <%= f.input :name %> - </div> - <div class="col-lg-3"> - <%= f.input :short_name %> - </div> - <div class="col-lg-3"> - <%= f.input :level, include_blank: false %> + <div class="col-lg-8"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('metadata') %></h5> + </div> + <div class="card-body"> + <%= f.input :name %> + <div class="row"> + <div class="col-lg-6"> + <%= f.input :short_name %> + </div> + <div class="col-lg-6"> + <%= f.input :level, include_blank: false %> + </div> + </div> + + </div> + </div> </div> </div> - <% content_for :action_bar_right do %> <%= submit f %> <% end %> diff --git a/app/views/admin/education/programs/_form.html.erb b/app/views/admin/education/programs/_form.html.erb index 4fbc4ae857b63c6b692304d9c864fc84f4dca70e..3bdded14d767ff25e04e8c127fc668dd3fc71d54 100644 --- a/app/views/admin/education/programs/_form.html.erb +++ b/app/views/admin/education/programs/_form.html.erb @@ -3,31 +3,7 @@ <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> <div class="row"> - <div class="col-md-3"> - <%= render 'admin/education/programs/forms/part', part: :technical do %> - <%= f.input :published %> - <%= f.input :slug, - as: :string, - input_html: program.persisted? ? {} : { - class: 'js-slug-input', - data: { source: '#education_program_name' } - } %> - <%= f.association :parent, - collection: collection_tree(current_university.education_programs, program), - label_method: ->(p) { sanitize p[:label] }, - value_method: ->(p) { p[:id] } %> - <% end %> - <%= render 'admin/application/featured_image/edit', about: program, f: f %> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= t('seo') %></h5> - </div> - <div class="card-body"> - <%= f.input :description %> - </div> - </div> - </div> - <div class="col-md-9"> + <div class="col-lg-8 col-xxl-9"> <%= render 'admin/education/programs/forms/part', part: :essential do %> <div class="row"> <div class="col-lg-9"> @@ -150,6 +126,30 @@ </div> <% end %> </div> + <div class="col-lg-4 col-xxl-3"> + <%= render 'admin/education/programs/forms/part', part: :technical do %> + <%= f.input :published %> + <%= f.input :slug, + as: :string, + input_html: program.persisted? ? {} : { + class: 'js-slug-input', + data: { source: '#education_program_name' } + } %> + <%= f.association :parent, + collection: collection_tree(current_university.education_programs, program), + label_method: ->(p) { sanitize p[:label] }, + value_method: ->(p) { p[:id] } %> + <% end %> + <%= render 'admin/application/featured_image/edit', about: program, f: f %> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('seo') %></h5> + </div> + <div class="card-body"> + <%= f.input :description %> + </div> + </div> + </div> </div> <% content_for :action_bar_right do %> diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 26a7b57c2ee63a549fbef539631ca3fe1e8f70ff..b5a0444f03857c663da78cb419ec4d37c0de2ee1 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -9,6 +9,7 @@ description: > position: <%= @about.position %> <%= render 'admin/communication/unsplash/static' %> category: "<%= @website.categories.find_by(program_id: @about.id)&.path %>/" +diploma: "<%= @about.diploma&.slug %>" teachers: <% teacher_involvements.each do |involvement| %> - "<%= involvement.person.slug %>"