decidim-elections 0.23.3 → 0.24.0.rc1
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/_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 +43 -18
- 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 +39 -6
- data/config/locales/cs.yml +640 -6
- data/config/locales/de.yml +635 -6
- data/config/locales/el.yml +0 -2
- data/config/locales/en.yml +636 -6
- data/config/locales/es-MX.yml +6 -10
- data/config/locales/es-PY.yml +6 -10
- data/config/locales/es.yml +6 -10
- data/config/locales/fi-plain.yml +635 -6
- data/config/locales/fi.yml +635 -6
- data/config/locales/fr-CA.yml +422 -6
- data/config/locales/fr.yml +422 -6
- data/config/locales/gl.yml +63 -6
- data/config/locales/it.yml +97 -6
- data/config/locales/ja.yml +8 -6
- data/config/locales/lv.yml +0 -2
- data/config/locales/nl.yml +498 -6
- data/config/locales/no.yml +0 -5
- data/config/locales/pl.yml +579 -9
- data/config/locales/pt.yml +0 -6
- data/config/locales/ro-RO.yml +0 -6
- data/config/locales/sv.yml +7 -6
- data/config/locales/tr-TR.yml +114 -6
- data/config/locales/zh-CN.yml +0 -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 +304 -21
- 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,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Elections
|
5
|
+
module Voter
|
6
|
+
# This command updates the vote status and sends a notification.
|
7
|
+
class UpdateVoteStatus < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# message_id - the message_id to find a pending_message that is related to a vote.
|
11
|
+
def initialize(vote)
|
12
|
+
@vote = vote
|
13
|
+
end
|
14
|
+
|
15
|
+
# Update status and send notification
|
16
|
+
#
|
17
|
+
# Broadcasts :ok if successful, :invalid otherwise
|
18
|
+
def call
|
19
|
+
return broadcast(:ok) unless status_changed?
|
20
|
+
|
21
|
+
transaction do
|
22
|
+
update_vote_status
|
23
|
+
send_vote_notification
|
24
|
+
end
|
25
|
+
|
26
|
+
broadcast(:ok)
|
27
|
+
rescue StandardError => e
|
28
|
+
broadcast(:invalid, e.message)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :vote
|
34
|
+
|
35
|
+
def status_changed?
|
36
|
+
vote.status != vote_status
|
37
|
+
end
|
38
|
+
|
39
|
+
def bulletin_board
|
40
|
+
@bulletin_board ||= Decidim::Elections.bulletin_board
|
41
|
+
end
|
42
|
+
|
43
|
+
def vote_status
|
44
|
+
@vote_status ||= bulletin_board.get_pending_message_status(vote.message_id)
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_vote_status
|
48
|
+
vote.status = vote_status
|
49
|
+
vote.save!
|
50
|
+
end
|
51
|
+
|
52
|
+
def send_vote_notification
|
53
|
+
return unless vote.accepted?
|
54
|
+
|
55
|
+
data = {
|
56
|
+
event: "decidim.events.elections.votes.accepted_votes",
|
57
|
+
event_class: Decidim::Elections::Votes::VoteAcceptedEvent,
|
58
|
+
resource: vote.election,
|
59
|
+
affected_users: [vote.user],
|
60
|
+
extra: {
|
61
|
+
vote: vote
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
Decidim::EventsManager.publish(data)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
module Admin
|
6
|
+
# A command with the business logic to create a new monitoring committee member
|
7
|
+
class CreateMonitoringCommitteeMember < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params
|
11
|
+
# current_user - The user creating the monitoring committee member
|
12
|
+
# voting - The Voting that will hold the monitoring committee member
|
13
|
+
def initialize(form, current_user, voting)
|
14
|
+
@form = form
|
15
|
+
@current_user = current_user
|
16
|
+
@voting = voting
|
17
|
+
end
|
18
|
+
|
19
|
+
# Executes the command. Broadcasts these events:
|
20
|
+
#
|
21
|
+
# - :ok when everything is valid.
|
22
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
23
|
+
#
|
24
|
+
# Returns nothing.
|
25
|
+
def call
|
26
|
+
return broadcast(:invalid) if form.invalid?
|
27
|
+
|
28
|
+
ActiveRecord::Base.transaction do
|
29
|
+
user = retrieve_or_invite_user
|
30
|
+
create_monitoring_committee_member(user)
|
31
|
+
end
|
32
|
+
|
33
|
+
broadcast(:ok)
|
34
|
+
rescue ActiveRecord::RecordInvalid
|
35
|
+
form.errors.add(:email, :taken)
|
36
|
+
broadcast(:invalid)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :form, :voting, :current_user
|
42
|
+
|
43
|
+
def retrieve_or_invite_user
|
44
|
+
form.user || existing_user || new_user
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_monitoring_committee_member(user)
|
48
|
+
Decidim.traceability.perform_action!(
|
49
|
+
:create,
|
50
|
+
Decidim::Votings::MonitoringCommitteeMember,
|
51
|
+
current_user,
|
52
|
+
resource: {
|
53
|
+
title: user.name
|
54
|
+
}
|
55
|
+
) do
|
56
|
+
Decidim::Votings::MonitoringCommitteeMember.find_or_create_by!(
|
57
|
+
user: user,
|
58
|
+
voting: voting
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def existing_user
|
64
|
+
@existing_user ||= begin
|
65
|
+
tentative_user = User.find_by(
|
66
|
+
email: form.email,
|
67
|
+
organization: voting.organization
|
68
|
+
)
|
69
|
+
|
70
|
+
InviteUserAgain.call(tentative_user, invitation_instructions) if tentative_user && !tentative_user.invitation_accepted?
|
71
|
+
|
72
|
+
tentative_user
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def new_user
|
77
|
+
@new_user ||= InviteUser.call(invite_user_form) do
|
78
|
+
on(:ok) do |invited_user|
|
79
|
+
return invited_user
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def invite_user_form
|
85
|
+
OpenStruct.new(name: form.name,
|
86
|
+
email: form.email.downcase,
|
87
|
+
organization: voting.organization,
|
88
|
+
admin: false,
|
89
|
+
invited_by: current_user,
|
90
|
+
invitation_instructions: invitation_instructions)
|
91
|
+
end
|
92
|
+
|
93
|
+
def invitation_instructions
|
94
|
+
"invite_collaborator"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
module Admin
|
6
|
+
# A command with the business logic to create a new polling officer
|
7
|
+
class CreatePollingOfficer < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params
|
11
|
+
# current_user - The user creating the polling officer
|
12
|
+
# voting - The Voting that will hold the polling officer
|
13
|
+
def initialize(form, current_user, voting)
|
14
|
+
@form = form
|
15
|
+
@current_user = current_user
|
16
|
+
@voting = voting
|
17
|
+
end
|
18
|
+
|
19
|
+
# Executes the command. Broadcasts these events:
|
20
|
+
#
|
21
|
+
# - :ok when everything is valid.
|
22
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
23
|
+
#
|
24
|
+
# Returns nothing.
|
25
|
+
def call
|
26
|
+
return broadcast(:invalid) if form.invalid?
|
27
|
+
|
28
|
+
ActiveRecord::Base.transaction do
|
29
|
+
user = retrieve_or_invite_user
|
30
|
+
create_polling_officer(user)
|
31
|
+
end
|
32
|
+
|
33
|
+
broadcast(:ok)
|
34
|
+
rescue ActiveRecord::RecordInvalid
|
35
|
+
form.errors.add(:email, :taken)
|
36
|
+
broadcast(:invalid)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :form, :voting, :current_user
|
42
|
+
|
43
|
+
def retrieve_or_invite_user
|
44
|
+
form.user || existing_user || new_user
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_polling_officer(user)
|
48
|
+
Decidim.traceability.perform_action!(
|
49
|
+
:create,
|
50
|
+
Decidim::Votings::PollingOfficer,
|
51
|
+
current_user,
|
52
|
+
resource: {
|
53
|
+
title: user.name
|
54
|
+
}
|
55
|
+
) do
|
56
|
+
Decidim::Votings::PollingOfficer.find_or_create_by!(
|
57
|
+
user: user,
|
58
|
+
voting: voting
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def existing_user
|
64
|
+
@existing_user ||= begin
|
65
|
+
tentative_user = User.find_by(
|
66
|
+
email: form.email,
|
67
|
+
organization: voting.organization
|
68
|
+
)
|
69
|
+
|
70
|
+
InviteUserAgain.call(tentative_user, invitation_instructions) if tentative_user && !tentative_user.invitation_accepted?
|
71
|
+
|
72
|
+
tentative_user
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def new_user
|
77
|
+
@new_user ||= InviteUser.call(invite_user_form) do
|
78
|
+
on(:ok) do |invited_user|
|
79
|
+
return invited_user
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def invite_user_form
|
85
|
+
OpenStruct.new(name: form.name,
|
86
|
+
email: form.email.downcase,
|
87
|
+
organization: voting.organization,
|
88
|
+
admin: false,
|
89
|
+
invited_by: current_user,
|
90
|
+
invitation_instructions: invitation_instructions)
|
91
|
+
end
|
92
|
+
|
93
|
+
def invitation_instructions
|
94
|
+
"invite_collaborator"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic when creating a new polling station
|
7
|
+
class CreatePollingStation < ManagePollingStation
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(form)
|
12
|
+
@form = form
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
polling_station = create_polling_station!
|
25
|
+
manage_polling_officers(polling_station, form.polling_station_president_id, form.polling_station_manager_ids)
|
26
|
+
|
27
|
+
if polling_station.persisted?
|
28
|
+
broadcast(:ok, polling_station)
|
29
|
+
else
|
30
|
+
broadcast(:invalid)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :form
|
37
|
+
|
38
|
+
def create_polling_station!
|
39
|
+
params = {
|
40
|
+
voting: form.voting,
|
41
|
+
title: form.title,
|
42
|
+
address: form.address,
|
43
|
+
latitude: form.latitude,
|
44
|
+
longitude: form.longitude,
|
45
|
+
location: form.location,
|
46
|
+
location_hints: form.location_hints
|
47
|
+
}
|
48
|
+
|
49
|
+
Decidim.traceability.create!(
|
50
|
+
PollingStation,
|
51
|
+
form.current_user,
|
52
|
+
params,
|
53
|
+
visibility: "all"
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic when creating a new voting space
|
7
|
+
class CreateVoting < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(form)
|
12
|
+
@form = form
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
voting = create_voting!
|
25
|
+
|
26
|
+
if voting.persisted?
|
27
|
+
broadcast(:ok, voting)
|
28
|
+
else
|
29
|
+
form.errors.add(:banner_image, voting.errors[:banner_image]) if voting.errors.include? :banner_image
|
30
|
+
form.errors.add(:introductory_image, voting.errors[:introductory_image]) if voting.errors.include? :introductory_image
|
31
|
+
broadcast(:invalid)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_reader :form
|
38
|
+
|
39
|
+
def create_voting!
|
40
|
+
Decidim.traceability.create(
|
41
|
+
Voting,
|
42
|
+
form.current_user,
|
43
|
+
organization: form.current_organization,
|
44
|
+
title: form.title,
|
45
|
+
slug: form.slug,
|
46
|
+
description: form.description,
|
47
|
+
scope: form.scope,
|
48
|
+
start_time: form.start_time,
|
49
|
+
end_time: form.end_time,
|
50
|
+
promoted: form.promoted,
|
51
|
+
banner_image: form.banner_image,
|
52
|
+
introductory_image: form.introductory_image,
|
53
|
+
voting_type: form.voting_type
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
module Admin
|
6
|
+
# A command with the business logic to destroy a monitoring committee member
|
7
|
+
class DestroyMonitoringCommitteeMember < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# monitoring_committee_member - the MonitoringCommitteeMember to destroy
|
11
|
+
# current_user - the user performing this action
|
12
|
+
def initialize(monitoring_committee_member, current_user)
|
13
|
+
@monitoring_committee_member = monitoring_committee_member
|
14
|
+
@current_user = current_user
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :ok when everything is valid.
|
20
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
destroy_monitoring_committee_member!
|
25
|
+
broadcast(:ok)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :monitoring_committee_member, :current_user
|
31
|
+
|
32
|
+
def destroy_monitoring_committee_member!
|
33
|
+
extra_info = {
|
34
|
+
resource: {
|
35
|
+
title: monitoring_committee_member.user.name
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
Decidim.traceability.perform_action!(
|
40
|
+
"delete",
|
41
|
+
monitoring_committee_member,
|
42
|
+
current_user,
|
43
|
+
extra_info
|
44
|
+
) do
|
45
|
+
monitoring_committee_member.destroy!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Votings
|
5
|
+
module Admin
|
6
|
+
# A command with the business logic to destroy a poling officer
|
7
|
+
class DestroyPollingOfficer < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# polling_officer - the PollingOfficer to destroy
|
11
|
+
# current_user - the user performing this action
|
12
|
+
def initialize(polling_officer, current_user)
|
13
|
+
@polling_officer = polling_officer
|
14
|
+
@current_user = current_user
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :ok when everything is valid.
|
20
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
destroy_polling_officer!
|
25
|
+
broadcast(:ok)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :polling_officer, :current_user
|
31
|
+
|
32
|
+
def destroy_polling_officer!
|
33
|
+
extra_info = {
|
34
|
+
resource: {
|
35
|
+
title: polling_officer.user.name
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
Decidim.traceability.perform_action!(
|
40
|
+
"delete",
|
41
|
+
polling_officer,
|
42
|
+
current_user,
|
43
|
+
extra_info
|
44
|
+
) do
|
45
|
+
polling_officer.destroy!
|
46
|
+
polling_officer
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|