diff --git a/app/lib/active_storage/service/ds_proxy_service.rb b/app/lib/active_storage/service/ds_proxy_service.rb index 78c420693..fe540d591 100644 --- a/app/lib/active_storage/service/ds_proxy_service.rb +++ b/app/lib/active_storage/service/ds_proxy_service.rb @@ -25,6 +25,29 @@ module ActiveStorage private + def object_for(key, &block) + blob_url = url(key) + if block_given? + request = Typhoeus::Request.new(blob_url) + request.on_headers do |response| + if response.code != 200 + raise Fog::OpenStack::Storage::NotFound.new + end + end + request.on_body do |chunk| + yield chunk + end + request.run + else + response = Typhoeus.get(blob_url) + if response.success? + response + else + raise Fog::OpenStack::Storage::NotFound.new + end + end + end + def publicize(url) search = %r{^https://[^/]+/v1/AUTH_[a-f0-9]{32}} replace = 'https://static.demarches-simplifiees.fr' diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index 68b571164..866593071 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -1,6 +1,5 @@ class Commentaire < ApplicationRecord belongs_to :dossier, inverse_of: :commentaires, touch: true - belongs_to :piece_justificative belongs_to :user belongs_to :gestionnaire diff --git a/app/views/admin/procedures/_list.html.haml b/app/views/admin/procedures/_list.html.haml index 833a6a6fc..e47503397 100644 --- a/app/views/admin/procedures/_list.html.haml +++ b/app/views/admin/procedures/_list.html.haml @@ -26,7 +26,7 @@ %td = link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn') - if !procedure.publiee_ou_archivee? - = link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), data: { method: :delete, confirm: "Confirmez-vous la suppression de la démarche ?" }, class: 'btn-sm btn-danger') + = link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), data: { method: :delete, confirm: "Confirmez-vous la suppression de la démarche ? \n\n Attention : toute suppression est définitive et s’appliquera aux éventuels autres administrateurs de cette démarche !" }, class: 'btn-sm btn-danger') = smart_listing.paginate = smart_listing.pagination_per_page_links diff --git a/app/views/shared/dossiers/messages/_message.html.haml b/app/views/shared/dossiers/messages/_message.html.haml index 518fbc191..74f314ad8 100644 --- a/app/views/shared/dossiers/messages/_message.html.haml +++ b/app/views/shared/dossiers/messages/_message.html.haml @@ -10,12 +10,7 @@ = commentaire_date(commentaire) .rich-text= sanitize(simple_format(commentaire.body)) - - if commentaire.piece_justificative - .attachment-link - = link_to commentaire.piece_justificative.content_url, class: "button", target: "_blank", rel: "noopener", title: "Télécharger" do - %span.icon.attachment - = commentaire.piece_justificative.original_filename - - elsif commentaire.file.present? + - if commentaire.file.present? .attachment-link = link_to commentaire.file_url, class: "button", target: "_blank", rel: "noopener", title: "Télécharger" do %span.icon.attachment diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 9d46a3874..e7debcc0c 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -13,7 +13,8 @@ Rails.application.config.content_security_policy do |policy| # Pour les CSS, on a beaucoup de style inline et quelques balises