decidim-elections 0.23.1 → 0.24.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/assets/config/admin/decidim_votings_manifest.css +0 -0
- data/app/assets/config/admin/decidim_votings_manifest.js +4 -0
- data/app/assets/config/decidim_elections_manifest.css +3 -0
- data/app/assets/config/decidim_elections_manifest.js +6 -0
- data/app/assets/config/decidim_votings_manifest.css +3 -0
- data/app/assets/config/decidim_votings_manifest.js +0 -0
- data/app/assets/images/decidim/votings/icon.svg +1 -0
- data/app/assets/javascripts/decidim/elections/admin/pending_action.js.es6 +16 -0
- data/app/assets/javascripts/decidim/elections/admin/vote_statistics.js.es6 +11 -0
- data/app/assets/javascripts/decidim/elections/trustee_zone.js.es6 +54 -0
- data/app/assets/javascripts/decidim/elections/trustee_zone/key_ceremony.js.es6 +126 -0
- data/app/assets/javascripts/decidim/elections/trustee_zone/tally.js.es6 +104 -0
- data/app/assets/javascripts/decidim/elections/vote.js.es6 +107 -160
- data/app/assets/javascripts/decidim/elections/vote_questions.component.js.es6 +129 -0
- data/app/assets/javascripts/decidim/elections/vote_verify.js.es6 +71 -0
- data/app/assets/javascripts/decidim/votings/admin/monitoring_committee_members_form.js.es6 +35 -0
- data/app/assets/javascripts/decidim/votings/admin/polling_officers_form.js.es6 +35 -0
- data/app/assets/javascripts/decidim/votings/admin/polling_officers_picker.js.es6 +35 -0
- data/app/assets/javascripts/decidim/votings/admin/polling_stations_form.js.es6 +5 -0
- data/app/assets/stylesheets/decidim/elections/elections.scss +0 -4
- data/app/assets/stylesheets/decidim/elections/focus/_accordion.scss +36 -0
- data/app/assets/stylesheets/decidim/elections/focus/_evote.scss +58 -0
- data/app/assets/stylesheets/decidim/elections/trustee_zone.scss +24 -0
- data/app/assets/stylesheets/decidim/votings/votings.scss +1 -0
- data/app/assets/stylesheets/decidim/votings/votings/_votings-header.scss +99 -0
- data/app/assets/stylesheets/decidim/votings/votings/_votings-home-banner.scss +11 -0
- data/app/cells/decidim/votings/content_block_cell.rb +17 -0
- data/app/cells/decidim/votings/content_blocks/highlighted_votings/show.erb +30 -0
- data/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb +33 -0
- data/app/cells/decidim/votings/content_blocks/highlighted_votings_settings_form/show.erb +3 -0
- data/app/cells/decidim/votings/content_blocks/highlighted_votings_settings_form_cell.rb +19 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/attachments_and_folders_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/description_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/header_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/metrics_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/stats_cell.rb +15 -0
- data/app/cells/decidim/votings/content_blocks/landing_page/timeline_cell.rb +15 -0
- data/app/cells/decidim/votings/polling_officers/polling_officers_picker/polling_officers.erb +12 -0
- data/app/cells/decidim/votings/polling_officers/polling_officers_picker/show.erb +14 -0
- data/app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb +73 -0
- data/app/cells/decidim/votings/voting_cell.rb +19 -0
- data/app/cells/decidim/votings/voting_m/data.erb +21 -0
- data/app/cells/decidim/votings/voting_m/footer.erb +5 -0
- data/app/cells/decidim/votings/voting_m_cell.rb +94 -0
- data/app/commands/decidim/elections/admin/add_user_as_trustee.rb +81 -0
- data/app/commands/decidim/elections/admin/create_election.rb +2 -1
- data/app/commands/decidim/elections/admin/end_vote.rb +63 -0
- data/app/commands/decidim/elections/admin/publish_results.rb +59 -0
- data/app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb +37 -0
- data/app/commands/decidim/elections/admin/setup_election.rb +160 -0
- data/app/commands/decidim/elections/admin/start_key_ceremony.rb +63 -0
- data/app/commands/decidim/elections/admin/start_tally.rb +63 -0
- data/app/commands/decidim/elections/admin/start_vote.rb +63 -0
- data/app/commands/decidim/elections/admin/update_action_status.rb +47 -0
- data/app/commands/decidim/elections/admin/update_answer_selection.rb +41 -0
- data/app/commands/decidim/elections/admin/update_trustee_participatory_space.rb +40 -0
- data/app/commands/decidim/elections/trustee_zone/update_election_bulletin_board_status.rb +39 -0
- data/app/commands/decidim/elections/trustee_zone/update_trustee.rb +41 -0
- data/app/commands/decidim/elections/voter/cast_vote.rb +59 -0
- data/app/commands/decidim/elections/voter/update_vote_status.rb +70 -0
- data/app/commands/decidim/votings/admin/create_monitoring_committee_member.rb +99 -0
- data/app/commands/decidim/votings/admin/create_polling_officer.rb +99 -0
- data/app/commands/decidim/votings/admin/create_polling_station.rb +59 -0
- data/app/commands/decidim/votings/admin/create_voting.rb +59 -0
- data/app/commands/decidim/votings/admin/destroy_monitoring_committee_member.rb +51 -0
- data/app/commands/decidim/votings/admin/destroy_polling_officer.rb +52 -0
- data/app/commands/decidim/votings/admin/destroy_polling_station.rb +40 -0
- data/app/commands/decidim/votings/admin/manage_polling_station.rb +64 -0
- data/app/commands/decidim/votings/admin/publish_voting.rb +40 -0
- data/app/commands/decidim/votings/admin/unpublish_voting.rb +40 -0
- data/app/commands/decidim/votings/admin/update_polling_station.rb +50 -0
- data/app/commands/decidim/votings/admin/update_voting.rb +85 -0
- data/app/constraints/decidim/votings/current_component.rb +28 -0
- data/app/constraints/decidim/votings/current_voting.rb +43 -0
- data/app/controllers/concerns/decidim/elections/orderable.rb +2 -2
- data/app/controllers/concerns/decidim/polling_officers/admin/filterable.rb +58 -0
- data/app/controllers/concerns/decidim/polling_stations/admin/filterable.rb +57 -0
- data/app/controllers/concerns/decidim/votings/admin/filterable.rb +27 -0
- data/app/controllers/concerns/decidim/votings/admin/voting_admin.rb +48 -0
- data/app/controllers/concerns/decidim/votings/needs_voting.rb +44 -0
- data/app/controllers/concerns/decidim/votings/orderable.rb +32 -0
- data/app/controllers/decidim/elections/admin/answers_controller.rb +32 -0
- data/app/controllers/decidim/elections/admin/elections_controller.rb +2 -2
- data/app/controllers/decidim/elections/admin/feedback_forms_controller.rb +55 -0
- data/app/controllers/decidim/elections/admin/steps_controller.rb +96 -0
- data/app/controllers/decidim/elections/admin/trustees_participatory_spaces_controller.rb +89 -0
- data/app/controllers/decidim/elections/elections_controller.rb +5 -1
- data/app/controllers/decidim/elections/feedbacks_controller.rb +38 -0
- data/app/controllers/decidim/elections/trustee_zone/application_controller.rb +45 -0
- data/app/controllers/decidim/elections/trustee_zone/elections_controller.rb +35 -0
- data/app/controllers/decidim/elections/trustee_zone/trustees_controller.rb +36 -0
- data/app/controllers/decidim/elections/votes_controller.rb +54 -2
- data/app/controllers/decidim/votings/admin/application_controller.rb +26 -0
- data/app/controllers/decidim/votings/admin/component_permissions_controller.rb +13 -0
- data/app/controllers/decidim/votings/admin/components_controller.rb +15 -0
- data/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb +62 -0
- data/app/controllers/decidim/votings/admin/polling_officers_controller.rb +66 -0
- data/app/controllers/decidim/votings/admin/polling_stations_controller.rb +92 -0
- data/app/controllers/decidim/votings/admin/voting_attachment_collections_controller.rb +22 -0
- data/app/controllers/decidim/votings/admin/voting_attachments_controller.rb +21 -0
- data/app/controllers/decidim/votings/admin/votings_controller.rb +124 -0
- data/app/controllers/decidim/votings/admin/votings_landing_page_content_blocks_controller.rb +44 -0
- data/app/controllers/decidim/votings/admin/votings_landing_page_controller.rb +46 -0
- data/app/controllers/decidim/votings/application_controller.rb +26 -0
- data/app/controllers/decidim/votings/polling_officer_zone/application_controller.rb +33 -0
- data/app/controllers/decidim/votings/polling_officer_zone/polling_officers_controller.rb +17 -0
- data/app/controllers/decidim/votings/polling_officer_zone/polling_stations_controller.rb +22 -0
- data/app/controllers/decidim/votings/votings_controller.rb +98 -0
- data/app/events/decidim/elections/trustees/notify_new_trustee_event.rb +28 -0
- data/app/events/decidim/elections/trustees/notify_trustee_new_election_event.rb +14 -0
- data/app/events/decidim/elections/votes/vote_accepted_event.rb +24 -0
- data/app/events/decidim/votings/polling_officers/polling_station_assigned_event.rb +44 -0
- data/app/forms/decidim/elections/admin/action_form.rb +34 -0
- data/app/forms/decidim/elections/admin/answer_form.rb +3 -2
- data/app/forms/decidim/elections/admin/election_form.rb +3 -2
- data/app/forms/decidim/elections/admin/setup_form.rb +79 -0
- data/app/forms/decidim/elections/admin/trustees_participatory_space_form.rb +22 -0
- data/app/forms/decidim/elections/admin/vote_period_form.rb +37 -0
- data/app/forms/decidim/elections/ballot/verify_vote_form.rb +29 -0
- data/app/forms/decidim/elections/trustee_zone/trustee_form.rb +26 -0
- data/app/forms/decidim/elections/voter/encrypted_vote_form.rb +49 -0
- data/app/forms/decidim/votings/admin/monitoring_committee_member_form.rb +27 -0
- data/app/forms/decidim/votings/admin/polling_officer_form.rb +27 -0
- data/app/forms/decidim/votings/admin/polling_station_form.rb +58 -0
- data/app/forms/decidim/votings/admin/voting_form.rb +71 -0
- data/app/helpers/decidim/elections/admin/answers_helper.rb +19 -0
- data/app/helpers/decidim/elections/admin/steps_helper.rb +23 -0
- data/app/helpers/decidim/elections/admin/trustees_participatory_spaces_helper.rb +31 -0
- data/app/helpers/decidim/elections/elections_helper.rb +29 -0
- data/app/helpers/decidim/votings/admin/polling_officers_picker_helper.rb +29 -0
- data/app/helpers/decidim/votings/votings_helper.rb +20 -0
- data/app/models/decidim/elections/action.rb +13 -0
- data/app/models/decidim/elections/election.rb +54 -3
- data/app/models/decidim/elections/elections_trustee.rb +11 -0
- data/app/models/decidim/elections/question.rb +19 -0
- data/app/models/decidim/elections/trustee.rb +26 -0
- data/app/models/decidim/elections/trustees_participatory_space.rb +13 -0
- data/app/models/decidim/elections/vote.rb +15 -0
- data/app/models/decidim/votings/monitoring_committee_member.rb +24 -0
- data/app/models/decidim/votings/polling_officer.rb +76 -0
- data/app/models/decidim/votings/polling_station.rb +64 -0
- data/app/models/decidim/votings/voting.rb +138 -0
- data/app/permissions/decidim/elections/admin/permissions.rb +50 -10
- data/app/permissions/decidim/elections/permissions.rb +20 -2
- data/app/permissions/decidim/elections/trustee_zone/permissions.rb +32 -0
- data/app/permissions/decidim/votings/admin/permissions.rb +127 -0
- data/app/permissions/decidim/votings/permissions.rb +40 -0
- data/app/permissions/decidim/votings/polling_officer_zone/permissions.rb +32 -0
- data/app/presenters/decidim/elections/admin_log/election_presenter.rb +1 -1
- data/app/presenters/decidim/elections/trustee_presenter.rb +24 -0
- data/app/presenters/decidim/votings/admin_log/voting_presenter.rb +45 -0
- data/app/presenters/decidim/votings/polling_station_presenter.rb +27 -0
- data/app/presenters/decidim/votings/voting_presenter.rb +36 -0
- data/app/queries/decidim/elections/admin/pending_actions.rb +20 -0
- data/app/queries/decidim/elections/admin/votes_for_statistics.rb +24 -0
- data/app/queries/decidim/elections/elections_finished_to_end.rb +19 -0
- data/app/queries/decidim/elections/elections_ready_to_start.rb +25 -0
- data/app/queries/decidim/elections/trustees/by_participatory_space.rb +24 -0
- data/app/queries/decidim/elections/trustees/by_participatory_space_trustee_ids.rb +24 -0
- data/app/queries/decidim/elections/votes/election_votes.rb +19 -0
- data/app/queries/decidim/elections/votes/pending_votes.rb +20 -0
- data/app/queries/decidim/elections/votes/user_election_last_vote.rb +26 -0
- data/app/queries/decidim/elections/votes/user_votes.rb +19 -0
- data/app/queries/decidim/votings/admin/admin_users.rb +39 -0
- data/app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb +33 -0
- data/app/queries/decidim/votings/admin/polling_officers_join_polling_stations_and_user.rb +34 -0
- data/app/queries/decidim/votings/admin/polling_officers_join_user.rb +32 -0
- data/app/queries/decidim/votings/organization_prioritized_votings.rb +21 -0
- data/app/queries/decidim/votings/organization_promoted_votings.rb +16 -0
- data/app/queries/decidim/votings/organization_published_votings.rb +19 -0
- data/app/queries/decidim/votings/organization_votings.rb +16 -0
- data/app/queries/decidim/votings/prioritized_votings.rb +13 -0
- data/app/queries/decidim/votings/published_votings.rb +12 -0
- data/app/services/decidim/votings/voting_search.rb +46 -0
- data/app/views/decidim/elections/admin/answers/index.html.erb +12 -0
- data/app/views/decidim/elections/admin/elections/index.html.erb +13 -1
- data/app/views/decidim/elections/admin/proposals_imports/new.html.erb +1 -1
- data/app/views/decidim/elections/admin/questions/index.html.erb +5 -1
- data/app/views/decidim/elections/admin/shared/_trustees_secondary_nav.html.erb +3 -0
- data/app/views/decidim/elections/admin/steps/_create_election.html.erb +38 -0
- data/app/views/decidim/elections/admin/steps/_created.html.erb +16 -0
- data/app/views/decidim/elections/admin/steps/_key_ceremony.html.erb +16 -0
- data/app/views/decidim/elections/admin/steps/_key_ceremony_ended.html.erb +15 -0
- data/app/views/decidim/elections/admin/steps/_tally.html.erb +17 -0
- data/app/views/decidim/elections/admin/steps/_tally_ended.html.erb +9 -0
- data/app/views/decidim/elections/admin/steps/_vote.html.erb +21 -0
- data/app/views/decidim/elections/admin/steps/_vote_ended.html.erb +15 -0
- data/app/views/decidim/elections/admin/steps/_vote_stats.html.erb +31 -0
- data/app/views/decidim/elections/admin/steps/index.html.erb +43 -0
- data/app/views/decidim/elections/admin/trustees_participatory_spaces/_form.html.erb +19 -0
- data/app/views/decidim/elections/admin/trustees_participatory_spaces/index.html.erb +64 -0
- data/app/views/decidim/elections/admin/trustees_participatory_spaces/new.html.erb +7 -0
- data/app/views/decidim/elections/elections/_filters_small_view.html.erb +1 -1
- data/app/views/decidim/elections/elections/_preview.html.erb +26 -0
- data/app/views/decidim/elections/elections/_results.html.erb +47 -0
- data/app/views/decidim/elections/elections/show.html.erb +39 -12
- data/app/views/decidim/elections/trustee_zone/elections/_backup_modal.html.erb +24 -0
- data/app/views/decidim/elections/trustee_zone/elections/_key_ceremony_steps.html.erb +44 -0
- data/app/views/decidim/elections/trustee_zone/elections/_restore_modal.html.erb +25 -0
- data/app/views/decidim/elections/trustee_zone/elections/_tally_steps.html.erb +43 -0
- data/app/views/decidim/elections/trustee_zone/elections/show.html.erb +38 -0
- data/app/views/decidim/elections/trustee_zone/elections/update.js.erb +5 -0
- data/app/views/decidim/elections/trustee_zone/trustees/show.html.erb +102 -0
- data/app/views/decidim/elections/votes/_election_votes_confirmed.html.erb +38 -17
- data/app/views/decidim/elections/votes/_election_votes_failed.html.erb +21 -0
- data/app/views/decidim/elections/votes/_election_votes_question.html.erb +4 -4
- data/app/views/decidim/elections/votes/cast_failed.js.erb +1 -0
- data/app/views/decidim/elections/votes/cast_success.js.erb +1 -0
- data/app/views/decidim/elections/votes/new.html.erb +41 -33
- data/app/views/decidim/elections/votes/verify.html.erb +78 -0
- data/app/views/decidim/votings/admin/monitoring_committee_members/_form.html.erb +27 -0
- data/app/views/decidim/votings/admin/monitoring_committee_members/index.html.erb +41 -0
- data/app/views/decidim/votings/admin/monitoring_committee_members/new.html.erb +7 -0
- data/app/views/decidim/votings/admin/polling_officers/_form.html.erb +27 -0
- data/app/views/decidim/votings/admin/polling_officers/index.html.erb +50 -0
- data/app/views/decidim/votings/admin/polling_officers/new.html.erb +7 -0
- data/app/views/decidim/votings/admin/polling_stations/_form.html.erb +40 -0
- data/app/views/decidim/votings/admin/polling_stations/edit.html.erb +7 -0
- data/app/views/decidim/votings/admin/polling_stations/index.html.erb +55 -0
- data/app/views/decidim/votings/admin/polling_stations/new.html.erb +7 -0
- data/app/views/decidim/votings/admin/votings/_form.html.erb +63 -0
- data/app/views/decidim/votings/admin/votings/edit.html.erb +31 -0
- data/app/views/decidim/votings/admin/votings/index.html.erb +87 -0
- data/app/views/decidim/votings/admin/votings/new.html.erb +13 -0
- data/app/views/decidim/votings/admin/votings/polling_officers_picker.html.erb +2 -0
- data/app/views/decidim/votings/polling_officer_zone/polling_officers/show.html.erb +42 -0
- data/app/views/decidim/votings/polling_officer_zone/polling_stations/show.html.erb +1 -0
- data/app/views/decidim/votings/votings/_count.html.erb +1 -0
- data/app/views/decidim/votings/votings/_filters.html.erb +25 -0
- data/app/views/decidim/votings/votings/_filters_small_view.html.erb +23 -0
- data/app/views/decidim/votings/votings/_promoted_voting.html.erb +27 -0
- data/app/views/decidim/votings/votings/_voting_details.html.erb +7 -0
- data/app/views/decidim/votings/votings/_votings.html.erb +25 -0
- data/app/views/decidim/votings/votings/index.html.erb +42 -0
- data/app/views/decidim/votings/votings/index.js.erb +10 -0
- data/app/views/decidim/votings/votings/show.html.erb +20 -0
- data/app/views/layouts/decidim/_voting_header.html.erb +16 -0
- data/app/views/layouts/decidim/admin/voting.html.erb +101 -0
- data/app/views/layouts/decidim/voting.html.erb +16 -0
- data/config/initializers/decidim_bulletin_board.rb +23 -0
- data/config/locales/ca.yml +635 -6
- data/config/locales/cs.yml +635 -6
- data/config/locales/de.yml +677 -10
- data/config/locales/el.yml +4 -2
- data/config/locales/en.yml +636 -6
- data/config/locales/es-MX.yml +636 -7
- data/config/locales/es-PY.yml +636 -7
- data/config/locales/es.yml +636 -7
- data/config/locales/fi-plain.yml +636 -7
- data/config/locales/fi.yml +637 -8
- data/config/locales/fr-CA.yml +419 -6
- data/config/locales/fr.yml +419 -6
- data/config/locales/gl.yml +168 -0
- data/config/locales/it.yml +108 -6
- data/config/locales/ja.yml +12 -6
- data/config/locales/lv.yml +4 -2
- data/config/locales/nl.yml +502 -6
- data/config/locales/no.yml +0 -6
- data/config/locales/pl.yml +657 -9
- data/config/locales/pt.yml +4 -6
- data/config/locales/ro-RO.yml +4 -6
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sv.yml +11 -6
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/tr-TR.yml +366 -0
- data/config/locales/zh-CN.yml +4 -6
- data/db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb +29 -0
- data/db/migrate/20200918153813_create_decidim_elections_trustees_participatory_spaces.rb +13 -0
- data/db/migrate/20200918153824_create_decidim_elections_elections_trustees.rb +10 -0
- data/db/migrate/20200918153835_create_decidim_elections_trustees.rb +12 -0
- data/db/migrate/20201026163334_add_blocked_at_and_bb_status_to_elections.rb +8 -0
- data/db/migrate/20201028090110_add_votes_to_decidim_elections_answers.rb +7 -0
- data/db/migrate/20201028135614_add_selected_to_decidim_elections_answers.rb +7 -0
- data/db/migrate/20201209110653_create_decidim_elections_votes.rb +14 -0
- data/db/migrate/20201216091123_add_name_to_trustees.rb +7 -0
- data/db/migrate/20210113113818_add_message_id_to_decidim_elections_votes.rb +7 -0
- data/db/migrate/20210113120115_create_decidim_elections_votings.rb +20 -0
- data/db/migrate/20210114100749_add_published_at_to_decidim_votings_votings.rb +7 -0
- data/db/migrate/20210114111850_add_user_to_decidim_elections_votes.rb +7 -0
- data/db/migrate/20210120164634_add_promoted_to_voting.rb +7 -0
- data/db/migrate/20210125124801_add_voting_type_to_voting_voting.rb +7 -0
- data/db/migrate/20210129124956_create_decidim_elections_actions.rb +14 -0
- data/db/migrate/20210204132111_add_votings_polling_stations.rb +19 -0
- data/db/migrate/20210208090441_add_polling_officers_to_votings.rb +12 -0
- data/db/migrate/20210210090738_add_votings_polling_station_references_to_votings_polling_officer.rb +8 -0
- data/db/migrate/20210216074707_add_monitoring_committee_member.rb +12 -0
- data/db/seeds/city.jpeg +0 -0
- data/lib/decidim/api/election_answer_type.rb +23 -0
- data/lib/decidim/api/election_question_type.rb +22 -0
- data/lib/decidim/api/election_type.rb +27 -0
- data/lib/decidim/api/elections_type.rb +32 -0
- data/lib/decidim/api/trustee_type.rb +16 -0
- data/lib/decidim/api/voting_type.rb +20 -0
- data/lib/decidim/elections.rb +19 -2
- data/lib/decidim/elections/admin_engine.rb +42 -1
- data/lib/decidim/elections/answer_serializer.rb +48 -0
- data/lib/decidim/elections/api.rb +11 -0
- data/lib/decidim/elections/component.rb +367 -24
- data/lib/decidim/elections/engine.rb +8 -1
- data/lib/decidim/elections/test/factories.rb +201 -4
- data/lib/decidim/elections/trustee_zone.rb +10 -0
- data/lib/decidim/elections/trustee_zone_engine.rb +35 -0
- data/lib/decidim/elections/version.rb +1 -1
- data/lib/decidim/votings.rb +16 -0
- data/lib/decidim/votings/admin.rb +10 -0
- data/lib/decidim/votings/admin_engine.rb +71 -0
- data/lib/decidim/votings/api.rb +7 -0
- data/lib/decidim/votings/engine.rb +147 -0
- data/lib/decidim/votings/participatory_space.rb +92 -0
- data/lib/decidim/votings/polling_officer_zone.rb +10 -0
- data/lib/decidim/votings/polling_officer_zone_engine.rb +33 -0
- data/lib/decidim/votings/query_extensions.rb +43 -0
- data/lib/decidim/votings/test/capybara_polling_officers_picker.rb +49 -0
- data/lib/decidim/votings/test/factories.rb +83 -0
- data/lib/decidim/votings/voting_serializer.rb +54 -0
- data/lib/tasks/decidim_elections.rake +68 -5
- metadata +309 -24
- data/app/types/decidim/elections/election_answer_type.rb +0 -24
- data/app/types/decidim/elections/election_question_type.rb +0 -25
- data/app/types/decidim/elections/election_type.rb +0 -27
- data/app/types/decidim/elections/elections_type.rb +0 -32
- data/config/i18n-tasks.yml +0 -10
- data/lib/decidim/elections/bulletin_board_client.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60832512a83be2c28933a82f146cba69c4e55e704b2516b43296d2c82e7c8669
|
4
|
+
data.tar.gz: 68fecb9645fc4bba7b9c64e9c6d3de420ba13a77aa04a40e401b883376cad882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d91e7c5d48d6e83f0db0eb843c724f86532a62d249301974b5968404efe9e30cc1d7dbeaa071839d02119e6595cfb45c9a68dcc7646672e7324d1b8f29a57e
|
7
|
+
data.tar.gz: ce428f9d81a27ffed42271e36f476b6af63c16fbb5df6fa9dfc02ce7430a3b10cffdf5bd9763b65be80af5b03faf325a9bb4fbbed79c9b14b677aaa3a0292940
|
data/README.md
CHANGED
@@ -8,6 +8,8 @@ The Elections module adds elections to any participatory space.
|
|
8
8
|
|
9
9
|
Elections will be available as a Component for a Participatory Space.
|
10
10
|
|
11
|
+
In order to celebrate [End-to-end auditable votings](https://en.wikipedia.org/wiki/End-to-end_auditable_voting_systems) using the Elections module, you will need to connect your Decidim instance with an instance of the [Decidim Bulletin Board application](https://github.com/decidim/decidim-bulletin-board/). To create this connection, please check the [instructions](https://github.com/decidim/decidim/blob/develop/docs/services/elections_bulletin_board.md).
|
12
|
+
|
11
13
|
## Installation
|
12
14
|
|
13
15
|
Add this line to your application's Gemfile:
|
File without changes
|
@@ -1,2 +1,8 @@
|
|
1
|
+
//= link decidim/elections/admin/pending_action.js
|
2
|
+
//= link decidim/elections/admin/vote_statistics.js.es6
|
3
|
+
//= link decidim/elections/trustee_zone/key_ceremony.js
|
4
|
+
//= link decidim/elections/trustee_zone/tally.js
|
5
|
+
//= link decidim/elections/trustee_zone.js
|
1
6
|
//= link decidim/elections/vote.js
|
7
|
+
//= link decidim/elections/vote_verify.js
|
2
8
|
//= link_tree ../images/decidim
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8"><path d="M2.91-.03a1 1 0 0 0-.13.03 1 1 0 0 0-.78 1v2a1 1 0 1 0 2 0v-2a1 1 0 0 0-1.09-1.03zm-2.56 2.03a.5.5 0 0 0-.34.5v.5c0 1.48 1.09 2.69 2.5 2.94v1.06h-.5c-.55 0-1 .45-1 1h4.01c0-.55-.45-1-1-1h-.5v-1.06c1.41-.24 2.5-1.46 2.5-2.94v-.5a.5.5 0 1 0-1 0v.5c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2v-.5a.5.5 0 0 0-.59-.5.5.5 0 0 0-.06 0z" transform="translate(1)"/></svg>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// = require decidim/bulletin_board/decidim-bulletin_board
|
2
|
+
|
3
|
+
$(() => {
|
4
|
+
const { Client } = decidimBulletinBoard;
|
5
|
+
const $form = $("form.step");
|
6
|
+
const $pendingAction = $form.find("#pending_action")
|
7
|
+
const bulletinBoardClient = new Client({
|
8
|
+
apiEndpointUrl: $pendingAction.data("apiEndpointUrl")
|
9
|
+
});
|
10
|
+
const messageId = $pendingAction.data("messageId")
|
11
|
+
|
12
|
+
bulletinBoardClient.waitForPendingMessageToBeProcessed(messageId).then(() => {
|
13
|
+
$form.submit();
|
14
|
+
});
|
15
|
+
});
|
16
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/* eslint-disable no-inline-comments */
|
2
|
+
/* eslint-disable line-comment-position */
|
3
|
+
// fetches Vote stats every 3 seconds
|
4
|
+
|
5
|
+
$(() => {
|
6
|
+
const WAIT_TIME_MS = 3000; // 3s
|
7
|
+
|
8
|
+
setInterval(function() {
|
9
|
+
$("#vote-stats").load($("#vote-stats").data("refreshUrl"));
|
10
|
+
}, WAIT_TIME_MS);
|
11
|
+
})
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/* eslint-disable require-jsdoc, no-alert, func-style */
|
2
|
+
// = require decidim/bulletin_board/decidim-bulletin_board
|
3
|
+
|
4
|
+
window.Decidim = window.Decidim || {};
|
5
|
+
|
6
|
+
$(() => {
|
7
|
+
const { IdentificationKeys } = window.decidimBulletinBoard;
|
8
|
+
|
9
|
+
function identificationKeys() {
|
10
|
+
const $form = $(".trustee_zone form");
|
11
|
+
const $trusteeUniqueId = $("#trustee_unique_id", $form);
|
12
|
+
const $trusteePublicKey = $("#trustee_public_key", $form);
|
13
|
+
|
14
|
+
window.trusteeIdentificationKeys = new IdentificationKeys($trusteeUniqueId.val(), $trusteePublicKey.val());
|
15
|
+
if (!window.trusteeIdentificationKeys.browserSupport) {
|
16
|
+
$("#not_supported_browser").addClass("visible");
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
|
20
|
+
const $submit = $("#submit_identification_keys");
|
21
|
+
const $generate = $("#generate_identification_keys");
|
22
|
+
const $upload = $("#upload_identification_keys");
|
23
|
+
|
24
|
+
$("button", $generate).click(() => {
|
25
|
+
window.trusteeIdentificationKeys.generate().then(() => {
|
26
|
+
$trusteePublicKey.val(JSON.stringify(window.trusteeIdentificationKeys.publicKey));
|
27
|
+
$submit.addClass("visible");
|
28
|
+
}).catch(() => {
|
29
|
+
alert($generate.data("error"))
|
30
|
+
});
|
31
|
+
});
|
32
|
+
|
33
|
+
$("button.hollow", $submit).click(() => {
|
34
|
+
$trusteePublicKey.val("");
|
35
|
+
$submit.removeClass("visible");
|
36
|
+
});
|
37
|
+
|
38
|
+
$("button", $upload).click(() => {
|
39
|
+
window.trusteeIdentificationKeys.upload().then(() => {
|
40
|
+
$upload.addClass("hide");
|
41
|
+
}).catch((errorMessage) => {
|
42
|
+
alert($upload.data(errorMessage));
|
43
|
+
});
|
44
|
+
})
|
45
|
+
|
46
|
+
window.trusteeIdentificationKeys.present((result) => {
|
47
|
+
$upload.toggleClass("hide", result);
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
$(document).ready(() => {
|
52
|
+
identificationKeys()
|
53
|
+
})
|
54
|
+
})
|
@@ -0,0 +1,126 @@
|
|
1
|
+
// = require decidim/bulletin_board/decidim-bulletin_board
|
2
|
+
|
3
|
+
/**
|
4
|
+
* This file is responsible to generate election keys,
|
5
|
+
* create a backup of keys for the trustee and
|
6
|
+
* update the election bulletin board status
|
7
|
+
*/
|
8
|
+
$(() => {
|
9
|
+
const {
|
10
|
+
KeyCeremonyComponent,
|
11
|
+
MessageIdentifier,
|
12
|
+
IdentificationKeys,
|
13
|
+
MESSAGE_RECEIVED
|
14
|
+
} = window.decidimBulletinBoard;
|
15
|
+
|
16
|
+
// UI Elements
|
17
|
+
const $keyCeremony = $(".key-ceremony");
|
18
|
+
const $startButton = $keyCeremony.find(".start");
|
19
|
+
const $backupModal = $("#show-backup-modal");
|
20
|
+
const $backupButton = $backupModal.find(".download-election-keys");
|
21
|
+
const $backButton = $keyCeremony.find(".back");
|
22
|
+
const $restoreModal = $("#show-restore-modal");
|
23
|
+
const $restoreButton = $restoreModal.find(".upload-election-keys");
|
24
|
+
const getStepRow = (step) => {
|
25
|
+
return $(`#${step.replace(".", "-")}`);
|
26
|
+
};
|
27
|
+
|
28
|
+
// Data
|
29
|
+
const bulletinBoardClientParams = {
|
30
|
+
apiEndpointUrl: $keyCeremony.data("apiEndpointUrl")
|
31
|
+
}
|
32
|
+
const electionUniqueId = `${$keyCeremony.data("authorityUniqueId")}.${$keyCeremony.data("electionId")}`
|
33
|
+
const trusteeContext = {
|
34
|
+
uniqueId: $keyCeremony.data("trusteeUniqueId"),
|
35
|
+
publicKeyJSON: JSON.stringify($keyCeremony.data("trusteePublicKey"))
|
36
|
+
};
|
37
|
+
let currentStep = null;
|
38
|
+
const trusteeIdentificationKeys = new IdentificationKeys(
|
39
|
+
trusteeContext.uniqueId,
|
40
|
+
trusteeContext.publicKeyJSON
|
41
|
+
);
|
42
|
+
|
43
|
+
// Use the key ceremony controller and bind all UI events
|
44
|
+
const controller = new KeyCeremonyComponent({
|
45
|
+
bulletinBoardClientParams,
|
46
|
+
electionUniqueId,
|
47
|
+
trusteeUniqueId: trusteeContext.uniqueId,
|
48
|
+
trusteeIdentificationKeys
|
49
|
+
});
|
50
|
+
|
51
|
+
trusteeIdentificationKeys.present(async (exists) => {
|
52
|
+
if (exists) {
|
53
|
+
await controller.bindEvents({
|
54
|
+
onBindRestoreButton(onEventTriggered) {
|
55
|
+
$restoreButton.on("change", ".restore-button-input", onEventTriggered);
|
56
|
+
},
|
57
|
+
onBindStartButton(onEventTriggered) {
|
58
|
+
$startButton.on("click", onEventTriggered);
|
59
|
+
},
|
60
|
+
onBindBackupButton(backupData, backupFilename, onEventTriggered) {
|
61
|
+
$backupButton.attr(
|
62
|
+
"href",
|
63
|
+
`data:text/plain;charset=utf-8,${backupData}`
|
64
|
+
);
|
65
|
+
$backupButton.attr("download", backupFilename);
|
66
|
+
$backupButton.on("click", onEventTriggered);
|
67
|
+
},
|
68
|
+
onSetup() {
|
69
|
+
$startButton.prop("disabled", false);
|
70
|
+
},
|
71
|
+
onEvent(event) {
|
72
|
+
let messageIdentifier = MessageIdentifier.parse(
|
73
|
+
event.message.messageId
|
74
|
+
);
|
75
|
+
|
76
|
+
if (event.type === MESSAGE_RECEIVED) {
|
77
|
+
if (currentStep && currentStep !== messageIdentifier.typeSubtype) {
|
78
|
+
const $previousStep = getStepRow(currentStep);
|
79
|
+
$previousStep.attr("data-step-status", "completed");
|
80
|
+
}
|
81
|
+
currentStep = messageIdentifier.typeSubtype;
|
82
|
+
|
83
|
+
const $currentStep = getStepRow(currentStep);
|
84
|
+
if ($currentStep.data("step-status") !== "completed") {
|
85
|
+
$currentStep.attr("data-step-status", "processing");
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
onRestore() {
|
90
|
+
$restoreModal.foundation("close");
|
91
|
+
},
|
92
|
+
onComplete() {
|
93
|
+
const $allSteps = $(".step_status");
|
94
|
+
$allSteps.attr("data-step-status", "completed");
|
95
|
+
|
96
|
+
$startButton.addClass("hide");
|
97
|
+
$backButton.removeClass("hide");
|
98
|
+
|
99
|
+
$.ajax({
|
100
|
+
method: "PATCH",
|
101
|
+
url: $keyCeremony.data("updateElectionStatusUrl"),
|
102
|
+
contentType: "application/json",
|
103
|
+
data: JSON.stringify({
|
104
|
+
status: "key_ceremony"
|
105
|
+
}),
|
106
|
+
headers: {
|
107
|
+
"X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
|
108
|
+
}
|
109
|
+
});
|
110
|
+
},
|
111
|
+
onStart() {
|
112
|
+
$startButton.prop("disabled", true);
|
113
|
+
},
|
114
|
+
onTrusteeNeedsToBeRestored() {
|
115
|
+
$restoreModal.foundation("open");
|
116
|
+
},
|
117
|
+
onBackupNeeded() {
|
118
|
+
$backupModal.foundation("open");
|
119
|
+
},
|
120
|
+
onBackupStarted() {
|
121
|
+
$backupModal.foundation("close");
|
122
|
+
}
|
123
|
+
});
|
124
|
+
}
|
125
|
+
});
|
126
|
+
});
|
@@ -0,0 +1,104 @@
|
|
1
|
+
// = require decidim/bulletin_board/decidim-bulletin_board
|
2
|
+
|
3
|
+
$(() => {
|
4
|
+
const { TallyComponent, IdentificationKeys, MessageIdentifier, MESSAGE_RECEIVED } = window.decidimBulletinBoard;
|
5
|
+
|
6
|
+
// UI Elements
|
7
|
+
const $tally = $(".tally");
|
8
|
+
const $startButton = $tally.find(".start");
|
9
|
+
const getStepRow = (step) => {
|
10
|
+
return $(`#${step.replace(".", "-")}`);
|
11
|
+
};
|
12
|
+
const $restoreModal = $("#show-restore-modal");
|
13
|
+
const $restoreButton = $restoreModal.find(".upload-election-keys");
|
14
|
+
const $backButton = $tally.find(".back");
|
15
|
+
|
16
|
+
// Data
|
17
|
+
const bulletinBoardClientParams = {
|
18
|
+
apiEndpointUrl: $tally.data("apiEndpointUrl")
|
19
|
+
};
|
20
|
+
const electionUniqueId = `${$tally.data("authorityUniqueId")}.${$tally.data("electionId")}`
|
21
|
+
const trusteeContext = {
|
22
|
+
uniqueId: $tally.data("trusteeUniqueId"),
|
23
|
+
publicKeyJSON: JSON.stringify($tally.data("trusteePublicKey"))
|
24
|
+
};
|
25
|
+
const trusteeIdentificationKeys = new IdentificationKeys(
|
26
|
+
trusteeContext.uniqueId,
|
27
|
+
trusteeContext.publicKeyJSON
|
28
|
+
);
|
29
|
+
let currentStep = null;
|
30
|
+
|
31
|
+
// Use the tally component and bind all UI events
|
32
|
+
const component = new TallyComponent({
|
33
|
+
bulletinBoardClientParams,
|
34
|
+
electionUniqueId,
|
35
|
+
trusteeUniqueId: trusteeContext.uniqueId,
|
36
|
+
trusteeIdentificationKeys
|
37
|
+
});
|
38
|
+
|
39
|
+
const bindComponentEvents = async () => {
|
40
|
+
await component.bindEvents({
|
41
|
+
onEvent(event) {
|
42
|
+
let messageIdentifier = MessageIdentifier.parse(
|
43
|
+
event.message.messageId
|
44
|
+
);
|
45
|
+
|
46
|
+
if (event.type === MESSAGE_RECEIVED) {
|
47
|
+
if (currentStep && currentStep !== messageIdentifier.typeSubtype) {
|
48
|
+
const $previousStep = getStepRow(currentStep);
|
49
|
+
$previousStep.attr("data-step-status", "completed");
|
50
|
+
}
|
51
|
+
currentStep = messageIdentifier.typeSubtype;
|
52
|
+
|
53
|
+
const $currentStep = getStepRow(currentStep);
|
54
|
+
if ($currentStep.data("step-status") !== "completed") {
|
55
|
+
$currentStep.attr("data-step-status", "processing");
|
56
|
+
}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
onSetup() {
|
60
|
+
$startButton.prop("disabled", false);
|
61
|
+
},
|
62
|
+
onBindStartButton(onEventTriggered) {
|
63
|
+
$startButton.on("click", onEventTriggered);
|
64
|
+
},
|
65
|
+
onStart() {
|
66
|
+
$startButton.prop("disabled", true);
|
67
|
+
},
|
68
|
+
onComplete() {
|
69
|
+
const $allSteps = $(".step_status");
|
70
|
+
$allSteps.attr("data-step-status", "completed");
|
71
|
+
|
72
|
+
$startButton.addClass("hide");
|
73
|
+
$backButton.removeClass("hide");
|
74
|
+
|
75
|
+
$.ajax({
|
76
|
+
method: "PATCH",
|
77
|
+
url: $tally.data("updateElectionStatusUrl"),
|
78
|
+
contentType: "application/json",
|
79
|
+
data: JSON.stringify({
|
80
|
+
status: "tally"
|
81
|
+
}),
|
82
|
+
headers: {
|
83
|
+
"X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
|
84
|
+
}
|
85
|
+
});
|
86
|
+
},
|
87
|
+
onTrusteeNeedsToBeRestored() {
|
88
|
+
$restoreModal.foundation("open");
|
89
|
+
},
|
90
|
+
onBindRestoreButton(onEventTriggered) {
|
91
|
+
$restoreButton.on("change", ".restore-button-input", onEventTriggered);
|
92
|
+
},
|
93
|
+
onRestore() {
|
94
|
+
$restoreModal.foundation("close");
|
95
|
+
}
|
96
|
+
});
|
97
|
+
};
|
98
|
+
|
99
|
+
trusteeIdentificationKeys.present(async (exists) => {
|
100
|
+
if (exists) {
|
101
|
+
await bindComponentEvents();
|
102
|
+
}
|
103
|
+
});
|
104
|
+
});
|
@@ -1,170 +1,117 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
$(() => {
|
5
|
-
const
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
function setCurrentStep() {
|
26
|
-
$currentStep = $vote.find(".focus__step:visible")
|
27
|
-
setSelections();
|
28
|
-
onSelectionChange();
|
29
|
-
}
|
30
|
-
|
31
|
-
function setSelections() {
|
32
|
-
$currentStepMaxSelection = $currentStep.find(".evote__options").data("max-selection")
|
33
|
-
}
|
1
|
+
// = require decidim/bulletin_board/decidim-bulletin_board
|
2
|
+
// = require ./vote_questions.component
|
3
|
+
|
4
|
+
$(async () => {
|
5
|
+
const { VoteQuestionsComponent } = window.Decidim;
|
6
|
+
const { VoteComponent } = window.decidimBulletinBoard;
|
7
|
+
|
8
|
+
// UI Elements
|
9
|
+
const $voteWrapper = $(".vote-wrapper");
|
10
|
+
|
11
|
+
// Data
|
12
|
+
const bulletinBoardClientParams = {
|
13
|
+
apiEndpointUrl: $voteWrapper.data("apiEndpointUrl")
|
14
|
+
};
|
15
|
+
const electionUniqueId = $voteWrapper.data("electionUniqueId");
|
16
|
+
const voterUniqueId = $voteWrapper.data("voterId");
|
17
|
+
|
18
|
+
// Use the questions component
|
19
|
+
const questionsComponent = new VoteQuestionsComponent($voteWrapper);
|
20
|
+
questionsComponent.init();
|
21
|
+
$(document).on("on.zf.toggler", () => {
|
22
|
+
// continue and back btn
|
23
|
+
questionsComponent.init()
|
24
|
+
});
|
34
25
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
});
|
42
|
-
}
|
26
|
+
// Use the voter component and bind all UI events
|
27
|
+
const voteComponent = new VoteComponent({
|
28
|
+
bulletinBoardClientParams,
|
29
|
+
electionUniqueId,
|
30
|
+
voterUniqueId
|
31
|
+
});
|
43
32
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
33
|
+
await voteComponent.bindEvents({
|
34
|
+
onSetup() {},
|
35
|
+
onBindStartButton(onEventTriggered) {
|
36
|
+
$(".button.confirm").on("click", onEventTriggered);
|
37
|
+
},
|
38
|
+
onStart() {},
|
39
|
+
onVoteValidation(validVoteFn) {
|
40
|
+
const getFormData = (formData) => {
|
41
|
+
return formData.serializeArray().reduce((acc, {name, value}) => {
|
42
|
+
if (!acc[name]) {
|
43
|
+
acc[name] = [];
|
44
|
+
}
|
45
|
+
acc[name] = [...acc[name], value];
|
46
|
+
return acc;
|
47
|
+
}, {"ballot_style": "unique"});
|
49
48
|
}
|
50
|
-
});
|
51
|
-
|
52
|
-
$("[data-disable-check]").on("change", function() {
|
53
|
-
let checkId = $(this).attr("id");
|
54
|
-
let checkStatus = this.checked;
|
55
49
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
const formData = getFormData($voteWrapper.find(".answer_input"));
|
51
|
+
validVoteFn(formData);
|
52
|
+
},
|
53
|
+
async onVoteEncrypted({encryptedVote, encryptedVoteHash}) {
|
54
|
+
const simulatePreviewDelay = () => {
|
55
|
+
return new Promise((resolve) => setTimeout(resolve, 500));
|
56
|
+
};
|
57
|
+
const isPreview = $voteWrapper.data("booth-mode") === "preview";
|
58
|
+
|
59
|
+
await $.ajax({
|
60
|
+
method: "POST",
|
61
|
+
url: $voteWrapper.data("castVoteUrl"),
|
62
|
+
contentType: "application/json",
|
63
|
+
data: JSON.stringify({ encrypted_vote: encryptedVote, encrypted_vote_hash: encryptedVoteHash }), // eslint-disable-line camelcase
|
64
|
+
headers: {
|
65
|
+
"X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
|
62
66
|
}
|
63
|
-
|
64
|
-
$(this).find("input[type=checkbox]").attr("aria-disabled", checkStatus);
|
65
67
|
});
|
66
|
-
});
|
67
|
-
}
|
68
|
-
|
69
|
-
function toggleContinueButton() {
|
70
|
-
if (checkAnswers() === true) {
|
71
|
-
// next step enabled
|
72
|
-
$($continueButton).addClass("show").removeClass("hide")
|
73
|
-
$($continueSpan).addClass("hide").removeClass("show")
|
74
|
-
} else {
|
75
|
-
// next step disabled
|
76
|
-
$($continueButton).addClass("hide").removeClass("show")
|
77
|
-
$($continueSpan).addClass("show").removeClass("hide")
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
// check if answers are correctly checked
|
82
|
-
function checkAnswers() {
|
83
|
-
let currentAnswersChecked = $("#" + $currentStep.attr("id") + " .answer_input:checked").length
|
84
|
-
let notaAnswerChecked = $("#" + $currentStep.attr("id") + " .nota_input:checked").length
|
85
|
-
|
86
|
-
if ((currentAnswersChecked >= 1 || notaAnswerChecked > 0) && (currentAnswersChecked <= $currentStepMaxSelection)) {
|
87
|
-
return true;
|
88
|
-
}
|
89
|
-
|
90
|
-
return false;
|
91
|
-
}
|
92
|
-
|
93
|
-
// receive confirmed answers
|
94
|
-
function toggleConfirmAnswers() {
|
95
|
-
$(".answer_input:checked").each(function() {
|
96
|
-
let confirmedAnswer = $(".evote__confirm").find("#" + this.value);
|
97
|
-
$(confirmedAnswer).removeClass("hide")
|
98
|
-
})
|
99
|
-
|
100
|
-
$(".answer_input").not(":checked").each(function() {
|
101
|
-
let confirmedAnswer = $(".evote__confirm").find("#" + this.value);
|
102
|
-
$(confirmedAnswer).addClass("hide")
|
103
|
-
})
|
104
68
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
}, 3000)
|
149
|
-
}
|
150
|
-
|
151
|
-
// exit message before confirming
|
152
|
-
const $form = $(".evote__options");
|
153
|
-
if ($form.length > 0) {
|
154
|
-
|
155
|
-
window.onbeforeunload = () => {
|
156
|
-
const voteCast = window.confirmed;
|
157
|
-
|
158
|
-
if (voteCast) {
|
159
|
-
return null;
|
69
|
+
if (isPreview) {
|
70
|
+
await simulatePreviewDelay();
|
71
|
+
$voteWrapper.find("#encrypting").addClass("hide");
|
72
|
+
$voteWrapper.find("#confirmed_page").removeClass("hide");
|
73
|
+
$voteWrapper.find(".vote-confirmed-result").hide();
|
74
|
+
questionsComponent.voteCasted = true;
|
75
|
+
await simulatePreviewDelay()
|
76
|
+
$voteWrapper.find(".vote-confirmed-processing").hide();
|
77
|
+
$voteWrapper.find(".vote-confirmed-result").show();
|
78
|
+
} else {
|
79
|
+
const messageId = $voteWrapper.find(".vote-confirmed-result").data("messageId");
|
80
|
+
const voteId = $voteWrapper.find(".vote-confirmed-result").data("voteId");
|
81
|
+
const pendingMessage = await voteComponent.bulletinBoardClient.waitForPendingMessageToBeProcessed(messageId);
|
82
|
+
|
83
|
+
await $.ajax({
|
84
|
+
method: "PATCH",
|
85
|
+
url: $voteWrapper.data("updateVoteStatusUrl"),
|
86
|
+
contentType: "application/json",
|
87
|
+
data: JSON.stringify({ vote_id: voteId }), // eslint-disable-line camelcase
|
88
|
+
headers: {
|
89
|
+
"X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
if (pendingMessage.status === "accepted") {
|
94
|
+
$voteWrapper.find("#encrypting").addClass("hide");
|
95
|
+
$voteWrapper.find("#confirmed_page").removeClass("hide");
|
96
|
+
$voteWrapper.find(".vote-confirmed-result").hide();
|
97
|
+
questionsComponent.voteCasted = true;
|
98
|
+
|
99
|
+
const logEntry = await voteComponent.voter.verifyVote(encryptedVoteHash);
|
100
|
+
|
101
|
+
if (logEntry) {
|
102
|
+
$voteWrapper.find(".vote-confirmed-processing").hide();
|
103
|
+
$voteWrapper.find(".vote-confirmed-result").show();
|
104
|
+
} else {
|
105
|
+
const $error = $voteWrapper.find(".vote-confirmed-result").data("error");
|
106
|
+
alert($error); // eslint-disable-line no-alert
|
107
|
+
}
|
108
|
+
} else {
|
109
|
+
const $error = $voteWrapper.find(".vote-confirmed-result").data("error");
|
110
|
+
alert($error); // eslint-disable-line no-alert
|
111
|
+
}
|
160
112
|
}
|
161
|
-
|
162
|
-
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
$(document).on("on.zf.toggler", (event) => {
|
167
|
-
// continue and back btn
|
168
|
-
initStep()
|
113
|
+
},
|
114
|
+
onComplete() {},
|
115
|
+
onInvalid() {}
|
169
116
|
});
|
170
117
|
});
|