Sha256: 90d537c546ea61287520b75efe02caf80a2cb852f3329c5c1b58c4316de4406b

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Decidim
  module Verifications
    module CsvCensus
      class AuthorizationsController < Decidim::ApplicationController
        helper_method :authorization

        before_action :load_authorization

        def new
          @form = CensusForm.from_params(user: current_user)
          ConfirmCensusAuthorization.call(@authorization, @form) do
            on(:ok) do
              flash[:notice] = t("authorizations.new.success", scope: "decidim.verifications.csv_census")
            end
            on(:invalid) do
              flash[:alert] = t("authorizations.new.error", scope: "decidim.verifications.csv_census")
            end
            redirect_to decidim_verifications.authorizations_path
          end
        end

        private

        def authorization
          @authorization ||= AuthorizationPresenter.new(@authorization)
        end

        def load_authorization
          @authorization = Decidim::Authorization.find_or_initialize_by(
            user: current_user,
            name: "csv_census"
          )
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-verifications-0.21.0 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.20.1 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.20.0 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.19.1 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.18.1 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.19.0 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.17.2 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.18.0 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.17.1 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb
decidim-verifications-0.17.0 app/controllers/decidim/verifications/csv_census/authorizations_controller.rb