From e9f63aaf34bdceb780e3abee6008f2b05b55a700 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 26 Dec 2022 17:21:39 +0100 Subject: [PATCH] theme version --- app/controllers/server/websites_controller.rb | 18 +++++++++++++ app/models/communication/website.rb | 1 + .../website/configs/default_languages.rb | 1 + .../website/configs/default_permalinks.rb | 1 + .../website/configs/development_config.rb | 1 + .../website/configs/production_config.rb | 1 + .../admin/application/static/_design.html.erb | 3 +++ app/views/server/websites/edit.html.erb | 6 +++++ app/views/server/websites/index.html.erb | 4 ++- ...theme_version_to_communication_websites.rb | 5 ++++ db/schema.rb | 3 ++- test/fixtures/communication/websites.yml | 1 + test/fixtures/education/schools.yml | 27 ++++++++++++++++++- test/fixtures/languages.yml | 12 ++++++++- 14 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 app/views/server/websites/edit.html.erb create mode 100644 db/migrate/20221226160909_add_theme_version_to_communication_websites.rb diff --git a/app/controllers/server/websites_controller.rb b/app/controllers/server/websites_controller.rb index 764ba04ca..856ed0692 100644 --- a/app/controllers/server/websites_controller.rb +++ b/app/controllers/server/websites_controller.rb @@ -5,4 +5,22 @@ class Server::WebsitesController < Server::ApplicationController breadcrumb end + def edit + @website = Communication::Website.find params[:id] + breadcrumb + add_breadcrumb @website + end + + def update + @website = Communication::Website.find params[:id] + @website.update_column :theme_version, params[:communication_website][:theme_version] + redirect_to server_websites_path + end + + protected + + def breadcrumb + super + add_breadcrumb Communication::Website.model_name.human(count: 2), server_websites_path + end end \ No newline at end of file diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 0d0c46680..fbfb3ca4a 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -14,6 +14,7 @@ # repository :string # style :text # style_updated_at :date +# theme_version :string # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/default_languages.rb b/app/models/communication/website/configs/default_languages.rb index dfaf62762..59fe81710 100644 --- a/app/models/communication/website/configs/default_languages.rb +++ b/app/models/communication/website/configs/default_languages.rb @@ -14,6 +14,7 @@ # repository :string # style :text # style_updated_at :date +# theme_version :string # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/default_permalinks.rb b/app/models/communication/website/configs/default_permalinks.rb index cb70b44bd..287cc69e4 100644 --- a/app/models/communication/website/configs/default_permalinks.rb +++ b/app/models/communication/website/configs/default_permalinks.rb @@ -14,6 +14,7 @@ # repository :string # style :text # style_updated_at :date +# theme_version :string # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/development_config.rb b/app/models/communication/website/configs/development_config.rb index f4f672d45..d3b15c0ec 100644 --- a/app/models/communication/website/configs/development_config.rb +++ b/app/models/communication/website/configs/development_config.rb @@ -14,6 +14,7 @@ # repository :string # style :text # style_updated_at :date +# theme_version :string # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/production_config.rb b/app/models/communication/website/configs/production_config.rb index e40eb7abd..c6eb64a65 100644 --- a/app/models/communication/website/configs/production_config.rb +++ b/app/models/communication/website/configs/production_config.rb @@ -14,6 +14,7 @@ # repository :string # style :text # style_updated_at :date +# theme_version :string # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/views/admin/application/static/_design.html.erb b/app/views/admin/application/static/_design.html.erb index c6212a7be..fd51f2089 100644 --- a/app/views/admin/application/static/_design.html.erb +++ b/app/views/admin/application/static/_design.html.erb @@ -6,6 +6,9 @@ toc_offcanvas = local_assigns.has_key?(:toc_offcanvas) ? local_assigns[:toc_off toc_present = local_assigns.has_key?(:toc_present) ? local_assigns[:toc_present] : @about.show_toc? %> +<% # legacy, please remove when site migrated %> +full_width: <%= full_width %> +<% # end of legacy%> design: full_width: <%= full_width %> toc: diff --git a/app/views/server/websites/edit.html.erb b/app/views/server/websites/edit.html.erb new file mode 100644 index 000000000..bfa63d2db --- /dev/null +++ b/app/views/server/websites/edit.html.erb @@ -0,0 +1,6 @@ +<%= simple_form_for @website, url: server_website_path(@website) do |f| %> + <%= f.input :theme_version %> + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/server/websites/index.html.erb b/app/views/server/websites/index.html.erb index e0766b309..b68d7f7e6 100644 --- a/app/views/server/websites/index.html.erb +++ b/app/views/server/websites/index.html.erb @@ -9,15 +9,17 @@ <th><%= Communication::Website.human_attribute_name('name') %></th> <th><%= Communication::Website.human_attribute_name('url') %></th> <th><%= Communication::Website.human_attribute_name('in_production') %></th> + <th><%= Communication::Website.human_attribute_name('theme_version') %></th> <th><%= University.model_name.human %></th> </tr> </thead> <tbody> <% @websites.each do |website| %> <tr> - <td><%= website.name %></td> + <td><%= link_to website.name, edit_server_website_path(website) %></td> <td><%= link_to website.url, website.url, target: :_blank if website.url.present? %></td> <td><%= t website.in_production %></td> + <td><%= website.theme_version %></td> <td><%= link_to website.university, [:server, website.university] %></td> </tr> <% end %> diff --git a/db/migrate/20221226160909_add_theme_version_to_communication_websites.rb b/db/migrate/20221226160909_add_theme_version_to_communication_websites.rb new file mode 100644 index 000000000..af77adc81 --- /dev/null +++ b/db/migrate/20221226160909_add_theme_version_to_communication_websites.rb @@ -0,0 +1,5 @@ +class AddThemeVersionToCommunicationWebsites < ActiveRecord::Migration[7.0] + def change + add_column :communication_websites, :theme_version, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 2d9463fce..bb15072bf 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.0].define(version: 2022_12_22_140427) do +ActiveRecord::Schema[7.0].define(version: 2022_12_26_160909) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -383,6 +383,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_22_140427) do t.string "git_branch" t.boolean "in_production", default: false t.uuid "default_language_id", null: false + t.string "theme_version" 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" diff --git a/test/fixtures/communication/websites.yml b/test/fixtures/communication/websites.yml index c8aedc20e..c88335243 100644 --- a/test/fixtures/communication/websites.yml +++ b/test/fixtures/communication/websites.yml @@ -14,6 +14,7 @@ # repository :string # style :text # style_updated_at :date +# theme_version :string # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/test/fixtures/education/schools.yml b/test/fixtures/education/schools.yml index 51fbf5bc6..c8a131ca1 100644 --- a/test/fixtures/education/schools.yml +++ b/test/fixtures/education/schools.yml @@ -1,3 +1,28 @@ +# == Schema Information +# +# Table name: education_schools +# +# id :uuid not null, primary key +# address :string +# city :string +# country :string +# latitude :float +# longitude :float +# name :string +# phone :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# +# Indexes +# +# index_education_schools_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_e01b37a3ad (university_id => universities.id) +# default_school: name: École de test - university: default_university \ No newline at end of file + university: default_university diff --git a/test/fixtures/languages.yml b/test/fixtures/languages.yml index 77d02342d..314cf445e 100644 --- a/test/fixtures/languages.yml +++ b/test/fixtures/languages.yml @@ -1,7 +1,17 @@ +# == Schema Information +# +# Table name: languages +# +# id :uuid not null, primary key +# iso_code :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# en: name: English iso_code: en fr: name: Français - iso_code: fr \ No newline at end of file + iso_code: fr -- GitLab