diff --git a/Gemfile.lock b/Gemfile.lock index 54c0680c830f3d40f5cf585e9ae215654edb5bd5..9705bb5e34ec40b006277747630da32be3e6a3ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -161,9 +161,9 @@ GEM csl (~> 2.0) cocoon (1.2.15) concurrent-ruby (1.2.2) - countries (5.6.0) + countries (5.7.0) unaccent (~> 0.3) - country_select (8.0.2) + country_select (8.0.3) countries (~> 5.0) crack (0.4.5) rexml @@ -353,7 +353,7 @@ GEM nesty (1.0.2) net-http (0.3.2) uri - net-imap (0.4.0) + net-imap (0.4.1) date net-protocol net-pop (0.1.2) @@ -461,7 +461,7 @@ GEM nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) rotp (6.3.0) - ruby-saml (1.15.0) + ruby-saml (1.16.0) nokogiri (>= 1.13.10) rexml ruby-vips (2.1.4) diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index 36d1774ab7007ba9548064944635871f2871064c..4d931dc92ab87943f0689be935bc2f1c3a4803b5 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -73,7 +73,7 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: :name, :url, :repository, :about_type, :about_id, :in_production, :git_provider, :git_endpoint, :git_branch, :plausible_url, :feature_posts, :feature_agenda, - :deuxfleurs_hosting, + :deuxfleurs_hosting, :default_image, :default_image_delete, :social_mastodon, :social_x, :social_linkedin, :social_youtube, :social_vimeo, :social_peertube, :social_instagram, :social_facebook, :social_tiktok, :social_email, :social_github, :deployment_status_badge, :autoupdate_theme, language_ids: [] ] diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 0942ac7510e8efac38b8f629d04a085e1012efae..0886d3dfcc57f6cdc360b6c147ce63507a18a4dc 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -77,6 +77,9 @@ class Communication::Website < ApplicationRecord gitlab: 1 } + has_one_attached_deletable :default_image + validates :default_image, size: { less_than: 5.megabytes } + before_validation :sanitize_fields scope :ordered, -> { order(:name) } @@ -114,7 +117,8 @@ class Communication::Website < ApplicationRecord events.where(language_id: language_ids) + categories.where(language_id: language_ids) + menus.where(language_id: language_ids) + - [about] + [about] + + [default_image&.blob] end def website diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb index 412b5a4453db33c49d84e60aca08dba9cf122b9f..57989105b5e04f9c3b03d6d12a98d914fb459282 100644 --- a/app/views/admin/communication/websites/_form.html.erb +++ b/app/views/admin/communication/websites/_form.html.erb @@ -35,6 +35,14 @@ label_method: lambda { |l| language_name(l.iso_code) }, input_html: (@website.persisted? ? { disabled: true } : { class: "js-default-language" }) %> <% end %> + <%= osuny_panel Communication::Website.human_attribute_name('appearance') do %> + <%= f.input :default_image, + as: :single_deletable_file, + direct_upload: true, + hint: '5 Mo max, .jpg, .jpeg, .png, .svg', + input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + preview: true %> + <% end %> </div> </div> <div class="row"> diff --git a/app/views/admin/communication/websites/static.html.erb b/app/views/admin/communication/websites/static.html.erb index 6ed5c1d2f474541989a87af0f542f894a394ef96..e7fe00d0838636b650d01ad696f2d3d6cc977bbc 100644 --- a/app/views/admin/communication/websites/static.html.erb +++ b/app/views/admin/communication/websites/static.html.erb @@ -1,5 +1,9 @@ title: > <%= @about.to_s %> +<% if @website.default_image.attached? %> +default_image: + id: <%= @website.default_image.blob&.id %> +<% end %> external_domains: <% @website.external_domains.each do |domain| %> - "<%= domain %>" diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 6cd50c56b90fb6f85137131d9504925fd33d90db..ef0bef5bd1c28b41557ceae12f3f4954c53df3e4 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -130,9 +130,11 @@ en: about_Research::Journal: Journal website about_Research::Laboratory: Laboratory website about_type: About + appearance: Appearance autoupdate_theme: Automatically update Osuny theme access_token: Access token created_at: Creation + default_image: Default image default_language: Default language deployment_status_badge: Deployment status badge deuxfleurs_hosting: Hébergement avec Deuxfleurs diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index a61369e14711f2ba2e070c4b620217ffbce5dcb1..e08fad43b1240e134d25975ebf1ef88d0f0fd875 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -130,9 +130,11 @@ fr: about_Research::Journal: Site de revue scientifique about_Research::Laboratory: Site de laboratoire about_type: Type de site + appearance: Apparence autoupdate_theme: Mise à jour automatique du thème Osuny access_token: Jeton d'accès created_at: Création + default_image: Image par défaut default_language: Langue par défaut deployment_status_badge: Badge de statut du déploiement deuxfleurs_hosting: Hébergement avec Deuxfleurs diff --git a/db/schema.rb b/db/schema.rb index cb3e15ec4b4180dc9e5047144c500940e13e8f60..eb300673cd28c521c85435321edf407fbb8057d0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -106,8 +106,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_06_145950) do t.datetime "updated_at", null: false t.string "title" t.boolean "published", default: true - t.uuid "communication_website_id" t.uuid "heading_id" + t.uuid "communication_website_id" t.string "migration_identifier" t.index ["about_type", "about_id"], name: "index_communication_website_blocks_on_about" t.index ["communication_website_id"], name: "index_communication_blocks_on_communication_website_id" @@ -229,7 +229,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_06_145950) do t.text "home_sentence" t.text "sass" t.text "css" - t.boolean "allow_experiences_modification", default: true t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about" t.index ["university_id"], name: "index_communication_extranets_on_university_id" end @@ -390,7 +389,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_06_145950) do t.index ["university_id"], name: "index_communication_website_pages_on_university_id" end - create_table "communication_website_permalinks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_permalinks", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.string "about_type", null: false