decidim-elections 0.26.9 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/cells/decidim/votings/content_blocks/highlighted_votings/show.erb +2 -2
  4. data/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb +4 -5
  5. data/app/cells/decidim/votings/content_blocks/landing_page/description/show.erb +1 -1
  6. data/app/cells/decidim/votings/content_blocks/landing_page/description_cell.rb +1 -1
  7. data/app/cells/decidim/votings/content_blocks/landing_page/header/show.erb +2 -2
  8. data/app/cells/decidim/votings/content_blocks/landing_page/header_cell.rb +1 -1
  9. data/app/commands/decidim/elections/admin/add_user_as_trustee.rb +1 -1
  10. data/app/commands/decidim/elections/admin/create_answer.rb +2 -2
  11. data/app/commands/decidim/elections/admin/create_election.rb +1 -1
  12. data/app/commands/decidim/elections/admin/create_question.rb +2 -2
  13. data/app/commands/decidim/elections/admin/destroy_answer.rb +2 -2
  14. data/app/commands/decidim/elections/admin/destroy_election.rb +2 -2
  15. data/app/commands/decidim/elections/admin/destroy_question.rb +2 -2
  16. data/app/commands/decidim/elections/admin/end_vote.rb +1 -1
  17. data/app/commands/decidim/elections/admin/import_proposals_to_elections.rb +3 -6
  18. data/app/commands/decidim/elections/admin/publish_election.rb +2 -2
  19. data/app/commands/decidim/elections/admin/publish_results.rb +1 -1
  20. data/app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb +1 -1
  21. data/app/commands/decidim/elections/admin/report_missing_trustee.rb +1 -1
  22. data/app/commands/decidim/elections/admin/setup_election.rb +1 -1
  23. data/app/commands/decidim/elections/admin/start_key_ceremony.rb +1 -1
  24. data/app/commands/decidim/elections/admin/start_tally.rb +1 -1
  25. data/app/commands/decidim/elections/admin/start_vote.rb +1 -1
  26. data/app/commands/decidim/elections/admin/unpublish_election.rb +1 -1
  27. data/app/commands/decidim/elections/admin/update_action_status.rb +1 -1
  28. data/app/commands/decidim/elections/admin/update_answer.rb +2 -2
  29. data/app/commands/decidim/elections/admin/update_answer_selection.rb +1 -1
  30. data/app/commands/decidim/elections/admin/update_election.rb +1 -1
  31. data/app/commands/decidim/elections/admin/update_question.rb +2 -2
  32. data/app/commands/decidim/elections/admin/update_trustee_participatory_space.rb +1 -1
  33. data/app/commands/decidim/elections/trustee_zone/update_election_bulletin_board_status.rb +1 -1
  34. data/app/commands/decidim/elections/trustee_zone/update_trustee.rb +1 -1
  35. data/app/commands/decidim/elections/voter/cast_vote.rb +1 -1
  36. data/app/commands/decidim/elections/voter/update_vote_status.rb +2 -2
  37. data/app/commands/decidim/votings/admin/create_ballot_style.rb +1 -1
  38. data/app/commands/decidim/votings/admin/create_monitoring_committee_member.rb +1 -1
  39. data/app/commands/decidim/votings/admin/create_polling_officer.rb +1 -1
  40. data/app/commands/decidim/votings/admin/create_voting.rb +3 -2
  41. data/app/commands/decidim/votings/admin/destroy_ballot_style.rb +1 -1
  42. data/app/commands/decidim/votings/admin/destroy_monitoring_committee_member.rb +1 -1
  43. data/app/commands/decidim/votings/admin/destroy_polling_officer.rb +1 -1
  44. data/app/commands/decidim/votings/admin/destroy_polling_station.rb +1 -1
  45. data/app/commands/decidim/votings/admin/manage_polling_station.rb +2 -2
  46. data/app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb +1 -1
  47. data/app/commands/decidim/votings/admin/publish_voting.rb +1 -1
  48. data/app/commands/decidim/votings/admin/unpublish_voting.rb +1 -1
  49. data/app/commands/decidim/votings/admin/update_ballot_style.rb +1 -1
  50. data/app/commands/decidim/votings/admin/update_voting.rb +3 -2
  51. data/app/commands/decidim/votings/census/admin/create_dataset.rb +22 -19
  52. data/app/commands/decidim/votings/census/admin/create_datum.rb +1 -1
  53. data/app/commands/decidim/votings/census/admin/destroy_dataset.rb +1 -1
  54. data/app/commands/decidim/votings/census/admin/increment_dataset_processed_rows.rb +1 -1
  55. data/app/commands/decidim/votings/census/admin/launch_access_codes_export.rb +1 -1
  56. data/app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb +1 -1
  57. data/app/commands/decidim/votings/census/admin/update_dataset.rb +1 -1
  58. data/app/commands/decidim/votings/certify_polling_station_closure.rb +1 -1
  59. data/app/commands/decidim/votings/check_census.rb +1 -1
  60. data/app/commands/decidim/votings/create_polling_station_closure.rb +1 -1
  61. data/app/commands/decidim/votings/create_polling_station_results.rb +1 -1
  62. data/app/commands/decidim/votings/send_access_code.rb +1 -1
  63. data/app/commands/decidim/votings/sign_polling_station_closure.rb +1 -1
  64. data/app/commands/decidim/votings/voter/in_person_vote.rb +1 -1
  65. data/app/commands/decidim/votings/voter/update_in_person_vote_status.rb +1 -1
  66. data/app/controllers/decidim/elections/admin/steps_controller.rb +2 -2
  67. data/app/controllers/decidim/elections/admin/trustees_participatory_spaces_controller.rb +1 -1
  68. data/app/controllers/decidim/elections/elections_controller.rb +11 -13
  69. data/app/controllers/decidim/elections/trustee_zone/application_controller.rb +4 -6
  70. data/app/controllers/decidim/elections/trustee_zone/elections_controller.rb +1 -1
  71. data/app/controllers/decidim/votings/admin/votings_landing_page_content_blocks_controller.rb +1 -1
  72. data/app/controllers/decidim/votings/admin/votings_landing_page_controller.rb +1 -1
  73. data/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb +1 -5
  74. data/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb +1 -5
  75. data/app/controllers/decidim/votings/votings_controller.rb +12 -15
  76. data/app/forms/decidim/elections/admin/setup_form.rb +3 -46
  77. data/app/forms/decidim/elections/admin/vote_period_form.rb +2 -2
  78. data/app/forms/decidim/votings/admin/ballot_style_form.rb +1 -1
  79. data/app/forms/decidim/votings/admin/voting_form.rb +4 -3
  80. data/app/forms/decidim/votings/census/admin/dataset_form.rb +2 -5
  81. data/app/forms/decidim/votings/census/admin/datum_form.rb +1 -1
  82. data/app/helpers/decidim/elections/application_helper.rb +1 -1
  83. data/app/helpers/decidim/votings/votings_helper.rb +1 -1
  84. data/app/models/decidim/elections/answer.rb +1 -6
  85. data/app/models/decidim/elections/election.rb +15 -4
  86. data/app/models/decidim/elections/question.rb +1 -6
  87. data/app/models/decidim/votings/polling_station.rb +2 -3
  88. data/app/models/decidim/votings/voting.rb +15 -0
  89. data/app/packs/src/decidim/elections/admin/pending_action.js +0 -2
  90. data/app/packs/src/decidim/elections/admin/trustees_process.js +0 -2
  91. data/app/packs/src/decidim/elections/trustee/key_ceremony.js +0 -3
  92. data/app/packs/src/decidim/elections/trustee/tally.js +1 -4
  93. data/app/packs/src/decidim/elections/voter/casting-vote.js +0 -3
  94. data/app/packs/src/decidim/elections/voter/setup-vote.js +0 -2
  95. data/app/packs/src/decidim/votings/in-person-vote.js +0 -3
  96. data/app/permissions/decidim/elections/admin/permissions.rb +7 -1
  97. data/app/permissions/decidim/votings/admin/permissions.rb +3 -18
  98. data/app/permissions/decidim/votings/permissions.rb +1 -3
  99. data/app/presenters/decidim/votings/voting_stats_presenter.rb +4 -1
  100. data/app/queries/decidim/elections/admin/pending_actions.rb +1 -1
  101. data/app/queries/decidim/elections/admin/votes_for_statistics.rb +1 -1
  102. data/app/queries/decidim/elections/elections_finished_to_end.rb +1 -1
  103. data/app/queries/decidim/elections/elections_ready_to_start.rb +1 -1
  104. data/app/queries/decidim/elections/filtered_elections.rb +1 -1
  105. data/app/queries/decidim/elections/trustees/by_participatory_space.rb +1 -1
  106. data/app/queries/decidim/elections/trustees/by_participatory_space_trustee_ids.rb +1 -1
  107. data/app/queries/decidim/elections/votes/last_vote_for_voter.rb +1 -1
  108. data/app/queries/decidim/elections/votes/pending_votes.rb +1 -1
  109. data/app/queries/decidim/votings/admin/admin_users.rb +1 -1
  110. data/app/queries/decidim/votings/admin/ballot_style_by_voting_code.rb +1 -1
  111. data/app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb +1 -1
  112. data/app/queries/decidim/votings/admin/polling_officers_join_polling_stations_and_user.rb +2 -2
  113. data/app/queries/decidim/votings/admin/polling_officers_join_user.rb +1 -1
  114. data/app/queries/decidim/votings/organization_prioritized_votings.rb +2 -2
  115. data/app/queries/decidim/votings/organization_promoted_votings.rb +1 -1
  116. data/app/queries/decidim/votings/organization_published_votings.rb +2 -2
  117. data/app/queries/decidim/votings/organization_votings.rb +1 -1
  118. data/app/queries/decidim/votings/prioritized_votings.rb +1 -1
  119. data/app/queries/decidim/votings/published_votings.rb +1 -1
  120. data/app/queries/decidim/votings/votes/in_person_vote_for_voter.rb +1 -1
  121. data/app/queries/decidim/votings/votes/pending_in_person_votes.rb +1 -1
  122. data/app/services/decidim/votings/census_vote_flow.rb +1 -3
  123. data/app/views/decidim/elections/admin/elections/edit.html.erb +0 -1
  124. data/app/views/decidim/elections/admin/elections/index.html.erb +0 -1
  125. data/app/views/decidim/elections/admin/elections/new.html.erb +0 -1
  126. data/app/views/decidim/elections/admin/steps/_create_election.html.erb +1 -14
  127. data/app/views/decidim/elections/admin/steps/{_tally.html.erb → _tally_started.html.erb} +1 -1
  128. data/app/views/decidim/elections/admin/steps/index.html.erb +0 -2
  129. data/app/views/decidim/elections/admin/trustees_participatory_spaces/index.html.erb +0 -1
  130. data/app/views/decidim/elections/admin/trustees_participatory_spaces/new.html.erb +0 -1
  131. data/app/views/decidim/elections/elections/_filters.html.erb +2 -2
  132. data/app/views/decidim/elections/elections/election_log.html.erb +3 -1
  133. data/app/views/decidim/elections/elections/show.html.erb +1 -1
  134. data/app/views/decidim/elections/trustee_zone/elections/show.html.erb +3 -4
  135. data/app/views/decidim/elections/trustee_zone/trustees/show.html.erb +3 -1
  136. data/app/views/decidim/elections/votes/_onboarding_modal.html.erb +3 -1
  137. data/app/views/decidim/elections/votes/_show_casting.html.erb +3 -3
  138. data/app/views/decidim/elections/votes/new.html.erb +10 -7
  139. data/app/views/decidim/elections/votes/verify.html.erb +4 -1
  140. data/app/views/decidim/votings/admin/ballot_styles/edit.html.erb +0 -1
  141. data/app/views/decidim/votings/admin/ballot_styles/index.html.erb +0 -1
  142. data/app/views/decidim/votings/admin/ballot_styles/new.html.erb +0 -1
  143. data/app/views/decidim/votings/admin/votings/_form.html.erb +10 -1
  144. data/app/views/decidim/votings/admin/votings/edit.html.erb +0 -1
  145. data/app/views/decidim/votings/admin/votings/index.html.erb +0 -1
  146. data/app/views/decidim/votings/admin/votings/new.html.erb +1 -0
  147. data/app/views/decidim/votings/census/admin/census/show.html.erb +0 -1
  148. data/app/views/decidim/votings/polling_officer_zone/closures/_certify_form.html.erb +3 -1
  149. data/app/views/decidim/votings/polling_officer_zone/closures/_sign_form.html.erb +3 -1
  150. data/app/views/decidim/votings/polling_officer_zone/closures/edit.html.erb +3 -1
  151. data/app/views/decidim/votings/polling_officer_zone/closures/new.html.erb +3 -1
  152. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/_complete_voting.html.erb +8 -2
  153. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/new.html.erb +3 -3
  154. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/show.html.erb +3 -3
  155. data/app/views/decidim/votings/votings/_filters.html.erb +2 -3
  156. data/app/views/decidim/votings/votings/_promoted_voting.html.erb +1 -1
  157. data/app/views/layouts/decidim/election_votes.html.erb +3 -1
  158. data/config/assets.rb +1 -1
  159. data/config/locales/am-ET.yml +1 -0
  160. data/config/locales/ar.yml +2 -41
  161. data/config/locales/bg.yml +1 -0
  162. data/config/locales/ca.yml +49 -69
  163. data/config/locales/cs.yml +46 -59
  164. data/config/locales/da.yml +1 -0
  165. data/config/locales/de.yml +24 -180
  166. data/config/locales/el.yml +2 -1090
  167. data/config/locales/en.yml +37 -56
  168. data/config/locales/eo.yml +1 -0
  169. data/config/locales/es-MX.yml +48 -68
  170. data/config/locales/es-PY.yml +48 -68
  171. data/config/locales/es.yml +50 -70
  172. data/config/locales/et.yml +1 -0
  173. data/config/locales/eu.yml +85 -201
  174. data/config/locales/fi-plain.yml +40 -57
  175. data/config/locales/fi.yml +45 -62
  176. data/config/locales/fr-CA.yml +38 -68
  177. data/config/locales/fr.yml +39 -69
  178. data/config/locales/ga-IE.yml +2 -19
  179. data/config/locales/gl.yml +30 -40
  180. data/config/locales/hr.yml +1 -0
  181. data/config/locales/hu.yml +25 -38
  182. data/config/locales/id-ID.yml +1 -0
  183. data/config/locales/is-IS.yml +2 -1
  184. data/config/locales/it.yml +42 -36
  185. data/config/locales/ja.yml +57 -83
  186. data/config/locales/ko.yml +1 -0
  187. data/config/locales/lb.yml +1 -0
  188. data/config/locales/lt.yml +1 -1443
  189. data/config/locales/lv.yml +5 -3
  190. data/config/locales/mt.yml +1 -0
  191. data/config/locales/nl.yml +43 -52
  192. data/config/locales/no.yml +18 -61
  193. data/config/locales/om-ET.yml +1 -0
  194. data/config/locales/pl.yml +50 -49
  195. data/config/locales/pt-BR.yml +40 -49
  196. data/config/locales/pt.yml +41 -35
  197. data/config/locales/ro-RO.yml +22 -71
  198. data/config/locales/ru.yml +1 -0
  199. data/config/locales/si-LK.yml +1 -0
  200. data/config/locales/sk.yml +1 -0
  201. data/config/locales/sl.yml +1 -0
  202. data/config/locales/so-SO.yml +1 -0
  203. data/config/locales/sr-CS.yml +1 -0
  204. data/config/locales/sv.yml +18 -80
  205. data/config/locales/sw-KE.yml +1 -0
  206. data/config/locales/ti-ER.yml +1 -0
  207. data/config/locales/tr-TR.yml +9 -68
  208. data/config/locales/uk.yml +1 -0
  209. data/config/locales/val-ES.yml +1 -0
  210. data/config/locales/vi.yml +1 -0
  211. data/config/locales/zh-CN.yml +7 -30
  212. data/config/locales/zh-TW.yml +1 -1386
  213. data/db/migrate/20220404112802_rename_bb_status_tally_to_tally_started.rb +19 -0
  214. data/db/migrate/20220424121541_add_show_check_census_to_votings.rb +7 -0
  215. data/db/migrate/20220615102642_remove_description_from_elections_questions.rb +1 -1
  216. data/lib/decidim/elections/component.rb +4 -4
  217. data/lib/decidim/elections/test/factories.rb +4 -5
  218. data/lib/decidim/elections/version.rb +1 -1
  219. data/lib/decidim/votings/admin_engine.rb +0 -4
  220. data/lib/decidim/votings/participatory_space.rb +3 -3
  221. data/lib/decidim/votings/test/factories.rb +2 -1
  222. data/lib/decidim/votings/voting_serializer.rb +2 -2
  223. metadata +27 -41
  224. data/app/controllers/decidim/votings/admin/exports_controller.rb +0 -14
  225. data/app/controllers/decidim/votings/admin/imports_controller.rb +0 -14
  226. data/app/controllers/decidim/votings/admin/reminders_controller.rb +0 -14
  227. data/app/packs/src/decidim/elections/broken_promises_handler.js +0 -11
  228. data/app/services/decidim/elections/election_search.rb +0 -35
  229. data/app/services/decidim/votings/voting_search.rb +0 -46
  230. data/app/views/decidim/elections/shared/_broken_promises_modal.html.erb +0 -33
  231. data/config/environment.rb +0 -3
  232. data/config/locales/fa-IR.yml +0 -1
  233. data/config/locales/gn-PY.yml +0 -1
  234. data/config/locales/ka-GE.yml +0 -1
  235. data/config/locales/kaa.yml +0 -1
  236. data/config/locales/lo-LA.yml +0 -1
  237. data/config/locales/oc-FR.yml +0 -1
  238. data/config/locales/sq-AL.yml +0 -1
  239. data/config/locales/th-TH.yml +0 -1
  240. /data/app/packs/entrypoints/{decidim_elections_trustee_tally.js → decidim_elections_trustee_tally_started.js} +0 -0
  241. /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 < Rectify::Command
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 < Rectify::Command
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 < Rectify::Command
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
- dataset = create_census_dataset!
28
+ process_file_locally(form.file) do |file_path|
29
+ @file_path = file_path
30
+ dataset = create_census_dataset!
27
31
 
28
- if csv_header_invalid?
29
- dataset.destroy!
30
- return broadcast(:invalid_csv_header)
31
- end
32
+ if csv_header_invalid?
33
+ dataset.destroy!
34
+ return broadcast(:invalid_csv_header)
35
+ end
32
36
 
33
- if dataset
34
- CSV.foreach(form.file.tempfile.path, col_sep: ";", headers: true, converters: ->(f) { f&.strip }) do |row|
35
- CreateDatumJob.perform_later(current_user, dataset, row.fields)
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
- attr_reader :form, :current_user
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.original_filename,
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(form.file.tempfile.path), col_sep: ";", headers: true, header_converters: :symbol).headers != expected_headers
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(form.file.tempfile.path) - 1
83
+ @csv_row_count ||= file_lines_count - 1
81
84
  end
82
85
 
83
- def file_lines_count(file_path)
84
- `wc -l "#{file_path.shellescape}"`.strip.split(" ")[0].to_i
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
@@ -6,7 +6,7 @@ module Decidim
6
6
  module Admin
7
7
  # A command with the business logic to create the datum for a
8
8
  # dataset row.
9
- class CreateDatum < Rectify::Command
9
+ class CreateDatum < Decidim::Command
10
10
  def initialize(form, dataset)
11
11
  @form = form
12
12
  @dataset = dataset
@@ -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 < Rectify::Command
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 < Rectify::Command
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 export
8
- class LaunchAccessCodesExport < Rectify::Command
8
+ class LaunchAccessCodesExport < Decidim::Command
9
9
  def initialize(dataset, user)
10
10
  @dataset = dataset
11
11
  @user = user
@@ -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 < Rectify::Command
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 < Rectify::Command
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 < Rectify::Command
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 to check if census data is given
6
- class CheckCensus < Rectify::Command
6
+ class CheckCensus < Decidim::Command
7
7
  def initialize(form)
8
8
  @form = form
9
9
  end
@@ -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 < Rectify::Command
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 < Rectify::Command
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 to send the access code
6
- class SendAccessCode < Rectify::Command
6
+ class SendAccessCode < Decidim::Command
7
7
  def initialize(datum, medium)
8
8
  @datum = datum
9
9
  @medium = medium
@@ -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 < Rectify::Command
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 < Rectify::Command
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 < Rectify::Command
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
- "tally" => ReportMissingTrusteeForm,
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
- "tally" => ReportMissingTrustee,
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], participatory_space: current_participatory_space)
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 ||= Election.where(component: current_component).published
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 ||= reorder(search.results.published)
61
- @paginated_elections = paginate(@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 ||= search_klass.new(search_params.merge(state: %w(active upcoming))).results
67
+ @scheduled_elections ||= search_with(filter_params.merge(with_any_date: %w(active upcoming))).result
66
68
  end
67
69
 
68
- def search_klass
69
- ElectionSearch
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
- search_text: "",
75
- state: default_filter_state_params
76
+ search_text_cont: "",
77
+ with_any_date: default_filter_date_params
76
78
  }
77
79
  end
78
80
 
79
- def default_filter_state_params
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
- ::Decidim.permissions_registry.chain_for(::Decidim::Elections::TrusteeZone::ApplicationController)
37
+ [
38
+ Decidim::Elections::Permissions,
39
+ Decidim::Permissions
40
+ ]
43
41
  end
44
42
  end
45
43
  end
@@ -41,7 +41,7 @@ module Decidim
41
41
  end
42
42
 
43
43
  def current_step
44
- @current_step ||= election.bb_status if election.bb_key_ceremony? || election.bb_tally?
44
+ @current_step ||= election.bb_status if election.bb_key_ceremony? || election.bb_tally_started?
45
45
  end
46
46
  end
47
47
  end
@@ -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], organization: current_organization)
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], organization: current_organization)
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.where(component: current_participatory_space.components).find(params[:election_id])
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 ||= reorder(search.results.published)
133
- @paginated_votings = paginate(@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 ||= search_klass.new(search_params.merge(state: ["finished"])).results
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 search_klass
151
- VotingSearch
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
- search_text: "",
157
- state: [""]
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: I18n.t("datetime.distance_in_words.x_hours", count: Decidim::Elections.setup_minimum_hours_before_start) },
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.map do |message, t_args, _valid|
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.any? || defined?(@trustees)
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.map do |message, t_args, _valid|
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.to_h
32
+ end
33
33
  end
34
34
  end
35
35
  end
@@ -11,7 +11,7 @@ module Decidim
11
11
  validates :code, presence: true
12
12
 
13
13
  def code
14
- @code&.upcase
14
+ super&.upcase
15
15
  end
16
16
  end
17
17
  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, String
18
+ attribute :banner_image
19
19
  attribute :remove_introductory_image, Boolean, default: false
20
- attribute :introductory_image, String
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, message: "%{value} is not a valid voting type" }
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
- validates_upload :file
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
@@ -25,7 +25,7 @@ module Decidim
25
25
  presence: true
26
26
 
27
27
  def ballot_style_code
28
- @ballot_style_code&.upcase
28
+ super&.upcase
29
29
  end
30
30
  end
31
31
  end