diff --git a/app/controllers/admin/communication/website/pages_controller.rb b/app/controllers/admin/communication/website/pages_controller.rb index 6588b3a8dbcbd961169dee6ed635da457df08284..25f582de143931aa282f6995966693b0db726d78 100644 --- a/app/controllers/admin/communication/website/pages_controller.rb +++ b/app/controllers/admin/communication/website/pages_controller.rb @@ -31,6 +31,11 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web breadcrumb end + def static + @about = @page + render layout: false + end + def new @page.website = @website breadcrumb diff --git a/app/controllers/admin/education/programs_controller.rb b/app/controllers/admin/education/programs_controller.rb index c61770002d241f0f867da2bc7f019db1247d86a6..70bb21dfd00f7b3a0cca19bbbac21ebd6da21170 100644 --- a/app/controllers/admin/education/programs_controller.rb +++ b/app/controllers/admin/education/programs_controller.rb @@ -85,12 +85,16 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro :name, :slug, :level, :capacity, :ects, :continuing, :description, :published, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :prerequisites, :objectives, :duration, :registration, :pedagogy, :content, - :evaluation, :accessibility, :pricing, :contacts, :opportunities, :other, - :parent_id, school_ids: [], university_person_involvements_attributes: [:id, :person_id, :description, :position, :_destroy] + :evaluation, :accessibility, :pricing, :contacts, :opportunities, :results, :other, + :parent_id, school_ids: [], + university_person_involvements_attributes: [:id, :person_id, :description, :position, :_destroy] ) end def load_teacher_people - @teacher_people = current_university.people.teachers.accessible_by(current_ability).ordered + @teacher_people = current_university.people + .teachers + .accessible_by(current_ability) + .ordered end end diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index f00c6def4ea10468377f14a444e40021e6de2387..a5ff5c58040dd786e9de27571e4cf684669065bc 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -5,7 +5,7 @@ # id :uuid not null, primary key # about_type :string indexed => [about_id] # access_token :string -# git_provider :integer default(0) +# git_provider :integer default("github") # name :string # repository :string # static_pathname_administrators :string default("administrators") diff --git a/app/models/communication/website/git_file.rb b/app/models/communication/website/git_file.rb index db09da8ad9c79e413613f490861ffa3ff6323e32..155b8cb073bf694efceb7e508dbbd3d478b4ec91 100644 --- a/app/models/communication/website/git_file.rb +++ b/app/models/communication/website/git_file.rb @@ -2,14 +2,15 @@ # # Table name: communication_website_git_files # -# id :uuid not null, primary key -# about_type :string not null, indexed => [about_id] -# previous_path :string -# previous_sha :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid not null, indexed => [about_type] -# website_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string not null, indexed => [about_id] +# previous_path :string +# previous_sha :string +# previous_sha256 :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid not null, indexed => [about_type] +# website_id :uuid not null, indexed # # Indexes # @@ -33,7 +34,7 @@ class Communication::Website::GitFile < ApplicationRecord end def synchronized_with_git? - git_sha == previous_sha + git_sha == previous_sha || git_sha == previous_sha256 end def should_create? @@ -48,8 +49,7 @@ class Communication::Website::GitFile < ApplicationRecord def should_update? !should_destroy? && ( - previous_path != path || - previous_sha != sha + different_path || different_sha ) end @@ -61,12 +61,24 @@ class Communication::Website::GitFile < ApplicationRecord @path ||= about.git_path(website)&.gsub(/\/+/, '/') end + def different_path + previous_path != path + end + + def different_sha + previous_sha != sha && previous_sha != sha256 + end + def sha # Git SHA-1 is calculated from the String "blob <length>\x00<contents>" # Source: https://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html @sha ||= OpenSSL::Digest::SHA1.hexdigest "blob #{to_s.bytesize}\x00#{to_s}" end + def sha256 + @sha256 ||= OpenSSL::Digest::SHA256.hexdigest to_s + end + def to_s @to_s ||= ApplicationController.render( template: "admin/#{about.class.name.underscore.pluralize}/static", diff --git a/app/services/git/providers/gitlab.rb b/app/services/git/providers/gitlab.rb index efb7433d21a90b623a66bca69fe9bca159d1a417..87c3012331c39eacfc6a5c67b88baeeaccc3e1fa 100644 --- a/app/services/git/providers/gitlab.rb +++ b/app/services/git/providers/gitlab.rb @@ -8,7 +8,7 @@ class Git::Providers::Gitlab < Git::Providers::Abstract end def update_file(path, previous_path, content) - file = find_in_tree previous_path + file = find previous_path return if file.nil? if previous_path != path batch << { diff --git a/app/services/git/repository.rb b/app/services/git/repository.rb index 722c6e6ad249e6a374b37b477eb2a09e03b80eda..f5b1579b7eaa59f665d5f9f57d1d40e687ceef82 100644 --- a/app/services/git/repository.rb +++ b/app/services/git/repository.rb @@ -55,7 +55,9 @@ class Git::Repository def mark_as_synced git_files.each do |git_file| - git_file.update previous_path: git_file.path, previous_sha: git_file.sha + git_file.update previous_path: git_file.path, + previous_sha: git_file.sha, + previous_sha256: git_file.sha256 end end end diff --git a/app/views/admin/communication/website/pages/show.html.erb b/app/views/admin/communication/website/pages/show.html.erb index 8fcde48610cb6eba98541245a846ca31db5db08a..217b3b1a81ed69afc27b8a899ba8b6f2b7efa0ec 100644 --- a/app/views/admin/communication/website/pages/show.html.erb +++ b/app/views/admin/communication/website/pages/show.html.erb @@ -87,6 +87,12 @@ <%= @page.text.to_s %> <% end %> +<% content_for :action_bar_left do %> + <%= link_to t('static'), + static_admin_communication_website_page_path(@page), + class: button_classes('btn-light') if can? :static, @page %> +<% end %> + <% content_for :action_bar_right do %> <%= preview_link %> <%= edit_link @page %> diff --git a/config/locales/en.yml b/config/locales/en.yml index cf1d5cfe72700d554a81b287f62dab7d23a549f7..487407b69f929ad46d93046637113da4b624694a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -147,6 +147,7 @@ en: test_chars: "%{min_length} characters min." show: Show slug_error: can only contain downcase letters, numbers, and dashes. + static: Static file terms_of_service: Terms of service terms_of_service_url: https://osuny.org/conditions-d-utilisation time: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ffe93797d39251912f3bf7d13eb1506989644dd7..43c4771c2a028b8efde22137377b2db4b24db2ac 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -147,6 +147,7 @@ fr: test_chars: "%{min_length} caractères min." show: Voir slug_error: ne peut contenir que des lettres minuscules, des chiffres et des traits d'union. + static: Fichier statique terms_of_service: Conditions d'utilisation terms_of_service_url: https://osuny.org/conditions-d-utilisation time: diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index c123047f9e3e96aec6a2d07d3ccedbd0a4e4d6b2..8188fd12a99ef256c6994892aa09c4d97f3f07cf 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -59,7 +59,7 @@ fr: university: sms_sender_name: "11 caractères maximum." university_person: - habilitation: "Bénéficie d’une Habilitation à Diriger des Recherches (HDR)." + habilitation: "Détient une Habilitation à Diriger des Recherches (HDR)." is_administration: "Remplit des missions administratives." is_author: "Écrit des articles pour les sites." is_researcher: "Écrit des articles dans des revues scientifiques." diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 87ed087750da7d711dcb4daf698c334afe595c21..5b465162b0b42507082623315c407af35dc21299 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -12,6 +12,7 @@ namespace :communication do end member do get :children + get :static end end resources :categories, controller: 'website/categories' do @@ -24,7 +25,11 @@ namespace :communication do end resources :authors, controller: 'website/authors', only: [:index, :show] resources :posts, controller: 'website/posts' - resources :curations, path: 'posts/curations', as: :post_curations, controller: 'website/posts/curations', only: [:new, :create] + resources :curations, + path: 'posts/curations', + as: :post_curations, + controller: 'website/posts/curations', + only: [:new, :create] resources :blocks, controller: 'website/blocks', except: :index do collection do post :reorder @@ -41,13 +46,13 @@ namespace :communication do end end end - get 'structure' => 'website/structure#edit' - patch 'structure' => 'website/structure#update' + get 'structure' => 'website/structure#edit' + patch 'structure' => 'website/structure#update' - get 'indexes' => 'website/index_pages#index' - get 'indexes/:kind' => 'website/index_pages#edit', as: :index - post 'indexes/:kind' => 'website/index_pages#update' + get 'indexes' => 'website/index_pages#index' + get 'indexes/:kind' => 'website/index_pages#edit', as: :index + post 'indexes/:kind' => 'website/index_pages#update' patch 'indexes/:kind' => 'website/index_pages#update' - put 'indexes/:kind' => 'website/index_pages#update' + put 'indexes/:kind' => 'website/index_pages#update' end end diff --git a/db/migrate/20220218173530_add_previous_sha256_to_communication_website_git_file.rb b/db/migrate/20220218173530_add_previous_sha256_to_communication_website_git_file.rb new file mode 100644 index 0000000000000000000000000000000000000000..aff10cef66733417767a72992514abbcceaba934 --- /dev/null +++ b/db/migrate/20220218173530_add_previous_sha256_to_communication_website_git_file.rb @@ -0,0 +1,5 @@ +class AddPreviousSha256ToCommunicationWebsiteGitFile < ActiveRecord::Migration[6.1] + def change + add_column :communication_website_git_files, :previous_sha256, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index f33a5da163de81b690ed20d157d38fc5823300f3..e07eaf67d85c3da947119c993fe1848370d57121 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_02_18_131148) do +ActiveRecord::Schema.define(version: 2022_02_18_173530) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -129,6 +129,7 @@ ActiveRecord::Schema.define(version: 2022_02_18_131148) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "previous_sha" + t.string "previous_sha256" t.index ["about_type", "about_id"], name: "index_communication_website_github_files_on_about" t.index ["website_id"], name: "index_communication_website_git_files_on_website_id" end