decidim-elections 0.26.8 → 0.27.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 +1 -1
- data/app/cells/decidim/votings/content_blocks/highlighted_votings/show.erb +2 -2
- data/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb +4 -5
- data/app/cells/decidim/votings/content_blocks/landing_page/description/show.erb +1 -1
- data/app/cells/decidim/votings/content_blocks/landing_page/description_cell.rb +1 -1
- data/app/cells/decidim/votings/content_blocks/landing_page/header/show.erb +2 -2
- data/app/cells/decidim/votings/content_blocks/landing_page/header_cell.rb +1 -1
- data/app/commands/decidim/elections/admin/add_user_as_trustee.rb +1 -1
- data/app/commands/decidim/elections/admin/create_answer.rb +2 -2
- data/app/commands/decidim/elections/admin/create_election.rb +1 -1
- data/app/commands/decidim/elections/admin/create_question.rb +2 -2
- data/app/commands/decidim/elections/admin/destroy_answer.rb +2 -2
- data/app/commands/decidim/elections/admin/destroy_election.rb +2 -2
- data/app/commands/decidim/elections/admin/destroy_question.rb +2 -2
- data/app/commands/decidim/elections/admin/end_vote.rb +1 -1
- data/app/commands/decidim/elections/admin/import_proposals_to_elections.rb +3 -6
- data/app/commands/decidim/elections/admin/publish_election.rb +2 -2
- data/app/commands/decidim/elections/admin/publish_results.rb +1 -1
- data/app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb +1 -1
- data/app/commands/decidim/elections/admin/report_missing_trustee.rb +1 -1
- data/app/commands/decidim/elections/admin/setup_election.rb +1 -1
- data/app/commands/decidim/elections/admin/start_key_ceremony.rb +1 -1
- data/app/commands/decidim/elections/admin/start_tally.rb +1 -1
- data/app/commands/decidim/elections/admin/start_vote.rb +1 -1
- data/app/commands/decidim/elections/admin/unpublish_election.rb +1 -1
- data/app/commands/decidim/elections/admin/update_action_status.rb +1 -1
- data/app/commands/decidim/elections/admin/update_answer.rb +2 -2
- data/app/commands/decidim/elections/admin/update_answer_selection.rb +1 -1
- data/app/commands/decidim/elections/admin/update_election.rb +1 -1
- data/app/commands/decidim/elections/admin/update_question.rb +2 -2
- data/app/commands/decidim/elections/admin/update_trustee_participatory_space.rb +1 -1
- data/app/commands/decidim/elections/trustee_zone/update_election_bulletin_board_status.rb +1 -1
- data/app/commands/decidim/elections/trustee_zone/update_trustee.rb +1 -1
- data/app/commands/decidim/elections/voter/cast_vote.rb +1 -1
- data/app/commands/decidim/elections/voter/update_vote_status.rb +2 -2
- data/app/commands/decidim/votings/admin/create_ballot_style.rb +1 -1
- data/app/commands/decidim/votings/admin/create_monitoring_committee_member.rb +1 -1
- data/app/commands/decidim/votings/admin/create_polling_officer.rb +1 -1
- data/app/commands/decidim/votings/admin/create_voting.rb +3 -2
- data/app/commands/decidim/votings/admin/destroy_ballot_style.rb +1 -1
- data/app/commands/decidim/votings/admin/destroy_monitoring_committee_member.rb +1 -1
- data/app/commands/decidim/votings/admin/destroy_polling_officer.rb +1 -1
- data/app/commands/decidim/votings/admin/destroy_polling_station.rb +1 -1
- data/app/commands/decidim/votings/admin/manage_polling_station.rb +2 -2
- data/app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb +1 -1
- data/app/commands/decidim/votings/admin/publish_voting.rb +1 -1
- data/app/commands/decidim/votings/admin/unpublish_voting.rb +1 -1
- data/app/commands/decidim/votings/admin/update_ballot_style.rb +1 -1
- data/app/commands/decidim/votings/admin/update_voting.rb +3 -2
- data/app/commands/decidim/votings/census/admin/create_dataset.rb +22 -19
- data/app/commands/decidim/votings/census/admin/create_datum.rb +1 -1
- data/app/commands/decidim/votings/census/admin/destroy_dataset.rb +1 -1
- data/app/commands/decidim/votings/census/admin/increment_dataset_processed_rows.rb +1 -1
- data/app/commands/decidim/votings/census/admin/launch_access_codes_export.rb +1 -1
- data/app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb +1 -1
- data/app/commands/decidim/votings/census/admin/update_dataset.rb +1 -1
- data/app/commands/decidim/votings/certify_polling_station_closure.rb +1 -1
- data/app/commands/decidim/votings/check_census.rb +1 -1
- data/app/commands/decidim/votings/create_polling_station_closure.rb +1 -1
- data/app/commands/decidim/votings/create_polling_station_results.rb +1 -1
- data/app/commands/decidim/votings/send_access_code.rb +1 -1
- data/app/commands/decidim/votings/sign_polling_station_closure.rb +1 -1
- data/app/commands/decidim/votings/voter/in_person_vote.rb +1 -1
- data/app/commands/decidim/votings/voter/update_in_person_vote_status.rb +1 -1
- data/app/controllers/decidim/elections/admin/steps_controller.rb +2 -2
- data/app/controllers/decidim/elections/admin/trustees_participatory_spaces_controller.rb +1 -1
- data/app/controllers/decidim/elections/elections_controller.rb +11 -13
- data/app/controllers/decidim/elections/trustee_zone/application_controller.rb +4 -6
- data/app/controllers/decidim/elections/trustee_zone/elections_controller.rb +1 -1
- data/app/controllers/decidim/votings/admin/votings_landing_page_content_blocks_controller.rb +1 -1
- data/app/controllers/decidim/votings/admin/votings_landing_page_controller.rb +1 -1
- data/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb +1 -5
- data/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb +1 -5
- data/app/controllers/decidim/votings/votings_controller.rb +12 -15
- data/app/forms/decidim/elections/admin/setup_form.rb +3 -46
- data/app/forms/decidim/elections/admin/vote_period_form.rb +2 -2
- data/app/forms/decidim/votings/admin/ballot_style_form.rb +1 -1
- data/app/forms/decidim/votings/admin/voting_form.rb +4 -3
- data/app/forms/decidim/votings/census/admin/dataset_form.rb +2 -5
- data/app/forms/decidim/votings/census/admin/datum_form.rb +1 -1
- data/app/helpers/decidim/elections/application_helper.rb +1 -1
- data/app/helpers/decidim/votings/votings_helper.rb +1 -1
- data/app/models/decidim/elections/answer.rb +1 -6
- data/app/models/decidim/elections/election.rb +15 -4
- data/app/models/decidim/elections/question.rb +1 -6
- data/app/models/decidim/votings/polling_station.rb +2 -3
- data/app/models/decidim/votings/voting.rb +15 -0
- data/app/packs/src/decidim/elections/admin/pending_action.js +0 -2
- data/app/packs/src/decidim/elections/admin/trustees_process.js +0 -2
- data/app/packs/src/decidim/elections/trustee/key_ceremony.js +0 -3
- data/app/packs/src/decidim/elections/trustee/tally.js +1 -4
- data/app/packs/src/decidim/elections/voter/casting-vote.js +0 -3
- data/app/packs/src/decidim/elections/voter/setup-vote.js +0 -2
- data/app/packs/src/decidim/votings/in-person-vote.js +0 -3
- data/app/permissions/decidim/elections/admin/permissions.rb +7 -1
- data/app/permissions/decidim/votings/admin/permissions.rb +3 -18
- data/app/permissions/decidim/votings/permissions.rb +1 -3
- data/app/presenters/decidim/votings/voting_stats_presenter.rb +4 -1
- data/app/queries/decidim/elections/admin/pending_actions.rb +1 -1
- data/app/queries/decidim/elections/admin/votes_for_statistics.rb +1 -1
- data/app/queries/decidim/elections/elections_finished_to_end.rb +1 -1
- data/app/queries/decidim/elections/elections_ready_to_start.rb +1 -1
- data/app/queries/decidim/elections/filtered_elections.rb +1 -1
- data/app/queries/decidim/elections/trustees/by_participatory_space.rb +1 -1
- data/app/queries/decidim/elections/trustees/by_participatory_space_trustee_ids.rb +1 -1
- data/app/queries/decidim/elections/votes/last_vote_for_voter.rb +1 -1
- data/app/queries/decidim/elections/votes/pending_votes.rb +1 -1
- data/app/queries/decidim/votings/admin/admin_users.rb +1 -1
- data/app/queries/decidim/votings/admin/ballot_style_by_voting_code.rb +1 -1
- data/app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb +1 -1
- data/app/queries/decidim/votings/admin/polling_officers_join_polling_stations_and_user.rb +2 -2
- data/app/queries/decidim/votings/admin/polling_officers_join_user.rb +1 -1
- data/app/queries/decidim/votings/organization_prioritized_votings.rb +2 -2
- data/app/queries/decidim/votings/organization_promoted_votings.rb +1 -1
- data/app/queries/decidim/votings/organization_published_votings.rb +2 -2
- data/app/queries/decidim/votings/organization_votings.rb +1 -1
- data/app/queries/decidim/votings/prioritized_votings.rb +1 -1
- data/app/queries/decidim/votings/published_votings.rb +1 -1
- data/app/queries/decidim/votings/votes/in_person_vote_for_voter.rb +1 -1
- data/app/queries/decidim/votings/votes/pending_in_person_votes.rb +1 -1
- data/app/services/decidim/votings/census_vote_flow.rb +1 -3
- data/app/views/decidim/elections/admin/elections/edit.html.erb +0 -1
- data/app/views/decidim/elections/admin/elections/index.html.erb +0 -1
- data/app/views/decidim/elections/admin/elections/new.html.erb +0 -1
- data/app/views/decidim/elections/admin/steps/_create_election.html.erb +1 -14
- data/app/views/decidim/elections/admin/steps/{_tally.html.erb → _tally_started.html.erb} +1 -1
- data/app/views/decidim/elections/admin/steps/index.html.erb +0 -2
- data/app/views/decidim/elections/admin/trustees_participatory_spaces/index.html.erb +0 -1
- data/app/views/decidim/elections/admin/trustees_participatory_spaces/new.html.erb +0 -1
- data/app/views/decidim/elections/elections/_filters.html.erb +2 -2
- data/app/views/decidim/elections/elections/election_log.html.erb +3 -1
- data/app/views/decidim/elections/elections/show.html.erb +1 -1
- data/app/views/decidim/elections/trustee_zone/elections/show.html.erb +3 -4
- data/app/views/decidim/elections/trustee_zone/trustees/show.html.erb +3 -1
- data/app/views/decidim/elections/votes/_onboarding_modal.html.erb +3 -1
- data/app/views/decidim/elections/votes/_show_casting.html.erb +3 -3
- data/app/views/decidim/elections/votes/new.html.erb +10 -7
- data/app/views/decidim/elections/votes/verify.html.erb +4 -1
- data/app/views/decidim/votings/admin/ballot_styles/edit.html.erb +0 -1
- data/app/views/decidim/votings/admin/ballot_styles/index.html.erb +0 -1
- data/app/views/decidim/votings/admin/ballot_styles/new.html.erb +0 -1
- data/app/views/decidim/votings/admin/votings/_form.html.erb +10 -1
- data/app/views/decidim/votings/admin/votings/edit.html.erb +0 -1
- data/app/views/decidim/votings/admin/votings/index.html.erb +0 -1
- data/app/views/decidim/votings/admin/votings/new.html.erb +1 -0
- data/app/views/decidim/votings/census/admin/census/show.html.erb +0 -1
- data/app/views/decidim/votings/polling_officer_zone/closures/_certify_form.html.erb +3 -1
- data/app/views/decidim/votings/polling_officer_zone/closures/_sign_form.html.erb +3 -1
- data/app/views/decidim/votings/polling_officer_zone/closures/edit.html.erb +3 -1
- data/app/views/decidim/votings/polling_officer_zone/closures/new.html.erb +3 -1
- data/app/views/decidim/votings/polling_officer_zone/in_person_votes/_complete_voting.html.erb +8 -2
- data/app/views/decidim/votings/polling_officer_zone/in_person_votes/new.html.erb +3 -3
- data/app/views/decidim/votings/polling_officer_zone/in_person_votes/show.html.erb +3 -3
- data/app/views/decidim/votings/votings/_filters.html.erb +2 -3
- data/app/views/decidim/votings/votings/_promoted_voting.html.erb +1 -1
- data/app/views/layouts/decidim/election_votes.html.erb +3 -1
- data/config/assets.rb +1 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +2 -43
- data/config/locales/bg.yml +1 -0
- data/config/locales/ca.yml +44 -64
- data/config/locales/cs.yml +47 -59
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +18 -174
- data/config/locales/el.yml +1 -1095
- data/config/locales/en.yml +37 -56
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +44 -64
- data/config/locales/es-PY.yml +44 -64
- data/config/locales/es.yml +46 -66
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +31 -54
- data/config/locales/fi-plain.yml +37 -57
- data/config/locales/fi.yml +40 -60
- data/config/locales/fr-CA.yml +57 -65
- data/config/locales/fr.yml +58 -66
- data/config/locales/ga-IE.yml +2 -19
- data/config/locales/gl.yml +28 -35
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +21 -29
- data/config/locales/id-ID.yml +1 -0
- data/config/locales/is-IS.yml +2 -1
- data/config/locales/it.yml +34 -32
- data/config/locales/ja.yml +46 -75
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +1 -0
- data/config/locales/lt.yml +1 -1401
- data/config/locales/lv.yml +1 -3
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +36 -49
- data/config/locales/no.yml +13 -54
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +43 -38
- data/config/locales/pt-BR.yml +35 -35
- data/config/locales/pt.yml +36 -35
- data/config/locales/ro-RO.yml +19 -69
- data/config/locales/ru.yml +1 -0
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +24 -73
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +5 -61
- data/config/locales/uk.yml +1 -0
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +2 -22
- data/config/locales/zh-TW.yml +1 -1391
- data/db/migrate/20220404112802_rename_bb_status_tally_to_tally_started.rb +19 -0
- data/db/migrate/20220424121541_add_show_check_census_to_votings.rb +7 -0
- data/db/migrate/20220615102642_remove_description_from_elections_questions.rb +1 -1
- data/lib/decidim/elections/component.rb +4 -4
- data/lib/decidim/elections/test/factories.rb +4 -5
- data/lib/decidim/elections/version.rb +1 -1
- data/lib/decidim/votings/admin_engine.rb +0 -4
- data/lib/decidim/votings/participatory_space.rb +3 -3
- data/lib/decidim/votings/test/factories.rb +2 -1
- metadata +27 -40
- data/app/controllers/decidim/votings/admin/exports_controller.rb +0 -14
- data/app/controllers/decidim/votings/admin/imports_controller.rb +0 -14
- data/app/controllers/decidim/votings/admin/reminders_controller.rb +0 -14
- data/app/forms/decidim/votings/admin/voting_role_form.rb +0 -29
- data/app/packs/src/decidim/elections/broken_promises_handler.js +0 -11
- data/app/services/decidim/elections/election_search.rb +0 -35
- data/app/services/decidim/votings/voting_search.rb +0 -46
- data/app/views/decidim/elections/shared/_broken_promises_modal.html.erb +0 -33
- data/config/environment.rb +0 -0
- data/config/locales/fa-IR.yml +0 -1
- data/config/locales/gn-PY.yml +0 -1
- data/config/locales/ka-GE.yml +0 -1
- data/config/locales/kaa.yml +0 -1
- data/config/locales/lo-LA.yml +0 -1
- data/config/locales/oc-FR.yml +0 -1
- /data/app/packs/entrypoints/{decidim_elections_trustee_tally.js → decidim_elections_trustee_tally_started.js} +0 -0
- /data/app/views/decidim/elections/trustee_zone/elections/{_tally_steps.html.erb → _tally_started_steps.html.erb} +0 -0
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Votings
|
5
5
|
module Admin
|
6
6
|
# A command with the business logic to update the ballot style
|
7
|
-
class UpdateBallotStyle <
|
7
|
+
class UpdateBallotStyle < Decidim::Command
|
8
8
|
def initialize(form, ballot_style)
|
9
9
|
@form = form
|
10
10
|
@ballot_style = ballot_style
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when updating an existing
|
7
7
|
# voting in the system.
|
8
|
-
class UpdateVoting <
|
8
|
+
class UpdateVoting < Decidim::Command
|
9
9
|
include ::Decidim::AttachmentAttributesMethods
|
10
10
|
|
11
11
|
# Public: Initializes the command.
|
@@ -67,7 +67,8 @@ module Decidim
|
|
67
67
|
scope: form.scope,
|
68
68
|
promoted: form.promoted,
|
69
69
|
voting_type: form.voting_type,
|
70
|
-
census_contact_information: form.census_contact_information
|
70
|
+
census_contact_information: form.census_contact_information,
|
71
|
+
show_check_census: form.show_check_census
|
71
72
|
}.merge(attachment_attributes(*image_fields))
|
72
73
|
end
|
73
74
|
end
|
@@ -8,7 +8,9 @@ module Decidim
|
|
8
8
|
module Admin
|
9
9
|
# A command with the business logic to create census dataset for a
|
10
10
|
# voting space.
|
11
|
-
class CreateDataset <
|
11
|
+
class CreateDataset < Decidim::Command
|
12
|
+
include Decidim::ProcessesFileLocally
|
13
|
+
|
12
14
|
def initialize(form, current_user)
|
13
15
|
@form = form
|
14
16
|
@current_user = current_user
|
@@ -23,23 +25,28 @@ module Decidim
|
|
23
25
|
def call
|
24
26
|
return broadcast(:invalid) unless form.valid?
|
25
27
|
|
26
|
-
|
28
|
+
process_file_locally(form.file) do |file_path|
|
29
|
+
@file_path = file_path
|
30
|
+
dataset = create_census_dataset!
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
if csv_header_invalid?
|
33
|
+
dataset.destroy!
|
34
|
+
return broadcast(:invalid_csv_header)
|
35
|
+
end
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
if dataset
|
38
|
+
CSV.foreach(file_path, col_sep: ";", headers: true, converters: ->(f) { f&.strip }) do |row|
|
39
|
+
CreateDatumJob.perform_later(current_user, dataset, row.fields)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
44
|
broadcast(:ok)
|
40
45
|
end
|
41
46
|
|
42
|
-
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_reader :form, :current_user, :file_path
|
43
50
|
attr_accessor :dataset
|
44
51
|
|
45
52
|
def create_census_dataset!
|
@@ -48,7 +55,7 @@ module Decidim
|
|
48
55
|
current_user,
|
49
56
|
{
|
50
57
|
voting: form.current_participatory_space,
|
51
|
-
file: form.file
|
58
|
+
file: form.file,
|
52
59
|
csv_row_raw_count: csv_row_count,
|
53
60
|
status: :creating_data
|
54
61
|
},
|
@@ -57,7 +64,7 @@ module Decidim
|
|
57
64
|
end
|
58
65
|
|
59
66
|
def csv_header_invalid?
|
60
|
-
CSV.parse_line(File.open(
|
67
|
+
CSV.parse_line(File.open(file_path), col_sep: ";", headers: true, header_converters: :symbol).headers != expected_headers
|
61
68
|
end
|
62
69
|
|
63
70
|
def headers
|
@@ -72,16 +79,12 @@ module Decidim
|
|
72
79
|
@expected_headers ||= form.current_participatory_space.has_ballot_styles? ? ballot_style_headers : headers
|
73
80
|
end
|
74
81
|
|
75
|
-
def csv_rows
|
76
|
-
@csv_rows ||= CSV.read(form.file.tempfile.path)
|
77
|
-
end
|
78
|
-
|
79
82
|
def csv_row_count
|
80
|
-
@csv_row_count ||= file_lines_count
|
83
|
+
@csv_row_count ||= file_lines_count - 1
|
81
84
|
end
|
82
85
|
|
83
|
-
def file_lines_count
|
84
|
-
`wc -l "#{file_path.shellescape}"`.strip.split
|
86
|
+
def file_lines_count
|
87
|
+
`wc -l "#{file_path.shellescape}"`.strip.split.first.to_i
|
85
88
|
end
|
86
89
|
end
|
87
90
|
end
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
module Admin
|
9
9
|
# A command with the business logic to destroy a census dataset
|
10
10
|
# from the admin panel.
|
11
|
-
class DestroyDataset <
|
11
|
+
class DestroyDataset < Decidim::Command
|
12
12
|
def initialize(dataset, current_user)
|
13
13
|
@dataset = dataset
|
14
14
|
@current_user = current_user
|
@@ -6,7 +6,7 @@ module Decidim
|
|
6
6
|
module Admin
|
7
7
|
# A command with the business logic to create increment the dataset
|
8
8
|
# processed rows and change the state when the last is processed
|
9
|
-
class IncrementDatasetProcessedRows <
|
9
|
+
class IncrementDatasetProcessedRows < Decidim::Command
|
10
10
|
def initialize(dataset)
|
11
11
|
@dataset = dataset
|
12
12
|
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Census
|
6
6
|
module Admin
|
7
7
|
# A command to launch the access codes generation
|
8
|
-
class LaunchAccessCodesGeneration <
|
8
|
+
class LaunchAccessCodesGeneration < Decidim::Command
|
9
9
|
def initialize(dataset, user)
|
10
10
|
@dataset = dataset
|
11
11
|
@user = user
|
@@ -11,7 +11,7 @@ module Decidim
|
|
11
11
|
# dataset - the Decidim::Votings::Census::Dataset to update
|
12
12
|
# attributes - the hash of attibutes to update
|
13
13
|
# user - the user performing the action (used for tracing)
|
14
|
-
class UpdateDataset <
|
14
|
+
class UpdateDataset < Decidim::Command
|
15
15
|
def initialize(dataset, attributes, user)
|
16
16
|
@dataset = dataset
|
17
17
|
@attributes = attributes
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Votings
|
5
5
|
# A command with all the business logic when signing a closure of a polling station
|
6
|
-
class CertifyPollingStationClosure <
|
6
|
+
class CertifyPollingStationClosure < Decidim::Command
|
7
7
|
include ::Decidim::AttachmentMethods
|
8
8
|
include ::Decidim::GalleryMethods
|
9
9
|
# Public: Initializes the command.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Votings
|
5
5
|
# A command with all the business logic when creating a closure for a polling station
|
6
|
-
class CreatePollingStationClosure <
|
6
|
+
class CreatePollingStationClosure < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# form - A form object with the params.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Votings
|
5
5
|
# A command with all the business logic when creating results for a polling station
|
6
|
-
class CreatePollingStationResults <
|
6
|
+
class CreatePollingStationResults < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# form - A form object with the params.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Votings
|
5
5
|
# A command with all the business logic when signing a closure of a polling station
|
6
|
-
class SignPollingStationClosure <
|
6
|
+
class SignPollingStationClosure < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# form - A form object with the params.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Votings
|
5
5
|
module Voter
|
6
6
|
# This command allows the user to register an in person vote.
|
7
|
-
class InPersonVote <
|
7
|
+
class InPersonVote < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A form with necessary info to register an in person vote.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Votings
|
5
5
|
module Voter
|
6
6
|
# This command updates the in person vote status
|
7
|
-
class UpdateInPersonVoteStatus <
|
7
|
+
class UpdateInPersonVoteStatus < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# in_person_vote - the in person vote that has been updated
|
@@ -73,7 +73,7 @@ module Decidim
|
|
73
73
|
"key_ceremony_ended" => VotePeriodForm,
|
74
74
|
"vote" => VotePeriodForm,
|
75
75
|
"vote_ended" => ActionForm,
|
76
|
-
"
|
76
|
+
"tally_started" => ReportMissingTrusteeForm,
|
77
77
|
"tally_ended" => ActionForm
|
78
78
|
}[current_step]
|
79
79
|
end
|
@@ -85,7 +85,7 @@ module Decidim
|
|
85
85
|
"key_ceremony_ended" => StartVote,
|
86
86
|
"vote" => EndVote,
|
87
87
|
"vote_ended" => StartTally,
|
88
|
-
"
|
88
|
+
"tally_started" => ReportMissingTrustee,
|
89
89
|
"tally_ended" => PublishResults
|
90
90
|
}[current_step]
|
91
91
|
end
|
@@ -72,7 +72,7 @@ module Decidim
|
|
72
72
|
private
|
73
73
|
|
74
74
|
def trustee_participatory_space
|
75
|
-
@trustee_participatory_space ||= TrusteesParticipatorySpace.find_by(id: params[:id]
|
75
|
+
@trustee_participatory_space ||= TrusteesParticipatorySpace.find_by(id: params[:id])
|
76
76
|
end
|
77
77
|
|
78
78
|
def trustees
|
@@ -26,10 +26,12 @@ module Decidim
|
|
26
26
|
delegate :bulletin_board_server, :authority_slug, to: :bulletin_board_client
|
27
27
|
|
28
28
|
def elections
|
29
|
-
@elections ||=
|
29
|
+
@elections ||= search_collection
|
30
30
|
end
|
31
31
|
|
32
32
|
def election
|
33
|
+
# The single election is searched from non-published records on purpose
|
34
|
+
# to allow previewing for admins.
|
33
35
|
@election ||= Election.where(component: current_component).find(params[:id])
|
34
36
|
end
|
35
37
|
|
@@ -57,26 +59,26 @@ module Decidim
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def paginated_elections
|
60
|
-
@paginated_elections ||=
|
61
|
-
@paginated_elections =
|
62
|
+
@paginated_elections ||= paginate(search.result.published)
|
63
|
+
@paginated_elections = reorder(@paginated_elections)
|
62
64
|
end
|
63
65
|
|
64
66
|
def scheduled_elections
|
65
|
-
@scheduled_elections ||=
|
67
|
+
@scheduled_elections ||= search_with(filter_params.merge(with_any_date: %w(active upcoming))).result
|
66
68
|
end
|
67
69
|
|
68
|
-
def
|
69
|
-
|
70
|
+
def search_collection
|
71
|
+
Election.where(component: current_component).published
|
70
72
|
end
|
71
73
|
|
72
74
|
def default_filter_params
|
73
75
|
{
|
74
|
-
|
75
|
-
|
76
|
+
search_text_cont: "",
|
77
|
+
with_any_date: default_filter_date_params
|
76
78
|
}
|
77
79
|
end
|
78
80
|
|
79
|
-
def
|
81
|
+
def default_filter_date_params
|
80
82
|
if elections.active.any?
|
81
83
|
%w(active)
|
82
84
|
elsif elections.upcoming.any?
|
@@ -85,10 +87,6 @@ module Decidim
|
|
85
87
|
%w()
|
86
88
|
end
|
87
89
|
end
|
88
|
-
|
89
|
-
def context_params
|
90
|
-
{ component: current_component, organization: current_organization }
|
91
|
-
end
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
@@ -13,11 +13,6 @@ module Decidim
|
|
13
13
|
|
14
14
|
before_action :ensure_configured_bulletin_board!
|
15
15
|
|
16
|
-
register_permissions(::Decidim::Elections::TrusteeZone::ApplicationController,
|
17
|
-
::Decidim::Elections::Permissions,
|
18
|
-
::Decidim::Admin::Permissions,
|
19
|
-
::Decidim::Permissions)
|
20
|
-
|
21
16
|
private
|
22
17
|
|
23
18
|
def ensure_configured_bulletin_board!
|
@@ -39,7 +34,10 @@ module Decidim
|
|
39
34
|
end
|
40
35
|
|
41
36
|
def permission_class_chain
|
42
|
-
|
37
|
+
[
|
38
|
+
Decidim::Elections::Permissions,
|
39
|
+
Decidim::Permissions
|
40
|
+
]
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
data/app/controllers/decidim/votings/admin/votings_landing_page_content_blocks_controller.rb
CHANGED
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def scoped_resource
|
21
|
-
@scoped_resource ||= Voting.find_by(slug: params[:voting_slug]
|
21
|
+
@scoped_resource ||= Voting.find_by(slug: params[:voting_slug])
|
22
22
|
end
|
23
23
|
|
24
24
|
def enforce_permission_to_update_resource
|
@@ -16,7 +16,7 @@ module Decidim
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def scoped_resource
|
19
|
-
@scoped_resource ||= Voting.find_by(slug: params[:voting_slug]
|
19
|
+
@scoped_resource ||= Voting.find_by(slug: params[:voting_slug])
|
20
20
|
end
|
21
21
|
|
22
22
|
def enforce_permission_to_update_resource
|
@@ -111,11 +111,7 @@ module Decidim
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def election
|
114
|
-
@election ||= Decidim::Elections::Election
|
115
|
-
.joins("INNER JOIN decidim_components component ON component.id = decidim_elections_elections.decidim_component_id")
|
116
|
-
.where(component: { participatory_space: current_organization.participatory_spaces })
|
117
|
-
.includes(questions: :answers)
|
118
|
-
.find_by(id: params[:election_id])
|
114
|
+
@election ||= Decidim::Elections::Election.includes(questions: :answers).find_by(id: params[:election_id])
|
119
115
|
end
|
120
116
|
|
121
117
|
def polling_station
|
@@ -121,11 +121,7 @@ module Decidim
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def election
|
124
|
-
@election ||= Decidim::Elections::Election
|
125
|
-
.joins("INNER JOIN decidim_components component ON component.id = decidim_elections_elections.decidim_component_id")
|
126
|
-
.where(component: { participatory_space: current_organization.participatory_spaces })
|
127
|
-
.includes(questions: :answers)
|
128
|
-
.find_by(id: params[:election_id])
|
124
|
+
@election ||= Decidim::Elections::Election.find(params[:election_id])
|
129
125
|
end
|
130
126
|
|
131
127
|
def polling_officer
|
@@ -49,11 +49,15 @@ module Decidim
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def show_check_census
|
52
|
+
raise ActionController::RoutingError, "Not Found" unless current_participatory_space.check_census_enabled?
|
53
|
+
|
52
54
|
@form = form(Census::CheckForm).instance
|
53
55
|
render :check_census, locals: { success: false, not_found: false }
|
54
56
|
end
|
55
57
|
|
56
58
|
def check_census
|
59
|
+
raise ActionController::RoutingError, "Not Found" unless current_participatory_space.check_census_enabled?
|
60
|
+
|
57
61
|
@form = form(Census::CheckForm).from_params(params).with_context(
|
58
62
|
current_participatory_space: current_participatory_space
|
59
63
|
)
|
@@ -99,7 +103,7 @@ module Decidim
|
|
99
103
|
end
|
100
104
|
|
101
105
|
def election
|
102
|
-
@election ||= Decidim::Elections::Election.
|
106
|
+
@election ||= Decidim::Elections::Election.find(params[:election_id])
|
103
107
|
end
|
104
108
|
|
105
109
|
def elections
|
@@ -129,8 +133,8 @@ module Decidim
|
|
129
133
|
end
|
130
134
|
|
131
135
|
def paginated_votings
|
132
|
-
@paginated_votings ||=
|
133
|
-
@paginated_votings =
|
136
|
+
@paginated_votings ||= paginate(search.result.published)
|
137
|
+
@paginated_votings = reorder(@paginated_votings)
|
134
138
|
end
|
135
139
|
|
136
140
|
def promoted_votings
|
@@ -138,7 +142,7 @@ module Decidim
|
|
138
142
|
end
|
139
143
|
|
140
144
|
def finished_votings
|
141
|
-
@finished_votings ||=
|
145
|
+
@finished_votings ||= search_with(filter_params.merge(with_any_date: %w(finished))).result
|
142
146
|
end
|
143
147
|
|
144
148
|
def only_finished_votings?
|
@@ -147,21 +151,14 @@ module Decidim
|
|
147
151
|
published_votings.count == finished_votings.count
|
148
152
|
end
|
149
153
|
|
150
|
-
def
|
151
|
-
|
154
|
+
def search_collection
|
155
|
+
Voting.where(organization: current_organization).published
|
152
156
|
end
|
153
157
|
|
154
158
|
def default_filter_params
|
155
159
|
{
|
156
|
-
|
157
|
-
|
158
|
-
}
|
159
|
-
end
|
160
|
-
|
161
|
-
def context_params
|
162
|
-
{
|
163
|
-
organization: current_organization,
|
164
|
-
current_user: current_user
|
160
|
+
search_text_cont: "",
|
161
|
+
with_any_date: [""]
|
165
162
|
}
|
166
163
|
end
|
167
164
|
|
@@ -13,12 +13,6 @@ module Decidim
|
|
13
13
|
validations.each do |message, t_args, valid|
|
14
14
|
errors.add(message, I18n.t("steps.create_election.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid
|
15
15
|
end
|
16
|
-
|
17
|
-
if needs_census?
|
18
|
-
census_validations.each do |message, t_args, valid|
|
19
|
-
errors.add(message, I18n.t("steps.create_election.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid
|
20
|
-
end
|
21
|
-
end
|
22
16
|
end
|
23
17
|
|
24
18
|
def current_step; end
|
@@ -41,30 +35,13 @@ module Decidim
|
|
41
35
|
[:max_selections, {}, election.valid_questions?],
|
42
36
|
[:published, {}, election.published_at.present?],
|
43
37
|
[:component_published, {}, election.component.published?],
|
44
|
-
[:time_before, { hours:
|
45
|
-
election.minimum_hours_before_start?],
|
38
|
+
[:time_before, { hours: Decidim::Elections.setup_minimum_hours_before_start }, election.minimum_hours_before_start?],
|
46
39
|
[:trustees_number, { number: bulletin_board.number_of_trustees }, participatory_space_trustees_with_public_key.size >= bulletin_board.number_of_trustees]
|
47
40
|
].freeze
|
48
41
|
end
|
49
42
|
|
50
|
-
def census_validations
|
51
|
-
return [] unless needs_census?
|
52
|
-
|
53
|
-
@census_validations ||= [
|
54
|
-
[:census_uploaded, {}, census.present? && census.data.exists?],
|
55
|
-
[:census_codes_generated, {}, census_codes_generated?],
|
56
|
-
[:census_frozen, {}, census&.freeze?]
|
57
|
-
].freeze
|
58
|
-
end
|
59
|
-
|
60
43
|
def messages
|
61
|
-
@messages ||= validations.
|
62
|
-
[message, I18n.t("steps.create_election.requirements.#{message}", **t_args, scope: "decidim.elections.admin")]
|
63
|
-
end.to_h
|
64
|
-
end
|
65
|
-
|
66
|
-
def census_messages
|
67
|
-
@census_messages ||= census_validations.to_h do |message, t_args, _valid|
|
44
|
+
@messages ||= validations.to_h do |message, t_args, _valid|
|
68
45
|
[message, I18n.t("steps.create_election.requirements.#{message}", **t_args, scope: "decidim.elections.admin")]
|
69
46
|
end
|
70
47
|
end
|
@@ -81,26 +58,6 @@ module Decidim
|
|
81
58
|
@bulletin_board ||= context[:bulletin_board] || Decidim::Elections.bulletin_board
|
82
59
|
end
|
83
60
|
|
84
|
-
def needs_census?
|
85
|
-
vote_flow.is_a?(Decidim::Votings::CensusVoteFlow)
|
86
|
-
end
|
87
|
-
|
88
|
-
def vote_flow
|
89
|
-
@vote_flow ||= election.participatory_space.try(:vote_flow_for, election)
|
90
|
-
end
|
91
|
-
|
92
|
-
def census_codes_generated?
|
93
|
-
return unless needs_census?
|
94
|
-
|
95
|
-
census&.codes_generated? || census&.exporting_codes? || census&.freeze?
|
96
|
-
end
|
97
|
-
|
98
|
-
def census
|
99
|
-
return unless needs_census?
|
100
|
-
|
101
|
-
@census ||= election.component.participatory_space.dataset
|
102
|
-
end
|
103
|
-
|
104
61
|
def main_button?
|
105
62
|
true
|
106
63
|
end
|
@@ -108,7 +65,7 @@ module Decidim
|
|
108
65
|
private
|
109
66
|
|
110
67
|
def choose_random_trustees
|
111
|
-
return @trustee_ids if @trustee_ids
|
68
|
+
return @trustee_ids if @trustee_ids&.any? || defined?(@trustees)
|
112
69
|
|
113
70
|
@trustees = if participatory_space_trustees_with_public_key.count >= bulletin_board.number_of_trustees
|
114
71
|
participatory_space_trustees_with_public_key.sample(bulletin_board.number_of_trustees)
|
@@ -27,9 +27,9 @@ module Decidim
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def messages
|
30
|
-
@messages ||= validations.
|
30
|
+
@messages ||= validations.to_h do |message, t_args, _valid|
|
31
31
|
[message, I18n.t("steps.#{current_step}.requirements.#{message}", **t_args, scope: "decidim.elections.admin")]
|
32
|
-
end
|
32
|
+
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -15,11 +15,12 @@ module Decidim
|
|
15
15
|
attribute :scope_id, Integer
|
16
16
|
attribute :promoted, Boolean
|
17
17
|
attribute :remove_banner_image, Boolean, default: false
|
18
|
-
attribute :banner_image
|
18
|
+
attribute :banner_image
|
19
19
|
attribute :remove_introductory_image, Boolean, default: false
|
20
|
-
attribute :introductory_image
|
20
|
+
attribute :introductory_image
|
21
21
|
attribute :voting_type, String
|
22
22
|
attribute :census_contact_information, String
|
23
|
+
attribute :show_check_census, Boolean, default: false
|
23
24
|
|
24
25
|
validates :title, translatable_presence: true
|
25
26
|
validates :description, translatable_presence: true
|
@@ -29,7 +30,7 @@ module Decidim
|
|
29
30
|
validates :end_time, presence: true, date: { after: :start_time }
|
30
31
|
validates :banner_image, passthru: { to: Decidim::Votings::Voting }
|
31
32
|
validates :introductory_image, passthru: { to: Decidim::Votings::Voting }
|
32
|
-
validates :voting_type, presence: true, inclusion: { in: Votings::Voting.voting_types
|
33
|
+
validates :voting_type, presence: true, inclusion: { in: Votings::Voting.voting_types }
|
33
34
|
|
34
35
|
validates :scope, presence: true, if: proc { |object| object.scope_id.present? }
|
35
36
|
|
@@ -6,14 +6,11 @@ module Decidim
|
|
6
6
|
module Admin
|
7
7
|
# A form to temporaly upload csv census data
|
8
8
|
class DatasetForm < Form
|
9
|
-
include Decidim::HasUploadValidations
|
10
|
-
|
11
9
|
mimic :dataset
|
12
10
|
|
13
|
-
attribute :file
|
11
|
+
attribute :file, Decidim::Attributes::Blob
|
14
12
|
|
15
|
-
|
16
|
-
validates :file, presence: true
|
13
|
+
validates :file, presence: true, file_content_type: { allow: ["text/csv"] }
|
17
14
|
|
18
15
|
def organization
|
19
16
|
context.current_participatory_space&.organization
|