diff --git a/app/assets/images/communication/blocks/templates/sound.jpg b/app/assets/images/communication/blocks/templates/sound.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f42a626b49a634551c61735aa4e1bf7a04a05273 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/sound.jpg differ diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 858d40aa191bc92083e00ef4a24cdb07690953b7..d9e386f5a6a09973276b7c040537bcb504988695 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -64,6 +64,7 @@ class Communication::Block < ApplicationRecord image: 51, gallery: 300, video: 52, + sound: 1005, key_figures: 56, features: 2010, datatable: 54, @@ -82,7 +83,7 @@ class Communication::Block < ApplicationRecord } CATEGORIES = { - basic: [:chapter, :image, :video, :datatable], + basic: [:chapter, :image, :video, :sound, :datatable], storytelling: [:key_figures, :features, :gallery, :call_to_action, :testimonials, :timeline], references: [:pages, :posts, :organization_chart, :partners, :programs], utilities: [:files, :definitions, :embed, :contact] diff --git a/app/models/communication/block/template/program.rb b/app/models/communication/block/template/program.rb index f81d8d185e3ff7d41e0dd8ced61e610faeaf2bb7..e0a66bef0f8edfc9a4ac235e3d37889148677e69 100644 --- a/app/models/communication/block/template/program.rb +++ b/app/models/communication/block/template/program.rb @@ -10,4 +10,11 @@ class Communication::Block::Template::Program < Communication::Block::Template:: @selected_programs ||= elements.map { |element| element.program }.compact end + def allowed_for_about? + !website.nil? + end + + def available_programs + website.education_programs + end end diff --git a/app/models/communication/block/template/sound.rb b/app/models/communication/block/template/sound.rb new file mode 100644 index 0000000000000000000000000000000000000000..459a4d19da820156b27b4659e18a75141a71374d --- /dev/null +++ b/app/models/communication/block/template/sound.rb @@ -0,0 +1,14 @@ +class Communication::Block::Template::Sound < Communication::Block::Template::Base + + has_component :file, :file + has_component :title, :string + has_component :transcription, :text + + protected + + def check_accessibility + super + accessibility_error 'accessibility.blocks.templates.sound.title_missing' if block.title.blank? && title.blank? + accessibility_error 'accessibility.blocks.templates.sound.transcription_missing' if transcription.blank? + end +end diff --git a/app/models/education/diploma.rb b/app/models/education/diploma.rb index 55fd25040b2a5540fe405f1f8aafbf7b6ea2ea3b..1582e6949cc25d3f814c0430f368095161f8c1d7 100644 --- a/app/models/education/diploma.rb +++ b/app/models/education/diploma.rb @@ -53,7 +53,11 @@ class Education::Diploma < ApplicationRecord end def dependencies - blocks + programs + blocks + end + + def references + programs end def to_s diff --git a/app/views/admin/communication/blocks/components/file/_edit.html.erb b/app/views/admin/communication/blocks/components/file/_edit.html.erb index 1161795efd45f16a8dc6f776c79fcb8ddf87c665..592c1f391cb482a5afc58c7cb6ea4276f3a2885e 100644 --- a/app/views/admin/communication/blocks/components/file/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/file/_edit.html.erb @@ -16,7 +16,7 @@ remove = t 'admin.communication.blocks.components.file.input.remove' :id="<%= dom_id.html_safe %>"> </div> <div v-if="<%= model %>.<%= property %>.id"> - <p><b>{{ element.file.filename }}</b></p> + <p><b>{{ <%= model %>.<%= property %>.filename }}</b></p> <a class="btn btn-sm text-danger" v-on:click="<%= model %>.<%= property %>={}"> <i class="<%= Icon::DELETE %>"></i> diff --git a/app/views/admin/communication/blocks/components/image/_edit.html.erb b/app/views/admin/communication/blocks/components/image/_edit.html.erb index 7691d20af29607b2f71806faa14b137f63fea9ef..2f4702ec6b3efc19033885dfa1989272649be42a 100644 --- a/app/views/admin/communication/blocks/components/image/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/image/_edit.html.erb @@ -12,6 +12,7 @@ remove = t 'admin.communication.blocks.components.image.input.remove' type="file" accept="image/*" @change="onFileImageChange( $event, <%= model %>, '<%= property %>' )" + data-size-limit="<%= Communication::Block::IMAGE_MAX_SIZE %>" :id="<%= dom_id.html_safe %>"> </div> <div v-if="<%= model %>.<%= property %>.id"> diff --git a/app/views/admin/communication/blocks/components/program/_edit.html.erb b/app/views/admin/communication/blocks/components/program/_edit.html.erb index efb38295f9a51c4d5954f67722d33dd25c3c4ec9..8f09ceb3a55c1a00acb3f806d93fbec465977399 100644 --- a/app/views/admin/communication/blocks/components/program/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/program/_edit.html.erb @@ -1,5 +1,5 @@ <%# TODO: Traduire les formations %> -<% programs = current_university.programs.ordered %> +<% programs = @block.template.available_programs %> <% if label.present? %> <label class="form-label" :for="<%= dom_id.html_safe %>"> diff --git a/app/views/admin/communication/blocks/components/string/_edit.html.erb b/app/views/admin/communication/blocks/components/string/_edit.html.erb index 9dc947a2be0bce3ef6d64f9853a8924b1de8832b..6285fb65bc3a5122c0159ec7d238e4bb8107ee7c 100644 --- a/app/views/admin/communication/blocks/components/string/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/string/_edit.html.erb @@ -3,7 +3,7 @@ <label class="form-label" aria-label="<%= label %>" :for="<%= dom_id.html_safe %>"> - <%= label%> + <%= label %> </label> <% end %> <input :id="<%= dom_id.html_safe %>" 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 3cc3f271cafd1199382131842173753e794cb432..1935b83fab980bd61232933c8ad92dbb042c0f4c 100644 --- a/app/views/admin/communication/blocks/templates/partners/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/partners/_edit.html.erb @@ -10,6 +10,7 @@ <%= block_component_edit :alphabetical %> </div> </div> +<%= block_component_add_element t('.add_partner') %> <draggable :list="data.elements" class="mb-3 <%= if_appstack 'list-group' %>" handle=".partnerHandle"> <div v-for="(element, index) in data.elements" class="draggable-item <%= if_appstack 'list-group-item' %>"> <div class="d-flex mb-n3"> @@ -42,4 +43,6 @@ </div> </div> </draggable> -<%= block_component_add_element t('.add_partner') %> +<div v-show="data.elements.length > 2"> + <%= block_component_add_element t('.add_partner') %> +</div> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/sound/_edit.html.erb b/app/views/admin/communication/blocks/templates/sound/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..ec65c4326fc1cd5652407fec86470084c9ef06ab --- /dev/null +++ b/app/views/admin/communication/blocks/templates/sound/_edit.html.erb @@ -0,0 +1,11 @@ +<div class="row pure__row--small"> + <div class="col-md-6"> + <%= block_component_edit :file %> + <%= block_component_edit :title %> + </div> + <div class="col-md-6"> + <%= block_component_edit :transcription, + label: t('admin.communication.blocks.components.text.transcription.label'), + placeholder: t('admin.communication.blocks.components.text.transcription.placeholder'), rows: 10 %> + </div> +</div> diff --git a/app/views/admin/communication/blocks/templates/sound/_preview.html.erb b/app/views/admin/communication/blocks/templates/sound/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..d287566753441b75e0d33eff7b3e7974c0444213 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/sound/_preview.html.erb @@ -0,0 +1,34 @@ +<% +class_name = "block block-sound" +unless @block.title.blank? + class_name += " block-with-title" +end +%> +<section class="<%= class_name %>"> + <div class="container"> + <div class="block-content"> + <% unless @block.title.blank? %> + <div class="top"> + <h2><%= @block.title %></h2> + </div> + <% end %> + <% if @block.template.file.present? %> + <% blob = @block.template.file_component.blob %> + <% if blob %> + <audio controls src="<%= blob.url %>"></audio> + <% end %> + <% end %> + <% if @block.template.title %> + <p><%= block_component_preview :title %></p> + <% end %> + <% unless @block.template.transcription.blank? %> + <div class="transcription"> + <details> + <summary><%= t 'accessibility.transcription' %></summary> + <p><%= block_component_preview :transcription %></p> + </details> + </div> + <% end %> + </div> + </div> +</section> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/sound/_static.html.erb b/app/views/admin/communication/blocks/templates/sound/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..08326619b00c3bb27491f7690ae9baefab7e2cb4 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/sound/_static.html.erb @@ -0,0 +1,3 @@ +<%= block_component_static :file %> +<%= block_component_static :title %> +<%= block_component_static :transcription %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index e25a3e57ec7bec58418febce75441927e26a9da6..89797b6279456e11b5f7e79e10b508aaede0add8 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -532,16 +532,17 @@ en: element: id: label: Organization - name: - label: Nom - placeholder: Enter organization's name - url: - label: Website - logo_label: Logo - placeholder: https:// - remove_logo: Remove logo placeholder: Choose organization unregistered: Unregistered organization + name: + label: Nom + placeholder: Enter organization's name + url: + label: Website + placeholder: https:// + logo: + label: Logo + remove_logo: Remove logo remove_partner: Remove organization with_link: label: With clickable link to each organization's page? @@ -582,6 +583,14 @@ en: description: A selection of programs. edit: add: Add a program + sound: + description: An audio recording with a text transcription for a proper accessibility. + edit: + file: + label: Audio file encoded for the Web (.mp3, .m4a...) + title: + label: Recording title + placeholder: Enter the title testimonials: description: One or more testimonies edit: @@ -756,6 +765,7 @@ en: partners: Organizations posts: Posts programs: Programs + sound: Sound testimonials: Testimonials timeline: Timeline video: Video diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index ff64b5856adcfb5c40b1abfd617f79d9e352fdb9..581e2739f599025d83bca886ae2ab1a655390bd5 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -532,16 +532,17 @@ fr: element: id: label: Organisation - name: - label: Nom - placeholder: Entrer le nom du partenaire - url: - label: Site Web - logo_label: Logo - placeholder: https:// - remove_logo: Enlever le logo placeholder: Choisir l'organisation unregistered: Organisation non enregistrée + name: + label: Nom + placeholder: Entrer le nom du partenaire + url: + label: Site Web + placeholder: https:// + logo: + label: Logo + remove_logo: Enlever le logo remove_partner: Enlever le partenaire with_link: label: Avec des liens cliquables vers les pages des organisations? @@ -582,6 +583,14 @@ fr: description: Une sélection de formations. edit: add: Ajouter une formation + sound: + description: Un enregistrement audio, avec sa transcription pour l'accessibilité. + edit: + file: + label: Fichier audio pour diffusion Web (.mp3, .m4a...) + title: + label: Titre de l'enregistrement + placeholder: Entrer le titre testimonials: description: Un ou plusieurs témoignages, avec le texte, l'auteur, sa fonction et sa photo. edit: @@ -756,6 +765,7 @@ fr: partners: Organisations posts: Actualités programs: Formations + sound: Son testimonials: Témoignages timeline: Frise chronologique video: Vidéo diff --git a/config/locales/en.yml b/config/locales/en.yml index 6b62cb7bcc02979d29ab83f17b73c77a9ac265d1..04fd72e9aef54b276bcea3524f73d6114d39298f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -19,13 +19,6 @@ en: blocks: components: templates: - video: - title_missing: - title: No title - text_html: Neither the block, neither the video have a title. It will prevent blind people from knowing what the video is about, as mentioned in <a href="https://www.numerique.gouv.fr/publications/rgaa-accessibilite/methode-rgaa/criteres/#topic4" target="_blank">criterion 4.7 of RGAA</a>. Please add a title to the video. - transcription_missing: - title: No transcription - text_html: The video has no text transcription for blind people, or for users with a low bitrate connection who could not read the video properly. Please add a text transcription. embed: title_missing: title: No frame title @@ -33,6 +26,20 @@ en: transcription_missing: title: No transcription text_html: The HTML iframe has no text transcription for blind people, for people with low bandwidth or no javascript enabled. Please add a text transcription. + sound: + title_missing: + title: No title + text_html: Neither the block, neither the recording have a title. It will prevent blind people from knowing what the recording is about, as mentioned in <a href="https://www.numerique.gouv.fr/publications/rgaa-accessibilite/methode-rgaa/criteres/#topic4" target="_blank">criterion 4.7 of RGAA</a>. Please add a title to the recording. + transcription_missing: + title: No transcription + text_html: The recording has no text transcription for blind people, or for users with a low bitrate connection who could not read the recording properly. Please add a text transcription. + video: + title_missing: + title: No title + text_html: Neither the block, neither the video have a title. It will prevent blind people from knowing what the video is about, as mentioned in <a href="https://www.numerique.gouv.fr/publications/rgaa-accessibilite/methode-rgaa/criteres/#topic4" target="_blank">criterion 4.7 of RGAA</a>. Please add a title to the video. + transcription_missing: + title: No transcription + text_html: The video has no text transcription for blind people, or for users with a low bitrate connection who could not read the video properly. Please add a text transcription. activerecord: attributes: import: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 0b4ea3ae3878c2bcce139298af1e75fa323136db..0a3513e105ed8c9027da31c463d2371a629aba8e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -19,13 +19,6 @@ fr: blocks: components: templates: - video: - title_missing: - title: Pas de titre - text_html: Ni le bloc ni la vidéo n'ont de titre, cela va empêcher les personnes malvoyantes de savoir de quoi parle la vidéo, comme expliqué dans le <a href="https://www.numerique.gouv.fr/publications/rgaa-accessibilite/methode-rgaa/criteres/#topic4" target="_blank">critère 4.7 du RGAA</a>. Merci d'ajouter un titre à la vidéo. - transcription_missing: - title: Pas de transcription - text_html: La vidéo n'est pas accompagnée d'une transcription textuelle pour les personnes malvoyantes, ou pour les situations de faible débit qui empêcheraient la lecture. embed: title_missing: title: Pas de titre de cadre @@ -33,6 +26,20 @@ fr: transcription_missing: title: Pas de transcription text_html: Le cadre HTML n'est pas accompagné d'une transcription textuelle pour les personnes malvoyantes, ou pour les situations de faible débit qui empêcheraient la lecture. + sound: + title_missing: + title: Pas de titre + text_html: Ni le bloc ni le fichier audio n'ont de titre, cela va empêcher les personnes malvoyantes de savoir de quoi parle l'enregistrement, comme expliqué dans le <a href="https://www.numerique.gouv.fr/publications/rgaa-accessibilite/methode-rgaa/criteres/#topic4" target="_blank">critère 4.7 du RGAA</a>. Merci d'ajouter un titre à l'enregistrement. + transcription_missing: + title: Pas de transcription + text_html: L'enregistrement n'est pas accompagné d'une transcription textuelle pour les personnes malvoyantes, ou pour les situations de faible débit qui empêcheraient la lecture. + video: + title_missing: + title: Pas de titre + text_html: Ni le bloc ni la vidéo n'ont de titre, cela va empêcher les personnes malvoyantes de savoir de quoi parle la vidéo, comme expliqué dans le <a href="https://www.numerique.gouv.fr/publications/rgaa-accessibilite/methode-rgaa/criteres/#topic4" target="_blank">critère 4.7 du RGAA</a>. Merci d'ajouter un titre à la vidéo. + transcription_missing: + title: Pas de transcription + text_html: La vidéo n'est pas accompagnée d'une transcription textuelle pour les personnes malvoyantes, ou pour les situations de faible débit qui empêcheraient la lecture. activerecord: attributes: import: diff --git a/test/models/communication/website/connection_test.rb b/test/models/communication/website/connection_test.rb index 7a1a541720f6bf8cf2e265c1d2f9a3413c2e5cf2..2ffb98bd3c1f2155419222a061ea67251cf41ca0 100644 --- a/test/models/communication/website/connection_test.rb +++ b/test/models/communication/website/connection_test.rb @@ -127,15 +127,15 @@ class Communication::Website::ConnectionTest < ActiveSupport::TestCase # En connectant l'école au site, on crée une connexion pour : # L'école, avec ses formations et ses diplômes en cascade, donc 3 connexions avec direct_source = website # En cascade, le save du website va créer les pages de liste des formations et des diplômes, qui ont elles aussi leurs dépendances - # La page des diplômes aura en dépendance les diplômes (default_diploma) et leurs formations en cascade (default_program), donc 2 connexions avec direct_source = page diplômes + # La page des diplômes aura en dépendance les diplômes (default_diploma), donc 1 connexion avec direct_source = page diplômes # La page des formations aura en dépendance les formations (default_program) et leurs diplômes en cascade (default_diploma), donc 2 connexions avec direct_source = page formations - # Donc un total de 3 + 2 + 2 = 7 connexions - assert_difference -> { Communication::Website::Connection.count } => 7 do + # Donc un total de 3 + 1 + 2 = 6 connexions + assert_difference -> { Communication::Website::Connection.count } => 6 do website_with_github.update(about: default_school) end # En déconnectant l'école du site, on supprime les connexions créées précédemment - assert_difference -> { Communication::Website::Connection.count } => -7 do + assert_difference -> { Communication::Website::Connection.count } => -6 do website_with_github.update(about: nil) end end