Module: Decidim::ActionDelegator::VotesControllerMethods
- Includes:
- SettingsHelper
- Defined in:
- app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb
Instance Method Summary
collapse
#current_resource_settings, #delegations_for, #elections_question_responses_by_type, #elections_question_stats, #elections_question_weighted_responses, #participant_voted?, #settings_for
Instance Method Details
#clear_delegations ⇒ Object
35
36
37
|
# File 'app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb', line 35
def clear_delegations
session.delete(:delegation_id)
end
|
#delegation ⇒ Object
22
23
24
|
# File 'app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb', line 22
def delegation
@delegation ||= delegations.find_by(id: delegation_id)
end
|
#delegations ⇒ Object
18
19
20
|
# File 'app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb', line 18
def delegations
@delegations ||= user_signed_in? ? delegations_for(election, current_user) : Decidim::ActionDelegator::Delegation.none
end
|
#info_for_paper_trail ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb', line 39
def info_for_paper_trail
return super unless delegation
super.merge(decidim_action_delegator_delegation_id: delegation.id)
end
|
#load_delegations ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb', line 26
def load_delegations
return unless user_signed_in?
@delegator = delegation&.user
return unless @delegator
session[:delegation_id] = delegation.id
end
|
#voter_uid ⇒ Object
If there is a delegation, we vote as the granter, we don’t use the census voter_uid default logic as the granter might not be verified (this might be changed in the future, or put as an option)
10
11
12
13
14
15
16
|
# File 'app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb', line 10
def voter_uid
@voter_uid ||= if @delegator
@delegator.to_global_id.to_s
else
election.census.voter_uid(election, session_attributes, current_user:)
end
end
|