Class: Decidim::DownloadYourDataController

Inherits:
ApplicationController show all
Includes:
UserProfile
Defined in:
decidim-core/app/controllers/decidim/download_your_data_controller.rb

Overview

The controller to handle the user’s download_my_data page.

Instance Method Summary collapse

Methods included from UserProfile

#available_verification_workflows

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#download_fileObject



25
26
27
28
29
30
31
32
33
34
# File 'decidim-core/app/controllers/decidim/download_your_data_controller.rb', line 25

def download_file
  enforce_permission_to(:download, :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

#exportObject



16
17
18
19
20
21
22
23
# File 'decidim-core/app/controllers/decidim/download_your_data_controller.rb', line 16

def export
  enforce_permission_to(:export, :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

#showObject



10
11
12
13
14
# File 'decidim-core/app/controllers/decidim/download_your_data_controller.rb', line 10

def show
  enforce_permission_to(:show, :user, current_user:)

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