Class: Decidim::Proposals::Admin::ValuationAssignmentForm

Inherits:
Form
  • Object
show all
Defined in:
app/forms/decidim/proposals/admin/valuation_assignment_form.rb

Instance Method Summary collapse

Instance Method Details

#proposalsObject



14
15
16
# File 'app/forms/decidim/proposals/admin/valuation_assignment_form.rb', line 14

def proposals
  @proposals ||= Decidim::Proposals::Proposal.where(component: current_component, id: proposal_ids).uniq
end

#same_participatory_spaceObject



22
23
24
25
26
27
28
29
30
31
# File 'app/forms/decidim/proposals/admin/valuation_assignment_form.rb', line 22

def same_participatory_space
  return if valuator_roles.empty? || !current_component

  valuator_roles.each do |valuator_role|
    if current_component.participatory_space != valuator_role.participatory_space
      errors.add(:id, :invalid)
      break
    end
  end
end

#valuator_rolesObject



18
19
20
# File 'app/forms/decidim/proposals/admin/valuation_assignment_form.rb', line 18

def valuator_roles
  @valuator_roles ||= current_component.participatory_space.user_roles(:valuator).where(id: valuator_role_ids)
end