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

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

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from AttributeObject::Form

#context

Instance Method Summary collapse

Methods inherited from AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, #map_model, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#proposalsObject


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

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

#same_participatory_spaceObject


29
30
31
32
33
# File 'decidim-proposals/app/forms/decidim/proposals/admin/valuation_assignment_form.rb', line 29

def same_participatory_space
  return if !valuator_role || !current_component

  errors.add(:id, :invalid) if current_component.participatory_space != valuator_role.participatory_space
end

#valuator_roleObject


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

def valuator_role
  @valuator_role ||= current_component.participatory_space.user_roles(:valuator).find_by(id: id)
end

#valuator_userObject


23
24
25
26
27
# File 'decidim-proposals/app/forms/decidim/proposals/admin/valuation_assignment_form.rb', line 23

def valuator_user
  return unless valuator_role

  @valuator_user ||= valuator_role.user
end