diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 36099f9fed95cad1cfb9c360a425e38a7bebd062..fe3fb85225e9da1d2bdbc5f3fd3ab86eda26e39b 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -59,6 +59,7 @@ class Communication::Website::Post < ApplicationRecord before_validation :set_published_at, if: :published_changed? + scope :published, -> { where(published: true) } scope :ordered, -> { order(published_at: :desc, created_at: :desc) } scope :recent, -> { order(published_at: :desc).limit(5) } diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index 2bc0a0b4907e0d9f363f83198d0c7dc9c6f37683..18dd5a55eed9ea3bc8ef51b25ff083d46dafeada 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -51,7 +51,11 @@ class Research::Journal::Volume < ApplicationRecord end def git_dependencies_static - articles + researchers + articles + researchers + active_storage_blobs + end + + def git_destroy_dependencies_static + active_storage_blobs end def to_s diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 3c3fa83f9e01630de0accef64d24b64ecd83b4b1..481511e1b0f01776bc614e3b9de1996637e61446 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -101,16 +101,31 @@ class University::Person < ApplicationRecord end def identifiers(website: nil) - website_id = website&.id list = [] - # TODO :administrator - [:author, :researcher, :teacher].each do |role| - list << role if send("#{role.to_s}_websites").pluck(:id).include?(website_id) + [:author, :researcher, :teacher, :administrator].each do |role| + list << role if public_send("is_#{role.to_s}_for_website", website) end list << :static unless list.empty? list end + def is_author_for_website(website) + is_author && communication_website_posts.published.where(communication_website_id: website&.id).any? + end + + def is_researcher_for_website(website) + is_researcher + end + + def is_teacher_for_website(website) + is_teacher && website.programs.published.joins(:teachers).where(education_program_teachers: { person_id: id }).any? + end + + def is_administrator_for_website(website) + # TODO + is_administrative + end + def git_path_static "content/persons/#{slug}.html" end diff --git a/app/views/admin/education/program/roles/_list.html.erb b/app/views/admin/education/program/roles/_list.html.erb index 9fbda8e94303c28ea6539804cf6efe4186e3961f..0a152d39a6e3204e32b1a026dbf9830b714074aa 100644 --- a/app/views/admin/education/program/roles/_list.html.erb +++ b/app/views/admin/education/program/roles/_list.html.erb @@ -1,33 +1,35 @@ -<table class="table table-sortable"> - <thead> - <tr> - <th><%= Education::Program::Role.model_name.human %></th> - <th><%= Education::Program::Role.human_attribute_name('people') %></th> - <th></th> - </tr> - </thead> - <tbody data-reorder-url="<%= reorder_admin_education_program_roles_path(program_id: @program.id) %>"> - <% roles.each do |role| %> - <tr class="handle" data-id="<%= role.id %>"> - <td> - <%= link_to_if can?(:read, role), - role, - admin_education_program_role_path(role, { program_id: @program.id }) %> - </td> - <td><%= role.people.includes(:person).ordered.map { |person| person.person.to_s }.to_sentence %></td> - <td class="text-end pe-0"> - <div class="btn-group" role="group"> - <%= link_to t('edit'), - edit_admin_education_program_role_path(role, { program_id: @program.id }), - class: button_classes %> - <%= link_to t('delete'), - admin_education_program_role_path(role, { program_id: @program.id }), - method: :delete, - data: { confirm: t('please_confirm') }, - class: button_classes_danger %> - </div> - </td> +<% if roles.any? %> + <table class="table table-sortable"> + <thead> + <tr> + <th class="ps-0"><%= Education::Program::Role.model_name.human %></th> + <th><%= Education::Program::Role.human_attribute_name('people') %></th> + <th></th> </tr> - <% end %> - </tbody> -</table> + </thead> + <tbody data-reorder-url="<%= reorder_admin_education_program_roles_path(program_id: @program.id) %>"> + <% roles.each do |role| %> + <tr class="handle" data-id="<%= role.id %>"> + <td class="ps-0"> + <%= link_to_if can?(:read, role), + role, + admin_education_program_role_path(role, { program_id: @program.id }) %> + </td> + <td><%= role.people.includes(:person).ordered.map { |person| person.person.to_s }.to_sentence %></td> + <td class="text-end pe-0"> + <div class="btn-group" role="group"> + <%= link_to t('edit'), + edit_admin_education_program_role_path(role, { program_id: @program.id }), + class: button_classes %> + <%= link_to t('delete'), + admin_education_program_role_path(role, { program_id: @program.id }), + method: :delete, + data: { confirm: t('please_confirm') }, + class: button_classes_danger %> + </div> + </td> + </tr> + <% end %> + </tbody> + </table> +<% end %> diff --git a/app/views/admin/education/program/teachers/_list.html.erb b/app/views/admin/education/program/teachers/_list.html.erb index d609934057f34ebea423ae7e43a87501700a9d58..5fb075887d0d93c3106f82133c7e966076b70fc1 100644 --- a/app/views/admin/education/program/teachers/_list.html.erb +++ b/app/views/admin/education/program/teachers/_list.html.erb @@ -2,7 +2,7 @@ <table class="table"> <thead> <tr> - <th><%= Education::Program::Teacher.model_name.human %></th> + <th class="ps-0"><%= Education::Program::Teacher.model_name.human %></th> <th><%= Education::Program::Teacher.human_attribute_name('description') %></th> <th></th> </tr> @@ -10,7 +10,7 @@ <tbody> <% teachers.each do |teacher| %> <tr> - <td> + <td class="ps-0"> <%= link_to_if can?(:read, teacher.person), teacher.person, admin_education_teacher_path(teacher.person) %> diff --git a/app/views/admin/education/programs/_form.html.erb b/app/views/admin/education/programs/_form.html.erb index c9574d775fa9ace5a45ca87c8896f91edb1c6d0f..f930ef9bfe4761f01d51c994ae8cd99c8d29ea66 100644 --- a/app/views/admin/education/programs/_form.html.erb +++ b/app/views/admin/education/programs/_form.html.erb @@ -28,7 +28,7 @@ </div> </div> </div> - <div class="col-md-5"> + <div class="col-md-6"> <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('education.program.useful_informations') %></h5> @@ -43,7 +43,7 @@ </div> </div> </div> - <div class="col-md-4"> + <div class="col-md-3"> <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('activerecord.attributes.education/program.featured_image') %></h5> @@ -75,18 +75,16 @@ </div> <div class="card-body"> <div class="row"> - <div class="col-md-4"> + <div class="col-md-6"> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :objectives %> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :content %> - </div> - <div class="col-md-4"> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :opportunities %> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :prerequisites %> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :results %> </div> - <div class="col-md-4"> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :evaluation %> + <div class="col-md-6"> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pedagogy %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :evaluation %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :opportunities %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :results %> </div> </div> </div> diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index 1a929183479aa4c93b6ef942f94c3a72e919b497..e3263475a8675bbb1f762c43708c6e7eb210c3c5 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -55,8 +55,6 @@ :duration, :contacts, :accessibility, - :content, - :results, :other ].each_with_index do |prop, index| %> <% @@ -87,7 +85,7 @@ <div class="row"> <div class="col-md-6"> <% i = 0 %> - <% ['prerequisites', 'objectives', 'opportunities'].each do |prop| %> + <% [:prerequisites, :objectives, :opportunities, :results].each do |prop| %> <% next if @program.public_send(prop).blank? %> <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name(prop) %></h3> <%= @program.public_send prop %> @@ -96,16 +94,12 @@ </div> <div class="col-md-6"> <% i = 0 %> - <% ['pedagogy', 'evaluation'].each do |prop| %> + <% ['pedagogy', 'evaluation', 'content'].each do |prop| %> <% next if @program.public_send(prop).blank? %> <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name(prop) %></h3> <%= @program.public_send prop %> <% i += 1 %> <% end %> - - <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name('teachers') %></h3> - <p><%= link_to t('create'), new_admin_education_program_teacher_path(program_id: @program.id), class: 'btn btn-primary' %></p> - <%= render 'admin/education/program/teachers/list', teachers: @program.teachers.includes(:person).ordered %> </div> </div> </div> @@ -113,11 +107,21 @@ <div class="card flex-fill w-100"> <div class="card-header"> - <h5 class="card-title mb-0"><%= Education::Program.human_attribute_name('roles') %></h5> + <h5 class="card-title mb-0"><%= Education::Program.human_attribute_name('team') %></h5> </div> <div class="card-body"> - <p><%= link_to t('create'), new_admin_education_program_role_path(program_id: @program.id), class: 'btn btn-primary' %></p> - <%= render 'admin/education/program/roles/list', roles: @program.roles.ordered %> + <div class="row"> + <div class="col-md-6"> + <h3 class="h5"><%= Education::Program.human_attribute_name('roles') %></h3> + <%= render 'admin/education/program/roles/list', roles: @program.roles.ordered %> + <%= link_to t('create'), new_admin_education_program_role_path(program_id: @program.id), class: button_classes %> + </div> + <div class="col-md-6"> + <h3 class="h5"><%= Education::Program.human_attribute_name('teachers') %></h3> + <%= render 'admin/education/program/teachers/list', teachers: @program.teachers.includes(:person).ordered %> + <%= link_to t('create'), new_admin_education_program_teacher_path(program_id: @program.id), class: button_classes %> + </div> + </div> </div> </div> diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 6bdeade466a4159b5b589a5290d10c96cde255ee..4fc644710346fc00df54796792e5f04b6a5acbba 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -9,23 +9,22 @@ position: <%= @program.position %> image: "<%= @program.best_featured_image.blob.id %>" image_alt: "<%= @program.featured_image_alt %>" <% end %> -categories: - - "<%= @website.categories.find_by(program_id: @program.id)&.id %>" +category: "<%= @website.categories.find_by(program_id: @program.id)&.id %>" teachers: - - "marlene-dulaurans" - - "arnaud-levy" -administrators: - - "quentin-bessiere" -contact_list: - - title: "Cheffe de département" - persons: - - "marlene-dulaurans" - - title: "Directeur des études" - persons: - - "arnaud-levy" - - title: "Secrétariat" +<% @program.teachers.includes(:person).ordered.each do |teacher| %> + - person: "<%= teacher.person.slug %>" + description: > + <%= teacher.description %> +<% end %> +roles: +<% @program.roles.ordered.each do |role| %> + - title: > + <%= role.to_s %> persons: - - "quentin-bessiere" + <% role.people.includes(:person).ordered.each do |role_person| %> + - "<%= role_person.person.slug %>" + <% end %> +<% end %> continuing: <%= @program.continuing %> level: <%= @program.level %> ects: <%= @program.ects %> diff --git a/app/views/admin/research/journal/volumes/static.html.erb b/app/views/admin/research/journal/volumes/static.html.erb index b7f348279d478c8d8184248988e485908d2606e3..a90daf5835c9072cbf121e8460787100f6d0839d 100644 --- a/app/views/admin/research/journal/volumes/static.html.erb +++ b/app/views/admin/research/journal/volumes/static.html.erb @@ -5,7 +5,7 @@ issn: "<%= @volume.journal.issn %>" keywords: "<%= @volume.keywords %>" date: "<%= @volume.published_at %>" <% if @volume.cover.attached? %> -image: "<%= @volume.cover_path %>" +image: "<%= @volume.cover.blob.id %>" image_alt: "<%= @volume.cover_alt %>" <% end %> articles: diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb index 0bbfffa7de21387fcaecd227f1ab6c70eff0c26e..c6e4a98351f7edf255c7b498f423a1fcc26358fa 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -7,16 +7,16 @@ last_name: "<%= @person.last_name %>" phone: "<%= @person.phone %>" email: "<%= @person.email %>" roles: -<% if @person.is_author %> +<% if @person.is_author_for_website(@website) %> - author <% end %> -<% if @person.is_teacher %> +<% if @person.is_teacher_for_website(@website) %> - teacher <% end %> -<% if @person.is_researcher %> +<% if @person.is_researcher_for_website(@website) %> - researcher <% end %> -<% if @person.is_administrative %> +<% if @person.is_administrator_for_website(@website) %> - administrator <% end %> --- diff --git a/test/fixtures/education/program/role/people.yml b/test/fixtures/education/program/role/people.yml index dd8da3363f801027e36fa69debfde394e349902f..50a25e47a89ea4b3a4cda4a15f37db6331820438 100644 --- a/test/fixtures/education/program/role/people.yml +++ b/test/fixtures/education/program/role/people.yml @@ -19,7 +19,6 @@ # fk_rails_... (person_id => university_people.id) # fk_rails_... (role_id => education_program_roles.id) # -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: position: 1