Sha256: c2cc8867c476fb171e71aff3ef8ec36087b172d632d0de2a38f002d5c311f711
Contents?: true
Size: 1.04 KB
Versions: 33
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 < Rectify::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
33 entries across 33 versions & 1 rubygems