decidim-elections 0.27.9 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (459) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +60 -3
  3. data/app/cells/decidim/elections/content_blocks/related_elections_cell.rb +13 -0
  4. data/app/cells/decidim/elections/election_cell.rb +7 -2
  5. data/app/cells/decidim/elections/election_g_cell.rb +23 -0
  6. data/app/cells/decidim/elections/election_metadata_cell.rb +57 -0
  7. data/app/cells/decidim/elections/election_preview/show.erb +24 -24
  8. data/app/cells/decidim/elections/election_results/progress_bar.erb +6 -7
  9. data/app/cells/decidim/elections/election_results/show.erb +36 -33
  10. data/app/cells/decidim/elections/election_s_cell.rb +10 -0
  11. data/app/cells/decidim/elections/election_vote_cta/show.erb +14 -26
  12. data/app/cells/decidim/elections/election_vote_cta_cell.rb +0 -9
  13. data/app/cells/decidim/elections/highlighted_elections_for_component/show.erb +18 -0
  14. data/app/cells/decidim/elections/highlighted_elections_for_component_cell.rb +50 -0
  15. data/app/cells/decidim/elections/remaining_time_callout/show.erb +1 -3
  16. data/app/cells/decidim/elections/voting_step_navigation/show.erb +21 -25
  17. data/app/cells/decidim/elections/voting_step_navigation_cell.rb +2 -2
  18. data/app/cells/decidim/votings/content_block_cell.rb +5 -1
  19. data/app/cells/decidim/votings/content_blocks/hero_cell.rb +53 -0
  20. data/app/cells/decidim/votings/content_blocks/hero_settings_form_cell.rb +15 -0
  21. data/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb +12 -21
  22. data/app/cells/decidim/votings/content_blocks/highlighted_votings_settings_form/show.erb +1 -1
  23. data/app/cells/decidim/votings/content_blocks/main_data_cell.rb +34 -0
  24. data/app/cells/decidim/votings/content_blocks/metrics_cell.rb +17 -0
  25. data/app/cells/decidim/votings/content_blocks/polling_stations/show.erb +21 -0
  26. data/app/cells/decidim/votings/content_blocks/polling_stations_cell.rb +31 -0
  27. data/app/cells/decidim/votings/content_blocks/statistics_cell.rb +18 -0
  28. data/app/cells/decidim/votings/polling_officers/polling_officers_picker/show.erb +14 -13
  29. data/app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb +19 -16
  30. data/app/cells/decidim/votings/polling_station_closure_certificate/show.erb +5 -7
  31. data/app/cells/decidim/votings/polling_station_closure_recount/show.erb +55 -59
  32. data/app/cells/decidim/votings/voting_cell.rb +7 -2
  33. data/app/cells/decidim/votings/voting_dropdown_metadata_cell.rb +19 -0
  34. data/app/cells/decidim/votings/voting_g_cell.rb +19 -0
  35. data/app/cells/decidim/votings/voting_map/show.erb +16 -0
  36. data/app/cells/decidim/votings/voting_map_cell.rb +28 -0
  37. data/app/cells/decidim/votings/voting_metadata_cell.rb +66 -0
  38. data/app/cells/decidim/votings/voting_s_cell.rb +10 -0
  39. data/app/commands/decidim/elections/admin/add_user_as_trustee.rb +5 -5
  40. data/app/commands/decidim/elections/admin/create_answer.rb +0 -1
  41. data/app/commands/decidim/elections/admin/create_election.rb +0 -1
  42. data/app/commands/decidim/elections/admin/destroy_answer.rb +0 -1
  43. data/app/commands/decidim/elections/admin/destroy_election.rb +0 -1
  44. data/app/commands/decidim/elections/admin/end_vote.rb +2 -2
  45. data/app/commands/decidim/elections/admin/import_proposals_to_elections.rb +1 -1
  46. data/app/commands/decidim/elections/admin/publish_election.rb +1 -1
  47. data/app/commands/decidim/elections/admin/publish_results.rb +2 -2
  48. data/app/commands/decidim/elections/admin/report_missing_trustee.rb +2 -2
  49. data/app/commands/decidim/elections/admin/setup_election.rb +2 -2
  50. data/app/commands/decidim/elections/admin/start_key_ceremony.rb +2 -2
  51. data/app/commands/decidim/elections/admin/start_tally.rb +2 -2
  52. data/app/commands/decidim/elections/admin/start_vote.rb +2 -2
  53. data/app/commands/decidim/elections/admin/unpublish_election.rb +1 -1
  54. data/app/commands/decidim/elections/admin/update_answer.rb +0 -1
  55. data/app/commands/decidim/elections/admin/update_answer_selection.rb +1 -1
  56. data/app/commands/decidim/elections/admin/update_election.rb +0 -1
  57. data/app/commands/decidim/elections/trustee_zone/update_election_bulletin_board_status.rb +3 -3
  58. data/app/commands/decidim/elections/voter/cast_vote.rb +1 -1
  59. data/app/commands/decidim/elections/voter/update_vote_status.rb +2 -2
  60. data/app/commands/decidim/votings/admin/create_ballot_style.rb +1 -1
  61. data/app/commands/decidim/votings/admin/create_monitoring_committee_member.rb +4 -4
  62. data/app/commands/decidim/votings/admin/create_polling_officer.rb +4 -4
  63. data/app/commands/decidim/votings/admin/create_polling_station.rb +1 -1
  64. data/app/commands/decidim/votings/admin/create_voting.rb +1 -1
  65. data/app/commands/decidim/votings/admin/destroy_ballot_style.rb +1 -1
  66. data/app/commands/decidim/votings/admin/destroy_monitoring_committee_member.rb +1 -1
  67. data/app/commands/decidim/votings/admin/destroy_polling_officer.rb +1 -1
  68. data/app/commands/decidim/votings/admin/manage_polling_station.rb +1 -1
  69. data/app/commands/decidim/votings/admin/monitoring_committee_validate_polling_station_closure.rb +1 -1
  70. data/app/commands/decidim/votings/admin/update_ballot_style.rb +1 -1
  71. data/app/commands/decidim/votings/admin/update_voting.rb +1 -1
  72. data/app/commands/decidim/votings/census/admin/create_dataset.rb +2 -2
  73. data/app/commands/decidim/votings/census/admin/create_datum.rb +3 -3
  74. data/app/commands/decidim/votings/census/admin/destroy_dataset.rb +1 -1
  75. data/app/commands/decidim/votings/census/admin/increment_dataset_processed_rows.rb +1 -1
  76. data/app/commands/decidim/votings/census/admin/launch_access_codes_generation.rb +1 -1
  77. data/app/commands/decidim/votings/census/admin/update_dataset.rb +1 -1
  78. data/app/commands/decidim/votings/certify_polling_station_closure.rb +1 -2
  79. data/app/commands/decidim/votings/create_polling_station_closure.rb +1 -1
  80. data/app/commands/decidim/votings/create_polling_station_results.rb +1 -1
  81. data/app/commands/decidim/votings/send_access_code.rb +5 -1
  82. data/app/commands/decidim/votings/sign_polling_station_closure.rb +2 -2
  83. data/app/commands/decidim/votings/voter/in_person_vote.rb +1 -1
  84. data/app/constraints/decidim/votings/current_voting.rb +1 -1
  85. data/app/controllers/concerns/decidim/elections/content_security_policy.rb +23 -0
  86. data/app/controllers/concerns/decidim/elections/has_vote_flow.rb +2 -2
  87. data/app/controllers/concerns/decidim/votings/admin/voting_admin.rb +1 -1
  88. data/app/controllers/concerns/decidim/votings/needs_voting.rb +1 -1
  89. data/app/controllers/decidim/elections/admin/answers_controller.rb +9 -10
  90. data/app/controllers/decidim/elections/admin/application_controller.rb +1 -0
  91. data/app/controllers/decidim/elections/admin/elections_controller.rb +7 -7
  92. data/app/controllers/decidim/elections/admin/feedback_forms_controller.rb +2 -2
  93. data/app/controllers/decidim/elections/admin/proposals_imports_controller.rb +3 -3
  94. data/app/controllers/decidim/elections/admin/questions_controller.rb +7 -7
  95. data/app/controllers/decidim/elections/admin/steps_controller.rb +4 -4
  96. data/app/controllers/decidim/elections/admin/trustees_participatory_spaces_controller.rb +2 -2
  97. data/app/controllers/decidim/elections/application_controller.rb +1 -0
  98. data/app/controllers/decidim/elections/elections_controller.rb +5 -2
  99. data/app/controllers/decidim/elections/trustee_zone/application_controller.rb +1 -0
  100. data/app/controllers/decidim/elections/trustee_zone/elections_controller.rb +2 -2
  101. data/app/controllers/decidim/elections/trustee_zone/trustees_controller.rb +3 -3
  102. data/app/controllers/decidim/elections/votes_controller.rb +19 -13
  103. data/app/controllers/decidim/votings/admin/monitoring_committee_election_results_controller.rb +11 -3
  104. data/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb +3 -3
  105. data/app/controllers/decidim/votings/admin/monitoring_committee_polling_station_closures_controller.rb +3 -3
  106. data/app/controllers/decidim/votings/admin/polling_officers_controller.rb +3 -3
  107. data/app/controllers/decidim/votings/admin/polling_stations_controller.rb +3 -4
  108. data/app/controllers/decidim/votings/admin/voting_attachment_collections_controller.rb +5 -0
  109. data/app/controllers/decidim/votings/admin/voting_attachments_controller.rb +5 -0
  110. data/app/controllers/decidim/votings/admin/voting_publications_controller.rb +25 -0
  111. data/app/controllers/decidim/votings/admin/votings_controller.rb +2 -26
  112. data/app/controllers/decidim/votings/admin/votings_landing_page_content_blocks_controller.rb +1 -5
  113. data/app/controllers/decidim/votings/admin/votings_landing_page_controller.rb +4 -7
  114. data/app/controllers/decidim/votings/census/admin/census_controller.rb +2 -2
  115. data/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb +12 -12
  116. data/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb +17 -10
  117. data/app/controllers/decidim/votings/polling_officer_zone/polling_officers_controller.rb +1 -1
  118. data/app/controllers/decidim/votings/votings_controller.rb +7 -9
  119. data/app/events/decidim/elections/election_published_event.rb +1 -1
  120. data/app/events/decidim/elections/trustees/notify_new_trustee_event.rb +1 -1
  121. data/app/events/decidim/elections/trustees/notify_trustee_new_election_event.rb +1 -1
  122. data/app/events/decidim/elections/votes/vote_accepted_event.rb +1 -1
  123. data/app/events/decidim/votings/polling_officers/polling_station_assigned_event.rb +1 -1
  124. data/app/forms/decidim/elections/admin/answer_form.rb +1 -1
  125. data/app/forms/decidim/elections/admin/election_form.rb +1 -1
  126. data/app/forms/decidim/votings/admin/publish_results_form.rb +5 -5
  127. data/app/forms/decidim/votings/admin/voting_form.rb +1 -1
  128. data/app/forms/decidim/votings/admin/{polling_officer_form.rb → voting_user_role_form.rb} +1 -1
  129. data/app/forms/decidim/votings/census/frontend_fields.rb +1 -1
  130. data/app/forms/decidim/votings/census/in_person_fields.rb +8 -4
  131. data/app/forms/decidim/votings/closure_result_form.rb +2 -2
  132. data/app/helpers/decidim/elections/admin/trustees_participatory_spaces_helper.rb +4 -2
  133. data/app/helpers/decidim/elections/application_helper.rb +8 -0
  134. data/app/helpers/decidim/votings/map_helper.rb +22 -0
  135. data/app/helpers/decidim/votings/votings_helper.rb +33 -0
  136. data/app/jobs/decidim/votings/census/admin/create_datum_job.rb +1 -1
  137. data/app/jobs/decidim/votings/census/admin/generate_access_codes_job.rb +2 -2
  138. data/app/mailers/decidim/votings/access_code_mailer.rb +1 -1
  139. data/app/mailers/decidim/votings/census/export_mailer.rb +1 -1
  140. data/app/models/decidim/elections/trustee.rb +2 -2
  141. data/app/models/decidim/votings/ballot_style.rb +1 -1
  142. data/app/models/decidim/votings/polling_officer.rb +2 -2
  143. data/app/models/decidim/votings/polling_station.rb +1 -1
  144. data/app/packs/entrypoints/decidim_elections.js +12 -0
  145. data/app/packs/entrypoints/decidim_elections_admin.js +6 -0
  146. data/app/packs/entrypoints/decidim_votings.js +11 -0
  147. data/app/packs/entrypoints/decidim_votings_admin.js +10 -0
  148. data/app/packs/src/decidim/elections/admin/pending_action.js +10 -7
  149. data/app/packs/src/decidim/elections/admin/trustees_process.js +107 -104
  150. data/app/packs/src/decidim/elections/admin/vote_statistics.js +6 -3
  151. data/app/packs/src/decidim/elections/broken_promises_handler.js +9 -7
  152. data/app/packs/src/decidim/elections/election_log.js +126 -128
  153. data/app/packs/src/decidim/elections/trustee/key_ceremony.js +138 -139
  154. data/app/packs/src/decidim/elections/trustee/tally.js +122 -118
  155. data/app/packs/src/decidim/elections/trustee/trustee_zone.js +9 -7
  156. data/app/packs/src/decidim/elections/voter/casting-vote.js +9 -7
  157. data/app/packs/src/decidim/elections/voter/new-vote.js +92 -71
  158. data/app/packs/src/decidim/elections/voter/setup-preview.js +0 -4
  159. data/app/packs/src/decidim/elections/voter/setup-vote.js +0 -4
  160. data/app/packs/src/decidim/elections/voter/verify-vote.js +11 -6
  161. data/app/packs/src/decidim/elections/voter/vote_questions.component.js +74 -28
  162. data/app/packs/src/decidim/votings/admin/polling_officers_picker.js +16 -31
  163. data/app/packs/src/decidim/votings/admin/polling_stations_form.js +4 -1
  164. data/app/packs/src/decidim/votings/admin/{polling_officers_form.js → voting_user_role_form.js} +1 -1
  165. data/app/packs/src/decidim/votings/in-person-vote.js +4 -4
  166. data/app/packs/src/decidim/votings/polling_officer_zone/edit-closure.js +4 -4
  167. data/app/packs/src/decidim/votings/polling_officer_zone/in-person-vote.js +1 -1
  168. data/app/packs/src/decidim/votings/polling_officer_zone/new-closure.js +6 -8
  169. data/app/packs/stylesheets/decidim/elections/elections.scss +200 -6
  170. data/app/packs/stylesheets/decidim/votings/admin/votings/_ballot-styles.scss +3 -3
  171. data/app/packs/stylesheets/decidim/votings/admin/votings/_monitoring-committee-polling-station-closures.scss +2 -2
  172. data/app/packs/stylesheets/decidim/votings/admin/votings/_results.scss +1 -1
  173. data/app/packs/stylesheets/decidim/votings/admin/votings.scss +20 -0
  174. data/app/packs/stylesheets/decidim/votings/votings.scss +53 -2
  175. data/app/permissions/decidim/votings/admin/permissions.rb +2 -2
  176. data/app/presenters/decidim/elections/admin_log/election_presenter.rb +2 -2
  177. data/app/presenters/decidim/elections/admin_log/trustee_presenter.rb +2 -2
  178. data/app/presenters/decidim/elections/trustee_presenter.rb +1 -1
  179. data/app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb +2 -2
  180. data/app/presenters/decidim/votings/admin_log/monitoring_committee_member_presenter.rb +2 -2
  181. data/app/presenters/decidim/votings/admin_log/polling_officer_presenter.rb +2 -2
  182. data/app/presenters/decidim/votings/admin_log/polling_station_presenter.rb +2 -2
  183. data/app/presenters/decidim/votings/admin_log/voting_presenter.rb +2 -2
  184. data/app/presenters/decidim/votings/census/admin_log/dataset_presenter.rb +2 -2
  185. data/app/presenters/decidim/votings/voting_stats_presenter.rb +3 -42
  186. data/app/services/decidim/votings/census/access_codes_exporter.rb +1 -1
  187. data/app/services/decidim/votings/census_vote_flow.rb +3 -3
  188. data/app/views/decidim/elections/admin/answers/_form.html.erb +16 -18
  189. data/app/views/decidim/elections/admin/answers/edit.html.erb +21 -5
  190. data/app/views/decidim/elections/admin/answers/index.html.erb +33 -18
  191. data/app/views/decidim/elections/admin/answers/new.html.erb +21 -5
  192. data/app/views/decidim/elections/admin/elections/_form.html.erb +20 -19
  193. data/app/views/decidim/elections/admin/elections/edit.html.erb +16 -6
  194. data/app/views/decidim/elections/admin/elections/index.html.erb +72 -70
  195. data/app/views/decidim/elections/admin/elections/new.html.erb +16 -6
  196. data/app/views/decidim/elections/admin/proposals_imports/new.html.erb +36 -21
  197. data/app/views/decidim/elections/admin/questions/_form.html.erb +18 -20
  198. data/app/views/decidim/elections/admin/questions/edit.html.erb +20 -6
  199. data/app/views/decidim/elections/admin/questions/index.html.erb +50 -49
  200. data/app/views/decidim/elections/admin/questions/new.html.erb +20 -5
  201. data/app/views/decidim/elections/admin/steps/_create_election.html.erb +41 -36
  202. data/app/views/decidim/elections/admin/steps/_created.html.erb +2 -2
  203. data/app/views/decidim/elections/admin/steps/_key_ceremony.html.erb +7 -7
  204. data/app/views/decidim/elections/admin/steps/_key_ceremony_ended.html.erb +2 -2
  205. data/app/views/decidim/elections/admin/steps/_results_published.html.erb +4 -4
  206. data/app/views/decidim/elections/admin/steps/_tally_ended.html.erb +4 -4
  207. data/app/views/decidim/elections/admin/steps/_tally_started.html.erb +11 -11
  208. data/app/views/decidim/elections/admin/steps/_vote.html.erb +3 -3
  209. data/app/views/decidim/elections/admin/steps/_vote_ended.html.erb +2 -2
  210. data/app/views/decidim/elections/admin/steps/_vote_stats.html.erb +2 -2
  211. data/app/views/decidim/elections/admin/steps/index.html.erb +44 -37
  212. data/app/views/decidim/elections/admin/trustees_participatory_spaces/_form.html.erb +10 -14
  213. data/app/views/decidim/elections/admin/trustees_participatory_spaces/index.html.erb +57 -60
  214. data/app/views/decidim/elections/admin/trustees_participatory_spaces/new.html.erb +16 -5
  215. data/app/views/decidim/elections/elections/_elections.html.erb +9 -16
  216. data/app/views/decidim/elections/elections/election_log.html.erb +171 -179
  217. data/app/views/decidim/elections/elections/index.html.erb +18 -21
  218. data/app/views/decidim/elections/elections/index.js.erb +0 -5
  219. data/app/views/decidim/elections/elections/show.html.erb +63 -39
  220. data/app/views/decidim/elections/shared/_broken_promises_modal.html.erb +18 -27
  221. data/app/views/decidim/elections/trustee_zone/elections/_backup_modal.html.erb +10 -20
  222. data/app/views/decidim/elections/trustee_zone/elections/_key_ceremony_steps.html.erb +32 -27
  223. data/app/views/decidim/elections/trustee_zone/elections/_restore_modal.html.erb +11 -21
  224. data/app/views/decidim/elections/trustee_zone/elections/_tally_started_steps.html.erb +46 -41
  225. data/app/views/decidim/elections/trustee_zone/elections/show.html.erb +4 -6
  226. data/app/views/decidim/elections/trustee_zone/trustees/_no_public_keys.html.erb +30 -0
  227. data/app/views/decidim/elections/trustee_zone/trustees/_public_keys.html.erb +17 -0
  228. data/app/views/decidim/elections/trustee_zone/trustees/_table.html.erb +28 -0
  229. data/app/views/decidim/elections/trustee_zone/trustees/show.html.erb +21 -96
  230. data/app/views/decidim/elections/votes/_new_ballot_decision_step.html.erb +22 -26
  231. data/app/views/decidim/elections/votes/_new_confirm_step.html.erb +59 -47
  232. data/app/views/decidim/elections/votes/_new_encrypting_step.html.erb +8 -19
  233. data/app/views/decidim/elections/votes/_new_question.html.erb +12 -28
  234. data/app/views/decidim/elections/votes/_new_question_modal.html.erb +20 -23
  235. data/app/views/decidim/elections/votes/_onboarding_modal.html.erb +14 -22
  236. data/app/views/decidim/elections/votes/_show_casted.html.erb +28 -30
  237. data/app/views/decidim/elections/votes/_show_casting.html.erb +12 -19
  238. data/app/views/decidim/elections/votes/_show_failed.html.erb +20 -17
  239. data/app/views/decidim/elections/votes/new.html.erb +78 -61
  240. data/app/views/decidim/elections/votes/show.html.erb +12 -11
  241. data/app/views/decidim/elections/votes/verify.html.erb +40 -61
  242. data/app/views/decidim/votings/admin/ballot_styles/_form.html.erb +19 -19
  243. data/app/views/decidim/votings/admin/ballot_styles/edit.html.erb +16 -6
  244. data/app/views/decidim/votings/admin/ballot_styles/index.html.erb +50 -54
  245. data/app/views/decidim/votings/admin/ballot_styles/new.html.erb +16 -6
  246. data/app/views/decidim/votings/admin/monitoring_committee_election_results/_results.html.erb +43 -46
  247. data/app/views/decidim/votings/admin/monitoring_committee_election_results/index.html.erb +23 -25
  248. data/app/views/decidim/votings/admin/monitoring_committee_election_results/show.html.erb +5 -5
  249. data/app/views/decidim/votings/admin/monitoring_committee_members/_form.html.erb +19 -20
  250. data/app/views/decidim/votings/admin/monitoring_committee_members/index.html.erb +32 -34
  251. data/app/views/decidim/votings/admin/monitoring_committee_members/new.html.erb +17 -6
  252. data/app/views/decidim/votings/admin/monitoring_committee_polling_station_closures/_closure_certificate_results.erb +1 -1
  253. data/app/views/decidim/votings/admin/monitoring_committee_polling_station_closures/_closures.html.erb +53 -56
  254. data/app/views/decidim/votings/admin/monitoring_committee_polling_station_closures/_elections.html.erb +22 -25
  255. data/app/views/decidim/votings/admin/monitoring_committee_polling_station_closures/edit.html.erb +12 -11
  256. data/app/views/decidim/votings/admin/monitoring_committee_polling_station_closures/show.html.erb +1 -1
  257. data/app/views/decidim/votings/admin/monitoring_committee_verify_elections/index.html.erb +37 -39
  258. data/app/views/decidim/votings/admin/polling_officers/_form.html.erb +19 -20
  259. data/app/views/decidim/votings/admin/polling_officers/index.html.erb +40 -41
  260. data/app/views/decidim/votings/admin/polling_officers/new.html.erb +17 -6
  261. data/app/views/decidim/votings/admin/polling_stations/_form.html.erb +25 -31
  262. data/app/views/decidim/votings/admin/polling_stations/edit.html.erb +17 -6
  263. data/app/views/decidim/votings/admin/polling_stations/index.html.erb +46 -47
  264. data/app/views/decidim/votings/admin/polling_stations/new.html.erb +17 -6
  265. data/app/views/decidim/votings/admin/votings/_form.html.erb +49 -52
  266. data/app/views/decidim/votings/admin/votings/edit.html.erb +35 -28
  267. data/app/views/decidim/votings/admin/votings/index.html.erb +58 -82
  268. data/app/views/decidim/votings/admin/votings/new.html.erb +16 -9
  269. data/app/views/decidim/votings/census/admin/census/_creating_data.html.erb +4 -4
  270. data/app/views/decidim/votings/census/admin/census/_export_codes.html.erb +3 -3
  271. data/app/views/decidim/votings/census/admin/census/_generate_codes.html.erb +8 -8
  272. data/app/views/decidim/votings/census/admin/census/_new_census.html.erb +8 -7
  273. data/app/views/decidim/votings/census/admin/census/_upload_info.html.erb +5 -5
  274. data/app/views/decidim/votings/census/admin/census/show.html.erb +7 -7
  275. data/app/views/decidim/votings/polling_officer_zone/closures/_answer_results_form_fields.html.erb +2 -3
  276. data/app/views/decidim/votings/polling_officer_zone/closures/_ballot_results_form_fields.html.erb +24 -35
  277. data/app/views/decidim/votings/polling_officer_zone/closures/_certify_form.html.erb +5 -9
  278. data/app/views/decidim/votings/polling_officer_zone/closures/_modal_ballots_count_error.html.erb +34 -48
  279. data/app/views/decidim/votings/polling_officer_zone/closures/_modal_ballots_results_count_error.html.erb +18 -18
  280. data/app/views/decidim/votings/polling_officer_zone/closures/_question_results_form_fields.html.erb +12 -17
  281. data/app/views/decidim/votings/polling_officer_zone/closures/_sign_form.html.erb +34 -49
  282. data/app/views/decidim/votings/polling_officer_zone/closures/edit.html.erb +50 -37
  283. data/app/views/decidim/votings/polling_officer_zone/closures/new.html.erb +57 -51
  284. data/app/views/decidim/votings/polling_officer_zone/closures/show.html.erb +44 -34
  285. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/_complete_voting.html.erb +40 -57
  286. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/_in_person_form.html.erb +34 -47
  287. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/_verify_document.html.erb +19 -22
  288. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/new.html.erb +12 -12
  289. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/show.html.erb +22 -21
  290. data/app/views/decidim/votings/polling_officer_zone/polling_officers/_polling_station.html.erb +34 -41
  291. data/app/views/decidim/votings/polling_officer_zone/polling_officers/index.html.erb +9 -5
  292. data/app/views/decidim/votings/votings/_access_code_modal.html.erb +26 -31
  293. data/app/views/decidim/votings/votings/_check_fields.html.erb +19 -28
  294. data/app/views/decidim/votings/votings/_polling_officers_picker.html.erb +4 -0
  295. data/app/views/decidim/votings/votings/_votings.html.erb +5 -11
  296. data/app/views/decidim/votings/votings/check_census.html.erb +53 -53
  297. data/app/views/decidim/votings/votings/elections_log.html.erb +25 -22
  298. data/app/views/decidim/votings/votings/index.html.erb +24 -25
  299. data/app/views/decidim/votings/votings/index.js.erb +0 -5
  300. data/app/views/decidim/votings/votings/login.html.erb +51 -44
  301. data/app/views/decidim/votings/votings/show.html.erb +5 -7
  302. data/app/views/layouts/decidim/admin/voting.html.erb +11 -11
  303. data/app/views/layouts/decidim/admin/votings.html.erb +16 -0
  304. data/app/views/layouts/decidim/votings.html.erb +10 -14
  305. data/config/assets.rb +3 -28
  306. data/config/locales/ar.yml +0 -6
  307. data/config/locales/bg.yml +0 -1431
  308. data/config/locales/ca.yml +169 -223
  309. data/config/locales/cs.yml +157 -210
  310. data/config/locales/de.yml +161 -215
  311. data/config/locales/el.yml +164 -108
  312. data/config/locales/en.yml +183 -237
  313. data/config/locales/es-MX.yml +164 -218
  314. data/config/locales/es-PY.yml +163 -217
  315. data/config/locales/es.yml +168 -222
  316. data/config/locales/eu.yml +165 -222
  317. data/config/locales/fi-plain.yml +154 -208
  318. data/config/locales/fi.yml +162 -216
  319. data/config/locales/fr-CA.yml +168 -223
  320. data/config/locales/fr.yml +171 -226
  321. data/config/locales/ga-IE.yml +0 -40
  322. data/config/locales/gl.yml +2 -79
  323. data/config/locales/hu.yml +0 -62
  324. data/config/locales/it.yml +6 -243
  325. data/config/locales/ja.yml +173 -227
  326. data/config/locales/lt.yml +135 -204
  327. data/config/locales/lv.yml +0 -34
  328. data/config/locales/nl.yml +2 -211
  329. data/config/locales/no.yml +1 -131
  330. data/config/locales/pl.yml +3 -407
  331. data/config/locales/pt-BR.yml +4 -374
  332. data/config/locales/pt.yml +4 -245
  333. data/config/locales/ro-RO.yml +2 -143
  334. data/config/locales/ru.yml +0 -5
  335. data/config/locales/sk.yml +0 -5
  336. data/config/locales/sv.yml +12 -109
  337. data/config/locales/tr-TR.yml +58 -126
  338. data/config/locales/uk.yml +0 -5
  339. data/config/locales/zh-CN.yml +1 -68
  340. data/config/locales/zh-TW.yml +84 -166
  341. data/db/migrate/20210310120708_add_followable_counter_cache_to_votings.rb +2 -6
  342. data/lib/decidim/api/election_type.rb +1 -1
  343. data/lib/decidim/api/elections_type.rb +1 -1
  344. data/lib/decidim/elections/admin_engine.rb +4 -19
  345. data/lib/decidim/elections/component.rb +4 -452
  346. data/lib/decidim/elections/engine.rb +23 -1
  347. data/lib/decidim/elections/menu.rb +39 -0
  348. data/lib/decidim/elections/seeds.rb +435 -0
  349. data/lib/decidim/elections/test/factories.rb +22 -21
  350. data/lib/decidim/elections/trustee_zone_engine.rb +3 -7
  351. data/lib/decidim/elections/version.rb +1 -1
  352. data/lib/decidim/elections.rb +6 -0
  353. data/lib/decidim/votings/admin_engine.rb +16 -122
  354. data/lib/decidim/votings/census_admin_engine.rb +4 -8
  355. data/lib/decidim/votings/census_menu.rb +18 -0
  356. data/lib/decidim/votings/content_blocks/registry_manager.rb +88 -0
  357. data/lib/decidim/votings/engine.rb +12 -88
  358. data/lib/decidim/votings/menu.rb +164 -0
  359. data/lib/decidim/votings/participatory_space.rb +6 -190
  360. data/lib/decidim/votings/polling_officer_zone_engine.rb +3 -7
  361. data/lib/decidim/votings/polling_officer_zone_menu.rb +17 -0
  362. data/lib/decidim/votings/query_extensions.rb +4 -4
  363. data/lib/decidim/votings/seeds.rb +197 -0
  364. data/lib/decidim/votings/test/factories.rb +29 -13
  365. data/lib/decidim/votings/voting_serializer.rb +1 -1
  366. data/lib/tasks/decidim_elections.rake +2 -2
  367. metadata +76 -125
  368. data/app/cells/decidim/elections/election_m/data.erb +0 -19
  369. data/app/cells/decidim/elections/election_m/footer.erb +0 -5
  370. data/app/cells/decidim/elections/election_m/tags.erb +0 -3
  371. data/app/cells/decidim/elections/election_m_cell.rb +0 -96
  372. data/app/cells/decidim/elections/election_results/blank_votes.erb +0 -7
  373. data/app/cells/decidim/votings/content_blocks/highlighted_votings/show.erb +0 -30
  374. data/app/cells/decidim/votings/content_blocks/landing_page/attachments_and_folders_cell.rb +0 -22
  375. data/app/cells/decidim/votings/content_blocks/landing_page/description/show.erb +0 -15
  376. data/app/cells/decidim/votings/content_blocks/landing_page/description_cell.rb +0 -25
  377. data/app/cells/decidim/votings/content_blocks/landing_page/elections/show.erb +0 -15
  378. data/app/cells/decidim/votings/content_blocks/landing_page/elections/single.erb +0 -11
  379. data/app/cells/decidim/votings/content_blocks/landing_page/elections_cell.rb +0 -47
  380. data/app/cells/decidim/votings/content_blocks/landing_page/header/show.erb +0 -29
  381. data/app/cells/decidim/votings/content_blocks/landing_page/header_cell.rb +0 -108
  382. data/app/cells/decidim/votings/content_blocks/landing_page/header_settings_form_cell.rb +0 -17
  383. data/app/cells/decidim/votings/content_blocks/landing_page/metrics/show.erb +0 -12
  384. data/app/cells/decidim/votings/content_blocks/landing_page/metrics_cell.rb +0 -19
  385. data/app/cells/decidim/votings/content_blocks/landing_page/polling_stations/address.erb +0 -14
  386. data/app/cells/decidim/votings/content_blocks/landing_page/polling_stations/map.erb +0 -18
  387. data/app/cells/decidim/votings/content_blocks/landing_page/polling_stations/show.erb +0 -25
  388. data/app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb +0 -56
  389. data/app/cells/decidim/votings/content_blocks/landing_page/statistics_cell.rb +0 -24
  390. data/app/cells/decidim/votings/content_blocks/landing_page/timeline/show.erb +0 -7
  391. data/app/cells/decidim/votings/content_blocks/landing_page/timeline_cell.rb +0 -17
  392. data/app/cells/decidim/votings/polling_officers/polling_officers_picker/polling_officers.erb +0 -12
  393. data/app/cells/decidim/votings/voting_m/data.erb +0 -21
  394. data/app/cells/decidim/votings/voting_m/footer.erb +0 -5
  395. data/app/cells/decidim/votings/voting_m_cell.rb +0 -94
  396. data/app/commands/decidim/votings/admin/publish_voting.rb +0 -40
  397. data/app/commands/decidim/votings/admin/unpublish_voting.rb +0 -40
  398. data/app/forms/decidim/votings/admin/monitoring_committee_member_form.rb +0 -27
  399. data/app/helpers/decidim/votings/admin/polling_officers_picker_helper.rb +0 -29
  400. data/app/packs/entrypoints/decidim_elections_admin_pending_action.js +0 -1
  401. data/app/packs/entrypoints/decidim_elections_admin_trustees_process.js +0 -1
  402. data/app/packs/entrypoints/decidim_elections_admin_vote_statistics.js +0 -1
  403. data/app/packs/entrypoints/decidim_elections_election_log.js +0 -1
  404. data/app/packs/entrypoints/decidim_elections_onboarding.js +0 -1
  405. data/app/packs/entrypoints/decidim_elections_trustee_key_ceremony.js +0 -1
  406. data/app/packs/entrypoints/decidim_elections_trustee_tally_started.js +0 -1
  407. data/app/packs/entrypoints/decidim_elections_trustee_trustee_zone.js +0 -1
  408. data/app/packs/entrypoints/decidim_elections_trustee_zone.js +0 -1
  409. data/app/packs/entrypoints/decidim_elections_trustee_zone.scss +0 -1
  410. data/app/packs/entrypoints/decidim_elections_voter_casting-vote.js +0 -1
  411. data/app/packs/entrypoints/decidim_elections_voter_new-vote.js +0 -1
  412. data/app/packs/entrypoints/decidim_elections_voter_setup-preview.js +0 -1
  413. data/app/packs/entrypoints/decidim_elections_voter_setup-vote.js +0 -1
  414. data/app/packs/entrypoints/decidim_elections_voter_verify-vote.js +0 -1
  415. data/app/packs/entrypoints/decidim_votings_admin_monitoring_committee_members_form.js +0 -1
  416. data/app/packs/entrypoints/decidim_votings_admin_polling_officers_form.js +0 -1
  417. data/app/packs/entrypoints/decidim_votings_admin_polling_officers_picker.js +0 -1
  418. data/app/packs/entrypoints/decidim_votings_admin_polling_stations_form.js +0 -1
  419. data/app/packs/entrypoints/decidim_votings_admin_update_census_dataset_status.js +0 -1
  420. data/app/packs/entrypoints/decidim_votings_admin_votings.js +0 -1
  421. data/app/packs/entrypoints/decidim_votings_admin_votings.scss +0 -1
  422. data/app/packs/entrypoints/decidim_votings_in-person-vote.js +0 -1
  423. data/app/packs/entrypoints/decidim_votings_voting-description-cell.js +0 -1
  424. data/app/packs/entrypoints/decidim_votings_voting_polling_officer_zone-edit-closure.js +0 -1
  425. data/app/packs/entrypoints/decidim_votings_voting_polling_officer_zone-in-person-vote.js +0 -1
  426. data/app/packs/entrypoints/decidim_votings_voting_polling_officer_zone-new-closure.js +0 -1
  427. data/app/packs/entrypoints/decidim_votings_voting_polling_officer_zone-sign-closure.js +0 -1
  428. data/app/packs/src/decidim/elections/onboarding.js +0 -5
  429. data/app/packs/src/decidim/votings/admin/monitoring_committee_members_form.js +0 -35
  430. data/app/packs/src/decidim/votings/voting-description-cell.js +0 -34
  431. data/app/packs/stylesheets/decidim/elections/focus/_accordion.scss +0 -36
  432. data/app/packs/stylesheets/decidim/elections/focus/_evote.scss +0 -344
  433. data/app/packs/stylesheets/decidim/elections/focus/_focus.scss +0 -128
  434. data/app/packs/stylesheets/decidim/elections/trustee_zone.scss +0 -24
  435. data/app/packs/stylesheets/decidim/votings/votings/_polling-stations-cell.scss +0 -6
  436. data/app/packs/stylesheets/decidim/votings/votings/_voting-description-cell.scss +0 -29
  437. data/app/views/decidim/elections/admin/answers/proposals_picker.html.erb +0 -1
  438. data/app/views/decidim/elections/elections/_count.html.erb +0 -1
  439. data/app/views/decidim/elections/elections/_election.html.erb +0 -1
  440. data/app/views/decidim/elections/elections/_filters.html.erb +0 -25
  441. data/app/views/decidim/elections/elections/_filters_small_view.html.erb +0 -18
  442. data/app/views/decidim/elections/votes/_focus_header.html.erb +0 -8
  443. data/app/views/decidim/elections/votes/_new_confirm_step_footer.html.erb +0 -23
  444. data/app/views/decidim/votings/admin/votings/polling_officers_picker.html.erb +0 -2
  445. data/app/views/decidim/votings/votings/_count.html.erb +0 -1
  446. data/app/views/decidim/votings/votings/_filters.html.erb +0 -25
  447. data/app/views/decidim/votings/votings/_filters_small_view.html.erb +0 -23
  448. data/app/views/decidim/votings/votings/_promoted_voting.html.erb +0 -27
  449. data/app/views/layouts/decidim/_election_votes_header.html.erb +0 -13
  450. data/app/views/layouts/decidim/election_votes.html.erb +0 -27
  451. data/app/views/layouts/decidim/voting_landing.html.erb +0 -13
  452. data/config/locales/he-IL.yml +0 -1
  453. data/db/seeds/Exampledocument.pdf +0 -0
  454. data/db/seeds/city.jpeg +0 -0
  455. data/db/seeds/city2.jpeg +0 -0
  456. data/decidim-elections.gemspec +0 -37
  457. data/lib/decidim/elections/seeds/city.jpeg +0 -0
  458. data/lib/decidim/votings/test/capybara_polling_officers_picker.rb +0 -49
  459. /data/app/cells/decidim/votings/content_blocks/{landing_page/header_settings_form → hero_settings_form}/show.erb +0 -0
@@ -1,17 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AddFollowableCounterCacheToVotings < ActiveRecord::Migration[5.2]
4
- class Voting < ApplicationRecord
5
- self.table_name = :decidim_votings_votings
6
- end
7
-
8
4
  def change
9
5
  add_column :decidim_votings_votings, :follows_count, :integer, null: false, default: 0, index: true
10
6
 
11
7
  reversible do |dir|
12
8
  dir.up do
13
- Voting.reset_column_information
14
- Voting.find_each do |record|
9
+ Decidim::Votings::Voting.reset_column_information
10
+ Decidim::Votings::Voting.find_each do |record|
15
11
  record.class.reset_counters(record.id, :follows)
16
12
  end
17
13
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  field :created_at, Decidim::Core::DateTimeType, "When this election was created", null: true
18
18
  field :updated_at, Decidim::Core::DateTimeType, "When this election was updated", null: true
19
19
  field :published_at, Decidim::Core::DateTimeType, "When this election was published", null: true
20
- field :blocked, GraphQL::Types::Boolean, "Whether this election has it's parameters blocked or not", method: :blocked?, null: true
20
+ field :blocked, GraphQL::Types::Boolean, "Whether this election has it is parameters blocked or not", method: :blocked?, null: true
21
21
  field :bb_status, GraphQL::Types::String, "The status for this election in the bulletin board", null: true, camelize: false
22
22
 
23
23
  field :questions, [Decidim::Elections::ElectionQuestionType, { null: true }], "The questions for this election", null: false
@@ -25,7 +25,7 @@ module Decidim
25
25
 
26
26
  module ElectionsTypeHelper
27
27
  def self.base_scope(component)
28
- Election.where(component: component).where.not(published_at: nil)
28
+ Election.where(component:).where.not(published_at: nil)
29
29
  end
30
30
  end
31
31
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "decidim/elections/menu"
4
+
3
5
  module Decidim
4
6
  module Elections
5
7
  # This is the engine that runs on the public interface of `Elections`.
@@ -50,25 +52,8 @@ module Decidim
50
52
  [:trustees]
51
53
  end
52
54
 
53
- initializer "decidim_admin_elections.menu_entry" do
54
- Decidim.participatory_space_registry.manifests.each do |participatory_space|
55
- menu_id = :"admin_#{participatory_space.name.to_s.singularize}_menu"
56
- Decidim.menu menu_id do |menu|
57
- component = current_participatory_space.try(:components)&.find_by(manifest_name: :elections)
58
- next unless component
59
-
60
- link = Decidim::EngineRouter.admin_proxy(component).trustees_path(locale: I18n.locale)
61
-
62
- has_election_components = current_participatory_space.components.select { |c| c.manifest_name == "elections" }.any?
63
-
64
- menu.add_item :trustees,
65
- I18n.t("trustees", scope: "decidim.elections.admin.menu"),
66
- link,
67
- if: has_election_components && (allowed_to?(:manage, :trustees) || current_user.admin?),
68
- position: 100,
69
- active: is_active_link?(link)
70
- end
71
- end
55
+ initializer "decidim_elections_admin.menu_entry" do
56
+ Decidim::Elections::Menu.register_participatory_space_registry_manifests!
72
57
  end
73
58
 
74
59
  def load_seed
@@ -1,17 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "decidim/components/namer"
4
-
5
3
  Decidim.register_component(:elections) do |component|
6
4
  component.engine = Decidim::Elections::Engine
7
5
  component.admin_engine = Decidim::Elections::AdminEngine
8
6
  component.icon = "media/images/decidim_elections.svg"
7
+ component.icon_key = "check-double-fill"
9
8
  component.stylesheet = "decidim/elections/elections"
10
9
  component.permissions_class_name = "Decidim::Elections::Permissions"
11
10
  component.query_type = "Decidim::Elections::ElectionsType"
12
11
 
13
12
  component.on(:before_destroy) do |instance|
14
- raise StandardError, "Can't remove this component" if Decidim::Elections::Election.where(component: instance).any?
13
+ raise StandardError, "Cannot remove this component" if Decidim::Elections::Election.where(component: instance).any?
15
14
  end
16
15
 
17
16
  # These actions permissions can be configured in the admin panel
@@ -66,456 +65,9 @@ Decidim.register_component(:elections) do |component|
66
65
  end
67
66
 
68
67
  component.seeds do |participatory_space|
69
- admin_user = Decidim::User.find_by(
70
- organization: participatory_space.organization,
71
- email: "admin@example.org"
72
- )
73
-
74
- params = {
75
- name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :elections).i18n_name,
76
- manifest_name: :elections,
77
- published_at: Time.current,
78
- participatory_space: participatory_space
79
- }
80
-
81
- component = Decidim.traceability.perform_action!(
82
- "publish",
83
- Decidim::Component,
84
- admin_user,
85
- visibility: "all"
86
- ) do
87
- Decidim::Component.create!(params)
88
- end
89
-
90
- # upcoming elections that may be published
91
- 2.times do
92
- upcoming_election = Decidim.traceability.create!(
93
- Decidim::Elections::Election,
94
- admin_user,
95
- {
96
- component: component,
97
- title: Decidim::Faker::Localized.sentence(word_count: 2),
98
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
99
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
100
- end,
101
- start_time: 3.weeks.from_now,
102
- end_time: 3.weeks.from_now + 4.hours,
103
- published_at: Faker::Boolean.boolean(true_ratio: 0.5) ? 1.week.ago : nil,
104
- salt: Decidim::Tokenizer.random_salt
105
- },
106
- visibility: "all"
107
- )
108
-
109
- rand(1...4).times do
110
- upcoming_question = Decidim.traceability.create!(
111
- Decidim::Elections::Question,
112
- admin_user,
113
- {
114
- election: upcoming_election,
115
- title: Decidim::Faker::Localized.sentence(word_count: 2),
116
- max_selections: Faker::Number.between(from: 1, to: 3),
117
- weight: Faker::Number.number(digits: 1),
118
- random_answers_order: Faker::Boolean.boolean(true_ratio: 0.5),
119
- min_selections: Faker::Number.between(from: 0, to: 1)
120
- },
121
- visibility: "all"
122
- )
123
-
124
- rand(upcoming_question.max_selections...5).times do
125
- answer = Decidim.traceability.create!(
126
- Decidim::Elections::Answer,
127
- admin_user,
128
- {
129
- question: upcoming_question,
130
- title: Decidim::Faker::Localized.sentence(word_count: 2),
131
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
132
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
133
- end,
134
- weight: Faker::Number.number(digits: 1),
135
- selected: Faker::Boolean.boolean(true_ratio: 0.2) # false
136
- },
137
- visibility: "all"
138
- )
139
-
140
- Decidim::Attachment.create!(
141
- title: Decidim::Faker::Localized.sentence(word_count: 2),
142
- description: Decidim::Faker::Localized.sentence(word_count: 5),
143
- attached_to: answer,
144
- content_type: "image/jpeg",
145
- file: ActiveStorage::Blob.create_and_upload!(
146
- io: File.open(File.join(__dir__, "seeds", "city.jpeg")),
147
- filename: "city.jpeg",
148
- content_type: "image/jpeg",
149
- metadata: nil
150
- ) # Keep after attached_to
151
- )
152
- end
153
-
154
- questionnaire = Decidim::Forms::Questionnaire.create!(
155
- title: Decidim::Faker::Localized.paragraph,
156
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
157
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
158
- end,
159
- tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
160
- Decidim::Faker::Localized.paragraph(sentence_count: 2)
161
- end,
162
- questionnaire_for: upcoming_election
163
- )
164
-
165
- %w(short_answer long_answer).each do |text_question_type|
166
- Decidim::Forms::Question.create!(
167
- questionnaire: questionnaire,
168
- body: Decidim::Faker::Localized.paragraph,
169
- question_type: text_question_type
170
- )
171
- end
172
-
173
- %w(single_option multiple_option).each do |multiple_choice_question_type|
174
- question = Decidim::Forms::Question.create!(
175
- questionnaire: questionnaire,
176
- body: Decidim::Faker::Localized.paragraph,
177
- question_type: multiple_choice_question_type
178
- )
179
-
180
- 3.times do
181
- question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
182
- end
183
- end
184
- end
185
- end
186
-
187
- # finished elections that may be published, with questionnaire
188
- 2.times do
189
- finished_election = Decidim.traceability.create!(
190
- Decidim::Elections::Election,
191
- admin_user,
192
- {
193
- component: component,
194
- title: Decidim::Faker::Localized.sentence(word_count: 2),
195
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
196
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
197
- end,
198
- start_time: 4.weeks.ago,
199
- end_time: 3.weeks.ago,
200
- published_at: 4.weeks.ago,
201
- salt: Decidim::Tokenizer.random_salt
202
- },
203
- visibility: "all"
204
- )
205
-
206
- rand(1...4).times do
207
- finished_question = Decidim.traceability.create!(
208
- Decidim::Elections::Question,
209
- admin_user,
210
- {
211
- election: finished_election,
212
- title: Decidim::Faker::Localized.sentence(word_count: 2),
213
- max_selections: 2,
214
- weight: Faker::Number.number(digits: 1),
215
- random_answers_order: Faker::Boolean.boolean(true_ratio: 0.5),
216
- min_selections: Faker::Number.between(from: 0, to: 1)
217
- },
218
- visibility: "all"
219
- )
220
-
221
- rand(2...5).times do
222
- answer = Decidim.traceability.create!(
223
- Decidim::Elections::Answer,
224
- admin_user,
225
- {
226
- question: finished_question,
227
- title: Decidim::Faker::Localized.sentence(word_count: 2),
228
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
229
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
230
- end,
231
- weight: Faker::Number.number(digits: 1),
232
- selected: Faker::Boolean.boolean(true_ratio: 0.2) # false
233
- },
234
- visibility: "all"
235
- )
236
-
237
- Decidim::Attachment.create!(
238
- title: Decidim::Faker::Localized.sentence(word_count: 2),
239
- description: Decidim::Faker::Localized.sentence(word_count: 5),
240
- attached_to: answer,
241
- content_type: "image/jpeg",
242
- file: ActiveStorage::Blob.create_and_upload!(
243
- io: File.open(File.join(__dir__, "seeds", "city.jpeg")),
244
- filename: "city.jpeg",
245
- content_type: "image/jpeg",
246
- metadata: nil
247
- ) # Keep after attached_to
248
- )
249
- end
250
-
251
- questionnaire = Decidim::Forms::Questionnaire.create!(
252
- title: Decidim::Faker::Localized.paragraph,
253
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
254
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
255
- end,
256
- tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
257
- Decidim::Faker::Localized.paragraph(sentence_count: 2)
258
- end,
259
- questionnaire_for: finished_election
260
- )
261
-
262
- %w(short_answer long_answer).each do |text_question_type|
263
- Decidim::Forms::Question.create!(
264
- questionnaire: questionnaire,
265
- body: Decidim::Faker::Localized.paragraph,
266
- question_type: text_question_type
267
- )
268
- end
269
-
270
- %w(single_option multiple_option).each do |multiple_choice_question_type|
271
- question = Decidim::Forms::Question.create!(
272
- questionnaire: questionnaire,
273
- body: Decidim::Faker::Localized.paragraph,
274
- question_type: multiple_choice_question_type
275
- )
276
-
277
- 3.times do
278
- question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
279
- end
280
- end
281
- end
282
- end
283
-
284
- # finished, published elections with results and with questionnaire
285
- 2.times do
286
- election_with_results = Decidim.traceability.create!(
287
- Decidim::Elections::Election,
288
- admin_user,
289
- {
290
- component: component,
291
- title: Decidim::Faker::Localized.sentence(word_count: 2),
292
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
293
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
294
- end,
295
- start_time: 4.weeks.ago,
296
- end_time: 3.weeks.ago,
297
- published_at: 3.weeks.ago,
298
- bb_status: "results_published",
299
- salt: Decidim::Tokenizer.random_salt
300
-
301
- },
302
- visibility: "all"
303
- )
68
+ require "decidim/elections/seeds"
304
69
 
305
- bb_closure = Decidim::Elections::BulletinBoardClosure.create!(
306
- election: election_with_results
307
- )
308
-
309
- valid_ballots = Faker::Number.number(digits: 3)
310
- Decidim::Elections::Result.create!(
311
- value: valid_ballots,
312
- closurable: bb_closure,
313
- question: nil,
314
- answer: nil,
315
- result_type: :valid_ballots
316
- )
317
-
318
- Decidim::Elections::Result.create!(
319
- value: valid_ballots,
320
- closurable: bb_closure,
321
- question: nil,
322
- answer: nil,
323
- result_type: :total_ballots
324
- )
325
-
326
- rand(1...4).times do
327
- result_question = Decidim.traceability.create!(
328
- Decidim::Elections::Question,
329
- admin_user,
330
- {
331
- election: election_with_results,
332
- title: Decidim::Faker::Localized.sentence(word_count: 2),
333
- max_selections: 2,
334
- weight: Faker::Number.number(digits: 1),
335
- random_answers_order: Faker::Boolean.boolean(true_ratio: 0.5),
336
- min_selections: Faker::Number.between(from: 0, to: 1)
337
- },
338
- visibility: "all"
339
- )
340
-
341
- question_pending = valid_ballots
342
- rand(2...5).times do
343
- answer = Decidim.traceability.create!(
344
- Decidim::Elections::Answer,
345
- admin_user,
346
- {
347
- question: result_question,
348
- title: Decidim::Faker::Localized.sentence(word_count: 2),
349
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
350
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
351
- end,
352
- weight: Faker::Number.number(digits: 1),
353
- selected: Faker::Boolean.boolean(true_ratio: 0.5)
354
- },
355
- visibility: "all"
356
- )
357
-
358
- Decidim::Attachment.create!(
359
- title: Decidim::Faker::Localized.sentence(word_count: 2),
360
- description: Decidim::Faker::Localized.sentence(word_count: 5),
361
- attached_to: answer,
362
- content_type: "image/jpeg",
363
- file: ActiveStorage::Blob.create_and_upload!(
364
- io: File.open(File.join(__dir__, "seeds", "city.jpeg")),
365
- filename: "city.jpeg",
366
- content_type: "image/jpeg",
367
- metadata: nil
368
- ) # Keep after attached_to
369
- )
370
-
371
- answer_value = Faker::Number.between(from: 0, to: question_pending)
372
- Decidim::Elections::Result.create!(
373
- value: answer_value,
374
- closurable: bb_closure,
375
- question: result_question,
376
- answer: answer,
377
- result_type: :valid_answers
378
- )
379
- question_pending -= answer_value
380
- end
381
-
382
- if result_question.nota_option? && result_question.max_selections == 1
383
- Decidim::Elections::Result.create!(
384
- value: question_pending,
385
- closurable: bb_closure,
386
- question: result_question,
387
- answer: nil,
388
- result_type: :blank_answers
389
- )
390
- end
391
-
392
- questionnaire = Decidim::Forms::Questionnaire.create!(
393
- title: Decidim::Faker::Localized.paragraph,
394
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
395
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
396
- end,
397
- tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
398
- Decidim::Faker::Localized.paragraph(sentence_count: 2)
399
- end,
400
- questionnaire_for: election_with_results
401
- )
402
-
403
- %w(short_answer long_answer).each do |text_question_type|
404
- Decidim::Forms::Question.create!(
405
- questionnaire: questionnaire,
406
- body: Decidim::Faker::Localized.paragraph,
407
- question_type: text_question_type
408
- )
409
- end
410
-
411
- %w(single_option multiple_option).each do |multiple_choice_question_type|
412
- question = Decidim::Forms::Question.create!(
413
- questionnaire: questionnaire,
414
- body: Decidim::Faker::Localized.paragraph,
415
- question_type: multiple_choice_question_type
416
- )
417
-
418
- 3.times do
419
- question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
420
- end
421
- end
422
- end
423
- end
424
-
425
- # ongoing election that is published
426
- ongoing_election = Decidim.traceability.create!(
427
- Decidim::Elections::Election,
428
- admin_user,
429
- {
430
- component: component,
431
- title: Decidim::Faker::Localized.sentence(word_count: 2),
432
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
433
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
434
- end,
435
- start_time: 2.weeks.ago,
436
- end_time: 2.weeks.from_now + 4.hours,
437
- published_at: 3.weeks.ago,
438
- salt: Decidim::Tokenizer.random_salt
439
- },
440
- visibility: "all"
441
- )
442
-
443
- rand(1...4).times do
444
- ongoing_question = Decidim.traceability.create!(
445
- Decidim::Elections::Question,
446
- admin_user,
447
- {
448
- election: ongoing_election,
449
- title: Decidim::Faker::Localized.sentence(word_count: 2),
450
- max_selections: 2,
451
- weight: Faker::Number.number(digits: 1),
452
- random_answers_order: Faker::Boolean.boolean(true_ratio: 0.5),
453
- min_selections: Faker::Number.between(from: 0, to: 1)
454
- },
455
- visibility: "all"
456
- )
457
-
458
- rand(3...5).times do
459
- answer = Decidim.traceability.create!(
460
- Decidim::Elections::Answer,
461
- admin_user,
462
- {
463
- question: ongoing_question,
464
- title: Decidim::Faker::Localized.sentence(word_count: 2),
465
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
466
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
467
- end,
468
- weight: Faker::Number.number(digits: 1),
469
- selected: Faker::Boolean.boolean(true_ratio: 0.2) # false
470
- },
471
- visibility: "all"
472
- )
473
-
474
- Decidim::Attachment.create!(
475
- title: Decidim::Faker::Localized.sentence(word_count: 2),
476
- description: Decidim::Faker::Localized.sentence(word_count: 5),
477
- attached_to: answer,
478
- content_type: "image/jpeg",
479
- file: ActiveStorage::Blob.create_and_upload!(
480
- io: File.open(File.join(__dir__, "seeds", "city.jpeg")),
481
- filename: "city.jpeg",
482
- content_type: "image/jpeg",
483
- metadata: nil
484
- ) # Keep after attached_to
485
- )
486
- end
487
- end
488
-
489
- questionnaire = Decidim::Forms::Questionnaire.create!(
490
- title: Decidim::Faker::Localized.paragraph,
491
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
492
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
493
- end,
494
- tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
495
- Decidim::Faker::Localized.paragraph(sentence_count: 2)
496
- end,
497
- questionnaire_for: ongoing_election
498
- )
499
-
500
- %w(short_answer long_answer).each do |text_question_type|
501
- Decidim::Forms::Question.create!(
502
- questionnaire: questionnaire,
503
- body: Decidim::Faker::Localized.paragraph,
504
- question_type: text_question_type
505
- )
506
- end
507
-
508
- %w(single_option multiple_option).each do |multiple_choice_question_type|
509
- question = Decidim::Forms::Question.create!(
510
- questionnaire: questionnaire,
511
- body: Decidim::Faker::Localized.paragraph,
512
- question_type: multiple_choice_question_type
513
- )
514
-
515
- 3.times do
516
- question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
517
- end
518
- end
70
+ Decidim::Elections::Seeds.new(participatory_space:).call
519
71
  end
520
72
  end
521
73
 
@@ -22,8 +22,22 @@ module Decidim
22
22
 
23
23
  get :election_log, on: :member
24
24
  end
25
+ scope "/elections" do
26
+ root to: "elections#index"
27
+ end
28
+ get "/", to: redirect("elections", status: 301)
29
+ end
25
30
 
26
- root to: "elections#index"
31
+ initializer "decidim_elections.register_icons" do
32
+ Decidim.icons.register(name: "Decidim::Elections::Election", icon: "chat-poll-line", description: "Election", category: "activity", engine: :elections)
33
+ Decidim.icons.register(name: "safe-line", icon: "safe-line", category: "system", description: "", engine: :elections)
34
+ Decidim.icons.register(name: "guide-line", icon: "guide-line", category: "system", description: "", engine: :elections)
35
+ Decidim.icons.register(name: "loader-4-line", icon: "loader-4-line", category: "system", description: "", engine: :elections)
36
+ Decidim.icons.register(name: "checkbox-multiple-line", icon: "checkbox-multiple-line", category: "system", description: "", engine: :elections)
37
+ Decidim.icons.register(name: "book-2-line", icon: "book-2-line", category: "system", description: "", engine: :elections)
38
+ Decidim.icons.register(name: "shut-down-line", icon: "shut-down-line", category: "system", description: "", engine: :elections)
39
+ Decidim.icons.register(name: "article-line", icon: "article-line", category: "system", description: "", engine: :elections)
40
+ Decidim.icons.register(name: "bar-chart-box-line", icon: "bar-chart-box-line", category: "system", description: "", engine: :elections)
27
41
  end
28
42
 
29
43
  initializer "decidim_elections.add_cells_view_paths" do
@@ -34,6 +48,14 @@ module Decidim
34
48
  initializer "decidim_elections.webpacker.assets_path" do
35
49
  Decidim.register_assets_path File.expand_path("app/packs", root)
36
50
  end
51
+
52
+ initializer "decidim_elections.authorization_transfer" do
53
+ config.to_prepare do
54
+ Decidim::AuthorizationTransfer.register(:elections) do |transfer|
55
+ transfer.move_records(Decidim::Elections::Vote, :decidim_user_id)
56
+ end
57
+ end
58
+ end
37
59
  end
38
60
  end
39
61
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Elections
5
+ class Menu
6
+ def self.register_user_menu!
7
+ Decidim.menu :user_menu do |menu|
8
+ menu.add_item :decidim_elections_trustee_zone,
9
+ I18n.t("menu.trustee_zone", scope: "decidim.elections.trustee_zone"),
10
+ decidim.decidim_elections_trustee_zone_path,
11
+ active: :inclusive,
12
+ if: Decidim::Elections::Trustee.trustee?(current_user)
13
+ end
14
+ end
15
+
16
+ def self.register_participatory_space_registry_manifests!
17
+ Decidim.participatory_space_registry.manifests.each do |participatory_space|
18
+ menu_id = :"admin_#{participatory_space.name.to_s.singularize}_menu"
19
+ Decidim.menu menu_id do |menu|
20
+ component = current_participatory_space.try(:components)&.find_by(manifest_name: :elections)
21
+ next unless component
22
+
23
+ link = Decidim::EngineRouter.admin_proxy(component).trustees_path(locale: I18n.locale)
24
+
25
+ has_election_components = current_participatory_space.components.select { |c| c.manifest_name == "elections" }.any?
26
+
27
+ menu.add_item :trustees,
28
+ I18n.t("trustees", scope: "decidim.elections.admin.menu"),
29
+ link,
30
+ if: has_election_components && (allowed_to?(:manage, :trustees) || current_user.admin?),
31
+ icon_name: "safe-line",
32
+ position: 100,
33
+ active: is_active_link?(link)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end