diff --git a/Gemfile b/Gemfile index d1539e47f8a66ef86c1af790034da5d5b6ea36d5..b11640c898b73efc000066366ef808d523d80b98 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem 'rails-i18n' gem "roo", "~> 2.9" gem 'sanitize' gem 'sassc-rails' -gem 'scout_apm', '~> 5.1' +# gem 'scout_apm', '~> 5.1' gem 'sib-api-v3-sdk' gem 'simple-navigation' gem 'simple_form' diff --git a/Gemfile.lock b/Gemfile.lock index 61e390fdb9ca71933a7d2d2fe91af790abf2609c..3f61e9ea7bfff1919952e394e1a826bec34e72fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,6 @@ GEM annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) - ast (2.4.2) autoprefixer-rails (10.4.7.0) execjs (~> 2) aws-eventstream (1.2.0) @@ -330,8 +329,6 @@ GEM omniauth (~> 2.0) ruby-saml (~> 1.12) orm_adapter (0.5.0) - parser (3.1.2.0) - ast (~> 2.4.1) pg (1.4.1) popper_js (2.9.3) public_suffix (4.0.7) @@ -409,8 +406,6 @@ GEM sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) - scout_apm (5.2.0) - parser selenium-webdriver (4.3.0) childprocess (>= 0.5, < 5.0) rexml (~> 3.2, >= 3.2.5) @@ -537,7 +532,6 @@ DEPENDENCIES roo (~> 2.9) sanitize sassc-rails - scout_apm (~> 5.1) selenium-webdriver sib-api-v3-sdk simple-navigation @@ -558,4 +552,4 @@ RUBY VERSION ruby 2.7.6p219 BUNDLED WITH - 2.3.12 + 2.3.11 diff --git a/app/assets/stylesheets/admin/preview.sass b/app/assets/stylesheets/admin/preview.sass index 7db0e22bde6f5296ad0d3743e4a1a4acbdabbae7..3a78e66b89330dea7dd8a46262e9b1d4ecaed079 100644 --- a/app/assets/stylesheets/admin/preview.sass +++ b/app/assets/stylesheets/admin/preview.sass @@ -1,11 +1,20 @@ .preview .modal-body - background: black - text-align: center + background: #EEEEEE overflow: hidden + padding: 0 + text-align: center + transition: padding 0.5s ease iframe + background: white + box-shadow: 0 3px 20px rgba(0, 0, 0, 0.1) height: 100% - transition: width 0.5s ease + transition: width 0.5s ease, height 0.5s ease + &--mobile, &--tablet + .modal-body + padding: 2rem + iframe + border-radius: 10px &--mobile iframe width: 415px diff --git a/app/controllers/admin/communication/blocks_controller.rb b/app/controllers/admin/communication/blocks_controller.rb index a7247dd3c566e8f79f2dc267387e99e845477e37..fa543158404e5ed3bc9f83f253dbcaeea7ae82cb 100644 --- a/app/controllers/admin/communication/blocks_controller.rb +++ b/app/controllers/admin/communication/blocks_controller.rb @@ -48,6 +48,11 @@ class Admin::Communication::BlocksController < Admin::Communication::Application end end + def duplicate + redirect_to [:edit, :admin, @block.duplicate], + notice: t('admin.successfully_duplicated_html', model: @block.to_s) + end + def destroy path = about_path @block.destroy @@ -80,6 +85,6 @@ class Admin::Communication::BlocksController < Admin::Communication::Application def block_params params.require(:communication_block) - .permit(:about_id, :about_type, :template_kind, :title, :data) + .permit(:about_id, :about_type, :template_kind, :title, :data, :published) end end diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index c6c290817899f759a8648cd5b61c6146260fafc3..b7c8e6a92b9c313266f33ed7f1a74eb749d8fce1 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -71,6 +71,11 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We end end + def duplicate + redirect_to [:admin, @page.duplicate], + notice: t('admin.successfully_duplicated_html', model: @page.to_s) + end + def destroy if @page.is_special_page? redirect_back(fallback_location: admin_communication_website_page_path(@page), alert: t('admin.communication.website.pages.delete_special_page_notice')) diff --git a/app/controllers/concerns/active_storage/check_abilities.rb b/app/controllers/concerns/active_storage/check_abilities.rb index 508ceb4d46b9ea600e5a60f76f792324512ec515..542b87fa4a8b309859064edb601a93e02c163a39 100644 --- a/app/controllers/concerns/active_storage/check_abilities.rb +++ b/app/controllers/concerns/active_storage/check_abilities.rb @@ -4,11 +4,17 @@ module ActiveStorage::CheckAbilities private def check_abilities - # TEMP: Warning, we disable university check (TO REMOVE) - # render(file: Rails.root.join('public/403.html'), formats: [:html], status: 403, layout: false) and return if current_university.present? && @blob.university_id != current_university.id + render(file: Rails.root.join('public/403.html'), formats: [:html], status: 403, layout: false) and return if current_university.present? && @blob.university_id != current_university.id + end + + def current_extranet + @current_extranet ||= Communication::Extranet.with_host(request.host) end def current_university - @current_university ||= University.with_host(request.host) + @current_university ||= begin + current_extranet.present? ? current_extranet.university + : University.with_host(request.host) + end end end diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index 172a0b59cf999863426330d2436783dfd1cbfc25..9820cf3fb4a12c4ab3c062f9f07e9164678d6193 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -45,6 +45,14 @@ module Admin::ApplicationHelper aria-controls=\"preview\">#{ t 'preview.button'}</button>" end + def duplicate_link(object) + link_to t('admin.duplicate'), + [:duplicate, :admin, object], + method: :post, + data: { confirm: t('please_confirm') }, + class: button_classes('btn-light') + end + def button_classes(additional = '', **options) classes = "btn btn-primary btn-xs #{additional}" classes += ' disabled' if options[:disabled] @@ -69,7 +77,7 @@ module Admin::ApplicationHelper end def prepare_html_for_static(html, university) - text = html.to_s + text = html.to_s.dup text = sanitize text text.gsub! "\r", '' text.gsub! "\n", ' ' @@ -78,19 +86,27 @@ module Admin::ApplicationHelper end def prepare_text_for_static(text, depth = 1) + text = strip_tags text.to_s.dup + text = indent text, depth + CGI.unescapeHTML text + end + + def prepare_code_for_static(code, depth = 1) + text = code.to_s.dup + text = indent text, depth + raw text + end + + def indent(text, depth) indentation = ' ' * depth - text = text.to_s.dup - text = strip_tags text - text = text.strip # Remove useless \r - text = text.gsub "\r\n", "\n" + text.gsub! "\r\n", "\n" # Replace lonely \r - text = text.gsub "\r", "\n" + text.gsub! "\r", "\n" # Indent properly to avoid broken frontmatter, with 2 lines so the linebreak work - text = text.gsub "\n", "\n#{indentation}\n#{indentation}" - # Remove extra newlines - text = text.chomp - CGI.unescapeHTML text + text.gsub! "\n", "\n#{indentation}\n#{indentation}" + text.chomp! + text end def prepare_media_for_static(object, key) diff --git a/app/models/administration/qualiopi/indicator.rb b/app/models/administration/qualiopi/indicator.rb index 6e06a027333a734dbc6b5b039d18b1b21626969a..300286f22c2b5b35c92568f4cde1b0c4b2bd6691 100644 --- a/app/models/administration/qualiopi/indicator.rb +++ b/app/models/administration/qualiopi/indicator.rb @@ -20,7 +20,7 @@ # # Foreign Keys # -# fk_rails_eed87f7acf (criterion_id => administration_qualiopi_criterions.id) +# fk_rails_31f1a0a2c9 (criterion_id => administration_qualiopi_criterions.id) # class Administration::Qualiopi::Indicator < ApplicationRecord include Sanitizable diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 5c07c25e34b97c83456e3d4760d2f57641102443..ed2a58be0fcdc11991209a21ef9281f3a321b895 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -6,6 +6,7 @@ # about_type :string indexed => [about_id] # data :jsonb # position :integer default(0), not null +# published :boolean default(TRUE) # template_kind :integer default(NULL), not null # title :string # created_at :datetime not null @@ -59,6 +60,8 @@ class Communication::Block < ApplicationRecord utilities: [:files, :definitions, :embed] } + scope :published, -> { where(published: true) } + before_save :attach_template_blobs after_commit :save_and_sync_about, on: [:update, :destroy] @@ -90,6 +93,12 @@ class Communication::Block < ApplicationRecord @template = nil end + def duplicate + block = self.dup + block.save + block + end + def to_s title.blank? ? "#{Communication::Block.model_name.human} #{position}" : "#{title}" diff --git a/app/models/communication/block/component/code.rb b/app/models/communication/block/component/code.rb index 6103aa8e60683bb3b983a2c810273c82feb017c9..49f21bde000ad872292c8185cff0d07070ce5dfd 100644 --- a/app/models/communication/block/component/code.rb +++ b/app/models/communication/block/component/code.rb @@ -1,8 +1,3 @@ class Communication::Block::Component::Code < Communication::Block::Component::Base - - def data=(value) - @data = Osuny::Sanitizer.sanitize value, 'text' - end - - end +end \ No newline at end of file diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index ec8ffed12ad4f46f3cac69fb9e2a8e1264d54b47..7f32cf185681e23ed00331f2f3965d38c16e1a1b 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -25,7 +25,7 @@ # # Foreign Keys # -# fk_rails_bb6a496c08 (university_id => universities.id) +# fk_rails_94b0abd85b (university_id => universities.id) # class Communication::Website < ApplicationRecord include WithUniversity diff --git a/app/models/communication/website/configs/base_url.rb b/app/models/communication/website/configs/base_url.rb index 2daeee8a29469d9f54419c721df481893f9f4e46..a28371ae484a8eea0cbfadf4b1c6a6f3d0a3b79e 100644 --- a/app/models/communication/website/configs/base_url.rb +++ b/app/models/communication/website/configs/base_url.rb @@ -25,7 +25,7 @@ # # Foreign Keys # -# fk_rails_bb6a496c08 (university_id => universities.id) +# fk_rails_94b0abd85b (university_id => universities.id) # class Communication::Website::Configs::BaseUrl < Communication::Website diff --git a/app/models/communication/website/configs/permalinks.rb b/app/models/communication/website/configs/permalinks.rb index df46d3c8fecc75aba6cf25a7418402a7e225dbca..7ba504bbb39f709ea6ef47af7825e4a2ad26d59f 100644 --- a/app/models/communication/website/configs/permalinks.rb +++ b/app/models/communication/website/configs/permalinks.rb @@ -25,7 +25,7 @@ # # Foreign Keys # -# fk_rails_bb6a496c08 (university_id => universities.id) +# fk_rails_94b0abd85b (university_id => universities.id) # class Communication::Website::Configs::Permalinks < Communication::Website diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index ad4e22bd9ef15307423e01999ed6457684374a37..85c2006d56dd76368a4f13c530897f78ceea8c49 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -145,6 +145,18 @@ class Communication::Website::Page < ApplicationRecord "/#{language.iso_code}" if website.languages.any? && language_id end + def duplicate + page = self.dup + page.published = false + page.save + blocks.each do |block| + b = block.duplicate + b.about = page + b.save + end + page + end + def to_s "#{title}" end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 6606cc0a800220c485453fdbf0551abdcb757c4c..8a9ebf684731b179be924b511517c6d1e4ee6620 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -45,7 +45,7 @@ # # Foreign Keys # -# fk_rails_08b351087c (university_id => universities.id) +# fk_rails_6e16107511 (university_id => universities.id) # fk_rails_ec1f16f607 (parent_id => education_programs.id) # class Education::Program < ApplicationRecord diff --git a/app/views/admin/application/_preview.html.erb b/app/views/admin/application/_preview.html.erb index 4a90bc7fe3250e74681f6d896dda9bbb9e42f1d8..71a273aacac194868332fa8eec2b78cac7cd7a1d 100644 --- a/app/views/admin/application/_preview.html.erb +++ b/app/views/admin/application/_preview.html.erb @@ -5,11 +5,11 @@ <h5 class="modal-title h4"><%= t 'preview.title' %></h5> <div class="btn-group m-auto" role="group" aria-label="Basic example"> <button type="button" class="btn btn-primary preview__button" data-mode="mobile"> - <i class="fas fa-mobile"></i> + <i class="fas fa-mobile-alt"></i> <%= t 'preview.mobile' %> </button> <button type="button" class="btn btn-light preview__button" data-mode="tablet"> - <i class="fas fa-tablet"></i> + <i class="fas fa-tablet-alt"></i> <%= t 'preview.tablet' %> </button> <button type="button" class="btn btn-light preview__button" data-mode="desktop"> @@ -19,7 +19,7 @@ </div> <button type="button" class="btn-close ms-0" data-bs-dismiss="modal" aria-label="Close"></button> </div> - <div class="modal-body p-2"> + <div class="modal-body"> <iframe src="<%= request.path %>/preview" loading="lazy"></iframe> </div> </div> diff --git a/app/views/admin/communication/blocks/_list.html.erb b/app/views/admin/communication/blocks/_list.html.erb index 8aff89419416a1bd71fc61cfbf2578891a66bd2e..4f407759b07e695e229ca57b0b80b846bf9db95f 100644 --- a/app/views/admin/communication/blocks/_list.html.erb +++ b/app/views/admin/communication/blocks/_list.html.erb @@ -24,7 +24,7 @@ </thead> <tbody data-sortable data-sort-url="<%= reorder_admin_communication_blocks_path %>"> <% about.blocks.ordered.each do |block| %> - <tr data-id="<%= block.id %>"> + <tr data-id="<%= block.id %>" class="<%= 'draft' unless block.published? %>"> <% if can? :reorder, Communication::Block %> <td><i class="fa fa-bars handle"></i></td> <% end %> @@ -32,10 +32,10 @@ <td><%= block.template_kind_i18n %></td> <td><%= render 'admin/application/a11y/status', about: block %></td> <td class="text-end"> - <%= edit_link block %> - <%= link_to 'Dependencies', - [:admin, block], - class: button_classes('btn-light') if current_user.server_admin? %> + <div class="btn-group"> + <%= duplicate_link block %> + <%= edit_link block %> + </div> </td> </tr> <% end %> diff --git a/app/views/admin/communication/blocks/_preview.html.erb b/app/views/admin/communication/blocks/_preview.html.erb index d58b3fae33005bda346eafe47995ffa252eb1d6f..a716dae7f1ddb8dc5cbb6d75f9da972595d7c4a6 100644 --- a/app/views/admin/communication/blocks/_preview.html.erb +++ b/app/views/admin/communication/blocks/_preview.html.erb @@ -1,4 +1,4 @@ -<% about.blocks.ordered.each do |block| %> +<% about.blocks.published.ordered.each do |block| %> <section class="block-<%= block.template_kind %>"> <div class="container"> <div class="block-content"> diff --git a/app/views/admin/communication/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb index f48693db8af3b0f27d902061e6799268d68a02e2..73a53873c086579463f866a439cd3bfb47a5e67e 100644 --- a/app/views/admin/communication/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -1,6 +1,6 @@ <% if about.blocks.any? %> blocks: -<% about.blocks.ordered.each do |block| +<% about.blocks.published.ordered.each do |block| @block = block @university = about.university %> diff --git a/app/views/admin/communication/blocks/components/code/_static.html.erb b/app/views/admin/communication/blocks/components/code/_static.html.erb index c4afc99498f820a9243b26e6091c3d1f8087324d..2d3119af23bb623dfef67ab3608471c87e76108c 100644 --- a/app/views/admin/communication/blocks/components/code/_static.html.erb +++ b/app/views/admin/communication/blocks/components/code/_static.html.erb @@ -1,7 +1,7 @@ <% if list %> <%= indentation %>- <%= property %>: >- -<%= indentation %> <%= prepare_html_for_static value, @university, depth + 2 %> +<%= indentation %> <%= prepare_code_for_static value, depth + 2 %> <% else %> <%= indentation %><%= property %>: >- -<%= indentation %> <%= prepare_html_for_static value, @university %> +<%= indentation %> <%= prepare_code_for_static value, depth + 1 %> <% end %> diff --git a/app/views/admin/communication/blocks/edit.html.erb b/app/views/admin/communication/blocks/edit.html.erb index a19e7e624604c9952c316a4a902fbba1db24c3e6..940c473ec23af60f7dbb6806b0974377a349e4b5 100644 --- a/app/views/admin/communication/blocks/edit.html.erb +++ b/app/views/admin/communication/blocks/edit.html.erb @@ -13,6 +13,10 @@ <div class="col-xxl-3 col-lg-6"> <%= f.input :title %> </div> + <div class="col-xxl-3 col-lg-6"> + <label class="form-label d-none d-lg-block"> </label> + <%= f.input :published %> + </div> </div> <%= render "admin/communication/blocks/templates/#{@block.template_kind}/edit", f: f %> </div> diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb index fff0006a12e0a0898d9738fd2d24463282a67e99..a624c9d2509b677cd450a420791bac037ba3b20e 100644 --- a/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb @@ -20,30 +20,26 @@ </div> <h3 class="h4"><%= t '.buttons' %></h3> -<div v-for="(element, index) in data.elements" class="list-group"> - <div class="list-group-item"> - <div class="flex-fill"> - <div class="row mb-n2"> - <div class="col-lg-3"> - <%= block_component_edit :title, template: @element %> - </div> - <div class="col-lg-4"> - <%= block_component_edit :url, template: @element %> - </div> - <div class="col-lg-4"> - <label class="form-label d-none d-xl-block"> </label> - <%= block_component_edit :target_blank, template: @element %> - </div> - <div class="col-lg-1"> - <a class="btn btn-sm btn-danger float-end" - v-on:click="data.elements.splice(data.elements.indexOf(element), 1)"> - <i class="fas fa-times"></i> - </a> - </div> +<div class="list-group"> + <div v-for="(element, index) in data.elements" class="list-group-item"> + <div class="row mb-n3"> + <div class="col-lg-3"> + <%= block_component_edit :title, template: @element %> + </div> + <div class="col-lg-4"> + <%= block_component_edit :url, template: @element %> + </div> + <div class="col-lg-4"> + <label class="form-label d-none d-xl-block"> </label> + <%= block_component_edit :target_blank, template: @element %> + </div> + <div class="col-lg-1"> + <a class="btn btn-sm btn-danger float-end" + v-on:click="data.elements.splice(data.elements.indexOf(element), 1)"> + <i class="fas fa-times"></i> + </a> </div> - </div> - </div> </div> <div v-if="data.elements.length < 3" class="mt-3"> diff --git a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb index 5a93367a43028539c0c3d16ba9f5d080820c674b..a80ac1993be6f063243f1b2ad0beead1ad2ad1ab 100644 --- a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb @@ -1,3 +1,8 @@ +<div class="row"> + <div class="col-md-6"> + <p class="text-danger lead"><%= t '.warning' %></p> + </div> +</div> <div class="row"> <div class="col-md-6"> <%= block_component_edit :code %> diff --git a/app/views/admin/communication/blocks/templates/partners/_edit.html.erb b/app/views/admin/communication/blocks/templates/partners/_edit.html.erb index d079fb2f41b93c4be9a80fb87a02bac7e8c34a8f..4741592e62edaece279adecaaa6057f63ee75c4a 100644 --- a/app/views/admin/communication/blocks/templates/partners/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/partners/_edit.html.erb @@ -13,12 +13,12 @@ </a> </div> <div class="flex-fill"> - <div class="row mb-n3"> + <div class="row"> <div class="col-lg-4"> <%= block_component_edit :id, template: @element, label: '' %> </div> </div> - <div class="row mb-n3" v-if="!element.id"> + <div class="row" v-if="!element.id"> <div class="col-lg-4"> <%= block_component_edit :name, template: @element %> </div> diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb index c9b6d1d07be8bf13de08dc88b074b9aa0d2f70f7..2c170bb7653e10cc31c9d3345220424ffc906ff3 100644 --- a/app/views/admin/communication/websites/_sidebar.html.erb +++ b/app/views/admin/communication/websites/_sidebar.html.erb @@ -10,18 +10,18 @@ icon: Icon::COMMUNICATION_WEBSITE_HOME, ability: can?(:read, @website) }, - { - title: t('admin.communication.website.pages.structure'), - path: admin_communication_website_pages_path(website_id: @website), - icon: Icon::COMMUNICATION_WEBSITE_PAGES, - ability: can?(:read, Communication::Website::Page) - }, { title: Communication::Website::Post.model_name.human(count: 2), path: admin_communication_website_posts_path(website_id: @website), icon: Icon::COMMUNICATION_WEBSITE_POST, ability: can?(:read, Communication::Website::Post) }, + { + title: t('admin.communication.website.pages.structure'), + path: admin_communication_website_pages_path(website_id: @website), + icon: Icon::COMMUNICATION_WEBSITE_PAGES, + ability: can?(:read, Communication::Website::Page) + }, { title: Communication::Website::Menu.model_name.human(count: 2), path: admin_communication_website_menus_path(website_id: @website), diff --git a/app/views/admin/communication/websites/categories/_form.html.erb b/app/views/admin/communication/websites/categories/_form.html.erb index 4f541fc6b91383181ef9e27d1ec186c426afe5e5..ca666d4069c86caa7ba19209dfef336b8cb73d4b 100644 --- a/app/views/admin/communication/websites/categories/_form.html.erb +++ b/app/views/admin/communication/websites/categories/_form.html.erb @@ -10,7 +10,7 @@ </div> <div class="card-body"> <%= f.input :name %> - <%= f.input :text, as: :summernote %> + <%= f.input :text %> </div> </div> <div class="card"> diff --git a/app/views/admin/communication/websites/categories/static.html.erb b/app/views/admin/communication/websites/categories/static.html.erb index 6d3b3a71493bd56077b705613117b413c24102f0..99e07cb40c59b68339343a7c23a1b1901a2cb08e 100644 --- a/app/views/admin/communication/websites/categories/static.html.erb +++ b/app/views/admin/communication/websites/categories/static.html.erb @@ -8,5 +8,6 @@ position: <%= @about.position %> <%= render 'admin/communication/unsplash/static' %> description: > <%= prepare_text_for_static @about.description %> +description_short: > + <%= prepare_text_for_static @about.text %> --- -<%= prepare_html_for_static @about.text, @about.university %> diff --git a/app/views/admin/communication/websites/pages/_treebranch.html.erb b/app/views/admin/communication/websites/pages/_treebranch.html.erb index 370aac563f0fdb3dffa7a8562a91506164fed5eb..47459b77cb0ef3f89570c4337ac36c47a8e379b9 100644 --- a/app/views/admin/communication/websites/pages/_treebranch.html.erb +++ b/app/views/admin/communication/websites/pages/_treebranch.html.erb @@ -28,6 +28,7 @@ <span class="me-3 show-on-hover"><%= t("communication.website.pages.defaults.#{page.kind}.admin_description") %></span> <% end %> <div class="btn-group"> + <%= duplicate_link page if page.is_regular_page?%> <%= edit_link page %> <%= destroy_link page, confirm_message: page.children.any? ? t('please_confirm_with_children') : t('please_confirm') if page.is_regular_page? %> </div> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index d1a68f946cbd72e5b546544b3566553940e47928..2a6344f84c752e1f1bb5425685d2a9dcca72aada 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,5 +1,5 @@ <div class="row"> - <div class="col-md-6"> + <div class="col-md-6 mb-5"> <h2 class="mb-4"><%= t('login.not_registered_yet') %></h2> <p><%= t('login.not_registered_yet_details') %></p> <div class="form-actions"> diff --git a/app/views/extranet/application/_footer.html.erb b/app/views/extranet/application/_footer.html.erb index e198e5f38cd97307193c36cddb173d59266dec12..0ea2da91e584d5cee8ea31a267f16ca24323f3ba 100644 --- a/app/views/extranet/application/_footer.html.erb +++ b/app/views/extranet/application/_footer.html.erb @@ -4,14 +4,20 @@ <%= render 'logo' %> </div> <div class="row justify-space-between"> - <address class="col-md-6" itemscope itemtype="https://schema.org/CollegeOrUniversity"> - <span itemprop="name">Institut de Journalisme Bordeaux Aquitaine</span> - <div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress"> - <span itemprop="streetAddress">1 rue Jacques Ellul</span><br> - <span itemprop="postalCode">33000</span> - <span itemprop="addressLocality">Bordeaux</span><br> + <% if current_extranet.about.is_a?(Education::School) %> + <address class="col-md-6" itemscope itemtype="https://schema.org/CollegeOrUniversity"> + <span itemprop="name"><%= current_extranet.about.name %></span> + <div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress"> + <span itemprop="streetAddress"><%= current_extranet.about.address %></span><br> + <span itemprop="postalCode"><%= current_extranet.about.zipcode %></span> + <span itemprop="addressLocality"><%= current_extranet.about.city %></span><br> + </div> + </address> + <% elsif current_extranet.about.is_a?(Education::Program) %> + <div class="col-md-6" itemscope itemtype="https://schema.org/EducationalOccupationalCredential"> + <span itemprop="name"><%= current_extranet.about.name %></span> </div> - </address> + <% end %> <nav class="text-md-end col-md-6"> <%= link_to t('terms_of_service'), diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 13bef18e41ec344cfe97346ea2dc73c161f85f6d..b5e6644ce1d933ef78bfd483703c0b97b35371fe 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -39,6 +39,7 @@ en: communication/block: name: Name template: Kind of block + published: Published? communication/extranet: about: About about_: Independent extranet @@ -67,7 +68,7 @@ en: communication/website/category: children: Children categories description: Meta Description - text: Text + text: Lead text featured_image: Featured image featured_image_alt: Alt text name: Name @@ -217,6 +218,7 @@ en: iframe_title: label: Iframe title (mandatory for accessibility) placeholder: Enter the title + warning: Beware, the code below is used as is, without any security filtering. Be extremely careful and never integrate possibly unreliable code. files: description: A list of downloadable files, mentioning their file size. edit: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 8926caa388db665b430a8e511212f3de46557b83..3360033356516d95a8acc9fff0f7976c3dbbdd97 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -39,6 +39,7 @@ fr: communication/block: title: Titre template: Type de bloc + published: Publié ? communication/extranet: about: Sujet de l'extranet about_: Extranet indépendant @@ -67,7 +68,7 @@ fr: communication/website/category: children: Catégories enfants description: Meta Description - text: Texte + text: Chapô featured_image: Image à la une featured_image_alt: Texte alternatif name: Nom @@ -217,6 +218,7 @@ fr: iframe_title: label: Titre de l'iframe (nécessaire pour l'accessibilité) placeholder: Entrer le titre + warning: Attention, le code ci-dessous est intégré tel quel, sans filtrage de sécurité. N'intégrez jamais de code externe dont la fiabilité n'est pas certaine. files: description: Une liste de fichiers téléchargeables, présentés avec leur poids. edit: diff --git a/config/locales/en.yml b/config/locales/en.yml index 2dfa65eba16ffe3f69f456f3bb06bacc54ea90d2..2b4fb3ba345533f677dfc5549764b2c3a4226f58 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -89,6 +89,7 @@ en: admin: attachment_not_available: Attachment not available dashboard: Dashboard + duplicate: Duplicate infos: Informations inheritance: sentence_without_link: Value inherited @@ -100,6 +101,7 @@ en: password_hint: Leave blank if you do not wish to change the password. successfully_created_html: "<i>%{model}</i> was successfully created." successfully_destroyed_html: "<i>%{model}</i> was successfully destroyed." + successfully_duplicated_html: "<i>%{model}</i> was successfully duplicated." successfully_quit_html: "<i>%{model}</i> successfully quit <i>%{target}</i>." successfully_removed_html: "<i>%{model}</i> was successfully removed." successfully_updated_html: "<i>%{model}</i> was successfully updated." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ce688b4a69edb208b77122309708edb1907b2f2a..d0cbab72ac02f1cf96a6a8f6bdc222663c45542e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -89,6 +89,7 @@ fr: admin: attachment_not_available: Impossible d'accéder à l'élément dashboard: Tableau de bord + duplicate: Dupliquer infos: Informations inheritance: sentence_without_link: Valeur héritée @@ -100,6 +101,7 @@ fr: password_hint: Laissez vide si vous ne souhaitez pas modifier le mot de passe. successfully_created_html: "<i>%{model}</i> a bien été créé(e)." successfully_destroyed_html: "<i>%{model}</i> a bien été détruit(e)." + successfully_duplicated_html: "<i>%{model}</i> a bien été dupliqué(e)." successfully_quit_html: "<i>%{model}</i> a bien quitté <i>%{target}</i>." successfully_removed_html: "<i>%{model}</i> a bien été retiré(e)." successfully_updated_html: "<i>%{model}</i> a bien été mis(e) à jour." @@ -129,6 +131,9 @@ fr: text_html: "Votre code d'authentification pour %{university} est :<br><br><b>%{code}</b><br><br>Il expirera dans 5 minutes." omniauth_callbacks: failure: "Échec de l'authentification." + passwords: + new: + send_me_reset_password_instructions: Réinitialiser mon mot de passe sessions: signed_in: '' shared: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index e8e5152c5402e022459a4c9650fe37e4dd2b9bd3..c8f3af92d272bf049aa7c52cf9552f8fa054dd93 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -15,6 +15,7 @@ namespace :communication do get :children get :static get :preview + post :duplicate end end resources :categories, controller: 'websites/categories' do @@ -55,6 +56,9 @@ namespace :communication do collection do post :reorder end + member do + post :duplicate + end end resources :extranets, controller: 'extranets' resources :alumni do diff --git a/db/migrate/20220704164321_add_published_to_communication_blocks.rb b/db/migrate/20220704164321_add_published_to_communication_blocks.rb new file mode 100644 index 0000000000000000000000000000000000000000..ad458b5e3aea11bf08b2080aea0b3ba8a5d56d5a --- /dev/null +++ b/db/migrate/20220704164321_add_published_to_communication_blocks.rb @@ -0,0 +1,5 @@ +class AddPublishedToCommunicationBlocks < ActiveRecord::Migration[6.1] + def change + add_column :communication_blocks, :published, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index a2425b0647abfc1ec7271ad351396b9deb9dfb5d..3a8420e9472bf89d4c66b57b80fd563e0be2fd80 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_07_01_064111) do +ActiveRecord::Schema.define(version: 2022_07_04_164321) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -89,6 +89,7 @@ ActiveRecord::Schema.define(version: 2022_07_01_064111) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "title" + t.boolean "published", default: true t.index ["about_type", "about_id"], name: "index_communication_website_blocks_on_about" t.index ["university_id"], name: "index_communication_blocks_on_university_id" end @@ -507,23 +508,6 @@ ActiveRecord::Schema.define(version: 2022_07_01_064111) do t.index ["university_id"], name: "index_education_schools_on_university_id" end - create_table "external_organizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "title" - t.text "description" - t.string "address" - t.string "zipcode" - t.string "city" - t.string "country" - t.string "website" - t.string "phone" - t.string "mail" - t.boolean "active" - t.string "sirene" - t.integer "kind" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - end - create_table "imports", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.integer "number_of_lines" t.jsonb "processing_errors" @@ -718,8 +702,8 @@ ActiveRecord::Schema.define(version: 2022_07_01_064111) do t.string "linkedin" t.boolean "is_alumnus", default: false t.text "description_short" - t.string "name" t.boolean "is_author" + t.string "name" t.integer "gender" t.date "birthdate" t.string "phone_professional" diff --git a/test/fixtures/communication/websites.yml b/test/fixtures/communication/websites.yml index 78817fa75f2494d30e61980d680f224d40cc6ccb..6b436633f64b74d0481604586bfe3dd4e1ae18c3 100644 --- a/test/fixtures/communication/websites.yml +++ b/test/fixtures/communication/websites.yml @@ -25,7 +25,7 @@ # # Foreign Keys # -# fk_rails_bb6a496c08 (university_id => universities.id) +# fk_rails_94b0abd85b (university_id => universities.id) # website_with_github: university: default_university