Sha256: 6f46655b8877979a158bb87d011cb98c50b750fa7827d2c50b13c2be1d2eac4a
Contents?: true
Size: 1.04 KB
Versions: 20
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Decidim module Budgets module Admin # This command is executed when the user updates a Budget # from the admin panel. class UpdateBudget < Decidim::Command def initialize(form, budget) @form = form @budget = budget end # Updates the budget if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if form.invalid? update_budget! broadcast(:ok, budget) end private attr_reader :form, :budget def update_budget! attributes = { scope: form.scope, title: form.title, weight: form.weight, description: form.description, total_budget: form.total_budget } Decidim.traceability.update!( budget, form.current_user, attributes, visibility: "all" ) end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems