From 6cb461b457bf6f33fca95dbf83d227ef641b2211 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 06:38:09 +0100 Subject: [PATCH 1/9] feature --- app/controllers/admin/communication/websites_controller.rb | 2 +- app/models/communication/website.rb | 1 + app/views/admin/communication/websites/_form.html.erb | 3 +++ config/locales/communication/en.yml | 4 +++- config/locales/communication/fr.yml | 4 +++- ...3354_add_feature_portfolio_to_communication_websites.rb | 5 +++++ db/schema.rb | 7 ++++--- 7 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20240307053354_add_feature_portfolio_to_communication_websites.rb diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index 0f4182f69..c34f273ba 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -78,7 +78,7 @@ def website_params attribute_names = [ :name, :url, :repository, :about_type, :about_id, :in_production, :git_provider, :git_endpoint, :git_branch, :plausible_url, - :feature_posts, :feature_agenda, + :feature_posts, :feature_agenda, :feature_portfolio, :default_time_zone, :deuxfleurs_hosting, :default_image, :default_image_delete, :default_shared_image, :default_shared_image_delete, :social_mastodon, :social_x, :social_linkedin, :social_youtube, :social_vimeo, :social_peertube, :social_instagram, :social_facebook, :social_tiktok, :social_email, :social_github, diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index d03ca7b31..475580bcc 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -11,6 +11,7 @@ # deuxfleurs_hosting :boolean default(TRUE) # deuxfleurs_identifier :string # feature_agenda :boolean default(FALSE) +# feature_portfolio :boolean default(FALSE) # feature_posts :boolean default(TRUE) # git_branch :string # git_endpoint :string diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb index e8d41e423..d61a25e24 100644 --- a/app/views/admin/communication/websites/_form.html.erb +++ b/app/views/admin/communication/websites/_form.html.erb @@ -18,6 +18,9 @@
<%= f.input :feature_agenda %>
+
+ <%= f.input :feature_portfolio %> +
<% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index e8a205f68..2cb21ff77 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -91,8 +91,9 @@ en: deuxfleurs_hosting: Hébergement avec Deuxfleurs deuxfleurs_identifier: Identifiant Deuxfleurs features: Features - feature_posts: Posts feature_agenda: Agenda + feature_portfolio: Portfolio + feature_posts: Posts git_branch: Git branch git_endpoint: Git endpoint git_provider: Git provider @@ -478,6 +479,7 @@ en: deployment_status_badge: "Badge URL: Github, Gitlab" feature_posts: To publish posts, like a media feature_agenda: To share events + feature_portfolio: To showcase projects git_branch: 'If blank, default branch will be used' git_endpoint: 'If blank, default will be used (https://github.com or https://gitlab.com/api/v4)' languages: 'If you select one language the website urls will not be prefixed. If you select more than one language the website will then be considered as multilingual, and therefore all urls will be prefixed with the language (/fr, /en)' diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index f005e484d..e2555fd8c 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -91,8 +91,9 @@ fr: deuxfleurs_hosting: Hébergement avec Deuxfleurs deuxfleurs_identifier: Identifiant Deuxfleurs features: Fonctionnalités - feature_posts: Actualités feature_agenda: Agenda + feature_portfolio: Portfolio + feature_posts: Actualités git_branch: Branche git_endpoint: Point d'accès Git git_provider: Fournisseur Git @@ -478,6 +479,7 @@ fr: deployment_status_badge: "URL du badge : Github, Gitlab" feature_posts: Pour publier des actualités, comme un média feature_agenda: Pour partager des événements + feature_portfolio: Pour présenter des projets git_branch: 'Laisser vide pour la branche par défaut' git_endpoint: 'Laisser vide pour les valeurs par défaut (https://github.com ou https://gitlab.com/api/v4)' languages: 'Si vous sélectionnez une seule langue les urls ne seront pas préfixées. Si vous en sélectionnez plusieurs le site sera considéré comme multilingue et donc toutes les urls seront préfixées avec la langue (/fr, /en)' diff --git a/db/migrate/20240307053354_add_feature_portfolio_to_communication_websites.rb b/db/migrate/20240307053354_add_feature_portfolio_to_communication_websites.rb new file mode 100644 index 000000000..5890e7261 --- /dev/null +++ b/db/migrate/20240307053354_add_feature_portfolio_to_communication_websites.rb @@ -0,0 +1,5 @@ +class AddFeaturePortfolioToCommunicationWebsites < ActiveRecord::Migration[7.1] + def change + add_column :communication_websites, :feature_portfolio, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 7a911566e..425549f75 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[7.1].define(version: 2024_03_04_172916) do +ActiveRecord::Schema[7.1].define(version: 2024_03_07_053354) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -142,8 +142,8 @@ 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" @@ -462,7 +462,7 @@ 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 @@ -567,6 +567,7 @@ t.string "social_email" t.string "social_github" t.string "default_time_zone" + t.boolean "feature_portfolio", default: false t.index ["about_type", "about_id"], name: "index_communication_websites_on_about" t.index ["default_language_id"], name: "index_communication_websites_on_default_language_id" t.index ["university_id"], name: "index_communication_websites_on_university_id" From 575306caee8c8d2fc65bf9c4fe1063ae9fc53675 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 07:06:22 +0100 Subject: [PATCH 2/9] wip --- app/models/communication/website/portfolio.rb | 8 ++++ .../website/portfolio/project.rb | 48 +++++++++++++++++++ app/services/icon.rb | 1 + .../communication/websites/_sidebar.html.erb | 7 +++ config/locales/communication/en.yml | 3 ++ config/locales/communication/fr.yml | 3 ++ config/routes/admin/communication.rb | 18 +++++++ ...ommunication_website_portfolio_projects.rb | 20 ++++++++ db/schema.rb | 27 ++++++++++- .../website/portfolio/projects.yml | 29 +++++++++++ .../website/portfolio/project_test.rb | 7 +++ 11 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 app/models/communication/website/portfolio.rb create mode 100644 app/models/communication/website/portfolio/project.rb create mode 100644 db/migrate/20240307054140_create_communication_website_portfolio_projects.rb create mode 100644 test/fixtures/communication/website/portfolio/projects.yml create mode 100644 test/models/communication/website/portfolio/project_test.rb diff --git a/app/models/communication/website/portfolio.rb b/app/models/communication/website/portfolio.rb new file mode 100644 index 000000000..81508a13a --- /dev/null +++ b/app/models/communication/website/portfolio.rb @@ -0,0 +1,8 @@ +module Communication::Website::Portfolio + extend ActiveModel::Naming + extend ActiveModel::Translation + + def self.table_name_prefix + "communication_website_portfolio_" + end +end diff --git a/app/models/communication/website/portfolio/project.rb b/app/models/communication/website/portfolio/project.rb new file mode 100644 index 000000000..5fe59335f --- /dev/null +++ b/app/models/communication/website/portfolio/project.rb @@ -0,0 +1,48 @@ +# == Schema Information +# +# Table name: communication_website_portfolio_projects +# +# id :uuid not null, primary key +# featured_image_alt :text +# featured_image_credit :text +# meta_description :text +# published :boolean default(FALSE) +# slug :string +# summary :text +# title :string +# year :integer +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# idx_on_communication_website_id_aac12e3adb (communication_website_id) +# idx_on_university_id_ac2f4a0bfc (university_id) +# index_communication_website_portfolio_projects_on_language_id (language_id) +# index_communication_website_portfolio_projects_on_original_id (original_id) +# +# Foreign Keys +# +# fk_rails_5c5fb357a3 (original_id => communication_website_portfolio_projects.id) +# fk_rails_6b220c2717 (communication_website_id => communication_websites.id) +# fk_rails_810f9f3908 (language_id => languages.id) +# fk_rails_a2d39c0893 (university_id => universities.id) +# +class Communication::Website::Portfolio::Project < ApplicationRecord + include AsDirectObject + include Contentful + include Sanitizable + include Sluggable + include WithAccessibility + include WithBlobs + include WithDuplication + include WithFeaturedImage + include WithMenuItemTarget + include WithPermalink + include WithTranslations + include WithUniversity +end diff --git a/app/services/icon.rb b/app/services/icon.rb index 190109f45..4120b2e73 100644 --- a/app/services/icon.rb +++ b/app/services/icon.rb @@ -11,6 +11,7 @@ class Icon COMMUNICATION_WEBSITE_PAGES = 'fas fa-sitemap' COMMUNICATION_WEBSITE_MENUS = 'fas fa-bars' COMMUNICATION_WEBSITE_AGENDA = 'fas fa-calendar' + COMMUNICATION_WEBSITE_PORTFOLIO = 'fas fa-briefcase' COMMUNICATION_WEBSITE_ANALYTICS = 'fas fa-chart-pie' COMMUNICATION_WEBSITE_PREVIEW_MOBILE = 'fas fa-mobile-alt' COMMUNICATION_WEBSITE_PREVIEW_TABLET = 'fas fa-tablet-alt' diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb index 43b53ce04..c7f82117c 100644 --- a/app/views/admin/communication/websites/_sidebar.html.erb +++ b/app/views/admin/communication/websites/_sidebar.html.erb @@ -24,6 +24,13 @@ ability: can?(:read, Communication::Website::Agenda::Event) } if @website.feature_agenda + navigation << { + title: Communication::Website::Portfolio.model_name.human(count: 2), + path: admin_communication_website_portfolio_projects_path(website_id: @website), + icon: Icon::COMMUNICATION_WEBSITE_PORTFOLIO, + ability: can?(:read, Communication::Website::Portfolio::Project) + } if @website.feature_portfolio + navigation << { title: t('admin.communication.website.pages.structure'), path: admin_communication_website_pages_path(website_id: @website), diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 2cb21ff77..b2bd23e45 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -4,6 +4,9 @@ en: activemodel: models: communication: Communication + communication/website/portfolio: + one: Portfolio + other: Portfolio activerecord: attributes: communication/block: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index e2555fd8c..c06846cfe 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -4,6 +4,9 @@ fr: activemodel: models: communication: Communication + communication/website/portfolio: + one: Portfolio + other: Portfolio activerecord: attributes: communication/block: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 48489bf19..d9fbce7b4 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -74,6 +74,24 @@ end end end + namespace :portfolio, path: '/:lang/portfolio' do + resources :projects, controller: '/admin/communication/websites/portfolio/projects' do + member do + get :static + post :duplicate + post :publish + end + end + resources :categories, controller: '/admin/communication/websites/portfolio/categories' do + collection do + post :reorder + end + member do + get :children + get :static + end + end + end resources :menus, controller: 'websites/menus', path: '/:lang/menus' do member do get :static diff --git a/db/migrate/20240307054140_create_communication_website_portfolio_projects.rb b/db/migrate/20240307054140_create_communication_website_portfolio_projects.rb new file mode 100644 index 000000000..76d2212f0 --- /dev/null +++ b/db/migrate/20240307054140_create_communication_website_portfolio_projects.rb @@ -0,0 +1,20 @@ +class CreateCommunicationWebsitePortfolioProjects < ActiveRecord::Migration[7.1] + def change + create_table :communication_website_portfolio_projects, id: :uuid do |t| + t.string :title + t.string :slug + t.text :featured_image_alt + t.text :featured_image_credit + t.integer :year + t.text :meta_description + t.boolean :published, default: false + t.text :summary + t.references :communication_website, null: false, foreign_key: true, type: :uuid + t.references :language, null: false, foreign_key: true, type: :uuid + t.references :original, foreign_key: {to_table: :communication_website_portfolio_projects}, type: :uuid + t.references :university, null: false, foreign_key: true, type: :uuid + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 425549f75..43f776422 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[7.1].define(version: 2024_03_07_053354) do +ActiveRecord::Schema[7.1].define(version: 2024_03_07_054140) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -476,6 +476,27 @@ t.index ["website_id"], name: "index_communication_website_permalinks_on_website_id" end + create_table "communication_website_portfolio_projects", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "title" + t.string "slug" + t.text "featured_image_alt" + t.text "featured_image_credit" + t.integer "year" + t.text "meta_description" + t.boolean "published", default: false + t.text "summary" + t.uuid "communication_website_id", null: false + t.uuid "language_id", null: false + t.uuid "original_id" + t.uuid "university_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["communication_website_id"], name: "idx_on_communication_website_id_aac12e3adb" + t.index ["language_id"], name: "index_communication_website_portfolio_projects_on_language_id" + t.index ["original_id"], name: "index_communication_website_portfolio_projects_on_original_id" + t.index ["university_id"], name: "idx_on_university_id_ac2f4a0bfc" + end + create_table "communication_website_post_categories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false @@ -1266,6 +1287,10 @@ add_foreign_key "communication_website_pages", "universities" add_foreign_key "communication_website_permalinks", "communication_websites", column: "website_id" add_foreign_key "communication_website_permalinks", "universities" + add_foreign_key "communication_website_portfolio_projects", "communication_website_portfolio_projects", column: "original_id" + add_foreign_key "communication_website_portfolio_projects", "communication_websites" + add_foreign_key "communication_website_portfolio_projects", "languages" + add_foreign_key "communication_website_portfolio_projects", "universities" add_foreign_key "communication_website_post_categories", "communication_website_post_categories", column: "original_id" add_foreign_key "communication_website_post_categories", "communication_website_post_categories", column: "parent_id" add_foreign_key "communication_website_post_categories", "communication_websites" diff --git a/test/fixtures/communication/website/portfolio/projects.yml b/test/fixtures/communication/website/portfolio/projects.yml new file mode 100644 index 000000000..d5e50bf4c --- /dev/null +++ b/test/fixtures/communication/website/portfolio/projects.yml @@ -0,0 +1,29 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + slug: MyString + featured_image_alt: MyText + featured_image_credit: MyText + year: 1 + meta_description: MyText + published: false + summary: MyText + communication_website: one + language: one + original: one + university: one + +two: + title: MyString + slug: MyString + featured_image_alt: MyText + featured_image_credit: MyText + year: 1 + meta_description: MyText + published: false + summary: MyText + communication_website: two + language: two + original: two + university: two diff --git a/test/models/communication/website/portfolio/project_test.rb b/test/models/communication/website/portfolio/project_test.rb new file mode 100644 index 000000000..9e6215ac6 --- /dev/null +++ b/test/models/communication/website/portfolio/project_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Communication::Website::Portfolio::ProjectTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 942463559db74f74e1ad3eb45313b44d0ce99839 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 07:32:17 +0100 Subject: [PATCH 3/9] refactor features in traits --- app/models/communication/website.rb | 3 ++ .../communication/website/feature_agenda.rb | 23 ++++++++++++++ .../communication/website/feature_blog.rb | 24 +++++++++++++++ .../website/feature_portfolio.rb | 23 ++++++++++++++ .../communication/website/permalink/author.rb | 4 +-- .../website/permalink/category.rb | 7 ++++- .../communication/website/permalink/post.rb | 2 +- .../website/with_associated_objects.rb | 30 ------------------- 8 files changed, 82 insertions(+), 34 deletions(-) create mode 100644 app/models/communication/website/feature_agenda.rb create mode 100644 app/models/communication/website/feature_blog.rb create mode 100644 app/models/communication/website/feature_portfolio.rb diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 475580bcc..367ba9f2c 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -56,6 +56,9 @@ class Communication::Website < ApplicationRecord self.filter_attributes += [:access_token] include Favoritable + include FeatureAgenda + include FeatureBlog + include FeaturePortfolio include WithAbouts include WithAssociatedObjects include WithConfigs diff --git a/app/models/communication/website/feature_agenda.rb b/app/models/communication/website/feature_agenda.rb new file mode 100644 index 000000000..42594526e --- /dev/null +++ b/app/models/communication/website/feature_agenda.rb @@ -0,0 +1,23 @@ +module Communication::Website::FeatureAgenda + extend ActiveSupport::Concern + + included do + has_many :agenda_events, + class_name: "Communication::Website::Agenda::Event", + foreign_key: :communication_website_id + alias :events :agenda_events + + has_many :agenda_categories, + class_name: 'Communication::Website::Agenda::Category', + foreign_key: :communication_website_id, + dependent: :destroy + end + + def has_agenda_events? + agenda_events.published.any? + end + + def has_agenda_categories? + agenda_categories.any? + end +end \ No newline at end of file diff --git a/app/models/communication/website/feature_blog.rb b/app/models/communication/website/feature_blog.rb new file mode 100644 index 000000000..9a888a0f0 --- /dev/null +++ b/app/models/communication/website/feature_blog.rb @@ -0,0 +1,24 @@ +module Communication::Website::FeatureBlog + extend ActiveSupport::Concern + + included do + has_many :posts, + foreign_key: :communication_website_id, + dependent: :destroy + + has_many :authors, -> { distinct }, through: :posts + + has_many :post_categories, + class_name: 'Communication::Website::Post::Category', + foreign_key: :communication_website_id, + dependent: :destroy + end + + def has_blog_posts? + posts.published.any? + end + + def has_blog_categories? + post_categories.any? + end +end \ No newline at end of file diff --git a/app/models/communication/website/feature_portfolio.rb b/app/models/communication/website/feature_portfolio.rb new file mode 100644 index 000000000..24737337a --- /dev/null +++ b/app/models/communication/website/feature_portfolio.rb @@ -0,0 +1,23 @@ +module Communication::Website::FeaturePortfolio + extend ActiveSupport::Concern + + included do + has_many :portfolio_projects, + class_name: "Communication::Website::Portfolio::Project", + foreign_key: :communication_website_id + alias :projects :portfolio_projects + + has_many :portfolio_categories, + class_name: 'Communication::Website::Portfolio::Category', + foreign_key: :communication_website_id, + dependent: :destroy + end + + def has_portfolio_projects? + projects.published.any? + end + + def has_portfolio_categories? + portfolio_categories.any? + end +end \ No newline at end of file diff --git a/app/models/communication/website/permalink/author.rb b/app/models/communication/website/permalink/author.rb index 0d483f999..0763c654a 100644 --- a/app/models/communication/website/permalink/author.rb +++ b/app/models/communication/website/permalink/author.rb @@ -1,7 +1,7 @@ class Communication::Website::Permalink::Author < Communication::Website::Permalink def self.required_in_config?(website) - # website might have authors but no communication_posts (if a post unpublished exists) - website.has_authors? && website.has_communication_posts? + # website might have authors but no posts (if a post unpublished exists) + website.has_authors? && website.has_blog_posts? end def self.static_config_key diff --git a/app/models/communication/website/permalink/category.rb b/app/models/communication/website/permalink/category.rb index c0690df46..411f3481e 100644 --- a/app/models/communication/website/permalink/category.rb +++ b/app/models/communication/website/permalink/category.rb @@ -1,6 +1,11 @@ +# Ce modèle concerne les catégories de posts, qui n'ont pas de namespace +# Il pourrait y avoir un namespace, par exemple Blog. +# Si c'était le cas, le modèle devrait être nommé : +# Communication::Website::Permalink::Blog::Category +# Et il faudrait migrer en conséquence class Communication::Website::Permalink::Category < Communication::Website::Permalink def self.required_in_config?(website) - website.has_communication_posts? && website.has_communication_categories? + website.has_blog_posts? && website.has_blog_categories? end def self.static_config_key diff --git a/app/models/communication/website/permalink/post.rb b/app/models/communication/website/permalink/post.rb index b2cac3c04..14afd6898 100644 --- a/app/models/communication/website/permalink/post.rb +++ b/app/models/communication/website/permalink/post.rb @@ -1,6 +1,6 @@ class Communication::Website::Permalink::Post < Communication::Website::Permalink def self.required_in_config?(website) - website.has_communication_posts? + website.has_blog_posts? end def self.static_config_key diff --git a/app/models/communication/website/with_associated_objects.rb b/app/models/communication/website/with_associated_objects.rb index 639bd2c7d..b2c9e1378 100644 --- a/app/models/communication/website/with_associated_objects.rb +++ b/app/models/communication/website/with_associated_objects.rb @@ -2,27 +2,10 @@ module Communication::Website::WithAssociatedObjects extend ActiveSupport::Concern included do - has_many :pages, foreign_key: :communication_website_id, dependent: :destroy - has_many :posts, - foreign_key: :communication_website_id, - dependent: :destroy - - has_many :authors, -> { distinct }, through: :posts - - has_many :post_categories, - class_name: 'Communication::Website::Post::Category', - foreign_key: :communication_website_id, - dependent: :destroy - - has_many :agenda_categories, - class_name: 'Communication::Website::Agenda::Category', - foreign_key: :communication_website_id, - dependent: :destroy - has_many :permalinks, class_name: "Communication::Website::Permalink", dependent: :destroy @@ -31,11 +14,6 @@ module Communication::Website::WithAssociatedObjects class_name: "Communication::Block", foreign_key: :communication_website_id alias :blocks :communication_blocks - - has_many :agenda_events, - class_name: "Communication::Website::Agenda::Event", - foreign_key: :communication_website_id - alias :events :agenda_events end def blocks_from_education @@ -86,14 +64,6 @@ def teachers has_teachers? ? about.teachers : University::Person.none end - def has_communication_posts? - posts.published.any? - end - - def has_communication_categories? - post_categories.any? || agenda_categories.any? - end - def has_organizations? connected_organizations.any? end From 981fe3ea99c19e86860be9db25c6a852ff8a0740 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 07:32:25 +0100 Subject: [PATCH 4/9] add controllers --- .../portfolio/application_controller.rb | 10 ++ .../portfolio/categories_controller.rb | 85 ++++++++++++++ .../websites/portfolio/projects_controller.rb | 106 ++++++++++++++++++ .../website/portfolio/project.rb | 2 + 4 files changed, 203 insertions(+) create mode 100644 app/controllers/admin/communication/websites/portfolio/application_controller.rb create mode 100644 app/controllers/admin/communication/websites/portfolio/categories_controller.rb create mode 100644 app/controllers/admin/communication/websites/portfolio/projects_controller.rb diff --git a/app/controllers/admin/communication/websites/portfolio/application_controller.rb b/app/controllers/admin/communication/websites/portfolio/application_controller.rb new file mode 100644 index 000000000..b82998d3c --- /dev/null +++ b/app/controllers/admin/communication/websites/portfolio/application_controller.rb @@ -0,0 +1,10 @@ +class Admin::Communication::Websites::Portfolio::ApplicationController < Admin::Communication::Websites::ApplicationController + + protected + + def breadcrumb + super + add_breadcrumb Communication::Website::Portfolio.model_name.human(count: 2), + admin_communication_website_portfolio_projects_path + end +end diff --git a/app/controllers/admin/communication/websites/portfolio/categories_controller.rb b/app/controllers/admin/communication/websites/portfolio/categories_controller.rb new file mode 100644 index 000000000..51449fcd6 --- /dev/null +++ b/app/controllers/admin/communication/websites/portfolio/categories_controller.rb @@ -0,0 +1,85 @@ +class Admin::Communication::Websites::Portfolio::CategoriesController < Admin::Communication::Websites::Portfolio::ApplicationController + load_and_authorize_resource class: 'Communication::Website::Portfolio::Category', + through: :website, + through_association: :agenda_categories + + include Admin::Translatable + include Admin::Categorizable + + def index + @root_categories = categories.root + @categories_class = categories_class + breadcrumb + end + + def show + @projects = @category.projects.ordered.page(params[:page]) + breadcrumb + end + + def static + @about = @category + render_as_plain_text + end + + def new + breadcrumb + end + + def edit + breadcrumb + add_breadcrumb t('edit') + end + + def create + @category.website = @website + @category.add_photo_import params[:photo_import] + if @category.save_and_sync + redirect_to admin_communication_website_agenda_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s) + else + breadcrumb + render :new, status: :unprocessable_entity + end + end + + def update + @category.add_photo_import params[:photo_import] + if @category.update_and_sync(category_params) + redirect_to admin_communication_website_agenda_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s) + else + breadcrumb + add_breadcrumb t('edit') + render :edit, status: :unprocessable_entity + end + end + + def destroy + @category.destroy + redirect_to admin_communication_website_agenda_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s) + end + + protected + + def categories_class + Communication::Website::Portfolio::Category + end + + def breadcrumb + super + add_breadcrumb categories_class.model_name.human(count: 2), + admin_communication_website_portfolio_categories_path + breadcrumb_for @category + end + + def category_params + params.require(:communication_website_portfolio_category) + .permit( + :name, :meta_description, :summary, :slug, + :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit + ) + .merge( + university_id: current_university.id, + language_id: current_website_language.id + ) + end +end diff --git a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb new file mode 100644 index 000000000..ef5769629 --- /dev/null +++ b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb @@ -0,0 +1,106 @@ +class Admin::Communication::Websites::Portfolio::ProjectsController < Admin::Communication::Websites::Portfolio::ApplicationController + load_and_authorize_resource class: Communication::Website::Portfolio::Project, + through: :website + + include Admin::Translatable + + def index + @projects = apply_scopes(@projects).for_language(current_website_language) + .ordered + .page(params[:page]) + # @root_categories = categories.root + # @categories_class = Communication::Website::Portfolio::Category + breadcrumb + end + + def publish + @project.published = true + @project.save_and_sync + redirect_back fallback_location: admin_communication_website_portfolio_project_path(@project), + notice: t('admin.communication.website.publish.notice') + end + + def show + breadcrumb + end + + def static + @about = @event + render_as_plain_text + end + + def new + @categories = categories + breadcrumb + end + + def edit + @categories = categories + breadcrumb + add_breadcrumb t('edit') + end + + def create + @project.website = @website + @project.add_photo_import params[:photo_import] + if @project.save_and_sync + redirect_to admin_communication_website_portfolio_project_path(@project), + notice: t('admin.successfully_created_html', model: @project.to_s) + else + @categories = categories + breadcrumb + render :new, status: :unprocessable_entity + end + end + + def update + @event.add_photo_import params[:photo_import] + if @event.update_and_sync(event_params) + redirect_to admin_communication_website_portfolio_project_path(@project), + notice: t('admin.successfully_updated_html', model: @project.to_s) + else + @categories = categories + breadcrumb + add_breadcrumb t('edit') + render :edit, status: :unprocessable_entity + end + end + + def duplicate + redirect_to [:admin, @project.duplicate], + notice: t('admin.successfully_duplicated_html', model: @project.to_s) + end + + def destroy + @project.destroy + redirect_to admin_communication_website_portolio_projects_url, + notice: t('admin.successfully_destroyed_html', model: @project.to_s) + end + protected + + def breadcrumb + super + add_breadcrumb Communication::Website::Portfolio::Project.model_name.human(count: 2), + admin_communication_website_portfolio_projects_path + breadcrumb_for @project + end + + def categories + @website.portfolio_categories + .for_language(current_website_language) + .ordered + end + + def project_params + params.require(:communication_website_portfolio_project) + .permit( + :title, :meta_description, :summary, :published, :slug, + :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit, + category_ids: [] + ) + .merge( + university_id: current_university.id, + language_id: current_website_language.id + ) + end +end \ No newline at end of file diff --git a/app/models/communication/website/portfolio/project.rb b/app/models/communication/website/portfolio/project.rb index 5fe59335f..c2cc32334 100644 --- a/app/models/communication/website/portfolio/project.rb +++ b/app/models/communication/website/portfolio/project.rb @@ -45,4 +45,6 @@ class Communication::Website::Portfolio::Project < ApplicationRecord include WithPermalink include WithTranslations include WithUniversity + + scope :ordered, -> { order(year: :desc, title: :asc) } end From 7c7a6e9c079fe965af2e18b186b9b425d331097b Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 07:41:18 +0100 Subject: [PATCH 5/9] views wip --- .../portfolio/categories/_form.html.erb | 25 ++++++++ .../portfolio/categories/_inline.html.erb | 5 ++ .../portfolio/categories/_list.html.erb | 29 +++++++++ .../portfolio/categories/_panel.html.erb | 6 ++ .../categories/_static_about.html.erb | 6 ++ .../portfolio/categories/edit.html.erb | 5 ++ .../portfolio/categories/index.html.erb | 7 ++ .../portfolio/categories/new.html.erb | 5 ++ .../portfolio/categories/show.html.erb | 31 +++++++++ .../portfolio/categories/static.html.erb | 14 ++++ .../portfolio/projects/_form.html.erb | 64 +++++++++++++++++++ .../portfolio/projects/_list.html.erb | 36 +++++++++++ .../websites/portfolio/projects/edit.html.erb | 5 ++ .../portfolio/projects/index.html.erb | 22 +++++++ .../websites/portfolio/projects/new.html.erb | 5 ++ .../websites/portfolio/projects/show.html.erb | 46 +++++++++++++ .../projects/show/_metadata.html.erb | 13 ++++ .../portfolio/projects/static.html.erb | 23 +++++++ config/locales/communication/en.yml | 19 ++++++ config/locales/communication/fr.yml | 19 ++++++ 20 files changed, 385 insertions(+) create mode 100644 app/views/admin/communication/websites/portfolio/categories/_form.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/_inline.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/_list.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/_panel.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/edit.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/index.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/new.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/show.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/categories/static.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/_form.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/_list.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/edit.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/index.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/new.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/show.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb create mode 100644 app/views/admin/communication/websites/portfolio/projects/static.html.erb diff --git a/app/views/admin/communication/websites/portfolio/categories/_form.html.erb b/app/views/admin/communication/websites/portfolio/categories/_form.html.erb new file mode 100644 index 000000000..fdc3f2267 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/_form.html.erb @@ -0,0 +1,25 @@ +<%= simple_form_for [:admin, category] do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + +
+
+ <%= osuny_panel t('content') do %> + <%= f.input :name %> + <%= render 'admin/application/summary/form', f: f, about: category %> + <% end %> + <%= render 'admin/application/meta_description/form', f: f, about: category %> +
+
+ <%= osuny_panel t('metadata') do %> + <%= render "admin/application/slug/form", + f: f, + source: '#communication_website_agenda_category_name' %> + <% end %> + <%= render 'admin/application/featured_image/edit', about: category, f: f %> +
+
+ <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/_inline.html.erb b/app/views/admin/communication/websites/portfolio/categories/_inline.html.erb new file mode 100644 index 000000000..a5b47d37a --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/_inline.html.erb @@ -0,0 +1,5 @@ +
    + <% about.categories.ordered.each do |category| %> +
  • <%= category %>
  • + <% end %> +
diff --git a/app/views/admin/communication/websites/portfolio/categories/_list.html.erb b/app/views/admin/communication/websites/portfolio/categories/_list.html.erb new file mode 100644 index 000000000..98c3944f6 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/_list.html.erb @@ -0,0 +1,29 @@ +
+ + + + + + + + + <% categories.each do |category| %> + + + + + <% end %> + +
<%= Communication::Website::Agenda::Category.human_attribute_name('name') %>
<%= link_to category, admin_communication_website_agenda_category_path(website_id: category.website.id, id: category.id) %> +
+ <%= link_to t('edit'), + edit_admin_communication_website_agenda_category_path(website_id: category.website.id, id: category.id), + class: button_classes if can?(:update, category) %> + <%= link_to t('delete'), + admin_communication_website_agenda_category_path(website_id: category.website.id, id: category.id), + method: :delete, + data: { confirm: t('please_confirm') }, + class: button_classes_danger if can?(:destroy, category) %> +
+
+
diff --git a/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb b/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb new file mode 100644 index 000000000..9c47fed43 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb @@ -0,0 +1,6 @@ +<% if can?(:create, Communication::Website::Agenda::Category) %> + <% action = create_link Communication::Website::Agenda::Category %> + <%= osuny_panel Communication::Website::Agenda::Category.model_name.human(count: 2), action: action do %> + <%= render 'admin/communication/websites/agenda/categories/list', categories: categories %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb b/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb new file mode 100644 index 000000000..9fb5b731f --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb @@ -0,0 +1,6 @@ +<% if @about.categories.any? %> +events_categories: + <% @about.agenda_categories.each do |category| %> + - "<%= category.slug_with_ancestors_slugs %>" + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/portfolio/categories/edit.html.erb b/app/views/admin/communication/websites/portfolio/categories/edit.html.erb new file mode 100644 index 000000000..bbb03b372 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, @category %> + +<%= render 'admin/communication/websites/sidebar' do %> + <%= render 'form', category: @category %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/index.html.erb b/app/views/admin/communication/websites/portfolio/categories/index.html.erb new file mode 100644 index 000000000..e3cdfc643 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/index.html.erb @@ -0,0 +1,7 @@ +<% content_for :title, "#{Communication::Website::Agenda::Category.model_name.human(count: 2)} (#{@categories.count})" %> + +<%= render 'admin/communication/websites/sidebar' do %> + <%= render 'admin/application/categories/panel', + root_categories: @root_categories, + categories_class: @categories_class %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/new.html.erb b/app/views/admin/communication/websites/portfolio/categories/new.html.erb new file mode 100644 index 000000000..2dd536238 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/new.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, Communication::Website::Post::Category.model_name.human %> + +<%= render 'admin/communication/websites/sidebar' do %> + <%= render 'form', category: @category %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/show.html.erb b/app/views/admin/communication/websites/portfolio/categories/show.html.erb new file mode 100644 index 000000000..d6db4a994 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/show.html.erb @@ -0,0 +1,31 @@ +<% content_for :title, @category %> + +<%= render 'admin/communication/websites/sidebar' do %> +
+
+ <%= render 'admin/application/summary/show', about: @category %> + <%= render 'admin/application/i18n/widget', about: @category %> +
+
+ <%= render 'admin/application/featured_image/show', about: @category %> + <%= render 'admin/application/meta_description/show', about: @category %> +
+
+ <%= render 'admin/communication/blocks/content/editor', about: @category %> + <% if @events.total_count > 0 %> + <%= osuny_panel Communication::Website::Agenda::Event.model_name.human(count: 2), + subtitle: "#{@events.total_count} #{Communication::Website::Agenda::Event.model_name.human(count: @events.total_count).downcase }" do %> + <%= render 'admin/communication/websites/agenda/events/list', events: @events, hide_category: true %> + <%= paginate @events, theme: 'bootstrap-5' %> + <% end %> + <% end %> +<% end %> + +<% content_for :action_bar_left do %> + <%= destroy_link @category %> + <%= static_link static_admin_communication_website_agenda_category_path(@category) %> +<% end %> + +<% content_for :action_bar_right do %> + <%= edit_link @category %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/static.html.erb b/app/views/admin/communication/websites/portfolio/categories/static.html.erb new file mode 100644 index 000000000..e99ad179a --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/categories/static.html.erb @@ -0,0 +1,14 @@ +--- +<%= render 'admin/application/static/title' %> +<%= render 'admin/application/static/permalink' %> +<%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, + current_title: @about.to_s %> +position: <%= @about.position %> +<%= render 'admin/application/i18n/static' %> +<%= render 'admin/application/featured_image/static' %> +<%= render 'admin/application/meta_description/static' %> +<%= render 'admin/application/summary/static' %> +<%= render 'admin/communication/blocks/content/static', about: @about %> +--- diff --git a/app/views/admin/communication/websites/portfolio/projects/_form.html.erb b/app/views/admin/communication/websites/portfolio/projects/_form.html.erb new file mode 100644 index 000000000..31de0c16b --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/_form.html.erb @@ -0,0 +1,64 @@ +<%= simple_form_for [:admin, event] do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + +
+
+ <%= osuny_panel t('content') do %> + <%= f.input :title %> + <%= f.input :subtitle %> + <%= render 'admin/application/summary/form', f: f, about: event %> + <% end %> + <%= osuny_panel Communication::Website::Agenda::Event.human_attribute_name('dates') do %> +
+
+ <%= f.input :from_day, html5: true %> +
+
+ <%= f.input :from_hour, html5: true %> +
+
+
+
+ <%= f.input :to_day, html5: true %> +
+
+ <%= f.input :to_hour, html5: true %> +
+
+ <%= f.input :time_zone, + collection: time_zones_for_select, + include_blank: false, + selected: f.object.time_zone || @website.default_time_zone %> + <% end %> + <% if @categories.any? %> + <%= osuny_panel t('activerecord.attributes.communication/website/agenda/event.categories') do %> + <%= f.association :categories, + label_text: false, + as: :check_boxes, + collection: collection_tree_for_checkboxes(@categories) %> + <% end %> + <% end %> + + <%= render 'admin/application/meta_description/form', f: f, about: event %> + +
+
+ <%= osuny_panel t('metadata') do %> + <%= f.input :published if can? :publish, event %> + <%= render "admin/application/slug/form", + f: f, + source: '#communication_website_agenda_event_title' %> + <% end %> + <%= render 'admin/application/featured_image/edit', about: event, f: f %> +
+
+ + <% content_for :action_bar_left do %> + <%= render 'admin/application/i18n/translate_button', about: event %> + <% end %> + + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/_list.html.erb b/app/views/admin/communication/websites/portfolio/projects/_list.html.erb new file mode 100644 index 000000000..16d46253c --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/_list.html.erb @@ -0,0 +1,36 @@ +<% if projects.none? %> +

<%= t('admin.communication.website.portfolio.projects.none') %>

+<% else %> +
+ + + + + + + + + + <% projects.each do |project| %> + + + + + + <% end %> + +
<%= Communication::Website::Portfolio::Project.human_attribute_name('title') %><%= Communication::Website::Portfolio::Project.human_attribute_name('categories') %><%= Communication::Website::Portfolio::Project.human_attribute_name('featured_image') %>
+

+ <%= link_to project, + admin_communication_website_portfolio_project_path(website_id: project.website.id, id: project.id) %> +

+ <% if project.subtitle.present? %> +

+ <%= project.subtitle %> +

+ <% end %> +
<%= render 'admin/communication/websites/portfolio/categories/inline', about: project %> + <%= kamifusen_tag project.featured_image, width: 100 if project.featured_image.attached? %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/portfolio/projects/edit.html.erb b/app/views/admin/communication/websites/portfolio/projects/edit.html.erb new file mode 100644 index 000000000..5f1d67644 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, @event %> + +<%= render 'admin/communication/websites/sidebar' do %> + <%= render 'form', event: @event %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/index.html.erb b/app/views/admin/communication/websites/portfolio/projects/index.html.erb new file mode 100644 index 000000000..757dc56bd --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/index.html.erb @@ -0,0 +1,22 @@ +<% content_for :title, Communication::Website::Portfolio::Project.model_name.human(count: 2) %> + +<% content_for :title_right do %> + <%= @projects.total_count %> + <%= Communication::Website::Portfolio::Project.model_name.human(count: @projects.total_count).downcase %> +<% end %> + +<%= render 'admin/communication/websites/sidebar' do %> + <% + title = Communication::Website::Portfolio::Project.model_name.human(count: 2) + action = create_link Communication::Website::Portfolio::Project + %> + <%= osuny_panel title, action: action do %> + <%= render 'admin/communication/websites/portfolio/projects/list', projects: @projects %> + <%= paginate @projects, theme: 'bootstrap-5' %> + <% end %> + + <%#= render 'admin/application/categories/panel', + root_categories: @root_categories, + categories_class: @categories_class %> +<% end %> + diff --git a/app/views/admin/communication/websites/portfolio/projects/new.html.erb b/app/views/admin/communication/websites/portfolio/projects/new.html.erb new file mode 100644 index 000000000..28707ba18 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/new.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, Communication::Website::Agenda::Event.model_name.human %> + +<%= render 'admin/communication/websites/sidebar' do %> + <%= render 'form', event: @event %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/show.html.erb b/app/views/admin/communication/websites/portfolio/projects/show.html.erb new file mode 100644 index 000000000..41591946e --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/show.html.erb @@ -0,0 +1,46 @@ +<% content_for :title, @event %> + +<%= render 'admin/communication/websites/sidebar' do %> +
+
+ <%= osuny_panel Communication::Website::Agenda::Event.human_attribute_name(:title), small: true do %> +

<%= @event.title %>

+ <% if @event.subtitle.present? %> +

<%= @event.subtitle %>

+ <% end %> +

<%= render 'admin/communication/websites/agenda/events/dates', event: @event, detailed: true %>

+ <% end %> +
+
+ <%= render 'admin/application/featured_image/show', about: @event, small: true %> +
+
+
+ <%= render 'admin/application/a11y/widget', about: @event, horizontal: true %> +
+
+
+ <%= render 'admin/communication/websites/agenda/events/show/metadata' %> +
+
+ <%= render 'admin/application/summary/show', about: @event, small: true %> + <%= render 'admin/application/meta_description/show', about: @event %> +
+
+ <%= render 'admin/communication/blocks/content/editor', about: @event %> +<% end %> + +<% content_for :action_bar_left do %> + <%= destroy_link @event %> + <%= duplicate_link @event %> + <%= static_link static_admin_communication_website_agenda_event_path(@event) %> +<% end %> + +<% content_for :action_bar_right do %> + <%= link_to t('open'), + @event.url, + target: :_blank, + class: 'btn btn-light btn-xs' if @event.url %> + <%= edit_link @event %> + <%= publish_link @event %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb b/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb new file mode 100644 index 000000000..da72152d5 --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb @@ -0,0 +1,13 @@ +<%= osuny_panel t('metadata'), small: true do %> + <%= @event.published ? Communication::Website::Agenda::Event.human_attribute_name(:published) + : t('admin.communication.website.agenda.events.draft') %> + + <%= render 'admin/application/i18n/inline', about: @event %> + <% if @event.categories.any? %> + <%= t( + 'admin.communication.website.posts.in', + categories: @event.categories.collect(&:to_s).join(', ') + ) %> + <% end %> + <%= render 'admin/application/permalinks/redirects', about: @event %> +<% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/static.html.erb b/app/views/admin/communication/websites/portfolio/projects/static.html.erb new file mode 100644 index 000000000..03a15d2cc --- /dev/null +++ b/app/views/admin/communication/websites/portfolio/projects/static.html.erb @@ -0,0 +1,23 @@ +--- +<%= render 'admin/application/static/title' %> +subtitle: >- + <%= prepare_text_for_static @about.subtitle %> +<%= render 'admin/communication/websites/agenda/events/dates_static', event: @about %> +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, + current_title: @about.to_s %> +weight: <%= @about.distance_in_days %> +<%= render 'admin/application/static/permalink' %> +<%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> +<%= render 'admin/application/i18n/static' %> +<%= render 'admin/application/featured_image/static' %> +<%= render 'admin/application/meta_description/static' %> +<%= render 'admin/application/summary/static' %> +<% if @about.categories.any? %> +events_categories: +<% @about.categories.ordered.each do |category| %> + - "<%= category.slug %>" +<% end %> +<% end %> +<%= render 'admin/communication/blocks/content/static', about: @about %> +--- diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index b2bd23e45..c21f60e34 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -139,6 +139,16 @@ en: title: Title to_day: To day to_hour: To hour + communication/website/portfolio/category: + featured_image: Featured image + featured_image_alt: Alt text + name: Name + slug: Slug + communication/website/portfolio/project: + categories: Categories + featured_image: Featured image + published: Published + title: Title communication/website/connection: direct_source: Direct source direct_source_type: Direct source type @@ -252,6 +262,12 @@ en: communication/website/agenda/event: one: Event other: Events + communication/website/portfolio/category: + one: Category + other: Categories + communication/website/portfolio/project: + one: Project + other: Projects communication/website/connection: one: Connection other: Connections @@ -311,6 +327,9 @@ en: published: Published published_status: Publication status with_children: "with children:" + portfolio: + projects: + none: No project yet posts: and_pinned: and pinned by: by %{author} diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index c06846cfe..a550751e9 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -139,6 +139,16 @@ fr: title: Titre to_day: Jour de fin to_hour: Heure de fin + communication/website/portfolio/category: + featured_image: Image à la une + featured_image_alt: Texte alternatif + name: Nom + slug: Slug + communication/website/portfolio/project: + categories: Catégories + featured_image: Image à la une + published: Publié + title: Titre communication/website/connection: direct_source: Source directe direct_source_type: Type de la source @@ -252,6 +262,12 @@ fr: communication/website/agenda/event: one: Événement other: Événements + communication/website/portfolio/category: + one: Catégorie + other: Catégories + communication/website/portfolio/project: + one: Projet + other: Projets communication/website/connection: one: Connexion other: Connexions @@ -311,6 +327,9 @@ fr: published: Publiée published_status: État de publication with_children: "avec comme pages enfants :" + portfolio: + projects: + none: Pas encore de projet posts: and_pinned: et mis en avant by: par %{author} From 17bd3823de8a51d21bc152407066eebcc84cd802 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 08:03:05 +0100 Subject: [PATCH 6/9] wip --- .../websites/portfolio/projects_controller.rb | 2 +- .../website/portfolio/category.rb | 109 ++++++++++++++++++ .../website/portfolio/project.rb | 63 ++++++++++ .../portfolio/projects/_form.html.erb | 40 ++----- .../portfolio/projects/_list.html.erb | 15 +-- .../websites/portfolio/projects/edit.html.erb | 4 +- .../websites/portfolio/projects/new.html.erb | 4 +- .../websites/portfolio/projects/show.html.erb | 36 +++--- .../projects/show/_metadata.html.erb | 12 +- ...munication_website_portfolio_categories.rb | 22 ++++ ...oin_table_portfolio_categories_projects.rb | 10 ++ db/schema.rb | 38 +++++- .../website/portfolio/categories.yml | 33 ++++++ .../website/portfolio/category_test.rb | 7 ++ 14 files changed, 322 insertions(+), 73 deletions(-) create mode 100644 app/models/communication/website/portfolio/category.rb create mode 100644 db/migrate/20240307064328_create_communication_website_portfolio_categories.rb create mode 100644 db/migrate/20240307065916_create_join_table_portfolio_categories_projects.rb create mode 100644 test/fixtures/communication/website/portfolio/categories.yml create mode 100644 test/models/communication/website/portfolio/category_test.rb diff --git a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb index ef5769629..27cb0dfe8 100644 --- a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb +++ b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb @@ -94,7 +94,7 @@ def categories def project_params params.require(:communication_website_portfolio_project) .permit( - :title, :meta_description, :summary, :published, :slug, + :title, :meta_description, :summary, :published, :slug, :year, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit, category_ids: [] ) diff --git a/app/models/communication/website/portfolio/category.rb b/app/models/communication/website/portfolio/category.rb new file mode 100644 index 000000000..1adc58958 --- /dev/null +++ b/app/models/communication/website/portfolio/category.rb @@ -0,0 +1,109 @@ +# == Schema Information +# +# Table name: communication_website_portfolio_categories +# +# id :uuid not null, primary key +# featured_image_alt :text +# featured_image_credit :text +# is_programs_root :boolean default(FALSE) +# meta_description :text +# name :string +# path :string +# position :integer +# slug :string +# summary :text +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid not null, indexed +# original_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# idx_on_communication_website_id_8f309901d4 (communication_website_id) +# idx_on_language_id_6e6ffc92a8 (language_id) +# idx_on_original_id_4cbc9f1290 (original_id) +# idx_on_university_id_a07cc0a296 (university_id) +# index_communication_website_portfolio_categories_on_parent_id (parent_id) +# +# Foreign Keys +# +# fk_rails_0f0db1988d (communication_website_id => communication_websites.id) +# fk_rails_35d652a63c (parent_id => communication_website_portfolio_categories.id) +# fk_rails_c82d8a59f0 (language_id => languages.id) +# fk_rails_d21380c33e (original_id => communication_website_portfolio_categories.id) +# fk_rails_eed5f4b819 (university_id => universities.id) +# +class Communication::Website::Portfolio::Category < ApplicationRecord + include AsDirectObject + include Contentful + include Sanitizable + include Sluggable # We override slug_unavailable? method + include Pathable # Included after Sluggable to make sure slug is correct before anything + include WithBlobs + include WithFeaturedImage + include WithMenuItemTarget + include WithPermalink + include WithPosition + include WithTranslations + include WithTree + include WithUniversity + + belongs_to :parent, + class_name: 'Communication::Website::Portfolio::Category', + optional: true + belongs_to :program, + class_name: 'Education::Program', + optional: true + has_many :children, + class_name: 'Communication::Website::Portfolio::Category', + foreign_key: :parent_id, + dependent: :destroy + has_and_belongs_to_many :project, + class_name: 'Communication::Website::Portfolio::Event', + join_table: :communication_website_portfolio_categories_projects, + foreign_key: :communication_website_portfolio_category_id, + association_foreign_key: :communication_website_portfolio_project_id + + validates :name, presence: true + + def to_s + "#{name}" + end + + def git_path(website) + "#{git_path_content_prefix(website)}projects_categories/#{slug}/_index.html" + end + + def template_static + "admin/communication/websites/portfolio/categories/static" + end + + def dependencies + active_storage_blobs + + contents_dependencies + + [website.config_default_content_security_policy] + end + + def references + references = projects + website.menus + references << parent if parent.present? + references + end + + def siblings + self.class.unscoped.where(parent: parent, university: university, website: website).where.not(id: id) + end + + protected + + def last_ordered_element + website.portfolio_categories.where(parent_id: parent_id, language_id: language_id).ordered.last + end + + def slug_unavailable?(slug) + self.class.unscoped.where(communication_website_id: self.communication_website_id, language_id: language_id, slug: slug).where.not(id: self.id).exists? + end +end diff --git a/app/models/communication/website/portfolio/project.rb b/app/models/communication/website/portfolio/project.rb index c2cc32334..129911b19 100644 --- a/app/models/communication/website/portfolio/project.rb +++ b/app/models/communication/website/portfolio/project.rb @@ -46,5 +46,68 @@ class Communication::Website::Portfolio::Project < ApplicationRecord include WithTranslations include WithUniversity + has_and_belongs_to_many :categories, + class_name: 'Communication::Website::Portfolio::Category', + join_table: :communication_website_portfolio_categories_projects, + foreign_key: :communication_website_portfolio_project_id, + association_foreign_key: :communication_website_portfolio_category_id + + validates :title, :year, presence: true + scope :ordered, -> { order(year: :desc, title: :asc) } + scope :published, -> { where(published: true) } + scope :draft, -> { where(published: false) } + + def git_path(website) + return unless website.id == communication_website_id && published + git_path_content_prefix(website) + git_path_relative + end + + def git_path_relative + path = "projects/" + path += "#{year}-#{slug}.html" + path + end + + def template_static + "admin/communication/websites/agenda/events/static" + end + + def dependencies + active_storage_blobs + + contents_dependencies + + [website.config_default_content_security_policy] + end + + def references + menus + + abouts_with_agenda_block + end + + def url + return unless published + return if website.url.blank? + return if website.special_page(Communication::Website::Page::CommunicationAgenda)&.path.blank? + return if current_permalink_in_website(website).blank? + "#{Static.remove_trailing_slash website.url}#{Static.clean_path current_permalink_in_website(website).path}" + end + + def to_s + "#{title}" + end + + protected + + def check_accessibility + accessibility_merge_array blocks + end + + def explicit_blob_ids + super.concat [featured_image&.blob_id] + end + + def abouts_with_agenda_block + website.blocks.agenda.collect(&:about) + end + end diff --git a/app/views/admin/communication/websites/portfolio/projects/_form.html.erb b/app/views/admin/communication/websites/portfolio/projects/_form.html.erb index 31de0c16b..b472ca2c1 100644 --- a/app/views/admin/communication/websites/portfolio/projects/_form.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for [:admin, event] do |f| %> +<%= simple_form_for [:admin, project] do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> @@ -6,33 +6,10 @@
<%= osuny_panel t('content') do %> <%= f.input :title %> - <%= f.input :subtitle %> - <%= render 'admin/application/summary/form', f: f, about: event %> - <% end %> - <%= osuny_panel Communication::Website::Agenda::Event.human_attribute_name('dates') do %> -
-
- <%= f.input :from_day, html5: true %> -
-
- <%= f.input :from_hour, html5: true %> -
-
-
-
- <%= f.input :to_day, html5: true %> -
-
- <%= f.input :to_hour, html5: true %> -
-
- <%= f.input :time_zone, - collection: time_zones_for_select, - include_blank: false, - selected: f.object.time_zone || @website.default_time_zone %> + <%= render 'admin/application/summary/form', f: f, about: project %> <% end %> <% if @categories.any? %> - <%= osuny_panel t('activerecord.attributes.communication/website/agenda/event.categories') do %> + <%= osuny_panel t('activerecord.attributes.communication/website/portfolio/project.categories') do %> <%= f.association :categories, label_text: false, as: :check_boxes, @@ -40,22 +17,23 @@ <% end %> <% end %> - <%= render 'admin/application/meta_description/form', f: f, about: event %> + <%= render 'admin/application/meta_description/form', f: f, about: project %>
<%= osuny_panel t('metadata') do %> - <%= f.input :published if can? :publish, event %> + <%= f.input :published if can? :publish, project %> + <%= f.input :year %> <%= render "admin/application/slug/form", f: f, - source: '#communication_website_agenda_event_title' %> + source: '#communication_website_agenda_project_title' %> <% end %> - <%= render 'admin/application/featured_image/edit', about: event, f: f %> + <%= render 'admin/application/featured_image/edit', about: project, f: f %>
<% content_for :action_bar_left do %> - <%= render 'admin/application/i18n/translate_button', about: event %> + <%= render 'admin/application/i18n/translate_button', about: project %> <% end %> <% content_for :action_bar_right do %> diff --git a/app/views/admin/communication/websites/portfolio/projects/_list.html.erb b/app/views/admin/communication/websites/portfolio/projects/_list.html.erb index 16d46253c..e7d814c8d 100644 --- a/app/views/admin/communication/websites/portfolio/projects/_list.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/_list.html.erb @@ -14,17 +14,12 @@ <% projects.each do |project| %> -

- <%= link_to project, - admin_communication_website_portfolio_project_path(website_id: project.website.id, id: project.id) %> -

- <% if project.subtitle.present? %> -

- <%= project.subtitle %> -

- <% end %> + <%= link_to project, + admin_communication_website_portfolio_project_path(website_id: project.website.id, id: project.id) %> + + + <%= render 'admin/communication/websites/portfolio/categories/inline', about: project %> - <%= render 'admin/communication/websites/portfolio/categories/inline', about: project %> <%= kamifusen_tag project.featured_image, width: 100 if project.featured_image.attached? %> diff --git a/app/views/admin/communication/websites/portfolio/projects/edit.html.erb b/app/views/admin/communication/websites/portfolio/projects/edit.html.erb index 5f1d67644..850c7c63e 100644 --- a/app/views/admin/communication/websites/portfolio/projects/edit.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/edit.html.erb @@ -1,5 +1,5 @@ -<% content_for :title, @event %> +<% content_for :title, @project %> <%= render 'admin/communication/websites/sidebar' do %> - <%= render 'form', event: @event %> + <%= render 'form', project: @project %> <% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/new.html.erb b/app/views/admin/communication/websites/portfolio/projects/new.html.erb index 28707ba18..4792e7dca 100644 --- a/app/views/admin/communication/websites/portfolio/projects/new.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/new.html.erb @@ -1,5 +1,5 @@ -<% content_for :title, Communication::Website::Agenda::Event.model_name.human %> +<% content_for :title, Communication::Website::Portfolio::Project.model_name.human %> <%= render 'admin/communication/websites/sidebar' do %> - <%= render 'form', event: @event %> + <%= render 'form', project: @project %> <% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/show.html.erb b/app/views/admin/communication/websites/portfolio/projects/show.html.erb index 41591946e..5e3b14d5c 100644 --- a/app/views/admin/communication/websites/portfolio/projects/show.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/show.html.erb @@ -1,46 +1,42 @@ -<% content_for :title, @event %> +<% content_for :title, @project %> <%= render 'admin/communication/websites/sidebar' do %>
- <%= osuny_panel Communication::Website::Agenda::Event.human_attribute_name(:title), small: true do %> -

<%= @event.title %>

- <% if @event.subtitle.present? %> -

<%= @event.subtitle %>

- <% end %> -

<%= render 'admin/communication/websites/agenda/events/dates', event: @event, detailed: true %>

+ <%= osuny_panel Communication::Website::Portfolio::Project.human_attribute_name(:title), small: true do %> +

<%= @project.title %>

<% end %>
- <%= render 'admin/application/featured_image/show', about: @event, small: true %> + <%= render 'admin/application/featured_image/show', about: @project, small: true %>

- <%= render 'admin/application/a11y/widget', about: @event, horizontal: true %> + <%= render 'admin/application/a11y/widget', about: @project, horizontal: true %>
- <%= render 'admin/communication/websites/agenda/events/show/metadata' %> + <%= render 'admin/communication/websites/portfolio/projects/show/metadata' %>
- <%= render 'admin/application/summary/show', about: @event, small: true %> - <%= render 'admin/application/meta_description/show', about: @event %> + <%= render 'admin/application/summary/show', about: @project, small: true %> + <%= render 'admin/application/meta_description/show', about: @project %>
- <%= render 'admin/communication/blocks/content/editor', about: @event %> + <%= render 'admin/communication/blocks/content/editor', about: @project %> <% end %> <% content_for :action_bar_left do %> - <%= destroy_link @event %> - <%= duplicate_link @event %> - <%= static_link static_admin_communication_website_agenda_event_path(@event) %> + <%= destroy_link @project %> + <%= duplicate_link @project %> + <%= static_link static_admin_communication_website_portfolio_project_path(@project) %> <% end %> <% content_for :action_bar_right do %> <%= link_to t('open'), - @event.url, + @project.url, target: :_blank, - class: 'btn btn-light btn-xs' if @event.url %> - <%= edit_link @event %> - <%= publish_link @event %> + class: 'btn btn-light btn-xs' if @project.url %> + <%= edit_link @project %> + <%= publish_link @project %> <% end %> diff --git a/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb b/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb index da72152d5..54bb65fff 100644 --- a/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/show/_metadata.html.erb @@ -1,13 +1,13 @@ <%= osuny_panel t('metadata'), small: true do %> - <%= @event.published ? Communication::Website::Agenda::Event.human_attribute_name(:published) - : t('admin.communication.website.agenda.events.draft') %> + <%= @project.published ? Communication::Website::Agenda::Event.human_attribute_name(:published) + : t('admin.communication.website.agenda.projects.draft') %> - <%= render 'admin/application/i18n/inline', about: @event %> - <% if @event.categories.any? %> + <%= render 'admin/application/i18n/inline', about: @project %> + <% if @project.categories.any? %> <%= t( 'admin.communication.website.posts.in', - categories: @event.categories.collect(&:to_s).join(', ') + categories: @project.categories.collect(&:to_s).join(', ') ) %> <% end %> - <%= render 'admin/application/permalinks/redirects', about: @event %> + <%= render 'admin/application/permalinks/redirects', about: @project %> <% end %> diff --git a/db/migrate/20240307064328_create_communication_website_portfolio_categories.rb b/db/migrate/20240307064328_create_communication_website_portfolio_categories.rb new file mode 100644 index 000000000..985c6a0fd --- /dev/null +++ b/db/migrate/20240307064328_create_communication_website_portfolio_categories.rb @@ -0,0 +1,22 @@ +class CreateCommunicationWebsitePortfolioCategories < ActiveRecord::Migration[7.1] + def change + create_table :communication_website_portfolio_categories, id: :uuid do |t| + t.string :name + t.string :slug + t.text :featured_image_alt + t.text :featured_image_credit + t.text :meta_description + t.boolean :is_programs_root, default: false + t.string :path + t.integer :position + t.text :summary + t.references :communication_website, null: false, foreign_key: true, type: :uuid + t.references :language, null: false, foreign_key: true, type: :uuid + t.references :original, foreign_key: {to_table: :communication_website_portfolio_categories}, type: :uuid + t.references :parent, foreign_key: {to_table: :communication_website_portfolio_categories}, type: :uuid + t.references :university, null: false, foreign_key: true, type: :uuid + + t.timestamps + end + end +end diff --git a/db/migrate/20240307065916_create_join_table_portfolio_categories_projects.rb b/db/migrate/20240307065916_create_join_table_portfolio_categories_projects.rb new file mode 100644 index 000000000..6562a52bc --- /dev/null +++ b/db/migrate/20240307065916_create_join_table_portfolio_categories_projects.rb @@ -0,0 +1,10 @@ +class CreateJoinTablePortfolioCategoriesProjects < ActiveRecord::Migration[7.1] + def change + create_table "communication_website_portfolio_categories_projects", id: false, force: :cascade do |t| + t.uuid "communication_website_portfolio_category_id", null: false + t.uuid "communication_website_portfolio_project_id", null: false + t.index ["communication_website_portfolio_category_id", "communication_website_portfolio_project_id"] + t.index ["communication_website_portfolio_project_id", "communication_website_portfolio_category_id"] + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 43f776422..8b681ad9f 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[7.1].define(version: 2024_03_07_054140) do +ActiveRecord::Schema[7.1].define(version: 2024_03_07_065916) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -476,6 +476,37 @@ t.index ["website_id"], name: "index_communication_website_permalinks_on_website_id" end + create_table "communication_website_portfolio_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "name" + t.string "slug" + t.text "featured_image_alt" + t.text "featured_image_credit" + t.text "meta_description" + t.boolean "is_programs_root", default: false + t.string "path" + t.integer "position" + t.text "summary" + t.uuid "communication_website_id", null: false + t.uuid "language_id", null: false + t.uuid "original_id" + t.uuid "parent_id" + t.uuid "university_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["communication_website_id"], name: "idx_on_communication_website_id_8f309901d4" + t.index ["language_id"], name: "idx_on_language_id_6e6ffc92a8" + t.index ["original_id"], name: "idx_on_original_id_4cbc9f1290" + t.index ["parent_id"], name: "index_communication_website_portfolio_categories_on_parent_id" + t.index ["university_id"], name: "idx_on_university_id_a07cc0a296" + end + + create_table "communication_website_portfolio_categories_projects", id: false, force: :cascade do |t| + t.uuid "communication_website_portfolio_category_id", null: false + t.uuid "communication_website_portfolio_project_id", null: false + t.index ["communication_website_portfolio_category_id", "communication_website_portfolio_project_id"], name: "idx_on_communication_website_portfolio_category_id__77417ffc96" + t.index ["communication_website_portfolio_project_id", "communication_website_portfolio_category_id"], name: "idx_on_communication_website_portfolio_project_id_c_8ffd53123b" + end + create_table "communication_website_portfolio_projects", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "title" t.string "slug" @@ -1287,6 +1318,11 @@ add_foreign_key "communication_website_pages", "universities" add_foreign_key "communication_website_permalinks", "communication_websites", column: "website_id" add_foreign_key "communication_website_permalinks", "universities" + add_foreign_key "communication_website_portfolio_categories", "communication_website_portfolio_categories", column: "original_id" + add_foreign_key "communication_website_portfolio_categories", "communication_website_portfolio_categories", column: "parent_id" + add_foreign_key "communication_website_portfolio_categories", "communication_websites" + add_foreign_key "communication_website_portfolio_categories", "languages" + add_foreign_key "communication_website_portfolio_categories", "universities" add_foreign_key "communication_website_portfolio_projects", "communication_website_portfolio_projects", column: "original_id" add_foreign_key "communication_website_portfolio_projects", "communication_websites" add_foreign_key "communication_website_portfolio_projects", "languages" diff --git a/test/fixtures/communication/website/portfolio/categories.yml b/test/fixtures/communication/website/portfolio/categories.yml new file mode 100644 index 000000000..6a194b80b --- /dev/null +++ b/test/fixtures/communication/website/portfolio/categories.yml @@ -0,0 +1,33 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + slug: MyString + featured_image_alt: MyText + featured_image_credit: MyText + meta_description: MyText + is_programs_root: false + path: MyString + position: 1 + summary: MyText + communication_website: one + language: one + original: one + parent: one + university: one + +two: + name: MyString + slug: MyString + featured_image_alt: MyText + featured_image_credit: MyText + meta_description: MyText + is_programs_root: false + path: MyString + position: 1 + summary: MyText + communication_website: two + language: two + original: two + parent: two + university: two diff --git a/test/models/communication/website/portfolio/category_test.rb b/test/models/communication/website/portfolio/category_test.rb new file mode 100644 index 000000000..64b4d3fa9 --- /dev/null +++ b/test/models/communication/website/portfolio/category_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Communication::Website::Portfolio::CategoryTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 6e6ba3b385ff32aca65f6160f6c90bcd0ba3c3a0 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 08:09:39 +0100 Subject: [PATCH 7/9] projects ! --- .../websites/portfolio/projects_controller.rb | 6 ++-- .../website/page/communication_portfolio.rb | 24 ++++++++++++++++ .../communication/website/page/with_type.rb | 1 + app/models/communication/website/permalink.rb | 2 ++ .../website/permalink/portfolio/category.rb | 27 ++++++++++++++++++ .../website/permalink/portfolio/project.rb | 28 +++++++++++++++++++ .../portfolio/projects/static.html.erb | 8 ++---- 7 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 app/models/communication/website/page/communication_portfolio.rb create mode 100644 app/models/communication/website/permalink/portfolio/category.rb create mode 100644 app/models/communication/website/permalink/portfolio/project.rb diff --git a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb index 27cb0dfe8..76a59bfd3 100644 --- a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb +++ b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb @@ -25,7 +25,7 @@ def show end def static - @about = @event + @about = @project render_as_plain_text end @@ -54,8 +54,8 @@ def create end def update - @event.add_photo_import params[:photo_import] - if @event.update_and_sync(event_params) + @project.add_photo_import params[:photo_import] + if @project.update_and_sync(project_params) redirect_to admin_communication_website_portfolio_project_path(@project), notice: t('admin.successfully_updated_html', model: @project.to_s) else diff --git a/app/models/communication/website/page/communication_portfolio.rb b/app/models/communication/website/page/communication_portfolio.rb new file mode 100644 index 000000000..ffffd34b5 --- /dev/null +++ b/app/models/communication/website/page/communication_portfolio.rb @@ -0,0 +1,24 @@ +class Communication::Website::Page::CommunicationPortfolio < Communication::Website::Page + + def editable_width? + false + end + + def full_width_by_default? + true + end + + def is_necessary_for_website? + website.feature_portfolio + end + + def dependencies + super + + [website.config_default_languages] + + website.projects + end + + def git_path_relative + 'projects/_index.html' + end +end diff --git a/app/models/communication/website/page/with_type.rb b/app/models/communication/website/page/with_type.rb index a668dd3a4..a71f0bc7c 100644 --- a/app/models/communication/website/page/with_type.rb +++ b/app/models/communication/website/page/with_type.rb @@ -11,6 +11,7 @@ module Communication::Website::Page::WithType Communication::Website::Page::CommunicationPost, Communication::Website::Page::CommunicationAgenda, Communication::Website::Page::CommunicationAgendaArchive, + Communication::Website::Page::CommunicationPortfolio, Communication::Website::Page::Person, Communication::Website::Page::Organization, # Education diff --git a/app/models/communication/website/permalink.rb b/app/models/communication/website/permalink.rb index 0f2f14764..c147b6c34 100644 --- a/app/models/communication/website/permalink.rb +++ b/app/models/communication/website/permalink.rb @@ -30,6 +30,8 @@ class Communication::Website::Permalink < ApplicationRecord "Communication::Website::Post::Category" => Communication::Website::Permalink::Category, "Communication::Website::Agenda::Event" => Communication::Website::Permalink::Agenda::Event, "Communication::Website::Agenda::Category" => Communication::Website::Permalink::Agenda::Category, + "Communication::Website::Portfolio::Project" => Communication::Website::Permalink::Portfolio::Project, + "Communication::Website::Portfolio::Category" => Communication::Website::Permalink::Portfolio::Category, "Administration::Location" => Communication::Website::Permalink::Location, "Education::Diploma" => Communication::Website::Permalink::Diploma, "Education::Program" => Communication::Website::Permalink::Program, diff --git a/app/models/communication/website/permalink/portfolio/category.rb b/app/models/communication/website/permalink/portfolio/category.rb new file mode 100644 index 000000000..f8d220fab --- /dev/null +++ b/app/models/communication/website/permalink/portfolio/category.rb @@ -0,0 +1,27 @@ +class Communication::Website::Permalink::Portfolio::Category < Communication::Website::Permalink + def self.required_in_config?(website) + website.feature_portfolio + end + + def self.static_config_key + :projects_categories + end + + # /projets/:slug/ + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::CommunicationPortfolio, language: language).slug_with_ancestors}/:slug/" + end + + protected + + def published? + website.id == about.communication_website_id + end + + def substitutions + { + slug: about.slug + } + end + +end diff --git a/app/models/communication/website/permalink/portfolio/project.rb b/app/models/communication/website/permalink/portfolio/project.rb new file mode 100644 index 000000000..eb4be05d0 --- /dev/null +++ b/app/models/communication/website/permalink/portfolio/project.rb @@ -0,0 +1,28 @@ +class Communication::Website::Permalink::Portfolio::Project < Communication::Website::Permalink + def self.required_in_config?(website) + website.feature_portfolio + end + + def self.static_config_key + :projects + end + + # /projets/2022-lac-project/ + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::CommunicationPortfolio, language: language).slug_with_ancestors}/:year-:slug/" + end + + protected + + def published? + website.id == about.communication_website_id && about.published + end + + def substitutions + { + year: about.from_day.strftime("%Y"), + slug: about.slug + } + end + +end diff --git a/app/views/admin/communication/websites/portfolio/projects/static.html.erb b/app/views/admin/communication/websites/portfolio/projects/static.html.erb index 03a15d2cc..ed6f867c4 100644 --- a/app/views/admin/communication/websites/portfolio/projects/static.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/static.html.erb @@ -1,12 +1,8 @@ --- <%= render 'admin/application/static/title' %> -subtitle: >- - <%= prepare_text_for_static @about.subtitle %> -<%= render 'admin/communication/websites/agenda/events/dates_static', event: @about %> <%= render 'admin/application/static/breadcrumbs', - pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, + pages: @website.special_page(Communication::Website::Page::CommunicationPortfolio).ancestors_and_self, current_title: @about.to_s %> -weight: <%= @about.distance_in_days %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> <%= render 'admin/application/i18n/static' %> @@ -14,7 +10,7 @@ weight: <%= @about.distance_in_days %> <%= render 'admin/application/meta_description/static' %> <%= render 'admin/application/summary/static' %> <% if @about.categories.any? %> -events_categories: +projects_categories: <% @about.categories.ordered.each do |category| %> - "<%= category.slug %>" <% end %> From 4728e5e5de07db919a1e55fd47b84dc4f11c5847 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 7 Mar 2024 08:47:23 +0100 Subject: [PATCH 8/9] done! --- .../websites/portfolio/categories_controller.rb | 8 ++++---- .../websites/portfolio/projects_controller.rb | 6 ++---- .../communication/website/feature_portfolio.rb | 3 ++- .../communication/website/portfolio/category.rb | 4 ++-- .../websites/portfolio/categories/_form.html.erb | 2 +- .../websites/portfolio/categories/_list.html.erb | 8 ++++---- .../websites/portfolio/categories/_panel.html.erb | 11 +++++++---- .../portfolio/categories/_static_about.html.erb | 4 ++-- .../websites/portfolio/categories/index.html.erb | 2 +- .../websites/portfolio/categories/new.html.erb | 1 - .../websites/portfolio/categories/show.html.erb | 15 +++++++++------ .../websites/portfolio/categories/static.html.erb | 2 +- .../websites/portfolio/projects/index.html.erb | 2 +- config/locales/communication/en.yml | 3 +++ config/locales/communication/fr.yml | 3 +++ 15 files changed, 42 insertions(+), 32 deletions(-) diff --git a/app/controllers/admin/communication/websites/portfolio/categories_controller.rb b/app/controllers/admin/communication/websites/portfolio/categories_controller.rb index 51449fcd6..278e7a1f7 100644 --- a/app/controllers/admin/communication/websites/portfolio/categories_controller.rb +++ b/app/controllers/admin/communication/websites/portfolio/categories_controller.rb @@ -1,7 +1,7 @@ class Admin::Communication::Websites::Portfolio::CategoriesController < Admin::Communication::Websites::Portfolio::ApplicationController load_and_authorize_resource class: 'Communication::Website::Portfolio::Category', through: :website, - through_association: :agenda_categories + through_association: :portfolio_categories include Admin::Translatable include Admin::Categorizable @@ -35,7 +35,7 @@ def create @category.website = @website @category.add_photo_import params[:photo_import] if @category.save_and_sync - redirect_to admin_communication_website_agenda_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s) + redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s) else breadcrumb render :new, status: :unprocessable_entity @@ -45,7 +45,7 @@ def create def update @category.add_photo_import params[:photo_import] if @category.update_and_sync(category_params) - redirect_to admin_communication_website_agenda_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s) + redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s) else breadcrumb add_breadcrumb t('edit') @@ -55,7 +55,7 @@ def update def destroy @category.destroy - redirect_to admin_communication_website_agenda_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s) + redirect_to admin_communication_website_portfolio_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s) end protected diff --git a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb index 76a59bfd3..20c578f6b 100644 --- a/app/controllers/admin/communication/websites/portfolio/projects_controller.rb +++ b/app/controllers/admin/communication/websites/portfolio/projects_controller.rb @@ -8,8 +8,8 @@ def index @projects = apply_scopes(@projects).for_language(current_website_language) .ordered .page(params[:page]) - # @root_categories = categories.root - # @categories_class = Communication::Website::Portfolio::Category + @root_categories = categories.root + @categories_class = Communication::Website::Portfolio::Category breadcrumb end @@ -80,8 +80,6 @@ def destroy def breadcrumb super - add_breadcrumb Communication::Website::Portfolio::Project.model_name.human(count: 2), - admin_communication_website_portfolio_projects_path breadcrumb_for @project end diff --git a/app/models/communication/website/feature_portfolio.rb b/app/models/communication/website/feature_portfolio.rb index 24737337a..2582748b5 100644 --- a/app/models/communication/website/feature_portfolio.rb +++ b/app/models/communication/website/feature_portfolio.rb @@ -5,12 +5,13 @@ module Communication::Website::FeaturePortfolio has_many :portfolio_projects, class_name: "Communication::Website::Portfolio::Project", foreign_key: :communication_website_id - alias :projects :portfolio_projects + alias :projects :portfolio_projects has_many :portfolio_categories, class_name: 'Communication::Website::Portfolio::Category', foreign_key: :communication_website_id, dependent: :destroy + alias :projects_categories :portfolio_categories end def has_portfolio_projects? diff --git a/app/models/communication/website/portfolio/category.rb b/app/models/communication/website/portfolio/category.rb index 1adc58958..8b2a58eee 100644 --- a/app/models/communication/website/portfolio/category.rb +++ b/app/models/communication/website/portfolio/category.rb @@ -61,8 +61,8 @@ class Communication::Website::Portfolio::Category < ApplicationRecord class_name: 'Communication::Website::Portfolio::Category', foreign_key: :parent_id, dependent: :destroy - has_and_belongs_to_many :project, - class_name: 'Communication::Website::Portfolio::Event', + has_and_belongs_to_many :projects, + class_name: 'Communication::Website::Portfolio::Project', join_table: :communication_website_portfolio_categories_projects, foreign_key: :communication_website_portfolio_category_id, association_foreign_key: :communication_website_portfolio_project_id diff --git a/app/views/admin/communication/websites/portfolio/categories/_form.html.erb b/app/views/admin/communication/websites/portfolio/categories/_form.html.erb index fdc3f2267..925120b61 100644 --- a/app/views/admin/communication/websites/portfolio/categories/_form.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/_form.html.erb @@ -14,7 +14,7 @@ <%= osuny_panel t('metadata') do %> <%= render "admin/application/slug/form", f: f, - source: '#communication_website_agenda_category_name' %> + source: '#communication_website_portfolio_category_name' %> <% end %> <%= render 'admin/application/featured_image/edit', about: category, f: f %> diff --git a/app/views/admin/communication/websites/portfolio/categories/_list.html.erb b/app/views/admin/communication/websites/portfolio/categories/_list.html.erb index 98c3944f6..70ed0c3b1 100644 --- a/app/views/admin/communication/websites/portfolio/categories/_list.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/_list.html.erb @@ -2,21 +2,21 @@ - + <% categories.each do |category| %> - +
<%= Communication::Website::Agenda::Category.human_attribute_name('name') %><%= Communication::Website::Portfolio::Category.human_attribute_name('name') %>
<%= link_to category, admin_communication_website_agenda_category_path(website_id: category.website.id, id: category.id) %><%= link_to category, admin_communication_website_portfolio_category_path(website_id: category.website.id, id: category.id) %>
<%= link_to t('edit'), - edit_admin_communication_website_agenda_category_path(website_id: category.website.id, id: category.id), + edit_admin_communication_website_portfolio_category_path(website_id: category.website.id, id: category.id), class: button_classes if can?(:update, category) %> <%= link_to t('delete'), - admin_communication_website_agenda_category_path(website_id: category.website.id, id: category.id), + admin_communication_website_portfolio_category_path(website_id: category.website.id, id: category.id), method: :delete, data: { confirm: t('please_confirm') }, class: button_classes_danger if can?(:destroy, category) %> diff --git a/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb b/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb index 9c47fed43..69a2b832a 100644 --- a/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/_panel.html.erb @@ -1,6 +1,9 @@ -<% if can?(:create, Communication::Website::Agenda::Category) %> - <% action = create_link Communication::Website::Agenda::Category %> - <%= osuny_panel Communication::Website::Agenda::Category.model_name.human(count: 2), action: action do %> - <%= render 'admin/communication/websites/agenda/categories/list', categories: categories %> +<% if can?(:create, Communication::Website::Portfolio::Category) %> + <% + title = Communication::Website::Portfolio::Category.model_name.human(count: 2) + action = create_link Communication::Website::Portfolio::Category + %> + <%= osuny_panel title, action: action do %> + <%= render 'admin/communication/websites/portfolio/categories/list', categories: categories %> <% end %> <% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb b/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb index 9fb5b731f..a18af7446 100644 --- a/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/_static_about.html.erb @@ -1,6 +1,6 @@ <% if @about.categories.any? %> -events_categories: - <% @about.agenda_categories.each do |category| %> +projects_categories: + <% @about.portfolio_categories.each do |category| %> - "<%= category.slug_with_ancestors_slugs %>" <% end %> <% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/portfolio/categories/index.html.erb b/app/views/admin/communication/websites/portfolio/categories/index.html.erb index e3cdfc643..f7236e3c1 100644 --- a/app/views/admin/communication/websites/portfolio/categories/index.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/index.html.erb @@ -1,4 +1,4 @@ -<% content_for :title, "#{Communication::Website::Agenda::Category.model_name.human(count: 2)} (#{@categories.count})" %> +<% content_for :title, "#{Communication::Website::Portfolio::Category.model_name.human(count: 2)} (#{@categories.count})" %> <%= render 'admin/communication/websites/sidebar' do %> <%= render 'admin/application/categories/panel', diff --git a/app/views/admin/communication/websites/portfolio/categories/new.html.erb b/app/views/admin/communication/websites/portfolio/categories/new.html.erb index 2dd536238..77feb6a4b 100644 --- a/app/views/admin/communication/websites/portfolio/categories/new.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/new.html.erb @@ -1,5 +1,4 @@ <% content_for :title, Communication::Website::Post::Category.model_name.human %> - <%= render 'admin/communication/websites/sidebar' do %> <%= render 'form', category: @category %> <% end %> diff --git a/app/views/admin/communication/websites/portfolio/categories/show.html.erb b/app/views/admin/communication/websites/portfolio/categories/show.html.erb index d6db4a994..e248313bf 100644 --- a/app/views/admin/communication/websites/portfolio/categories/show.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/show.html.erb @@ -12,18 +12,21 @@
<%= render 'admin/communication/blocks/content/editor', about: @category %> - <% if @events.total_count > 0 %> - <%= osuny_panel Communication::Website::Agenda::Event.model_name.human(count: 2), - subtitle: "#{@events.total_count} #{Communication::Website::Agenda::Event.model_name.human(count: @events.total_count).downcase }" do %> - <%= render 'admin/communication/websites/agenda/events/list', events: @events, hide_category: true %> - <%= paginate @events, theme: 'bootstrap-5' %> + <% if @projects.total_count > 0 %> + <% + title = Communication::Website::Portfolio::Project.model_name.human(count: 2) + subtitle = "#{@projects.total_count} #{Communication::Website::Portfolio::Project.model_name.human(count: @projects.total_count).downcase }" + %> + <%= osuny_panel title, subtitle: subtitle do %> + <%= render 'admin/communication/websites/portfolio/projects/list', projects: @projects, hide_category: true %> + <%= paginate @projects, theme: 'bootstrap-5' %> <% end %> <% end %> <% end %> <% content_for :action_bar_left do %> <%= destroy_link @category %> - <%= static_link static_admin_communication_website_agenda_category_path(@category) %> + <%= static_link static_admin_communication_website_portfolio_category_path(@category) %> <% end %> <% content_for :action_bar_right do %> diff --git a/app/views/admin/communication/websites/portfolio/categories/static.html.erb b/app/views/admin/communication/websites/portfolio/categories/static.html.erb index e99ad179a..dc6e0efec 100644 --- a/app/views/admin/communication/websites/portfolio/categories/static.html.erb +++ b/app/views/admin/communication/websites/portfolio/categories/static.html.erb @@ -3,7 +3,7 @@ <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> <%= render 'admin/application/static/breadcrumbs', - pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, + pages: @website.special_page(Communication::Website::Page::CommunicationPortfolio).ancestors_and_self, current_title: @about.to_s %> position: <%= @about.position %> <%= render 'admin/application/i18n/static' %> diff --git a/app/views/admin/communication/websites/portfolio/projects/index.html.erb b/app/views/admin/communication/websites/portfolio/projects/index.html.erb index 757dc56bd..86e20d90f 100644 --- a/app/views/admin/communication/websites/portfolio/projects/index.html.erb +++ b/app/views/admin/communication/websites/portfolio/projects/index.html.erb @@ -15,7 +15,7 @@ <%= paginate @projects, theme: 'bootstrap-5' %> <% end %> - <%#= render 'admin/application/categories/panel', + <%= render 'admin/application/categories/panel', root_categories: @root_categories, categories_class: @categories_class %> <% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index c21f60e34..256c56755 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -412,6 +412,9 @@ en: communication_agenda_archive: slug: archives title: Archives + communication_portfolio: + slug: projects + title: Projects education_diploma: slug: diplomas title: Diplomas diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index a550751e9..3f9f33184 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -412,6 +412,9 @@ fr: communication_agenda_archive: slug: archives title: Archives + communication_portfolio: + slug: projets + title: Projets education_diploma: slug: diplomes title: "Diplômes" From ad5b1c7eda94797e392690f53f7b5ed177bfe447 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Fri, 8 Mar 2024 14:43:59 +0100 Subject: [PATCH 9/9] fix --- .../website/portfolio/categories.yml | 18 ++++------- .../website/portfolio/projects.yml | 32 ++++++++----------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/test/fixtures/communication/website/portfolio/categories.yml b/test/fixtures/communication/website/portfolio/categories.yml index 6a194b80b..f6742cfa1 100644 --- a/test/fixtures/communication/website/portfolio/categories.yml +++ b/test/fixtures/communication/website/portfolio/categories.yml @@ -1,5 +1,3 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - one: name: MyString slug: MyString @@ -10,11 +8,9 @@ one: path: MyString position: 1 summary: MyText - communication_website: one - language: one - original: one - parent: one - university: one + university: default_university + website: website_with_github + language: fr two: name: MyString @@ -26,8 +22,6 @@ two: path: MyString position: 1 summary: MyText - communication_website: two - language: two - original: two - parent: two - university: two + university: default_university + website: website_with_github + language: fr diff --git a/test/fixtures/communication/website/portfolio/projects.yml b/test/fixtures/communication/website/portfolio/projects.yml index d5e50bf4c..660973bc4 100644 --- a/test/fixtures/communication/website/portfolio/projects.yml +++ b/test/fixtures/communication/website/portfolio/projects.yml @@ -1,29 +1,25 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - one: - title: MyString - slug: MyString + title: My string + slug: "my-string" featured_image_alt: MyText featured_image_credit: MyText - year: 1 + year: 2020 meta_description: MyText - published: false + published: true summary: MyText - communication_website: one - language: one - original: one - university: one + university: default_university + website: website_with_github + language: fr two: - title: MyString - slug: MyString + title: My string + slug: "my-string" featured_image_alt: MyText featured_image_credit: MyText - year: 1 + year: 2020 meta_description: MyText - published: false + published: true summary: MyText - communication_website: two - language: two - original: two - university: two + university: default_university + website: website_with_github + language: fr