diff --git a/config/storage.yml b/config/storage.yml index 54e2f21..38850f5 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -14,6 +14,7 @@ scaleway: region: fr-par bucket: <%= Rails.application.secrets.dig(:scaleway, :bucket_name) %> force_path_style: true + public: true # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) # amazon: diff --git a/lib/tasks/decidim_app.rake b/lib/tasks/decidim_app.rake index c0d7ed6..fa7b51b 100644 --- a/lib/tasks/decidim_app.rake +++ b/lib/tasks/decidim_app.rake @@ -5,6 +5,31 @@ require "decidim_app/k8s/organization_exporter" require "decidim_app/k8s/manager" namespace :decidim_app do + desc "Exports proposals from process" + task export_proposals: :environment do + host = "oye.participer.lyon.fr" + pp = Decidim::ParticipatoryProcess.find_by(slug: "bp2022") + component = Decidim::Component.find(1) + proposals = Decidim::Proposals::Proposal.includes(:attachments).where(component: component).state_published + props = proposals.map do |prop| + proposal_h = {} + proposal_h = proposal_h.merge(prop.attributes) + proposal_h[:attachments] = prop.attachments.map do |attc| + Rails.application.routes.url_helpers.rails_blob_url(attc.file.blob, host: host) + end + + proposal_h + end + + byebug + + puts proposal_h + # attc = proposals[0..100].select { |prop| prop.attachments.present? } + # attc.first.attachments.first.file_blob.representation(resize_to_limit: [100, 100]).processed.url + + # Find URL : Rails.application.routes.url_helpers.rails_blob_url(ActiveStorage::Blob.find(245), host: "oye.participer.lyon.fr") + end + desc "Setup Decidim-app" task setup: :environment do # :nocov: