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
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Decidim.register_participatory_space(:votings) do |participatory_space|
|
4
|
+
participatory_space.icon = "decidim/votings/icon.svg"
|
5
|
+
participatory_space.model_class_name = "Decidim::Votings::Voting"
|
6
|
+
participatory_space.permissions_class_name = "Decidim::Votings::Permissions"
|
7
|
+
participatory_space.stylesheet = "decidim/votings/votings"
|
8
|
+
participatory_space.query_type = "Decidim::Votings::VotingType"
|
9
|
+
|
10
|
+
participatory_space.participatory_spaces do |organization|
|
11
|
+
Decidim::Votings::Voting.where(organization: organization)
|
12
|
+
end
|
13
|
+
|
14
|
+
participatory_space.register_resource(:voting) do |resource|
|
15
|
+
resource.model_class_name = "Decidim::Votings::Voting"
|
16
|
+
resource.card = "decidim/votings/voting"
|
17
|
+
resource.searchable = true
|
18
|
+
end
|
19
|
+
|
20
|
+
participatory_space.context(:public) do |context|
|
21
|
+
context.engine = Decidim::Votings::Engine
|
22
|
+
context.layout = "layouts/decidim/votings"
|
23
|
+
context.helper = "Decidim::Votings::ApplicationHelper"
|
24
|
+
end
|
25
|
+
|
26
|
+
participatory_space.context(:admin) do |context|
|
27
|
+
context.engine = Decidim::Votings::AdminEngine
|
28
|
+
context.layout = "layouts/decidim/admin/voting"
|
29
|
+
end
|
30
|
+
|
31
|
+
participatory_space.exports :votings do |export|
|
32
|
+
export.collection do |voting|
|
33
|
+
Decidim::Votings::Voting.where(id: voting.id)
|
34
|
+
end
|
35
|
+
|
36
|
+
export.include_in_open_data = true
|
37
|
+
|
38
|
+
export.serializer Decidim::Votings::VotingSerializer
|
39
|
+
end
|
40
|
+
|
41
|
+
participatory_space.seeds do
|
42
|
+
organization = Decidim::Organization.first
|
43
|
+
seeds_root = File.join(__dir__, "..", "..", "..", "db", "seeds")
|
44
|
+
|
45
|
+
3.times do |n|
|
46
|
+
params = {
|
47
|
+
organization: organization,
|
48
|
+
title: Decidim::Faker::Localized.sentence(word_count: 5),
|
49
|
+
slug: Decidim::Faker::Internet.unique.slug(words: nil, glue: "-"),
|
50
|
+
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
51
|
+
Decidim::Faker::Localized.paragraph(sentence_count: 3)
|
52
|
+
end,
|
53
|
+
scope: n.positive? ? nil : Decidim::Scope.reorder(Arel.sql("RANDOM()")).first,
|
54
|
+
banner_image: File.new(File.join(seeds_root, "city.jpeg")),
|
55
|
+
published_at: 2.weeks.ago,
|
56
|
+
start_time: n.weeks.from_now,
|
57
|
+
end_time: (n + 1).weeks.from_now + 4.hours,
|
58
|
+
voting_type: Decidim::Votings::Voting.voting_types.values.sample,
|
59
|
+
promoted: n.odd?
|
60
|
+
}
|
61
|
+
|
62
|
+
voting = Decidim.traceability.perform_action!(
|
63
|
+
"publish",
|
64
|
+
Decidim::Votings::Voting,
|
65
|
+
organization.users.first,
|
66
|
+
visibility: "all"
|
67
|
+
) do
|
68
|
+
Decidim::Votings::Voting.create!(params)
|
69
|
+
end
|
70
|
+
voting.add_to_index_as_search_resource
|
71
|
+
|
72
|
+
landing_page_content_blocks = [:header, :description, :elections, :polling_stations, :attachments_and_folders, :stats, :metrics]
|
73
|
+
|
74
|
+
landing_page_content_blocks.each.with_index(1) do |manifest_name, index|
|
75
|
+
Decidim::ContentBlock.create(
|
76
|
+
organization: organization,
|
77
|
+
scope_name: :voting_landing_page,
|
78
|
+
manifest_name: manifest_name,
|
79
|
+
weight: index,
|
80
|
+
scoped_resource_id: voting.id,
|
81
|
+
published_at: Time.current
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
Decidim.register_global_engine(
|
89
|
+
:decidim_votings_polling_officer_zone,
|
90
|
+
Decidim::Votings::PollingOfficerZoneEngine,
|
91
|
+
at: "/polling_officers"
|
92
|
+
)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
# This is the engine that runs on the public interface for polling officers of `decidim-elections`.
|
6
|
+
# It mostly handles rendering the polling officers frontend zone.
|
7
|
+
class PollingOfficerZoneEngine < ::Rails::Engine
|
8
|
+
isolate_namespace Decidim::Votings::PollingOfficerZone
|
9
|
+
|
10
|
+
paths["db/migrate"] = nil
|
11
|
+
paths["lib/tasks"] = nil
|
12
|
+
|
13
|
+
routes do
|
14
|
+
resource :polling_officers, path: "/", only: [:show] do
|
15
|
+
resources :polling_stations, only: [:show]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_seed
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
initializer "decidim_elections.polling_officer_zone.menu" do
|
24
|
+
Decidim.menu :user_menu do |menu|
|
25
|
+
menu.item I18n.t("menu.polling_officer_zone", scope: "decidim.votings.polling_officer_zone"),
|
26
|
+
decidim.decidim_votings_polling_officer_zone_path,
|
27
|
+
active: :inclusive,
|
28
|
+
if: Decidim::Votings::PollingOfficer.polling_officer?(current_user)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
# This module's job is to extend the API with custom fields related to
|
6
|
+
# decidim-votings.
|
7
|
+
module QueryExtensions
|
8
|
+
# Public: Extends a type with `decidim-votings`'s fields.
|
9
|
+
#
|
10
|
+
# type - A GraphQL::BaseType to extend.
|
11
|
+
#
|
12
|
+
# Returns nothing.
|
13
|
+
def self.included(type)
|
14
|
+
type.field :votings,
|
15
|
+
[Decidim::Votings::VotingType],
|
16
|
+
null: true,
|
17
|
+
description: "Lists all votings" do
|
18
|
+
argument :filter, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputFilter, "This argument let's you filter the results", required: false
|
19
|
+
argument :order, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputSort, "This argument let's you order the results", required: false
|
20
|
+
end
|
21
|
+
|
22
|
+
type.field :voting,
|
23
|
+
Decidim::Votings::VotingType,
|
24
|
+
null: true,
|
25
|
+
description: "Finds a voting" do
|
26
|
+
argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def votings(filter: {}, order: {})
|
31
|
+
manifest = Decidim.participatory_space_manifests.select { |m| m.name == :votings }.first
|
32
|
+
|
33
|
+
Decidim::Core::ParticipatorySpaceListBase.new(manifest: manifest).call(object, { filter: filter, order: order }, context)
|
34
|
+
end
|
35
|
+
|
36
|
+
def voting(id: nil)
|
37
|
+
manifest = Decidim.participatory_space_manifests.select { |m| m.name == :votings }.first
|
38
|
+
|
39
|
+
Decidim::Core::ParticipatorySpaceFinderBase.new(manifest: manifest).call(object, { id: id }, context)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/dev/test/rspec_support/capybara_data_picker"
|
4
|
+
|
5
|
+
module Capybara
|
6
|
+
module PollingOfficersPicker
|
7
|
+
include DataPicker
|
8
|
+
|
9
|
+
RSpec::Matchers.define :have_polling_officers_picked do |expected|
|
10
|
+
match do |polling_officers_picker|
|
11
|
+
data_picker = polling_officers_picker.data_picker
|
12
|
+
|
13
|
+
expected.each do |polling_officer|
|
14
|
+
expect(data_picker).to have_selector(".picker-values div input[value='#{polling_officer.id}']", visible: :all)
|
15
|
+
expect(data_picker).to have_selector(:xpath, "//div[contains(@class,'picker-values')]/div/a[text()[contains(.,\"#{translated(polling_officer.name)}\")]]")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec::Matchers.define :have_polling_officers_not_picked do |expected|
|
21
|
+
match do |polling_officers_picker|
|
22
|
+
data_picker = polling_officers_picker.data_picker
|
23
|
+
|
24
|
+
expected.each do |polling_officer|
|
25
|
+
expect(data_picker).not_to have_selector(".picker-values div input[value='#{polling_officer.id}']", visible: :all)
|
26
|
+
expect(data_picker).not_to have_selector(:xpath, "//div[contains(@class,'picker-values')]/div/a[text()[contains(.,\"#{translated(polling_officer.name)}\")]]")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def polling_officers_pick(polling_officers_picker, polling_officers)
|
32
|
+
data_picker = polling_officers_picker.data_picker
|
33
|
+
|
34
|
+
expect(data_picker).to have_selector(".picker-prompt")
|
35
|
+
data_picker.find(".picker-prompt").click
|
36
|
+
|
37
|
+
polling_officers.each do |polling_officer|
|
38
|
+
data_picker_choose_value(polling_officer.id)
|
39
|
+
end
|
40
|
+
data_picker_close
|
41
|
+
|
42
|
+
expect(polling_officers_picker).to have_polling_officers_picked(polling_officers)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
RSpec.configure do |config|
|
48
|
+
config.include Capybara::PollingOfficersPicker, type: :system
|
49
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/core/test/factories"
|
4
|
+
require "decidim/forms/test/factories"
|
5
|
+
|
6
|
+
FactoryBot.define do
|
7
|
+
sequence(:voting_slug) do |n|
|
8
|
+
"#{Decidim::Faker::Internet.slug(words: nil, glue: "-")}-#{n}"
|
9
|
+
end
|
10
|
+
|
11
|
+
factory :voting, class: "Decidim::Votings::Voting" do
|
12
|
+
organization
|
13
|
+
slug { generate(:voting_slug) }
|
14
|
+
title { generate_localized_title }
|
15
|
+
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
16
|
+
published_at { Time.current }
|
17
|
+
start_time { 1.day.from_now }
|
18
|
+
end_time { 3.days.from_now }
|
19
|
+
decidim_scope_id { create(:scope, organization: organization).id }
|
20
|
+
banner_image { Decidim::Dev.test_file("city2.jpeg", "image/jpeg") }
|
21
|
+
introductory_image { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
|
22
|
+
voting_type { "hybrid" }
|
23
|
+
|
24
|
+
trait :unpublished do
|
25
|
+
published_at { nil }
|
26
|
+
end
|
27
|
+
|
28
|
+
trait :published do
|
29
|
+
published_at { Time.current }
|
30
|
+
end
|
31
|
+
|
32
|
+
trait :upcoming do
|
33
|
+
start_time { 7.days.from_now }
|
34
|
+
end_time { 1.month.from_now + 7.days }
|
35
|
+
end
|
36
|
+
|
37
|
+
trait :ongoing do
|
38
|
+
start_time { 7.days.ago }
|
39
|
+
end_time { 1.month.from_now - 7.days }
|
40
|
+
end
|
41
|
+
|
42
|
+
trait :finished do
|
43
|
+
start_time { 1.month.ago - 7.days }
|
44
|
+
end_time { 7.days.ago }
|
45
|
+
end
|
46
|
+
|
47
|
+
trait :promoted do
|
48
|
+
promoted { true }
|
49
|
+
end
|
50
|
+
|
51
|
+
trait :online do
|
52
|
+
voting_type { "online" }
|
53
|
+
end
|
54
|
+
|
55
|
+
trait :in_person do
|
56
|
+
voting_type { "in_person" }
|
57
|
+
end
|
58
|
+
|
59
|
+
trait :hybrid do
|
60
|
+
voting_type { "hybrid" }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
factory :polling_station, class: "Decidim::Votings::PollingStation" do
|
65
|
+
title { generate_localized_title }
|
66
|
+
location { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
67
|
+
location_hints { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
|
68
|
+
address { Faker::Lorem.sentence(word_count: 3) }
|
69
|
+
latitude { Faker::Address.latitude }
|
70
|
+
longitude { Faker::Address.longitude }
|
71
|
+
voting { create(:voting) }
|
72
|
+
end
|
73
|
+
|
74
|
+
factory :polling_officer, class: "Decidim::Votings::PollingOfficer" do
|
75
|
+
user { create :user, organization: voting.organization }
|
76
|
+
voting { create :voting }
|
77
|
+
end
|
78
|
+
|
79
|
+
factory :monitoring_committee_member, class: "Decidim::Votings::MonitoringCommitteeMember" do
|
80
|
+
user
|
81
|
+
voting { create :voting, organization: user.organization }
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
# This class serializes a Voting so it can be exported to CSV, JSON or other
|
6
|
+
# formats.
|
7
|
+
class VotingSerializer < Decidim::Exporters::Serializer
|
8
|
+
include Decidim::ApplicationHelper
|
9
|
+
include Decidim::ResourceHelper
|
10
|
+
include Decidim::TranslationsHelper
|
11
|
+
|
12
|
+
# Public: Initializes the serializer with a voting.
|
13
|
+
def initialize(voting)
|
14
|
+
@voting = voting
|
15
|
+
end
|
16
|
+
|
17
|
+
# Public: Exports a hash with the serialized data for this voting.
|
18
|
+
def serialize
|
19
|
+
{
|
20
|
+
participatory_space_id: voting.id,
|
21
|
+
url: url,
|
22
|
+
title: voting.title,
|
23
|
+
description: voting.description,
|
24
|
+
start_time: voting.start_time.to_s(:db),
|
25
|
+
end_time: voting.end_time.to_s(:db),
|
26
|
+
voting_type: translated_voting_type,
|
27
|
+
scope: {
|
28
|
+
id: voting.scope.try(:id),
|
29
|
+
name: voting.scope.try(:name)
|
30
|
+
},
|
31
|
+
banner_image_url: Decidim::Votings::VotingPresenter.new(voting).banner_image_url,
|
32
|
+
introductory_image_url: Decidim::Votings::VotingPresenter.new(voting).introductory_image_url
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :voting
|
39
|
+
|
40
|
+
def translated_voting_type
|
41
|
+
translation_hash = {}
|
42
|
+
voting.organization.available_locales.each do |locale|
|
43
|
+
translation_hash[locale] = I18n.t(voting.voting_type, scope: "decidim.votings.admin.votings.form.voting_type")
|
44
|
+
end
|
45
|
+
|
46
|
+
translation_hash
|
47
|
+
end
|
48
|
+
|
49
|
+
def url
|
50
|
+
Decidim::Votings::Engine.routes.url_helpers.voting_url(host: voting.organization.host, slug: voting.slug)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,16 +1,79 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
namespace :decidim_elections do
|
4
|
-
desc "Add a new client to the bulletin board"
|
5
|
-
|
6
4
|
IDENTIFICATION_PRIVATE_KEY_SIZE = 4096
|
7
5
|
|
6
|
+
desc "Add a new client to the bulletin board"
|
8
7
|
task :generate_identification_keys do
|
9
|
-
|
8
|
+
identification_jwk_keypair = JWT::JWK.new(OpenSSL::PKey::RSA.new(IDENTIFICATION_PRIVATE_KEY_SIZE))
|
10
9
|
|
11
|
-
puts
|
10
|
+
puts "\nPRIVATE KEY:"
|
11
|
+
puts "\n"
|
12
|
+
puts Decidim::BulletinBoard::JwkUtils.private_export(identification_jwk_keypair).to_json
|
12
13
|
puts "\n"
|
13
|
-
puts
|
14
|
+
puts "PUBLIC KEY:"
|
15
|
+
puts "\n"
|
16
|
+
puts identification_jwk_keypair.export.map { |k, v| "#{k}=#{v}" }.join("&")
|
14
17
|
puts "\nAbove are the generated private and public keys.\n\nSee Decidim docs at docs/services/bulletin_board.md in order to set them up.\n\n"
|
15
18
|
end
|
19
|
+
|
20
|
+
desc "Scheduled tasks"
|
21
|
+
task :scheduled_tasks, [] => :environment do
|
22
|
+
Decidim::Elections::ElectionsReadyToStart.for.each do |election|
|
23
|
+
puts "\nStarting vote period for election ##{election.id}:"
|
24
|
+
form = Decidim::Elections::Admin::VotePeriodForm.new.with_context(election: election, current_user: nil)
|
25
|
+
Decidim::Elections::Admin::StartVote.call(form) do
|
26
|
+
on(:ok) do
|
27
|
+
puts "\n✓ Voting period start requested.\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
on(:invalid) do |message|
|
31
|
+
puts "\n✗ Voting period not started. Message: #{message}\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
puts "\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
Decidim::Elections::ElectionsFinishedToEnd.for.each do |election|
|
38
|
+
puts "\nEnding vote period for election ##{election.id}:"
|
39
|
+
form = Decidim::Elections::Admin::VotePeriodForm.new.with_context(election: election, current_user: nil)
|
40
|
+
Decidim::Elections::Admin::EndVote.call(form) do
|
41
|
+
on(:ok) do
|
42
|
+
puts "\n✓ Voting period end requested.\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
on(:invalid) do |message|
|
46
|
+
puts "\n✗ Voting period not ended. Message: #{message}\n"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
puts "\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
Decidim::Elections::Votes::PendingVotes.for.each do |vote|
|
53
|
+
puts "\nChecking status for Vote ##{vote.id}:"
|
54
|
+
Decidim::Elections::Voter::UpdateVoteStatus.call(vote) do
|
55
|
+
on(:ok) do
|
56
|
+
puts "\n✓ Vote status updated\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
on(:invalid) do |message|
|
60
|
+
puts "\n✗ Vote status failed. Message: #{message}\n"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
puts "\n"
|
64
|
+
end
|
65
|
+
|
66
|
+
Decidim::Elections::Admin::PendingActions.for.each do |action|
|
67
|
+
puts "\nChecking status for action '#{action.action}' for election ##{action.election.id}:"
|
68
|
+
Decidim::Elections::Admin::UpdateActionStatus.call(action) do
|
69
|
+
on(:ok) do
|
70
|
+
puts "\n✓ Action status updated\n"
|
71
|
+
end
|
72
|
+
on(:invalid) do |message|
|
73
|
+
puts "\n✗ Update status failed. Message: #{message}\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
puts "\n"
|
77
|
+
end
|
78
|
+
end
|
16
79
|
end
|