diff --git a/app/controllers/admin/communication/website/blocks_controller.rb b/app/controllers/admin/communication/website/blocks_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..4b0abb3b4b35d6f45e74cd097e5618ed0873af05 --- /dev/null +++ b/app/controllers/admin/communication/website/blocks_controller.rb @@ -0,0 +1,61 @@ +class Admin::Communication::Website::BlocksController < Admin::Communication::Website::ApplicationController + load_and_authorize_resource class: Communication::Website::Block, through: :website + + def reorder + ids = params[:ids] || [] + first_page = nil + ids.each.with_index do |id, index| + block = @website.blocks.find(id) + block.update position: index + 1 + end + end + + def new + @block.about_type = params[:about_type] + @block.about_id = params[:about_id] + breadcrumb + end + + def edit + breadcrumb + end + + def create + @block.university = @website.university + @block.website = @website + if @block.save + redirect_to [:admin, @block.about], notice: t('admin.successfully_created_html', model: @block.to_s) + else + render :new, status: :unprocessable_entity + end + end + + def update + if @block.update(block_params) + redirect_to [:admin, @block.about], notice: t('admin.successfully_updated_html', model: @block.to_s) + else + render :edit, status: :unprocessable_entity + end + end + + def destroy + @about = @block.about + @block.destroy + redirect_to [:admin, @about], notice: t('admin.successfully_destroyed_html', model: @block.to_s) + end + + protected + + def breadcrumb + super + add_breadcrumb @block.about.model_name.human(count: 2), [:admin, @block.about.class] + add_breadcrumb @block.about, [:admin, @block.about] + add_breadcrumb t('communication.website.block.choose_template') + end + + + def block_params + params.require(:communication_website_block) + .permit(:about_id, :about_type, :template, :data) + end +end diff --git a/app/models/communication/website/block.rb b/app/models/communication/website/block.rb new file mode 100644 index 0000000000000000000000000000000000000000..ca0170661f68027e26a90afd92a2439684c10567 --- /dev/null +++ b/app/models/communication/website/block.rb @@ -0,0 +1,46 @@ +# == Schema Information +# +# Table name: communication_website_blocks +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# data :jsonb +# position :integer default(0), not null +# template :integer default(0), not null +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# communication_website_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_blocks_on_about (about_type,about_id) +# index_communication_website_blocks_on_communication_website_id (communication_website_id) +# index_communication_website_blocks_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_18291ef65f (university_id => universities.id) +# fk_rails_75bd7c8d6c (communication_website_id => communication_websites.id) +# +class Communication::Website::Block < ApplicationRecord + include WithPosition + + belongs_to :university + belongs_to :website, foreign_key: :communication_website_id + belongs_to :about, polymorphic: true + + enum template: { + organization_chart: 100, + partners: 200 + } + + def to_s + "Bloc #{position}" + end + + def last_ordered_element + about.blocks.ordered.last + end +end diff --git a/app/models/communication/website/home.rb b/app/models/communication/website/home.rb index e35d331f377e598439ec04feb6943c2d1aeb18a6..00353bdc29900672e5fe998248be50318b553a78 100644 --- a/app/models/communication/website/home.rb +++ b/app/models/communication/website/home.rb @@ -6,6 +6,7 @@ # description :text # featured_image_alt :string # github_path :text +# text_new :text # created_at :datetime not null # updated_at :datetime not null # communication_website_id :uuid not null, indexed diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 4a81253e0070ce429948cdf519765335cfd96bca..4ffcf0ecd2cabf864d145f7ae800cae08d4b7b4b 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -12,6 +12,7 @@ # position :integer default(0), not null # published :boolean default(FALSE) # slug :string +# text_new :text # title :string # created_at :datetime not null # updated_at :datetime not null @@ -45,6 +46,7 @@ class Communication::Website::Page < ApplicationRecord include WithSlug # We override slug_unavailable? method include WithTree include WithPosition + include WithBlocks has_rich_text :text diff --git a/app/models/communication/website/with_abouts.rb b/app/models/communication/website/with_abouts.rb index 83916b81544fc65b6e2c256bc20e4053ddcff20e..556203472bbeb2e397d3a92968723b2ac9c96f72 100644 --- a/app/models/communication/website/with_abouts.rb +++ b/app/models/communication/website/with_abouts.rb @@ -26,6 +26,10 @@ module Communication::Website::WithAbouts foreign_key: :communication_website_id, dependent: :destroy + has_many :blocks, + foreign_key: :communication_website_id, + dependent: :destroy + def self.about_types [ nil, diff --git a/app/models/concerns/with_blocks.rb b/app/models/concerns/with_blocks.rb new file mode 100644 index 0000000000000000000000000000000000000000..bdfbf632b8c9752e5a430c663ee5f5e5669f23f1 --- /dev/null +++ b/app/models/concerns/with_blocks.rb @@ -0,0 +1,7 @@ +module WithBlocks + extend ActiveSupport::Concern + + included do + has_many :blocks, as: :about + end +end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 4396afb139e0ed0ba87bb3148ae45937dbc4a7a6..9abd988e96d3f1c9c75cb32f48b67e4630aa1557 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -3,16 +3,29 @@ # Table name: education_programs # # id :uuid not null, primary key +# accessibility_new :text # capacity :integer +# contacts_new :text +# content_new :text # continuing :boolean # description :text +# duration_new :text # ects :integer +# evaluation_new :text # featured_image_alt :string # level :integer # name :string +# objectives_new :text +# opportunities_new :text +# other_new :text # path :string +# pedagogy_new :text # position :integer default(0) +# prerequisites_new :text +# pricing_new :text # published :boolean default(FALSE) +# registration_new :text +# results_new :text # slug :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index bfe4270b1f2ebc51197cebd6e0d5abcd76fd2678..3ff64d1093a41146aa9c9ee78e2b7fc03833624f 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -5,12 +5,12 @@ # id :uuid not null, primary key # abstract :text # keywords :text -# old_text :text # position :integer # published :boolean default(FALSE) # published_at :datetime # references :text # slug :string +# text_new :text # title :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/research/laboratory/axis.rb b/app/models/research/laboratory/axis.rb index 372f8165f5f7340b4ad1749e4fe27f8b48faf77d..5556990de730a60877322bdc79974b3085253335 100644 --- a/app/models/research/laboratory/axis.rb +++ b/app/models/research/laboratory/axis.rb @@ -7,6 +7,7 @@ # name :string # position :integer # short_name :string +# text_new :text # created_at :datetime not null # updated_at :datetime not null # research_laboratory_id :uuid not null, indexed diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 311541fc3cbd5ef26c5e72858c0243da12a238aa..8f25ccd6d549213397050f95e310eb72ee3221ca 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -3,6 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key +# biography_new :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/administrator.rb b/app/models/university/person/administrator.rb index 422bbd69544b4216ae726f1afd368d7eda1c3c79..45c0cf4c7c389a6029fadf3018d75465cccc01b2 100644 --- a/app/models/university/person/administrator.rb +++ b/app/models/university/person/administrator.rb @@ -3,6 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key +# biography_new :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/author.rb b/app/models/university/person/author.rb index eee35eb4270c38c23a153466120b59931f94b2ac..1bb44c1eb9111e6857654761c402c169e7b2db21 100644 --- a/app/models/university/person/author.rb +++ b/app/models/university/person/author.rb @@ -3,6 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key +# biography_new :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index 165f8868de5ca732c2aaba98710ed05c2a8d40f0..207a0919a838b9554625946d10b22f74952b33e1 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -3,6 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key +# biography_new :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/teacher.rb b/app/models/university/person/teacher.rb index 59c75c7b3ee28e7ba59219af8296e984e58c0047..18518ba9231e6231cbe06d3b9aa4b3b96f6cce7d 100644 --- a/app/models/university/person/teacher.rb +++ b/app/models/university/person/teacher.rb @@ -3,6 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key +# biography_new :text # description :text # email :string # first_name :string diff --git a/app/views/admin/communication/website/blocks/_list.html.erb b/app/views/admin/communication/website/blocks/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..cc32c21ab40cd81782af93deba11be1efdb00dd8 --- /dev/null +++ b/app/views/admin/communication/website/blocks/_list.html.erb @@ -0,0 +1,28 @@ +<div class="card flex-fill w-100"> + <div class="card-header"> + <div class="float-end"> + <%= link_to t('add'), + new_admin_communication_website_block_path(about_id: about.id, about_type: about.class.name), + class: button_classes %> + </div> + <h2 class="card-title mb-0 h5"> + <%= Communication::Website::Block.model_name.human(count: 2) %> + </h2> + </div> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Communication::Website::Block.human_attribute_name('name') %></th> + <th><%= Communication::Website::Block.human_attribute_name('template') %></th> + </tr> + </thead> + <tbody> + <% about.blocks.each do |block| %> + <tr> + <td><%= link_to block, edit_admin_communication_website_block_path(block) %></td> + <td><%= block.template_i18n %></td> + </tr> + <% end %> + </tbody> + </table> +</div> diff --git a/app/views/admin/communication/website/blocks/_static.html.erb b/app/views/admin/communication/website/blocks/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/website/blocks/edit.html.erb b/app/views/admin/communication/website/blocks/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..7502b581b79a56009d16a1c8c221b9beb2df9cc8 --- /dev/null +++ b/app/views/admin/communication/website/blocks/edit.html.erb @@ -0,0 +1,8 @@ +<% content_for :title, @block %> + +<%= simple_form_for [:admin, @block] do |f| %> + <%= render "admin/communication/website/blocks/templates/#{@block.template}/edit", f: f %> + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/website/blocks/new.html.erb b/app/views/admin/communication/website/blocks/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..82d23c0ee9c077a843848653065766ddc3e65152 --- /dev/null +++ b/app/views/admin/communication/website/blocks/new.html.erb @@ -0,0 +1,20 @@ +<% content_for :title, t('communication.website.block.choose_template') %> + +<div class="row"> + <% Communication::Website::Block.templates.keys.each do |template| %> + <% @block.template = template %> + <div class="col-lg-3 col-md-4"> + <div class="card"> + <div class="card-body"> + <h5 class="card-title"><%= t "enums.communication.website.block.template.#{template}" %></h5> + <%= simple_form_for [:admin, @block] do |f| %> + <%= f.input :about_type, as: :hidden %> + <%= f.input :about_id, as: :hidden %> + <%= f.input :template, as: :hidden %> + <%= f.submit t('communication.website.block.choose'), class: button_classes %> + <% end %> + </div> + </div> + </div> + <% end %> +</div> diff --git a/app/views/admin/communication/website/blocks/templates/organization_chart/_edit.html.erb b/app/views/admin/communication/website/blocks/templates/organization_chart/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..f805d4a4e69b8e04508372115e218b5d2d98d1e1 --- /dev/null +++ b/app/views/admin/communication/website/blocks/templates/organization_chart/_edit.html.erb @@ -0,0 +1 @@ +<%= f.input :data %> diff --git a/app/views/admin/communication/website/blocks/templates/organization_chart/_show.html.erb b/app/views/admin/communication/website/blocks/templates/organization_chart/_show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/website/blocks/templates/organization_chart/_static.html.erb b/app/views/admin/communication/website/blocks/templates/organization_chart/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/website/blocks/templates/partners/_edit.html.erb b/app/views/admin/communication/website/blocks/templates/partners/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..f805d4a4e69b8e04508372115e218b5d2d98d1e1 --- /dev/null +++ b/app/views/admin/communication/website/blocks/templates/partners/_edit.html.erb @@ -0,0 +1 @@ +<%= f.input :data %> diff --git a/app/views/admin/communication/website/blocks/templates/partners/_show.html.erb b/app/views/admin/communication/website/blocks/templates/partners/_show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/website/blocks/templates/partners/_static.html.erb b/app/views/admin/communication/website/blocks/templates/partners/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/website/pages/show.html.erb b/app/views/admin/communication/website/pages/show.html.erb index 898684ec08ae6278bc47ed3ddf9f1286d7f4d665..d92e5afa41747b66d313340b0dd18552a933d770 100644 --- a/app/views/admin/communication/website/pages/show.html.erb +++ b/app/views/admin/communication/website/pages/show.html.erb @@ -16,6 +16,7 @@ <%= @page.text %> </div> </div> + <%= render 'admin/communication/website/blocks/list', about: @page %> </div> <div class="col-md-4"> <div class="card flex-fill w-100"> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index afa0575fb77b327c31e45825cf2b67937648015c..f7cc60ce5ecbb1db71d531df167323d194ea92e4 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -7,6 +7,9 @@ en: communication/website: one: Website other: Websites + communication/website/block: + one: Content block + other: Content blocks communication/website/category: one: Category other: Categories @@ -43,6 +46,9 @@ en: about_type: About name: Name url: URL + communication/website/block: + name: Name + template: Kind of block communication/website/category: children: Children categories description: Description @@ -130,6 +136,9 @@ en: manage_authors: Manage authors number_of_posts: Nunber of posts website: + block: + choose_template: Choose the kind of block to add + choose: Choose git: Git imported: from: Imported from @@ -150,6 +159,10 @@ en: enums: communication: website: + block: + template: + organization_chart: Organization chart + partners: Partners menu: item: kind: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index c59adc6e002d75a01a485bf8f9c7a73b1579ff10..957fdc4fa9c2aeb67b819042d36f5a5deed33d46 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -7,6 +7,9 @@ fr: communication/website: one: Site Web other: Sites Web + communication/website/block: + one: Bloc de contenu + other: Blocs de contenu communication/website/category: one: Catégorie other: Catégories @@ -43,6 +46,9 @@ fr: about_type: Sujet du site name: Nom url: URL + communication/website/block: + name: Nom + template: Type de bloc communication/website/category: children: Catégories enfants description: Description @@ -130,6 +136,9 @@ fr: manage_authors: Gérer les auteur·rice·s number_of_posts: Nombre d'actualités website: + block: + choose_template: Choisir le type de bloc à ajouter + choose: Choisir git: Git imported: from: Importé depuis @@ -150,6 +159,10 @@ fr: enums: communication: website: + block: + template: + organization_chart: Organigramme + partners: Partenaires menu: item: kind: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 705d9fb2837234f6e43b74e2a6e065d920712c27..6acaccc89e44109ed7f3cc189a13fb33baf9db1e 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -25,6 +25,7 @@ namespace :communication do resources :authors, controller: 'website/authors', only: [:index, :show] resources :posts, controller: 'website/posts' resources :curations, path: 'posts/curations', as: :post_curations, controller: 'website/posts/curations', only: [:new, :create] + resources :blocks, controller: 'website/blocks', except: [:index, :show] resources :menus, controller: 'website/menus' do resources :items, controller: 'website/menu/items', except: :index do collection do diff --git a/db/migrate/20220215094808_create_communication_website_blocks.rb b/db/migrate/20220215094808_create_communication_website_blocks.rb new file mode 100644 index 0000000000000000000000000000000000000000..dddd548af2c38a68d6d2fb09a4b7fe812442b2ec --- /dev/null +++ b/db/migrate/20220215094808_create_communication_website_blocks.rb @@ -0,0 +1,14 @@ +class CreateCommunicationWebsiteBlocks < ActiveRecord::Migration[6.1] + def change + create_table :communication_website_blocks, id: :uuid do |t| + t.references :university, null: false, foreign_key: true, type: :uuid + t.references :communication_website, null: false, foreign_key: true, type: :uuid + t.references :about, polymorphic: true, type: :uuid + t.integer :template, default: 0, null: false + t.jsonb :data + t.integer :position, default: 0, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f18cf9d8e339870c4fa2278fd359150f27a4ac29..11b72faae612a55bbf551356fe5ab41f0a683f07 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_02_10_105040) do +ActiveRecord::Schema.define(version: 2022_02_15_094808) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -79,6 +79,21 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id" end + create_table "communication_website_blocks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "university_id", null: false + t.uuid "communication_website_id", null: false + t.string "about_type" + t.uuid "about_id" + t.integer "template", default: 0, null: false + t.jsonb "data" + t.integer "position", default: 0, null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["about_type", "about_id"], name: "index_communication_website_blocks_on_about" + t.index ["communication_website_id"], name: "index_communication_website_blocks_on_communication_website_id" + t.index ["university_id"], name: "index_communication_website_blocks_on_university_id" + end + create_table "communication_website_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false @@ -126,6 +141,7 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.text "github_path" t.string "featured_image_alt" t.text "description" + t.text "text_new" t.index ["communication_website_id"], name: "idx_comm_website_homes_on_communication_website_id" t.index ["university_id"], name: "index_communication_website_homes_on_university_id" end @@ -288,6 +304,7 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.text "github_path" t.uuid "related_category_id" t.string "featured_image_alt" + t.text "text_new" t.index ["about_type", "about_id"], name: "index_communication_website_pages_on_about" t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id" t.index ["parent_id"], name: "index_communication_website_pages_on_parent_id" @@ -407,6 +424,19 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.text "description" t.boolean "published", default: false t.string "featured_image_alt" + t.text "accessibility_new" + t.text "contacts_new" + t.text "duration_new" + t.text "evaluation_new" + t.text "objectives_new" + t.text "opportunities_new" + t.text "other_new" + t.text "pedagogy_new" + t.text "prerequisites_new" + t.text "pricing_new" + t.text "registration_new" + t.text "content_new" + t.text "results_new" t.index ["parent_id"], name: "index_education_programs_on_parent_id" t.index ["university_id"], name: "index_education_programs_on_university_id" end @@ -448,7 +478,6 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do create_table "research_journal_articles", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "title" - t.text "old_text" t.datetime "published_at" t.uuid "university_id", null: false t.uuid "research_journal_id", null: false @@ -462,6 +491,7 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.string "slug" t.boolean "published", default: false t.integer "position" + t.text "text_new" t.index ["research_journal_id"], name: "index_research_journal_articles_on_research_journal_id" t.index ["research_journal_volume_id"], name: "index_research_journal_articles_on_research_journal_volume_id" t.index ["university_id"], name: "index_research_journal_articles_on_university_id" @@ -525,6 +555,7 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "short_name" + t.text "text_new" t.index ["research_laboratory_id"], name: "index_research_laboratory_axes_on_research_laboratory_id" t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id" end @@ -578,6 +609,7 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do t.text "description" t.boolean "habilitation", default: false t.boolean "tenure", default: false + t.text "biography_new" t.index ["university_id"], name: "index_university_people_on_university_id" t.index ["user_id"], name: "index_university_people_on_user_id" end @@ -655,6 +687,8 @@ ActiveRecord::Schema.define(version: 2022_02_10_105040) do add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "administration_qualiopi_indicators", "administration_qualiopi_criterions", column: "criterion_id" + add_foreign_key "communication_website_blocks", "communication_websites" + add_foreign_key "communication_website_blocks", "universities" add_foreign_key "communication_website_categories", "communication_website_categories", column: "parent_id" add_foreign_key "communication_website_categories", "communication_websites" add_foreign_key "communication_website_categories", "education_programs", column: "program_id" diff --git a/docs/communication/websites/blocks.md b/docs/communication/websites/blocks.md index 626779b0f10a911f5380efa61861c5c2b78d245d..b71d384d8c4cec3af82c0b7b64a88a2c77f592c1 100644 --- a/docs/communication/websites/blocks.md +++ b/docs/communication/websites/blocks.md @@ -15,6 +15,7 @@ communication/website/Block - website:references - about:references (polymorphic) - template:integer (enum) +- position:integer - data:jsonb ``` diff --git a/test/controllers/communication/website/blocks_controller_test.rb b/test/controllers/communication/website/blocks_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..09dc448c4b510f6a15c936b1d06590fe8fcf7b0f --- /dev/null +++ b/test/controllers/communication/website/blocks_controller_test.rb @@ -0,0 +1,48 @@ +require "test_helper" + +class Communication::Website::BlocksControllerTest < ActionDispatch::IntegrationTest + setup do + @communication_website_block = communication_website_blocks(:one) + end + + test "should get index" do + get communication_website_blocks_url + assert_response :success + end + + test "should get new" do + get new_communication_website_block_url + assert_response :success + end + + test "should create communication_website_block" do + assert_difference('Communication::Website::Block.count') do + post communication_website_blocks_url, params: { communication_website_block: { about_id: @communication_website_block.about_id, communication_website_id: @communication_website_block.communication_website_id, data: @communication_website_block.data, position: @communication_website_block.position, template: @communication_website_block.template, university_id: @communication_website_block.university_id } } + end + + assert_redirected_to communication_website_block_url(Communication::Website::Block.last) + end + + test "should show communication_website_block" do + get communication_website_block_url(@communication_website_block) + assert_response :success + end + + test "should get edit" do + get edit_communication_website_block_url(@communication_website_block) + assert_response :success + end + + test "should update communication_website_block" do + patch communication_website_block_url(@communication_website_block), params: { communication_website_block: { about_id: @communication_website_block.about_id, communication_website_id: @communication_website_block.communication_website_id, data: @communication_website_block.data, position: @communication_website_block.position, template: @communication_website_block.template, university_id: @communication_website_block.university_id } } + assert_redirected_to communication_website_block_url(@communication_website_block) + end + + test "should destroy communication_website_block" do + assert_difference('Communication::Website::Block.count', -1) do + delete communication_website_block_url(@communication_website_block) + end + + assert_redirected_to communication_website_blocks_url + end +end diff --git a/test/fixtures/communication/website/blocks.yml b/test/fixtures/communication/website/blocks.yml new file mode 100644 index 0000000000000000000000000000000000000000..6ca674282ed9092d1f238906d7041ddb5587b1b9 --- /dev/null +++ b/test/fixtures/communication/website/blocks.yml @@ -0,0 +1,43 @@ +# == Schema Information +# +# Table name: communication_website_blocks +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# data :jsonb +# position :integer default(0), not null +# template :integer default(0), not null +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# communication_website_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_blocks_on_about (about_type,about_id) +# index_communication_website_blocks_on_communication_website_id (communication_website_id) +# index_communication_website_blocks_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_18291ef65f (university_id => universities.id) +# fk_rails_75bd7c8d6c (communication_website_id => communication_websites.id) +# +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + university: one + communication_website: one + about: one + template: 1 + data: + position: 1 + +two: + university: two + communication_website: two + about: two + template: 1 + data: + position: 1 diff --git a/test/fixtures/research/laboratory/axes.yml b/test/fixtures/research/laboratory/axes.yml index 51a668b6624c3851ba74e0016f84ffd54a5f5247..1ff6715cc3683b92cfac45e891a5d28d35047dec 100644 --- a/test/fixtures/research/laboratory/axes.yml +++ b/test/fixtures/research/laboratory/axes.yml @@ -7,6 +7,7 @@ # name :string # position :integer # short_name :string +# text_new :text # created_at :datetime not null # updated_at :datetime not null # research_laboratory_id :uuid not null, indexed diff --git a/test/models/communication/website/block_test.rb b/test/models/communication/website/block_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..78ac46988392b53ff14c101391a8f17465aa6d6b --- /dev/null +++ b/test/models/communication/website/block_test.rb @@ -0,0 +1,33 @@ +# == Schema Information +# +# Table name: communication_website_blocks +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# data :jsonb +# position :integer default(0), not null +# template :integer default(0), not null +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# communication_website_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_blocks_on_about (about_type,about_id) +# index_communication_website_blocks_on_communication_website_id (communication_website_id) +# index_communication_website_blocks_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_18291ef65f (university_id => universities.id) +# fk_rails_75bd7c8d6c (communication_website_id => communication_websites.id) +# +require "test_helper" + +class Communication::Website::BlockTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/research/laboratory/axis_test.rb b/test/models/research/laboratory/axis_test.rb index 909fb0dd87343a26630336b64b75ee32b03c67cf..0ed57cec560d0ee30ea592ce89f14472526cc58b 100644 --- a/test/models/research/laboratory/axis_test.rb +++ b/test/models/research/laboratory/axis_test.rb @@ -7,6 +7,7 @@ # name :string # position :integer # short_name :string +# text_new :text # created_at :datetime not null # updated_at :datetime not null # research_laboratory_id :uuid not null, indexed diff --git a/test/system/communication/website/blocks_test.rb b/test/system/communication/website/blocks_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..c00bb64c8fe617f8629ca0441da0d884b8a5213b --- /dev/null +++ b/test/system/communication/website/blocks_test.rb @@ -0,0 +1,53 @@ +require "application_system_test_case" + +class Communication::Website::BlocksTest < ApplicationSystemTestCase + setup do + @communication_website_block = communication_website_blocks(:one) + end + + test "visiting the index" do + visit communication_website_blocks_url + assert_selector "h1", text: "Communication/Website/Blocks" + end + + test "creating a Block" do + visit communication_website_blocks_url + click_on "New Communication/Website/Block" + + fill_in "About", with: @communication_website_block.about_id + fill_in "Communication website", with: @communication_website_block.communication_website_id + fill_in "Data", with: @communication_website_block.data + fill_in "Position", with: @communication_website_block.position + fill_in "Template", with: @communication_website_block.template + fill_in "University", with: @communication_website_block.university_id + click_on "Create Block" + + assert_text "Block was successfully created" + click_on "Back" + end + + test "updating a Block" do + visit communication_website_blocks_url + click_on "Edit", match: :first + + fill_in "About", with: @communication_website_block.about_id + fill_in "Communication website", with: @communication_website_block.communication_website_id + fill_in "Data", with: @communication_website_block.data + fill_in "Position", with: @communication_website_block.position + fill_in "Template", with: @communication_website_block.template + fill_in "University", with: @communication_website_block.university_id + click_on "Update Block" + + assert_text "Block was successfully updated" + click_on "Back" + end + + test "destroying a Block" do + visit communication_website_blocks_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Block was successfully destroyed" + end +end