Class: Decidim::Votings::Census::Admin::CensusController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- Admin::ApplicationController
- ApplicationController
- Decidim::Votings::Census::Admin::CensusController
- Defined in:
- app/controllers/decidim/votings/census/admin/census_controller.rb
Overview
This controller allows to create or update the census.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #download_access_codes_file ⇒ Object
- #export_access_codes ⇒ Object
- #generate_access_codes ⇒ Object
- #show ⇒ Object
- #status ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 21 def create :manage, :census, voting: current_participatory_space @form = form(DatasetForm).from_params(params).with_context( current_participatory_space: ) CreateDataset.call(@form, current_user) do on(:invalid_csv_header) do flash[:alert] = t("create.invalid_csv_header", scope: "decidim.votings.census.admin.census") end on(:invalid) do flash[:alert] = t("create.invalid", scope: "decidim.votings.census.admin.census") end end redirect_to admin_voting_census_path end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 41 def destroy :manage, :census, voting: current_participatory_space DestroyDataset.call(current_census, current_user) do on(:ok) do flash[:notice] = t("destroy.success", scope: "decidim.votings.census.admin.census") end on(:invalid) do flash[:alert] = t("destroy.error", scope: "decidim.votings.census.admin.census") end end redirect_to admin_voting_census_path end |
#download_access_codes_file ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 95 def download_access_codes_file :manage, :census, voting: current_participatory_space if current_census.access_codes_file.attached? redirect_to Rails.application.routes.url_helpers.rails_blob_url(current_census.access_codes_file.blob, only_path: true) else flash[:error] = t("export_access_codes.file_not_exist", scope: "decidim.votings.census.admin.census") redirect_to admin_voting_census_path end end |
#export_access_codes ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 79 def export_access_codes :manage, :census, voting: current_participatory_space LaunchAccessCodesExport.call(current_census, current_user) do on(:ok) do flash[:notice] = t("export_access_codes.launch_success", scope: "decidim.votings.census.admin.census", email: current_user.email) end on(:invalid) do flash[:alert] = t("export_access_codes.launch_error", scope: "decidim.votings.census.admin.census") end end redirect_to admin_voting_census_path end |
#generate_access_codes ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 63 def generate_access_codes :manage, :census, voting: current_participatory_space LaunchAccessCodesGeneration.call(current_census, current_user) do on(:ok) do flash[:notice] = t("generate_access_codes.launch_success", scope: "decidim.votings.census.admin.census") end on(:invalid) do flash[:alert] = t("generate_access_codes.launch_error", scope: "decidim.votings.census.admin.census") end end redirect_to admin_voting_census_path end |
#show ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 13 def show :manage, :census, voting: current_participatory_space flash[:notice] = "Finished processing #{current_census.filename}" if current_census.data_created? @form = form(DatasetForm).instance end |
#status ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/decidim/votings/census/admin/census_controller.rb', line 57 def status respond_to do |format| format.js end end |