Merge pull request #3998 from betagouv/dev

2019-06-26-01
This commit is contained in:
Paul Chavard 2019-06-26 16:29:32 +02:00 committed by GitHub
commit 1c5b30a42e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 11 deletions

View file

@ -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'

View file

@ -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

View file

@ -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 sappliquera aux éventuels autres administrateurs de cette démarche !" }, class: 'btn-sm btn-danger')
= smart_listing.paginate
= smart_listing.pagination_per_page_links

View file

@ -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

View file

@ -13,7 +13,8 @@ Rails.application.config.content_security_policy do |policy|
# Pour les CSS, on a beaucoup de style inline et quelques balises <style>
# c'est trop compliqué pour être rectifié immédiatement (et sans valeur ajoutée:
# c'est hardcodé dans les vues, donc pas injectable).
policy.style_src :self, :unsafe_inline
policy.style_src :self, :unsafe_inline, "*.crisp.chat", "crisp.chat"
policy.connect_src "wss://*.crisp.chat"
# Pour tout le reste, par défaut on accepte uniquement ce qui vient de chez nous
# et dans la notification on inclue la source de l'erreur
policy.default_src :self, :data, :report_sample, "fonts.gstatic.com", "in-automate.sendinblue.com", "player.vimeo.com", "app.franceconnect.gouv.fr", "sentry.io", "static.demarches-simplifiees.fr", "*.crisp.chat", "crisp.chat", "*.sibautomation.com", "sibautomation.com", "data"

View file

@ -7,8 +7,6 @@ describe Commentaire do
it { is_expected.to have_db_column(:updated_at) }
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:piece_justificative) }
describe "#notify" do
let(:procedure) { create(:procedure) }
let(:gestionnaire) { create(:gestionnaire) }