Module: Decidim::ActionDelegator::Admin::SettingsHelper
- Defined in:
- app/helpers/decidim/action_delegator/admin/settings_helper.rb
Instance Method Summary collapse
- #existing_authorizations(participants) ⇒ Object
- #grantees_for_select ⇒ Object
- #granters_for_select ⇒ Object
- #missing_decidim_users(participants) ⇒ Object
-
#missing_registered_users(participants) ⇒ Object
TODO: need to check.
- #participants_uniq_ids(participants) ⇒ Object
- #ponderations_for_select(setting) ⇒ Object
- #total_missing_authorizations(participants) ⇒ Object
Instance Method Details
#existing_authorizations(participants) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 37 def (participants) uniq_ids = participants_uniq_ids(participants) user_ids = current_organization.users.select(:id).where(email: participants.select(:email)) Decidim::Authorization.select(:decidim_user_id).where(unique_id: uniq_ids).or( Decidim::Authorization.select(:decidim_user_id).where(decidim_user_id: user_ids) ) end |
#grantees_for_select ⇒ Object
11 12 13 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 11 def grantees_for_select current_organization.users end |
#granters_for_select ⇒ Object
7 8 9 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 7 def granters_for_select current_organization.users end |
#missing_decidim_users(participants) ⇒ Object
19 20 21 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 19 def missing_decidim_users(participants) participants.where(decidim_user: nil).or(participants.where.not(decidim_user: current_organization.users)).where.not(id: missing_registered_users(participants)) end |
#missing_registered_users(participants) ⇒ Object
TODO: need to check
24 25 26 27 28 29 30 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 24 def missing_registered_users(participants) participants.where.not(email: current_organization.users.select(:email)) .where.not("MD5(CONCAT(phone, '-', CAST(? AS text), '-', CAST(? AS text))) IN (?)", current_organization.id, Digest::MD5.hexdigest(Rails.application.secret_key_base), Authorization.select(:unique_id).where.not(unique_id: nil)) end |
#participants_uniq_ids(participants) ⇒ Object
32 33 34 35 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 32 def participants_uniq_ids(participants) phones = Participant.phone_combinations(participants.pluck(:phone)) Participant.verifier_ids(Participant.phone_combinations(phones.map { |phone| "#{phone}-#{current_organization.id}" })) end |
#ponderations_for_select(setting) ⇒ Object
15 16 17 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 15 def ponderations_for_select(setting) setting.ponderations.map { |ponderation| [ponderation.title, ponderation.id] } end |
#total_missing_authorizations(participants) ⇒ Object
45 46 47 |
# File 'app/helpers/decidim/action_delegator/admin/settings_helper.rb', line 45 def (participants) participants.count - (participants).count end |