Sha256: 000d4b1d9ccaf8861d0169a6f07f9198268ca8c2031b914ed62c85744a6bc273

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require "zip"

module Decidim
  # The controller to handle the user's download_my_data page.
  class DownloadYourDataController < Decidim::ApplicationController
    include Decidim::UserProfile

    def show
      enforce_permission_to :show, :user, current_user: current_user

      @account = form(AccountForm).from_model(current_user)
    end

    def export
      enforce_permission_to :export, :user, current_user: current_user

      DownloadYourDataExportJob.perform_later(current_user)

      flash[:notice] = t("decidim.account.download_your_data_export.notice")
      redirect_back(fallback_location: download_your_data_path)
    end

    def download_file
      enforce_permission_to :download, :user, current_user: current_user

      if current_user.download_your_data_file.attached?
        redirect_to Rails.application.routes.url_helpers.rails_blob_url(current_user.download_your_data_file.blob, only_path: true)
      else
        flash[:error] = t("decidim.account.download_your_data_export.file_no_exists")
        redirect_to download_your_data_path
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.8 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.7 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.6 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.5 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.4 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.3 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.2 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.1 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.0 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.0.rc2 app/controllers/decidim/download_your_data_controller.rb
decidim-core-0.27.0.rc1 app/controllers/decidim/download_your_data_controller.rb