Class: Decidim::Proposals::ProposalCreator

Inherits:
Admin::Import::Creator
  • Object
show all
Defined in:
lib/decidim/proposals/proposal_creator.rb

Overview

This class is responsible for creating the imported proposals and must be included in proposals component’s import manifest.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resource_klassObject

Retuns the resource class to be created with the provided data.



9
10
11
# File 'lib/decidim/proposals/proposal_creator.rb', line 9

def self.resource_klass
  Decidim::Proposals::Proposal
end

Instance Method Details

#finish!Object

Saves the proposal



23
24
25
26
27
# File 'lib/decidim/proposals/proposal_creator.rb', line 23

def finish!
  super # resource.save!
  notify(resource)
  publish(resource)
end

#produceObject

Produces a proposal from parsed data

Returns a proposal



16
17
18
19
20
# File 'lib/decidim/proposals/proposal_creator.rb', line 16

def produce
  resource.add_coauthor(context[:current_user], user_group: context[:user_group])

  resource
end