Sha256: 1ab314b088abca490916b169ad0154744633cc47d958f792e9c4bd2178dfd991

Contents?: true

Size: 1.09 KB

Versions: 19

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "zip"

module Decidim
  # The controller to handle the user's download_my_data page.
  class DataPortabilityController < 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

      DataPortabilityExportJob.perform_later(current_user)

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

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

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.9 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.8 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.7 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.5 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.4 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.3 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.2 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.1 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.0 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.0.rc2 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.26.0.rc1 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.2 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.1 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.0 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.0.rc4 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.0.rc3 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.0.rc2 app/controllers/decidim/data_portability_controller.rb
decidim-core-0.25.0.rc1 app/controllers/decidim/data_portability_controller.rb