decidim-elections 0.26.1 → 0.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/elections/election_vote_cta_cell.rb +8 -3
  3. data/app/cells/decidim/votings/content_blocks/highlighted_votings/show.erb +1 -1
  4. data/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb +1 -0
  5. data/app/cells/decidim/votings/content_blocks/landing_page/description/show.erb +2 -13
  6. data/app/cells/decidim/votings/content_blocks/landing_page/description_cell.rb +0 -8
  7. data/app/cells/decidim/votings/content_blocks/landing_page/header/show.erb +2 -2
  8. data/app/commands/decidim/elections/admin/add_user_as_trustee.rb +21 -11
  9. data/app/commands/decidim/elections/admin/create_question.rb +2 -6
  10. data/app/commands/decidim/elections/admin/setup_election.rb +3 -1
  11. data/app/commands/decidim/elections/admin/update_question.rb +0 -1
  12. data/app/commands/decidim/votings/admin/destroy_ballot_style.rb +1 -1
  13. data/app/controllers/decidim/elections/admin/questions_controller.rb +5 -0
  14. data/app/controllers/decidim/votings/census/admin/census_controller.rb +1 -1
  15. data/app/controllers/decidim/votings/votings_controller.rb +2 -0
  16. data/app/forms/decidim/elections/admin/question_form.rb +0 -2
  17. data/app/forms/decidim/elections/admin/setup_form.rb +43 -0
  18. data/app/forms/decidim/votings/census/admin/datum_form.rb +4 -0
  19. data/app/helpers/decidim/elections/votes_helper.rb +3 -1
  20. data/app/mailers/decidim/elections/trustee_mailer.rb +28 -0
  21. data/app/models/decidim/elections/election.rb +2 -2
  22. data/app/models/decidim/elections/question.rb +1 -1
  23. data/app/packs/src/decidim/elections/admin/pending_action.js +2 -0
  24. data/app/packs/src/decidim/elections/admin/trustees_process.js +2 -0
  25. data/app/packs/src/decidim/elections/broken_promises_handler.js +11 -0
  26. data/app/packs/src/decidim/elections/trustee/key_ceremony.js +3 -0
  27. data/app/packs/src/decidim/elections/trustee/tally.js +3 -0
  28. data/app/packs/src/decidim/elections/voter/casting-vote.js +3 -0
  29. data/app/packs/src/decidim/elections/voter/setup-vote.js +9 -0
  30. data/app/packs/src/decidim/votings/in-person-vote.js +3 -0
  31. data/app/packs/src/decidim/votings/voting-description-cell.js +1 -8
  32. data/app/permissions/decidim/votings/admin/permissions.rb +3 -1
  33. data/app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb +5 -1
  34. data/app/views/decidim/elections/admin/questions/_form.html.erb +0 -4
  35. data/app/views/decidim/elections/admin/steps/_create_election.html.erb +14 -1
  36. data/app/views/decidim/elections/admin/steps/index.html.erb +2 -0
  37. data/app/views/decidim/elections/shared/_broken_promises_modal.html.erb +33 -0
  38. data/app/views/decidim/elections/trustee_mailer/notification.html.erb +5 -0
  39. data/app/views/decidim/elections/trustee_zone/elections/show.html.erb +3 -0
  40. data/app/views/decidim/elections/votes/_server_error_modal.html.erb +28 -0
  41. data/app/views/decidim/elections/votes/_show_casting.html.erb +2 -0
  42. data/app/views/decidim/elections/votes/new.html.erb +11 -6
  43. data/app/views/decidim/votings/admin/votings/_form.html.erb +6 -6
  44. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/new.html.erb +2 -0
  45. data/app/views/decidim/votings/polling_officer_zone/in_person_votes/show.html.erb +2 -0
  46. data/app/views/decidim/votings/votings/_check_fields.html.erb +13 -15
  47. data/app/views/decidim/votings/votings/_promoted_voting.html.erb +1 -1
  48. data/app/views/decidim/votings/votings/check_census.html.erb +5 -1
  49. data/config/locales/ar.yml +9 -2
  50. data/config/locales/ca.yml +48 -13
  51. data/config/locales/cs.yml +55 -19
  52. data/config/locales/de.yml +38 -18
  53. data/config/locales/el.yml +0 -1
  54. data/config/locales/en.yml +48 -14
  55. data/config/locales/es-MX.yml +57 -22
  56. data/config/locales/es-PY.yml +52 -17
  57. data/config/locales/es.yml +52 -17
  58. data/config/locales/eu.yml +3 -16
  59. data/config/locales/fi-plain.yml +49 -15
  60. data/config/locales/fi.yml +49 -15
  61. data/config/locales/fr-CA.yml +50 -16
  62. data/config/locales/fr.yml +50 -16
  63. data/config/locales/ga-IE.yml +3 -0
  64. data/config/locales/gl.yml +10 -14
  65. data/config/locales/hu.yml +14 -1
  66. data/config/locales/it.yml +7 -18
  67. data/config/locales/ja.yml +49 -16
  68. data/config/locales/lt.yml +1427 -0
  69. data/config/locales/lv.yml +0 -1
  70. data/config/locales/nl.yml +15 -17
  71. data/config/locales/no.yml +8 -4
  72. data/config/locales/oc-FR.yml +1 -0
  73. data/config/locales/pl.yml +9 -17
  74. data/config/locales/pt-BR.yml +4 -17
  75. data/config/locales/pt.yml +4 -17
  76. data/config/locales/ro-RO.yml +2 -15
  77. data/config/locales/sv.yml +53 -10
  78. data/config/locales/tr-TR.yml +8 -1
  79. data/config/locales/zh-CN.yml +7 -1
  80. data/db/migrate/20220615102642_remove_description_from_elections_questions.rb +7 -0
  81. data/lib/decidim/api/election_question_type.rb +0 -1
  82. data/lib/decidim/elections/admin_engine.rb +4 -1
  83. data/lib/decidim/elections/component.rb +0 -12
  84. data/lib/decidim/elections/test/factories.rb +0 -1
  85. data/lib/decidim/elections/version.rb +1 -1
  86. metadata +19 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afdf9a7aa52a455c7f5f0ea11e46884df0829f4aa8bd63b815947574f63eeb56
4
- data.tar.gz: 392b8291c4d4eeaddafce24832da3144ad444cf974597f21a9fef71a2aed34e1
3
+ metadata.gz: 79cbe0a072815eeb089fe22866c15107b9dd0f68e6a3a3cc3c45471f7186777c
4
+ data.tar.gz: d67f9a69166f20546353b2b40d7a19ce08a59f4837fde321d2c369c7c9a9ab3f
5
5
  SHA512:
6
- metadata.gz: dcbbfc891f43a3a46e8866504211df489be49dbbf80e6438e4dc72c1f35284ebc258ce973c8b663a027a6ae9c62c370fe03e0ecc8ad0a667bf5337006181ac30
7
- data.tar.gz: 7b490ae2ec90c5df75855bf4f8296a8a4c8b16acbfda0e922aa16b00bb4d7c9d356d5c71b4b445623438fda9c70234ab395b3b906025711186996158956f5d4e
6
+ metadata.gz: b2ef4df36d4b64aa1f6d26d01716d39ce15511c1c4c70be51c86830f29c43d4d854ab2b1a5d3f2fd38ee0f8f9c31d0c9542497b86cc261030cdb8278b739aa34
7
+ data.tar.gz: 6da057cd74be00affe5622b0b6de4be710838768b0ec778596bf8588b166d5a4c6ca8357563b396f62169a49c8a4449bfb7a9e653eceeecd21fdbfe65157210a
@@ -5,15 +5,20 @@ module Decidim
5
5
  # This cell renders the results
6
6
  # for a given instance of an Election
7
7
  class ElectionVoteCtaCell < Decidim::ViewModel
8
+ include Decidim::Elections::HasVoteFlow
9
+
8
10
  delegate :current_user,
9
11
  :current_participatory_space,
10
- :preview_mode?,
11
- :can_preview?,
12
- :vote_flow,
12
+ :allowed_to?,
13
13
  to: :controller
14
14
 
15
15
  private
16
16
 
17
+ # This is needed by HasVoteFlow
18
+ def election
19
+ model
20
+ end
21
+
17
22
  def last_vote
18
23
  @last_vote ||= Decidim::Elections::Votes::LastVoteForVoter.for(model, vote_flow.voter_id) if vote_flow.has_voter?
19
24
  end
@@ -8,7 +8,7 @@
8
8
  <div class="column">
9
9
  <%= link_to decidim_votings.voting_path(voting), class: "card card--voting card--mini" do %>
10
10
  <div aria-hidden="true" class="card__image-top"
11
- style="background-image:url(<%= voting.attached_uploader(:banner_image).path %>)"></div>
11
+ style="background-image:url('<%= voting.attached_uploader(:banner_image).path %>')"></div>
12
12
  <div class="card__content">
13
13
  <span class="card__title card__link"><%= translated_attribute voting.title %></span>
14
14
  </div>
@@ -37,6 +37,7 @@ module Decidim
37
37
  def cache_hash
38
38
  hash = []
39
39
  hash.push(I18n.locale)
40
+ hash.push(highlighted_votings.map(&:cache_key_with_version))
40
41
  hash.join(Decidim.cache_key_separator)
41
42
  end
42
43
  end
@@ -1,25 +1,14 @@
1
- <div class="row section voting-description-cell">
1
+ <div class="row section voting-description-cell mt-m">
2
2
  <div class="columns">
3
3
  <% if introductory_image.attached? %>
4
4
  <div id="introductory-image" class="columns medium-4 mediumlarge-5">
5
5
  <img src="<%= introductory_image.path %>" alt="">
6
6
  </div>
7
7
  <% end %>
8
- <div class="columns medium-8 mediumlarge-7 content">
8
+ <div class="columns medium-8 mediumlarge-7">
9
9
  <h2 class="show-for-sr"><%= t("decidim.votings.content_blocks.landing_page.description.title") %></h2>
10
10
  <div><%= description_text %></div>
11
11
  </div>
12
- <div class="content-height-toggler show-more">
13
- <button class="button button--muted tiny">
14
- <span class="button-text show-more-content">
15
- <%= button_show_more_text %>
16
- </span>
17
-
18
- <span class="button-text show-less-content hide">
19
- <%= button_show_less_text %>
20
- </span>
21
- </button>
22
- </div>
23
12
  </div>
24
13
  </div>
25
14
 
@@ -18,14 +18,6 @@ module Decidim
18
18
  def description_text
19
19
  decidim_sanitize_editor(translated_attribute(current_participatory_space.description))
20
20
  end
21
-
22
- def button_show_more_text
23
- t(:show_more, scope: "decidim.votings.content_blocks.landing_page.description")
24
- end
25
-
26
- def button_show_less_text
27
- t(:show_less, scope: "decidim.votings.content_blocks.landing_page.description")
28
- end
29
21
  end
30
22
  end
31
23
  end
@@ -1,4 +1,4 @@
1
- <section class="extended hero" style="background-image:url(<%= current_participatory_space.attached_uploader(:banner_image).path %>);">
1
+ <section class="extended hero" style="background-image:url('<%= current_participatory_space.attached_uploader(:banner_image).path %>');">
2
2
  <div class="hero__container">
3
3
  <div class="row">
4
4
  <div class="columns large-10 text-left">
@@ -24,6 +24,6 @@
24
24
  </div>
25
25
  </section>
26
26
 
27
- <section class="section">
27
+ <section>
28
28
  <%= extended_navigation_bar(navigation_items) %>
29
29
  </section>
@@ -11,6 +11,8 @@ module Decidim
11
11
  # form - A form object with the params.
12
12
  def initialize(form, current_user)
13
13
  @form = form
14
+ @user = form.user
15
+ @participatory_space = form.current_participatory_space
14
16
  @current_user = current_user
15
17
  end
16
18
 
@@ -27,29 +29,31 @@ module Decidim
27
29
  notify_user_about_trustee_role if new_trustee?
28
30
  end
29
31
 
32
+ send_email
33
+
30
34
  broadcast(:ok)
31
35
  end
32
36
 
33
37
  private
34
38
 
35
- attr_reader :form, :current_user, :trustee
39
+ attr_reader :form, :current_user, :trustee, :participatory_space, :user
36
40
 
37
41
  def add_user_as_trustee!
38
42
  @trustee = Decidim.traceability.create!(
39
43
  Trustee,
40
- form.current_user,
41
- user: form.user,
42
- organization: form.user.organization
44
+ current_user,
45
+ user: user,
46
+ organization: user.organization
43
47
  )
44
48
  end
45
49
 
46
50
  # If a trustee exists for this participatory space, it won't get created again
47
51
  def existing_trustee_participatory_spaces?
48
- trustees_space = TrusteesParticipatorySpace.where(participatory_space: form.current_participatory_space).includes(:trustee)
52
+ trustees_space = TrusteesParticipatorySpace.where(participatory_space: participatory_space).includes(:trustee)
49
53
  @existing_trustee_participatory_spaces ||= Decidim::Elections::Trustee.joins(:trustees_participatory_spaces)
50
54
  .includes([:user])
51
55
  .where(trustees_participatory_spaces: trustees_space)
52
- .where(decidim_user_id: form.user.id).any?
56
+ .where(decidim_user_id: user.id).any?
53
57
  end
54
58
 
55
59
  # if there's no user - trustee relation, the trustee gets created and the notification
@@ -57,13 +61,13 @@ module Decidim
57
61
  def new_trustee?
58
62
  return @new_trustee if defined?(@new_trustee)
59
63
 
60
- @new_trustee = Decidim::Elections::Trustee.where(decidim_user_id: form.user.id).empty?
64
+ @new_trustee = Decidim::Elections::Trustee.where(decidim_user_id: user.id).empty?
61
65
  end
62
66
 
63
67
  def add_participatory_space
64
- trustee = Decidim::Elections::Trustee.find_by(decidim_user_id: form.user.id)
68
+ trustee = Decidim::Elections::Trustee.find_by(decidim_user_id: user.id)
65
69
  trustee.trustees_participatory_spaces.create!(
66
- participatory_space: form.current_participatory_space
70
+ participatory_space: participatory_space
67
71
  )
68
72
  end
69
73
 
@@ -71,11 +75,17 @@ module Decidim
71
75
  data = {
72
76
  event: "decidim.events.elections.trustees.new_trustee",
73
77
  event_class: Decidim::Elections::Trustees::NotifyNewTrusteeEvent,
74
- resource: form.current_participatory_space,
75
- affected_users: [form.user]
78
+ resource: participatory_space,
79
+ affected_users: [user]
76
80
  }
77
81
  Decidim::EventsManager.publish(**data)
78
82
  end
83
+
84
+ def send_email
85
+ Decidim::Elections::TrusteeMailer.notification(
86
+ user, participatory_space, I18n.locale.to_s
87
+ ).deliver_later
88
+ end
79
89
  end
80
90
  end
81
91
  end
@@ -14,7 +14,8 @@ module Decidim
14
14
  #
15
15
  # Broadcasts :ok if successful, :invalid otherwise.
16
16
  def call
17
- return broadcast(:invalid) if invalid?
17
+ return broadcast(:election_started) if form.election.started?
18
+ return broadcast(:invalid) if form.invalid?
18
19
 
19
20
  create_question!
20
21
 
@@ -25,15 +26,10 @@ module Decidim
25
26
 
26
27
  attr_reader :form, :question
27
28
 
28
- def invalid?
29
- form.election.started? || form.invalid?
30
- end
31
-
32
29
  def create_question!
33
30
  attributes = {
34
31
  election: form.election,
35
32
  title: form.title,
36
- description: form.description,
37
33
  max_selections: form.max_selections,
38
34
  weight: form.weight,
39
35
  random_answers_order: form.random_answers_order,
@@ -94,7 +94,9 @@ module Decidim
94
94
  weight: question.weight,
95
95
  max_selections: question.max_selections,
96
96
  title: flatten_translations(question.title),
97
- description: flatten_translations(question.description),
97
+ # the bulletin_board gem (ruby client) expects a description for the question
98
+ # as development is in a separate repository, let's send an empty content for the moment
99
+ description: {},
98
100
  answers: question_answers_data(question)
99
101
  }
100
102
  end
@@ -33,7 +33,6 @@ module Decidim
33
33
  def update_question!
34
34
  attributes = {
35
35
  title: form.title,
36
- description: form.description,
37
36
  max_selections: form.max_selections,
38
37
  weight: form.weight,
39
38
  random_answers_order: form.random_answers_order,
@@ -30,7 +30,7 @@ module Decidim
30
30
  :delete,
31
31
  ballot_style,
32
32
  current_user,
33
- visibility: "all"
33
+ { visibility: "all", code: ballot_style.code }
34
34
  ) do
35
35
  ballot_style.destroy!
36
36
  end
@@ -26,6 +26,11 @@ module Decidim
26
26
  flash.now[:alert] = I18n.t("questions.create.invalid", scope: "decidim.elections.admin")
27
27
  render action: "new"
28
28
  end
29
+
30
+ on(:election_started) do
31
+ flash.now[:alert] = I18n.t("questions.create.election_started", scope: "decidim.elections.admin")
32
+ render action: "new"
33
+ end
29
34
  end
30
35
  end
31
36
 
@@ -98,7 +98,7 @@ module Decidim
98
98
  if current_census.access_codes_file.attached?
99
99
  redirect_to Rails.application.routes.url_helpers.rails_blob_url(current_census.access_codes_file.blob, only_path: true)
100
100
  else
101
- flash[:error] = t("export_access_codes.file_not_exists", scope: "decidim.votings.census.admin.census")
101
+ flash[:error] = t("export_access_codes.file_not_exist", scope: "decidim.votings.census.admin.census")
102
102
  redirect_to admin_voting_census_path
103
103
  end
104
104
  end
@@ -103,6 +103,8 @@ module Decidim
103
103
  end
104
104
 
105
105
  def elections
106
+ raise ActionController::RoutingError, "Not Found" unless current_participatory_space
107
+
106
108
  Decidim::Elections::Election.where(component: current_participatory_space.components).where.not(bb_status: nil)
107
109
  end
108
110
 
@@ -8,14 +8,12 @@ module Decidim
8
8
  include TranslatableAttributes
9
9
 
10
10
  translatable_attribute :title, String
11
- translatable_attribute :description, String
12
11
  attribute :max_selections, Integer, default: 1
13
12
  attribute :weight, Integer, default: 0
14
13
  attribute :random_answers_order, Boolean, default: true
15
14
  attribute :min_selections, Integer, default: 1
16
15
 
17
16
  validates :title, translatable_presence: true
18
- validates :description, translatable_presence: true
19
17
  validates :max_selections, presence: true, numericality: { greater_than_or_equal_to: 1 }
20
18
 
21
19
  def election
@@ -13,6 +13,12 @@ module Decidim
13
13
  validations.each do |message, t_args, valid|
14
14
  errors.add(message, I18n.t("steps.create_election.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid
15
15
  end
16
+
17
+ if needs_census?
18
+ census_validations.each do |message, t_args, valid|
19
+ errors.add(message, I18n.t("steps.create_election.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid
20
+ end
21
+ end
16
22
  end
17
23
 
18
24
  def current_step; end
@@ -34,17 +40,34 @@ module Decidim
34
40
  [:minimum_answers, {}, election.minimum_answers?],
35
41
  [:max_selections, {}, election.valid_questions?],
36
42
  [:published, {}, election.published_at.present?],
43
+ [:component_published, {}, election.component.published?],
37
44
  [:time_before, { hours: Decidim::Elections.setup_minimum_hours_before_start }, election.minimum_hours_before_start?],
38
45
  [:trustees_number, { number: bulletin_board.number_of_trustees }, participatory_space_trustees_with_public_key.size >= bulletin_board.number_of_trustees]
39
46
  ].freeze
40
47
  end
41
48
 
49
+ def census_validations
50
+ return [] unless needs_census?
51
+
52
+ @census_validations ||= [
53
+ [:census_uploaded, {}, census.present? && census.data.exists?],
54
+ [:census_codes_generated, {}, census_codes_generated?],
55
+ [:census_frozen, {}, census&.freeze?]
56
+ ].freeze
57
+ end
58
+
42
59
  def messages
43
60
  @messages ||= validations.map do |message, t_args, _valid|
44
61
  [message, I18n.t("steps.create_election.requirements.#{message}", **t_args, scope: "decidim.elections.admin")]
45
62
  end.to_h
46
63
  end
47
64
 
65
+ def census_messages
66
+ @census_messages ||= census_validations.to_h do |message, t_args, _valid|
67
+ [message, I18n.t("steps.create_election.requirements.#{message}", **t_args, scope: "decidim.elections.admin")]
68
+ end
69
+ end
70
+
48
71
  def participatory_space_trustees
49
72
  @participatory_space_trustees ||= Decidim::Elections::Trustees::ByParticipatorySpace.new(election.component.participatory_space).to_a
50
73
  end
@@ -57,6 +80,26 @@ module Decidim
57
80
  @bulletin_board ||= context[:bulletin_board] || Decidim::Elections.bulletin_board
58
81
  end
59
82
 
83
+ def needs_census?
84
+ vote_flow.is_a?(Decidim::Votings::CensusVoteFlow)
85
+ end
86
+
87
+ def vote_flow
88
+ @vote_flow ||= election.participatory_space.try(:vote_flow_for, election)
89
+ end
90
+
91
+ def census_codes_generated?
92
+ return unless needs_census?
93
+
94
+ census&.codes_generated? || census&.exporting_codes? || census&.freeze?
95
+ end
96
+
97
+ def census
98
+ return unless needs_census?
99
+
100
+ @census ||= election.component.participatory_space.dataset
101
+ end
102
+
60
103
  def main_button?
61
104
  true
62
105
  end
@@ -17,9 +17,13 @@ module Decidim
17
17
  attribute :email, String
18
18
  attribute :ballot_style_code, String
19
19
 
20
+ validates :birthdate, format: { with: /\A\d{8}\z/ }
21
+
20
22
  validates :full_name,
21
23
  :full_address,
24
+ :birthdate,
22
25
  presence: true
26
+
23
27
  def ballot_style_code
24
28
  @ballot_style_code&.upcase
25
29
  end
@@ -14,7 +14,9 @@ module Decidim
14
14
  end
15
15
 
16
16
  def more_information?(answer)
17
- answer.description || answer.proposals.any? || answer.photos.any?
17
+ translated_attribute(answer.description).present? ||
18
+ answer.proposals.any? ||
19
+ answer.photos.any?
18
20
  end
19
21
  end
20
22
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Elections
5
+ # This mailer sends a notification email to a recently added trustee
6
+ class TrusteeMailer < Decidim::ApplicationMailer
7
+ include TranslatableAttributes
8
+
9
+ # Public: Sends an email to a trustee that just got added to a participatory space.
10
+ #
11
+ # user - The user to be notified
12
+ # participatory_space - The participatory space where the trustee was added.
13
+ # locale - The locale that will be used for the email content (optional).
14
+ #
15
+ # Returns nothing.
16
+ def notification(user, participatory_space, locale = nil)
17
+ @user = user
18
+ @participatory_space = participatory_space
19
+ @organization = user.organization
20
+
21
+ I18n.with_locale(locale || @organization.default_locale) do
22
+ @participatory_space_title = translated_attribute(participatory_space.title)
23
+ mail(to: user.email, subject: I18n.t("subject", scope: "decidim.elections.admin.mailers.trustee_mailer", resource_name: @participatory_space_title))
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -86,7 +86,7 @@ module Decidim
86
86
  #
87
87
  # Returns a boolean.
88
88
  def minimum_answers?
89
- questions.all? { |question| question.answers.size > 1 }
89
+ questions.any? && questions.all? { |question| question.answers.size > 1 }
90
90
  end
91
91
 
92
92
  # Public: Checks if the election results are published and election finished
@@ -107,7 +107,7 @@ module Decidim
107
107
  #
108
108
  # Returns a boolean.
109
109
  def valid_questions?
110
- questions.all?(&:valid_max_selection?)
110
+ questions.any? && questions.all?(&:valid_max_selection?)
111
111
  end
112
112
 
113
113
  # Public: Gets the voting period status of the election
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Elections
5
5
  # The data store for a Question in the Decidim::Elections component. It stores a
6
- # title, description and a maximum number of selection that voters can choose.
6
+ # title and a maximum number of selection that voters can choose.
7
7
  class Question < ApplicationRecord
8
8
  include Decidim::Resourceable
9
9
  include Traceable
@@ -1,3 +1,5 @@
1
+ // show a message to the user if comunication is lost
2
+ import "src/decidim/elections/broken_promises_handler";
1
3
  import { Client } from "@decidim/decidim-bulletin_board";
2
4
 
3
5
  $(() => {
@@ -1,3 +1,5 @@
1
+ // show a message to the user if comunication is lost
2
+ import "src/decidim/elections/broken_promises_handler";
1
3
  import {
2
4
  Client,
3
5
  Election,
@@ -0,0 +1,11 @@
1
+ /* Fallback for non-handled failed promises */
2
+ window.addEventListener("unhandledrejection", (event) => {
3
+ console.log("broken", event)
4
+ $("#server-failure .tech-info").html(event.reason);
5
+ if (event.reason.toString().indexOf("fetch") === -1) {
6
+ $("#server-failure .communication_error").addClass("hide");
7
+ $("#server-failure .generic_error").removeClass("hide");
8
+ }
9
+ $("#server-failure").foundation("open");
10
+ });
11
+
@@ -1,3 +1,6 @@
1
+ // show a message to the user if comunication is lost
2
+ import "src/decidim/elections/broken_promises_handler";
3
+
1
4
  import {
2
5
  KeyCeremonyComponent,
3
6
  MessageIdentifier,
@@ -1,3 +1,6 @@
1
+ // show a message to the user if comunication is lost
2
+ import "src/decidim/elections/broken_promises_handler";
3
+
1
4
  import {
2
5
  TallyComponent,
3
6
  IdentificationKeys,
@@ -1,3 +1,6 @@
1
+ // show a message to the user if comunication is lost
2
+ import "src/decidim/elections/broken_promises_handler";
3
+
1
4
  import { Client } from "@decidim/decidim-bulletin_board";
2
5
 
3
6
  $(async () => {
@@ -1,5 +1,7 @@
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";
3
5
  import { VoteComponent } from "@decidim/decidim-bulletin_board";
4
6
 
5
7
  import * as VotingSchemesDummy from "@decidim/voting_schemes-dummy";
@@ -46,5 +48,12 @@ export default function setupVoteComponent($voteWrapper) {
46
48
  });
47
49
  }
48
50
 
51
+ /* Fallback for non-handled failed promises */
52
+ window.addEventListener("unhandledrejection", (event) => {
53
+ $("#server-failure .tech-info").html(event.reason);
54
+ $("#server-failure").foundation("open");
55
+ });
56
+
49
57
  window.Decidim = window.Decidim || {};
50
58
  window.Decidim.setupVoteComponent = setupVoteComponent;
59
+
@@ -1,3 +1,6 @@
1
+ // show a message to the user if comunication is lost
2
+ import "src/decidim/elections/broken_promises_handler";
3
+
1
4
  import { Client } from "@decidim/decidim-bulletin_board";
2
5
 
3
6
  $(async () => {
@@ -1,6 +1,4 @@
1
1
  $(() => {
2
- const isShowMoreButton = ($button) => $button.hasClass("show-more-content");
3
-
4
2
  const remToPx = (count) => {
5
3
  const unit = $("html").css("font-size");
6
4
 
@@ -25,17 +23,12 @@ $(() => {
25
23
  $content.css("max-height", contentMaxHeight);
26
24
  }
27
25
 
28
- $button.on("click", (event) => {
29
- const $buttonTextMore = $button.find(".button-text.show-more-content");
26
+ $button.on("click", () => {
30
27
  const $buttonTextLess = $button.find(".button-text.show-less-content");
31
28
 
32
29
  let newHeight = contentMaxHeight;
33
- if (isShowMoreButton($(event.target))) {
34
- newHeight = contentHeight;
35
- }
36
30
 
37
31
  $content.css("max-height", newHeight);
38
32
  $buttonTextLess.toggleClass("hide");
39
- $buttonTextMore.toggleClass("hide");
40
33
  });
41
34
  });
@@ -8,6 +8,9 @@ module Decidim
8
8
  return permission_action unless user
9
9
  return user_allowed_to_read_admin_dashboard? if read_admin_dashboard_action?
10
10
  return permission_action unless permission_action.scope == :admin
11
+
12
+ user_can_enter_space_area?
13
+
11
14
  return permission_action if voting && !voting.is_a?(Decidim::Votings::Voting)
12
15
 
13
16
  unless user_can_read_votings_admin_dashboard?
@@ -15,7 +18,6 @@ module Decidim
15
18
  return permission_action
16
19
  end
17
20
 
18
- user_can_enter_space_area?
19
21
  allowed_read_participatory_space?
20
22
  allowed_voting_action?
21
23
 
@@ -17,10 +17,14 @@ module Decidim
17
17
 
18
18
  def i18n_params
19
19
  super.merge(
20
- ballot_style_code: action_log.resource.code
20
+ ballot_style_code: ballot_style_code.to_s
21
21
  )
22
22
  end
23
23
 
24
+ def ballot_style_code
25
+ action_log&.resource&.code || action_log.extra["code"]
26
+ end
27
+
24
28
  def action_string
25
29
  case action
26
30
  when "create", "delete", "update"
@@ -8,10 +8,6 @@
8
8
  <%= form.translated :text_field, :title, autofocus: true %>
9
9
  </div>
10
10
 
11
- <div class="row column">
12
- <%= form.translated :editor, :description %>
13
- </div>
14
-
15
11
  <div class="row column">
16
12
  <%= form.number_field :max_selections, step: 1, min: 0 %>
17
13
  </div>
@@ -14,10 +14,23 @@
14
14
  <% end %>
15
15
  </ul>
16
16
 
17
+ <% if form.needs_census? %>
18
+ <h4><%= t(".census") %></h4>
19
+ <ul class="no-bullet-indented">
20
+ <% form.census_messages.each do |key, value| %>
21
+ <% if form.errors.include?(key) %>
22
+ <li><%= icon "x", class: "text-alert", role: "img", "aria-hidden": true %>&nbsp;<%= form.errors.messages[key][0].html_safe %></li>
23
+ <% else %>
24
+ <li><%= icon "check", class: "text-success", role: "img", "aria-hidden": true %>&nbsp;<%= value.html_safe %></li>
25
+ <% end %>
26
+ <% end %>
27
+ </ul>
28
+ <% end %>
29
+
17
30
  <h4><%= t(".trustees") %></h4>
18
31
  <ul class="no-bullet-indented">
19
32
  <% if form.participatory_space_trustees.none? %>
20
- <li><%= t(".no_trustees") %></li>
33
+ <li><%= icon "x", class: "text-alert", role: "img", "aria-hidden": true %>&nbsp;<%= t(".no_trustees") %></li>
21
34
  <% end %>
22
35
 
23
36
  <% form.participatory_space_trustees.map {|trustee| [trustee, form.trustees.none? || form.trustees.include?(trustee)] }
@@ -43,3 +43,5 @@
43
43
  <%= render partial: current_step.to_s %>
44
44
  </div>
45
45
  <% end %>
46
+
47
+ <%= render "decidim/elections/shared/broken_promises_modal" %>