Class: Decidim::Demographics::DemographicsController

Inherits:
ApplicationController show all
Includes:
Forms::Concerns::HasQuestionnaire, UserProfile
Defined in:
decidim-demographics/app/controllers/decidim/demographics/demographics_controller.rb

Instance Method Summary collapse

Methods included from UserProfile

#available_verification_workflows

Methods inherited from ApplicationController

#permission_class_chain

Methods inherited from ApplicationController

#store_share_token

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 TranslatableAttributes

#attachment?, #default_locale?

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#destroyObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'decidim-demographics/app/controllers/decidim/demographics/demographics_controller.rb', line 19

def destroy
  DeleteDemographicData.call(questionnaire, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("destroy.success", scope: "decidim.demographics")
      redirect_to demographics_engine.demographics_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("destroy.error", scope: "decidim.demographics")
      redirect_to demographics_engine.demographics_path
    end
  end
end

#showObject



11
12
13
14
15
16
17
# File 'decidim-demographics/app/controllers/decidim/demographics/demographics_controller.rb', line 11

def show
  @form = form(Decidim::Forms::QuestionnaireForm).from_model(questionnaire)
  @form.add_responses!(questionnaire:, session_token:, ip_hash:)
  @form.allow_editing_responses = true

  render template:
end

#templateObject



33
34
35
# File 'decidim-demographics/app/controllers/decidim/demographics/demographics_controller.rb', line 33

def template
  "decidim/demographics/demographics/show"
end