Sha256: 8536bb0495bd4fc1aa7f6579be964a30666e11eef39ea3eb286474bf7fbbd38f
Contents?: true
Size: 1.8 KB
Versions: 5
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: true module Decidim module Budgets module Admin # This controller allows an admin to manage projects from a Participatory Process class ProjectsController < Admin::ApplicationController helper_method :projects def new @form = form(ProjectForm).instance end def create @form = form(ProjectForm).from_params(params) CreateProject.call(@form) do on(:ok) do flash[:notice] = I18n.t("projects.create.success", scope: "decidim.budgets.admin") redirect_to projects_path end on(:invalid) do flash.now[:alert] = I18n.t("projects.create.invalid", scope: "decidim.budgets.admin") render action: "new" end end end def edit @form = form(ProjectForm).from_model(project) end def update @form = form(ProjectForm).from_params(params) UpdateProject.call(@form, project) do on(:ok) do flash[:notice] = I18n.t("projects.update.success", scope: "decidim.budgets.admin") redirect_to projects_path end on(:invalid) do flash.now[:alert] = I18n.t("projects.update.invalid", scope: "decidim.budgets.admin") render action: "edit" end end end def destroy project.destroy! flash[:notice] = I18n.t("projects.destroy.success", scope: "decidim.budgets.admin") redirect_to projects_path end private def projects @projects ||= Project.where(feature: current_feature) end def project @project ||= projects.find(params[:id]) end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems