Module: Decidim::Accountability::Admin::HasResultCommand

Included in:
CreateImportedResult, CreateResult, UpdateImportedResult, UpdateResult
Defined in:
app/commands/decidim/accountability/admin/has_result_command.rb

Instance Method Summary collapse

Instance Method Details



33
34
35
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 33

def link_meetings
  resource.link_resources(meetings, "meetings_through_proposals")
end


29
30
31
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 29

def link_projects
  resource.link_resources(projects, "included_projects")
end


25
26
27
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 25

def link_proposals
  resource.link_resources(proposals, "included_proposals")
end

#meeting_idsObject



15
16
17
18
19
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 15

def meeting_ids
  @meeting_ids ||= proposals.flat_map do |proposal|
    proposal.linked_resources(:meetings, "proposals_from_meeting").pluck(:id)
  end.uniq
end

#meetingsObject



21
22
23
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 21

def meetings
  @meetings ||= resource.sibling_scope(:meetings).where(id: meeting_ids)
end

#notify_proposal_followersObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 37

def notify_proposal_followers
  proposals.each do |proposal|
    Decidim::EventsManager.publish(
      event: "decidim.events.accountability.proposal_linked",
      event_class: Decidim::Accountability::ProposalLinkedEvent,
      resource:,
      affected_users: proposal.notifiable_identities,
      followers: proposal.followers - proposal.notifiable_identities,
      extra: {
        proposal_id: proposal.id
      }
    )
  end
end

#projectsObject



11
12
13
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 11

def projects
  @projects ||= resource.sibling_scope(:projects).where(id: form.project_ids)
end

#proposalsObject



7
8
9
# File 'app/commands/decidim/accountability/admin/has_result_command.rb', line 7

def proposals
  @proposals ||= resource.sibling_scope(:proposals).where(id: form.proposal_ids)
end