Class: Decidim::Proposals::Admin::ProposalsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- Admin::ApplicationController
- Admin::Components::BaseController
- ApplicationController
- Decidim::Proposals::Admin::ProposalsController
- Includes:
- ApplicationHelper, Filterable
- Defined in:
- decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb
Overview
This controller allows admins to manage proposals in a participatory process.
Constant Summary
Constants included from AmendmentsHelper
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #publish_answers ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_category ⇒ Object
- #update_scope ⇒ Object
Methods included from ApplicationHelper
#cell, #edit_link, #extra_admin_link, #html_truncate, #present, #prevent_timeout_seconds, #resolve_presenter_class, #step_cta_url
Methods included from CacheHelper
Methods included from AmendmentsHelper
#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amend_button_for, #amendments_enabled?, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #current_step, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body, #total_steps, #wizard_aside_back_url, #wizard_header_title
Methods included from RichTextEditorHelper
Methods included from ContextualHelpHelper
Methods included from ScopesHelper
#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_select_field, #scopes_select_tag
Methods included from TranslatableAttributes
Methods included from DecidimFormHelper
#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #ordered_scopes_descendants, #ordered_scopes_descendants_for_select, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag
Methods included from OmniauthHelper
#normalize_provider_name, #oauth_icon, #provider_name
Methods inherited from Admin::Components::BaseController
#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #set_component_breadcrumb_item, #skip_manage_component_permission
Methods included from RegistersPermissions
Methods inherited from Admin::ApplicationController
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Methods included from Headers::HttpCachingDisabler
Methods included from NeedsSnippets
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 29 def create :create, :proposal @form = form(Decidim::Proposals::Admin::ProposalForm).from_params(params) Admin::CreateProposal.call(@form) do on(:ok) do flash[:notice] = I18n.t("proposals.create.success", scope: "decidim.proposals.admin") redirect_to proposals_path end on(:invalid) do flash.now[:alert] = I18n.t("proposals.create.invalid", scope: "decidim.proposals.admin") render action: "new" end end end |
#edit ⇒ Object
124 125 126 127 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 124 def edit (:edit, :proposal, proposal:) @form = form(Admin::ProposalForm).from_model(proposal) end |
#new ⇒ Object
22 23 24 25 26 27 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 22 def new :create, :proposal @form = form(Decidim::Proposals::Admin::ProposalForm).from_params( attachment: form(AttachmentForm).from_params({}) ) end |
#publish_answers ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 75 def publish_answers :publish_answers, :proposals Decidim::Proposals::Admin::PublishAnswers.call(current_component, current_user, proposal_ids) do on(:invalid) do flash.now[:alert] = t( "proposals.publish_answers.select_a_proposal", scope: "decidim.proposals.admin" ) end on(:ok) do flash.now[:notice] = I18n.t("proposals.publish_answers.success", scope: "decidim") end end respond_to do |format| format.js end end |
#show ⇒ Object
17 18 19 20 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 17 def show @notes_form = form(ProposalNoteForm).instance @answer_form = form(Admin::ProposalAnswerForm).from_model(proposal) end |
#update ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 129 def update (:edit, :proposal, proposal:) @form = form(Admin::ProposalForm).from_params(params) Admin::UpdateProposal.call(@form, @proposal) do on(:ok) do |_proposal| flash[:notice] = t("proposals.update.success", scope: "decidim") redirect_to proposals_path end on(:invalid) do flash.now[:alert] = t("proposals.update.error", scope: "decidim") render :edit end end end |
#update_category ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 46 def update_category :update, :proposal_category Admin::UpdateProposalCategory.call(params[:category][:id], proposal_ids) do on(:invalid_category) do flash.now[:error] = I18n.t( "proposals.update_category.select_a_category", scope: "decidim.proposals.admin" ) end on(:invalid_proposal_ids) do flash.now[:alert] = I18n.t( "proposals.update_category.select_a_proposal", scope: "decidim.proposals.admin" ) end on(:update_proposals_category) do flash.now[:notice] = update_proposals_bulk_response_successful(@response, :category) flash.now[:alert] = update_proposals_bulk_response_errored(@response, :category) end end respond_to do |format| format.js { render :update_attribute, locals: { form_selector: "#js-form-recategorize-projects", attribute_selector: "#category_id" } } end end |
#update_scope ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb', line 96 def update_scope :update, :proposal_scope Admin::UpdateProposalScope.call(params[:scope_id], proposal_ids) do on(:invalid_scope) do flash.now[:error] = t( "proposals.update_scope.select_a_scope", scope: "decidim.proposals.admin" ) end on(:invalid_proposal_ids) do flash.now[:alert] = t( "proposals.update_scope.select_a_proposal", scope: "decidim.proposals.admin" ) end on(:update_proposals_scope) do flash.now[:notice] = update_proposals_bulk_response_successful(@response, :scope) flash.now[:alert] = update_proposals_bulk_response_errored(@response, :scope) end end respond_to do |format| format.js { render :update_attribute, locals: { form_selector: "#js-form-scope-change-projects", attribute_selector: "#scope_id" } } end end |