Class: Decidim::Verifications::CsvCensus::Admin::CensusController

Inherits:
Admin::ApplicationController show all
Includes:
Admin::WorkflowsBreadcrumb
Defined in:
decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb

Instance Method Summary collapse

Methods inherited from Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from TranslatableAttributes

#default_locale?

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb', line 23

def create
  enforce_permission_to :create, :authorization
  @form = form(CensusDataForm).from_params(params)
  @status = Status.new(current_organization)
  CreateCensusData.call(@form, current_organization) do
    on(:ok) do
      flash[:notice] = t(".success", count: @form.data.values.count, errors: @form.data.errors.count)
      redirect_to census_path
    end

    on(:invalid) do
      flash[:alert] = t(".error")
      render :index
    end
  end
end

#destroy_allObject



40
41
42
43
44
45
# File 'decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb', line 40

def destroy_all
  enforce_permission_to :destroy, :authorization
  CsvDatum.clear(current_organization)

  redirect_to census_path, notice: t(".success")
end

#indexObject



17
18
19
20
21
# File 'decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb', line 17

def index
  enforce_permission_to :index, :authorization
  @form = form(CensusDataForm).instance
  @status = Status.new(current_organization)
end