Sha256: 5ee1b0a0e8eade7696050c7695e91169998cf587003e4014b9e44f96b40a4f90
Contents?: true
Size: 1.07 KB
Versions: 19
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Decidim module Budgets module Admin # This command is executed when the user creates an Budget # from the admin panel. class CreateBudget < Decidim::Command def initialize(form) @form = form end # Creates the budget if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if form.invalid? create_budget! broadcast(:ok, budget) end private attr_reader :form, :budget def create_budget! attributes = { component: form.current_component, scope: form.scope, title: form.title, weight: form.weight, description: form.description, total_budget: form.total_budget } @budget = Decidim.traceability.create!( Budget, form.current_user, attributes, visibility: "all" ) end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems