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

Inherits:
Admin::ApplicationController show all
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 HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb', line 19

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

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

#destroy_allObject


34
35
36
37
38
39
# File 'decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb', line 34

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

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

#indexObject


13
14
15
16
17
# File 'decidim-verifications/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb', line 13

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