Sha256: 833989b354aff9e2ab5211fa1f650bf2495aecd1c39916ba1338cb97986df443
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
# frozen_string_literal: true module Decidim module ReportingProposals module Admin class ProposalsController < Admin::ApplicationController def hide_proposal enforce_permission_to(:hide_proposal, :proposals, proposal:) Decidim::Admin::HideResource.call(proposal, current_user) do on(:ok) do flash[:notice] = I18n.t("reportable.hide.success", scope: "decidim.moderations.admin") end on(:invalid) do flash.now[:alert] = I18n.t("reportable.hide.invalid", scope: "decidim.moderations.admin") end end redirect_back(fallback_location: decidim_admin.root_path) end def add_photos enforce_permission_to(:edit_photos, :proposals, proposal:) @photo_form = form(Decidim::ReportingProposals::Admin::ProposalPhotoForm).from_params(params, current_component: proposal.component) Decidim::ReportingProposals::Admin::UpdateProposal.call(@photo_form, proposal) do on(:ok) do |_proposal| flash[:notice] = t("proposals.update.success", scope: "decidim") end on(:invalid) do flash[:alert] = t("proposals.update.error", scope: "decidim") end end redirect_to Decidim::ResourceLocatorPresenter.new(proposal).show end def remove_photo enforce_permission_to(:edit_photos, :proposals, proposal:) attachment = proposal.attachments.find_by(id: params[:photo_id]) if attachment.try(:photo?) attachment.destroy! flash[:notice] = t("proposals.update.success", scope: "decidim") else flash[:alert] = t("proposals.update.error", scope: "decidim") end redirect_to Decidim::ResourceLocatorPresenter.new(proposal).show end private def proposal @proposal ||= Decidim::Proposals::Proposal.find(params[:id]) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-reporting_proposals-0.6.0 | app/controllers/decidim/reporting_proposals/admin/proposals_controller.rb |