decidim-elections 0.26.8 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) 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 -43
  161. data/config/locales/bg.yml +1 -0
  162. data/config/locales/ca.yml +44 -64
  163. data/config/locales/cs.yml +47 -59
  164. data/config/locales/da.yml +1 -0
  165. data/config/locales/de.yml +18 -174
  166. data/config/locales/el.yml +1 -1095
  167. data/config/locales/en.yml +37 -56
  168. data/config/locales/eo.yml +1 -0
  169. data/config/locales/es-MX.yml +44 -64
  170. data/config/locales/es-PY.yml +44 -64
  171. data/config/locales/es.yml +46 -66
  172. data/config/locales/et.yml +1 -0
  173. data/config/locales/eu.yml +31 -54
  174. data/config/locales/fi-plain.yml +37 -57
  175. data/config/locales/fi.yml +40 -60
  176. data/config/locales/fr-CA.yml +57 -65
  177. data/config/locales/fr.yml +58 -66
  178. data/config/locales/ga-IE.yml +2 -19
  179. data/config/locales/gl.yml +28 -35
  180. data/config/locales/hr.yml +1 -0
  181. data/config/locales/hu.yml +21 -29
  182. data/config/locales/id-ID.yml +1 -0
  183. data/config/locales/is-IS.yml +2 -1
  184. data/config/locales/it.yml +34 -32
  185. data/config/locales/ja.yml +46 -75
  186. data/config/locales/ko.yml +1 -0
  187. data/config/locales/lb.yml +1 -0
  188. data/config/locales/lt.yml +1 -1401
  189. data/config/locales/lv.yml +1 -3
  190. data/config/locales/mt.yml +1 -0
  191. data/config/locales/nl.yml +36 -49
  192. data/config/locales/no.yml +13 -54
  193. data/config/locales/om-ET.yml +1 -0
  194. data/config/locales/pl.yml +43 -38
  195. data/config/locales/pt-BR.yml +35 -35
  196. data/config/locales/pt.yml +36 -35
  197. data/config/locales/ro-RO.yml +19 -69
  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 +24 -73
  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 +5 -61
  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 +2 -22
  212. data/config/locales/zh-TW.yml +1 -1391
  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. metadata +27 -40
  223. data/app/controllers/decidim/votings/admin/exports_controller.rb +0 -14
  224. data/app/controllers/decidim/votings/admin/imports_controller.rb +0 -14
  225. data/app/controllers/decidim/votings/admin/reminders_controller.rb +0 -14
  226. data/app/forms/decidim/votings/admin/voting_role_form.rb +0 -29
  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 -0
  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/app/packs/entrypoints/{decidim_elections_trustee_tally.js → decidim_elections_trustee_tally_started.js} +0 -0
  239. /data/app/views/decidim/elections/trustee_zone/elections/{_tally_steps.html.erb → _tally_started_steps.html.erb} +0 -0
@@ -7,7 +7,7 @@ module Decidim
7
7
  module ApplicationHelper
8
8
  include Decidim::CheckBoxesTreeHelper
9
9
 
10
- def state_filter_values
10
+ def date_filter_values
11
11
  TreeNode.new(
12
12
  TreePoint.new("", t("elections.elections.filters.all", scope: "decidim")),
13
13
  [
@@ -5,7 +5,7 @@ module Decidim
5
5
  module VotingsHelper
6
6
  include Decidim::CheckBoxesTreeHelper
7
7
 
8
- def filter_states_values
8
+ def date_filter_values
9
9
  TreeNode.new(
10
10
  TreePoint.new("", t("votings.filters.all", scope: "decidim.votings")),
11
11
  [
@@ -39,12 +39,7 @@ module Decidim
39
39
  # A result percentage relative to the question
40
40
  # Returns a Float.
41
41
  def results_percentage
42
- @results_percentage ||= begin
43
- return 0 unless results_total.positive?
44
-
45
- result = results_total.to_f / question.results_total * 100.0
46
- result.round
47
- end
42
+ @results_percentage ||= results_total.positive? ? (results_total.to_f / question.results_total * 100.0).round : 0
48
43
  end
49
44
  end
50
45
  end
@@ -14,10 +14,11 @@ module Decidim
14
14
  include Traceable
15
15
  include Loggable
16
16
  include Decidim::Forms::HasQuestionnaire
17
+ include Decidim::FilterableResource
17
18
 
18
19
  translatable_fields :title, :description
19
20
 
20
- enum bb_status: [:created, :key_ceremony, :key_ceremony_ended, :vote, :vote_ended, :tally, :tally_ended, :results_published].index_with(&:to_s), _prefix: :bb
21
+ enum bb_status: [:created, :key_ceremony, :key_ceremony_ended, :vote, :vote_ended, :tally_started, :tally_ended, :results_published].index_with(&:to_s), _prefix: :bb
21
22
 
22
23
  component_manifest_name "elections"
23
24
 
@@ -43,6 +44,8 @@ module Decidim
43
44
  .where("end_time < ?", Time.current)
44
45
  }
45
46
 
47
+ scope_search_multi :with_any_date, [:active, :upcoming, :finished]
48
+
46
49
  def self.log_presenter_class_for(_log)
47
50
  Decidim::Elections::AdminLog::ElectionPresenter
48
51
  end
@@ -86,7 +89,7 @@ module Decidim
86
89
  #
87
90
  # Returns a boolean.
88
91
  def minimum_answers?
89
- questions.any? && questions.all? { |question| question.answers.size > 1 }
92
+ questions.all? { |question| question.answers.size > 1 }
90
93
  end
91
94
 
92
95
  # Public: Checks if the election results are published and election finished
@@ -107,7 +110,7 @@ module Decidim
107
110
  #
108
111
  # Returns a boolean.
109
112
  def valid_questions?
110
- questions.any? && questions.all?(&:valid_max_selection?)
113
+ questions.all?(&:valid_max_selection?)
111
114
  end
112
115
 
113
116
  # Public: Gets the voting period status of the election
@@ -124,7 +127,7 @@ module Decidim
124
127
  end
125
128
 
126
129
  def trustee_action_required?
127
- bb_key_ceremony? || bb_tally?
130
+ bb_key_ceremony? || bb_tally_started?
128
131
  end
129
132
 
130
133
  # Public: Checks if the election has a blocked_at value
@@ -138,6 +141,14 @@ module Decidim
138
141
  def allow_resource_permissions?
139
142
  true
140
143
  end
144
+
145
+ # Create i18n ransackers for :title and :description.
146
+ # Create the :search_text ransacker alias for searching from both of these.
147
+ ransacker_i18n_multi :search_text, [:title, :description]
148
+
149
+ def self.ransackable_scopes(_auth_object = nil)
150
+ [:with_any_date]
151
+ end
141
152
  end
142
153
  end
143
154
  end
@@ -41,12 +41,7 @@ module Decidim
41
41
  # A result percentage relative to the question
42
42
  # Returns a Float.
43
43
  def blank_votes_percentage
44
- @blank_votes_percentage ||= begin
45
- return 0 unless results_total.positive?
46
-
47
- result = blank_votes.to_f / results_total * 100.0
48
- result.round
49
- end
44
+ @blank_votes_percentage ||= results_total.positive? ? (blank_votes.to_f / results_total * 100.0).round : 0
50
45
  end
51
46
 
52
47
  def slug
@@ -7,6 +7,7 @@ module Decidim
7
7
  include Traceable
8
8
  include Loggable
9
9
  include Decidim::TranslatableResource
10
+ include Decidim::FilterableResource
10
11
 
11
12
  translatable_fields :title, :location, :location_hints
12
13
 
@@ -37,9 +38,7 @@ module Decidim
37
38
  alias participatory_space voting
38
39
 
39
40
  # Allow ransacker to search for a key in a hstore column (`title`.`en`)
40
- ransacker :title do |parent|
41
- Arel::Nodes::InfixOperation.new("->>", parent.table[:title], Arel::Nodes.build_quoted(I18n.locale.to_s))
42
- end
41
+ ransacker_i18n :title
43
42
 
44
43
  [:manager, :president].each do |role|
45
44
  [:name, :email, :nickname].each do |field|
@@ -16,6 +16,7 @@ module Decidim
16
16
  include Decidim::HasUploadValidations
17
17
  include Decidim::HasAttachments
18
18
  include Decidim::HasAttachmentCollections
19
+ include Decidim::FilterableResource
19
20
 
20
21
  enum voting_type: [:in_person, :online, :hybrid].index_with(&:to_s), _suffix: :voting
21
22
 
@@ -62,6 +63,8 @@ module Decidim
62
63
  scope :order_by_most_recent, -> { order(created_at: :desc) }
63
64
  scope :promoted, -> { published.where(promoted: true) }
64
65
 
66
+ scope_search_multi :with_any_date, [:active, :upcoming, :finished]
67
+
65
68
  def upcoming?
66
69
  start_time > Time.now.utc
67
70
  end
@@ -135,6 +138,10 @@ module Decidim
135
138
  ballot_styles.exists?
136
139
  end
137
140
 
141
+ def check_census_enabled?
142
+ dataset.present? && show_check_census?
143
+ end
144
+
138
145
  def elections
139
146
  Decidim::Elections::Election.where(component: components)
140
147
  end
@@ -156,6 +163,14 @@ module Decidim
156
163
  def vote_flow_for(election)
157
164
  Decidim::Votings::CensusVoteFlow.new(election)
158
165
  end
166
+
167
+ # Create i18n ransackers for :title and :description.
168
+ # Create the :search_text ransacker alias for searching from both of these.
169
+ ransacker_i18n_multi :search_text, [:title, :description]
170
+
171
+ def self.ransackable_scopes(_auth_object = nil)
172
+ [:with_any_date]
173
+ end
159
174
  end
160
175
  end
161
176
  end
@@ -1,5 +1,3 @@
1
- // show a message to the user if comunication is lost
2
- import "src/decidim/elections/broken_promises_handler";
3
1
  import { Client } from "@decidim/decidim-bulletin_board";
4
2
 
5
3
  $(() => {
@@ -1,5 +1,3 @@
1
- // show a message to the user if comunication is lost
2
- import "src/decidim/elections/broken_promises_handler";
3
1
  import {
4
2
  Client,
5
3
  Election,
@@ -1,6 +1,3 @@
1
- // show a message to the user if comunication is lost
2
- import "src/decidim/elections/broken_promises_handler";
3
-
4
1
  import {
5
2
  KeyCeremonyComponent,
6
3
  MessageIdentifier,
@@ -1,6 +1,3 @@
1
- // show a message to the user if comunication is lost
2
- import "src/decidim/elections/broken_promises_handler";
3
-
4
1
  import {
5
2
  TallyComponent,
6
3
  IdentificationKeys,
@@ -115,7 +112,7 @@ $(() => {
115
112
  url: $tally.data("updateElectionStatusUrl"),
116
113
  contentType: "application/json",
117
114
  data: JSON.stringify({
118
- status: "tally"
115
+ status: "tally_started"
119
116
  }),
120
117
  headers: {
121
118
  "X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
@@ -1,6 +1,3 @@
1
- // show a message to the user if comunication is lost
2
- import "src/decidim/elections/broken_promises_handler";
3
-
4
1
  import { Client } from "@decidim/decidim-bulletin_board";
5
2
 
6
3
  $(async () => {
@@ -1,7 +1,5 @@
1
1
  /* eslint-disable require-jsdoc */
2
2
 
3
- // show a message to the user if comunication is lost
4
- import "src/decidim/elections/broken_promises_handler";
5
3
  import { VoteComponent } from "@decidim/decidim-bulletin_board";
6
4
 
7
5
  import * as VotingSchemesDummy from "@decidim/voting_schemes-dummy";
@@ -1,6 +1,3 @@
1
- // show a message to the user if comunication is lost
2
- import "src/decidim/elections/broken_promises_handler";
3
-
4
1
  import { Client } from "@decidim/decidim-bulletin_board";
5
2
 
6
3
  $(async () => {
@@ -24,8 +24,10 @@ module Decidim
24
24
  case permission_action.action
25
25
  when :create, :read
26
26
  allow!
27
- when :delete, :update, :unpublish, :publish
27
+ when :delete, :update, :unpublish
28
28
  allow_if_not_blocked
29
+ when :publish
30
+ allow_if_valid_and_not_blocked
29
31
  end
30
32
  when :trustees
31
33
  case permission_action.action
@@ -78,6 +80,10 @@ module Decidim
78
80
  toggle_allow(election && !election.blocked?)
79
81
  end
80
82
 
83
+ def allow_if_valid_and_not_blocked
84
+ toggle_allow(election && !election.blocked? && election.valid_questions?)
85
+ end
86
+
81
87
  def allow_if_not_related_to_any_election
82
88
  toggle_allow(trustee_participatory_space.trustee.elections.empty?)
83
89
  end
@@ -59,8 +59,7 @@ module Decidim
59
59
  :monitoring_committee_verify_elections,
60
60
  :monitoring_committee_election_result, :monitoring_committee_election_results,
61
61
  :census,
62
- :ballot_style, :ballot_styles,
63
- :component_data
62
+ :ballot_style, :ballot_styles
64
63
  ].member? permission_action.subject
65
64
 
66
65
  case permission_action.subject
@@ -79,7 +78,7 @@ module Decidim
79
78
  end
80
79
  when :landing_page
81
80
  toggle_allow(user.admin?) if permission_action.action == :update
82
- when :components
81
+ when :ballot_styles, :components, :polling_stations, :polling_officers, :monitoring_committee_members
83
82
  toggle_allow(user.admin?) if permission_action.action == :read
84
83
  when :polling_station
85
84
  case permission_action.action
@@ -88,8 +87,6 @@ module Decidim
88
87
  when :update, :delete
89
88
  toggle_allow(user.admin? && polling_station.present?)
90
89
  end
91
- when :polling_stations
92
- toggle_allow(user.admin?) if permission_action.action == :read
93
90
  when :polling_officer
94
91
  case permission_action.action
95
92
  when :create
@@ -97,8 +94,6 @@ module Decidim
97
94
  when :delete
98
95
  toggle_allow(user.admin? && polling_officer.present?)
99
96
  end
100
- when :polling_officers
101
- toggle_allow(user.admin?) if permission_action.action == :read
102
97
  when :monitoring_committee_member
103
98
  case permission_action.action
104
99
  when :create
@@ -108,18 +103,12 @@ module Decidim
108
103
  end
109
104
  when :monitoring_committee_menu
110
105
  toggle_allow(user_can_read_voting?) if permission_action.action == :read
111
- when :monitoring_committee_members
112
- toggle_allow(user.admin?) if permission_action.action == :read
113
106
  when :monitoring_committee_polling_station_closure
114
107
  toggle_allow(user_monitoring_committee_for_voting? && closure.present?) if [:read, :validate].member?(permission_action.action)
115
- when :monitoring_committee_polling_station_closures
116
- toggle_allow(user_monitoring_committee_for_voting?) if permission_action.action == :read
117
- when :monitoring_committee_verify_elections
108
+ when :monitoring_committee_polling_station_closures, :monitoring_committee_verify_elections, :monitoring_committee_election_results
118
109
  toggle_allow(user_monitoring_committee_for_voting?) if permission_action.action == :read
119
110
  when :monitoring_committee_election_result
120
111
  toggle_allow(user_monitoring_committee_for_voting? && election.present?) if [:read, :validate].member?(permission_action.action)
121
- when :monitoring_committee_election_results
122
- toggle_allow(user_monitoring_committee_for_voting?) if permission_action.action == :read
123
112
  when :census
124
113
  toggle_allow(user.admin?) if permission_action.action == :manage
125
114
  when :ballot_style
@@ -129,10 +118,6 @@ module Decidim
129
118
  when :update, :delete
130
119
  toggle_allow(user.admin? && (voting.dataset.blank? || voting.dataset.init_data?) && ballot_style.present?)
131
120
  end
132
- when :ballot_styles
133
- toggle_allow(user.admin?) if permission_action.action == :read
134
- when :component_data
135
- toggle_allow(user.admin?) if [:import, :export].member? permission_action.action
136
121
  end
137
122
  end
138
123
 
@@ -27,12 +27,10 @@ module Decidim
27
27
  return unless permission_action.scope == :public
28
28
 
29
29
  case permission_action.subject
30
- when :votings
30
+ when :votings, :participatory_space
31
31
  allow!
32
32
  when :voting
33
33
  toggle_allow(voting.published? || user&.admin?)
34
- when :participatory_space
35
- allow!
36
34
  end
37
35
  end
38
36
 
@@ -4,9 +4,12 @@ module Decidim
4
4
  module Votings
5
5
  # A presenter to render statistics in the homepage.
6
6
  class VotingStatsPresenter < Decidim::StatsPresenter
7
- attribute :voting, Decidim::Votings::Voting
8
7
  include Decidim::IconHelper
9
8
 
9
+ def voting
10
+ __getobj__.fetch(:voting)
11
+ end
12
+
10
13
  # Public: returns a collection of stats (Hash) for the Voting Landing.
11
14
  def collection
12
15
  highlighted_stats = voting_participants_stats
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Elections
5
5
  module Admin
6
6
  # A class used to find actions with a pending status
7
- class PendingActions < Rectify::Query
7
+ class PendingActions < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  def self.for
10
10
  new.query
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Elections
5
5
  module Admin
6
6
  # A class used to find election votes for statistics
7
- class VotesForStatistics < Rectify::Query
7
+ class VotesForStatistics < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried object.
9
9
  def self.for(election)
10
10
  new(election).query
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Elections
5
5
  # A class used to find elections finished to close their voting period
6
- class ElectionsFinishedToEnd < Rectify::Query
6
+ class ElectionsFinishedToEnd < Decidim::Query
7
7
  # Syntactic sugar to initialize the class and return the queried objects.
8
8
  def self.for
9
9
  new.query
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Elections
5
5
  # A class used to find elections ready and near to start the voting period
6
- class ElectionsReadyToStart < Rectify::Query
6
+ class ElectionsReadyToStart < Decidim::Query
7
7
  # Syntactic sugar to initialize the class and return the queried objects.
8
8
  def self.for
9
9
  new.query
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Elections
5
5
  # A class used to find elections filtered by its state
6
- class FilteredElections < Rectify::Query
6
+ class FilteredElections < Decidim::Query
7
7
  # Syntactic sugar to initialize the class and return the queried objects.
8
8
  #
9
9
  # components - An array of Decidim::Component
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Elections
5
5
  module Trustees
6
6
  # A class used to find trustees by participatory space.
7
- class ByParticipatorySpace < Rectify::Query
7
+ class ByParticipatorySpace < Decidim::Query
8
8
  # Initializes the class.
9
9
  #
10
10
  def initialize(participatory_space)
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Elections
5
5
  module Trustees
6
6
  # A class used to find trustees by participatory space trustee ids.
7
- class ByParticipatorySpaceTrusteeIds < Rectify::Query
7
+ class ByParticipatorySpaceTrusteeIds < Decidim::Query
8
8
  # Initializes the class.
9
9
  #
10
10
  def initialize(trustee_ids)
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Elections
5
5
  module Votes
6
6
  # A class used to find the last vote casted by a voter in an election
7
- class LastVoteForVoter < Rectify::Query
7
+ class LastVoteForVoter < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # election - the election where the vote was casted
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Elections
5
5
  module Votes
6
6
  # A class used to find votes with a pending status
7
- class PendingVotes < Rectify::Query
7
+ class PendingVotes < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  def self.for
10
10
  new.query
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Admin
6
6
  # A class used to find the admins for a voting or an organization votings.
7
- class AdminUsers < Rectify::Query
7
+ class AdminUsers < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # voting - a voting that needs to find its voting admins
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Admin
6
6
  # A class used to find trustees by participatory space.
7
- class BallotStyleByVotingCode < Rectify::Query
7
+ class BallotStyleByVotingCode < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # voting - the voting of the Ballot Style
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Admin
6
6
  # A class join the polling officers with their respective polling stations.
7
- class PollingOfficersJoinPollingStations < Rectify::Query
7
+ class PollingOfficersJoinPollingStations < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # polling_officers - the collection of polling officers
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Admin
6
6
  # A class join the polling officers with their respective polling stations and users.
7
- class PollingOfficersJoinPollingStationsAndUser < Rectify::Query
7
+ class PollingOfficersJoinPollingStationsAndUser < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # polling_officers - the collection of polling officers
@@ -23,7 +23,7 @@ module Decidim
23
23
  #
24
24
  # Returns an ActiveRecord::Relation.
25
25
  def query
26
- Rectify::Query.merge(
26
+ Decidim::Query.merge(
27
27
  PollingOfficersJoinPollingStations.new(@polling_officers),
28
28
  PollingOfficersJoinUser.new(@polling_officers)
29
29
  ).query
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Admin
6
6
  # A class join the polling officers with their respective decidim user.
7
- class PollingOfficersJoinUser < Rectify::Query
7
+ class PollingOfficersJoinUser < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # polling_officers - the collection of polling officers
@@ -4,14 +4,14 @@ module Decidim
4
4
  module Votings
5
5
  # This query class filters public votings given an organization in a
6
6
  # meaningful prioritized order.
7
- class OrganizationPrioritizedVotings < Rectify::Query
7
+ class OrganizationPrioritizedVotings < Decidim::Query
8
8
  def initialize(organization, user = nil)
9
9
  @organization = organization
10
10
  @user = user
11
11
  end
12
12
 
13
13
  def query
14
- Rectify::Query.merge(
14
+ Decidim::Query.merge(
15
15
  OrganizationPublishedVotings.new(@organization),
16
16
  PrioritizedVotings.new
17
17
  ).query
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Votings
5
5
  # This query selects the promoted votings
6
- class OrganizationPromotedVotings < Rectify::Query
6
+ class OrganizationPromotedVotings < Decidim::Query
7
7
  def initialize(organization)
8
8
  @organization = organization
9
9
  end
@@ -3,13 +3,13 @@
3
3
  module Decidim
4
4
  module Votings
5
5
  # This query class filters published votings given an organization.
6
- class OrganizationPublishedVotings < Rectify::Query
6
+ class OrganizationPublishedVotings < Decidim::Query
7
7
  def initialize(organization)
8
8
  @organization = organization
9
9
  end
10
10
 
11
11
  def query
12
- Rectify::Query.merge(
12
+ Decidim::Query.merge(
13
13
  OrganizationVotings.new(@organization),
14
14
  PublishedVotings.new
15
15
  ).query
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Votings
5
5
  # This query class filters all votings given an organization.
6
- class OrganizationVotings < Rectify::Query
6
+ class OrganizationVotings < Decidim::Query
7
7
  def initialize(organization)
8
8
  @organization = organization
9
9
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  # This query orders votings by importance, prioritizing promoted
6
6
  # votings.
7
- class PrioritizedVotings < Rectify::Query
7
+ class PrioritizedVotings < Decidim::Query
8
8
  def query
9
9
  Decidim::Votings::Voting.order(promoted: :desc)
10
10
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Votings
5
5
  # This query filters published votings only.
6
- class PublishedVotings < Rectify::Query
6
+ class PublishedVotings < Decidim::Query
7
7
  def query
8
8
  Decidim::Votings::Voting.published
9
9
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Votes
6
6
  # A class used to find a non-rejected in person vote registered for a voter in an election
7
- class InPersonVoteForVoter < Rectify::Query
7
+ class InPersonVoteForVoter < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
10
10
  # election - the election where the vote was casted
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Votings
5
5
  module Votes
6
6
  # A class used to find in person votes with a pending status
7
- class PendingInPersonVotes < Rectify::Query
7
+ class PendingInPersonVotes < Decidim::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  def self.for
10
10
  new.query
@@ -97,9 +97,7 @@ module Decidim
97
97
  end
98
98
 
99
99
  def valid_token_flow_data?
100
- @valid_token_flow_data ||= begin
101
- has_voter? && received_voter_token_data[:flow].as_json == voter_data.as_json
102
- end
100
+ @valid_token_flow_data ||= has_voter? && received_voter_token_data[:flow].as_json == voter_data.as_json
103
101
  end
104
102
  end
105
103
  end
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= decidim_form_for(@form, html: { class: "form edit_election" }) do |f| %>
3
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
3
 
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <div class="card">
3
2
  <div class="card-divider">
4
3
  <h2 class="card-title">
@@ -1,4 +1,3 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
1
  <%= decidim_form_for(@form, html: { class: "form new_election" }) do |f| %>
3
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
4
3