decidim-bulletin_board 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f57fb62ad80dd77a01967428857403e6bf924b914436ba925326d3a42f0ea788
4
- data.tar.gz: cc268ad78df55d1b237d323ca7a718e1684a1525b6e11e1aa92c62dad30dbac9
3
+ metadata.gz: 5bd025ed5f336f685e503a1401902e26c62f4eba4e5bef652fa811a1d83a874f
4
+ data.tar.gz: e71eadb9dd3221324ac7a114f5fd73222089c87db377b32f120632ea6a3b9673
5
5
  SHA512:
6
- metadata.gz: a67ac0126b78b6eb5be7c8867cbd2ca87f0d8eb7961bc421ecc718cf016c9a7d4e490ac28bf40cc1f3e894cfc61ca707e949f05dc445c80e86af4b3bb408039d
7
- data.tar.gz: 4e12f82f34a1d1c3db236b01e686ce4c14711ba9f8ba9121bdec49352d796fd63605b37646560e1777d0cf58f027a9eedcaf1eb5e061cc6d2570b48453ea4999
6
+ metadata.gz: 912fda5b140c9ee1acc4ed7eb9513e24aca52586d3974708c9d03b6b5716a59890025f018ded4a981bc46457ea02d287aa15a00b068b550cf75e392ecd2c8a80
7
+ data.tar.gz: f7913e4ccd28f94c816d0d0d348a47ec9b7877e1c9cba5bb00287da840740a50550066cb2a370ad99dc13032bee96f21bb4071cb5926bc749597c5b679ccaf78
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- decidim-bulletin_board (0.17.1)
4
+ decidim-bulletin_board (0.18.0)
5
5
  byebug (~> 11.0)
6
6
  graphlient (~> 0.4.0)
7
7
  jwt (~> 2.2.2)
@@ -119,6 +119,10 @@ GEM
119
119
  nokogiri (1.11.3)
120
120
  mini_portile2 (~> 2.5.0)
121
121
  racc (~> 1.4)
122
+ nokogiri (1.11.3-x86_64-darwin)
123
+ racc (~> 1.4)
124
+ nokogiri (1.11.3-x86_64-linux)
125
+ racc (~> 1.4)
122
126
  parallel (1.20.1)
123
127
  parser (2.7.2.0)
124
128
  ast (~> 2.4.1)
@@ -227,4 +231,4 @@ DEPENDENCIES
227
231
  wisper-rspec (~> 1.1.0)
228
232
 
229
233
  BUNDLED WITH
230
- 2.2.0
234
+ 2.2.15
@@ -50,6 +50,7 @@ module Decidim
50
50
  bulletin_board: bulletin_board,
51
51
  authority: authority,
52
52
  trustees: trustees,
53
+ polling_stations: polling_stations,
53
54
  description: {
54
55
  name: text(election_data[:title]),
55
56
  start_date: election_data[:start_date].strftime("%FT%T%:z"),
@@ -94,6 +95,10 @@ module Decidim
94
95
  end
95
96
  end
96
97
 
98
+ def polling_stations
99
+ election_data[:polling_stations] || []
100
+ end
101
+
97
102
  def contests
98
103
  election_data[:questions].each_with_index.map do |question, index|
99
104
  {
@@ -14,6 +14,7 @@ require "decidim/bulletin_board/authority/publish_results"
14
14
  require "decidim/bulletin_board/authority/get_election_results"
15
15
  require "decidim/bulletin_board/voter/cast_vote"
16
16
  require "decidim/bulletin_board/voter/get_pending_message_status"
17
+ require "decidim/bulletin_board/voter/in_person_vote"
17
18
  require "decidim/bulletin_board/test/reset_test_database"
18
19
 
19
20
  module Decidim
@@ -62,6 +63,14 @@ module Decidim
62
63
  cast_vote.call
63
64
  end
64
65
 
66
+ def in_person_vote(election_id, voter_id, polling_station_id)
67
+ in_person_vote = configure Voter::InPersonVote.new(election_id, voter_id, polling_station_id)
68
+ yield in_person_vote.message_id if block_given?
69
+ in_person_vote.on(:ok) { |pending_message| return pending_message }
70
+ in_person_vote.on(:error) { |error_message| raise StandardError, error_message }
71
+ in_person_vote.call
72
+ end
73
+
65
74
  def get_pending_message_status(message_id)
66
75
  get_pending_message_status = configure Voter::GetPendingMessageStatus.new(message_id)
67
76
  get_pending_message_status.on(:ok) { |status| return status }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Decidim
4
4
  module BulletinBoard
5
- VERSION = "0.17.1"
5
+ VERSION = "0.18.0"
6
6
  end
7
7
  end
@@ -7,7 +7,9 @@ module Decidim
7
7
  class CastVote < Decidim::BulletinBoard::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
- # form - A form object with the params.
10
+ # election_id - The local election identifier
11
+ # voter_id - The unique identifier of the voter
12
+ # encrypted_vote - The content of the encrypted vote.
11
13
  def initialize(election_id, voter_id, encrypted_vote)
12
14
  @election_id = election_id
13
15
  @voter_id = voter_id
@@ -55,8 +57,6 @@ module Decidim
55
57
 
56
58
  private
57
59
 
58
- delegate :cast_vote_message_id, to: :class
59
-
60
60
  attr_reader :election_id, :voter_id, :encrypted_vote
61
61
  end
62
62
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module BulletinBoard
5
+ module Voter
6
+ # This command uses the GraphQL client to inform about a vote casted in person in a polling station.
7
+ class InPersonVote < Decidim::BulletinBoard::Command
8
+ # Public: Initializes the command.
9
+ #
10
+ # election_id - The local election identifier
11
+ # voter_id - The unique identifier of the voter
12
+ # polling_station_id - The identifier of the polling station where the vote was casted.
13
+ def initialize(election_id, voter_id, polling_station_id)
14
+ @election_id = election_id
15
+ @voter_id = voter_id
16
+ @polling_station_id = polling_station_id
17
+ end
18
+
19
+ # Returns the message_id related to the operation
20
+ def message_id
21
+ @message_id ||= build_message_id(unique_election_id(election_id), "vote.in_person", voter_id)
22
+ end
23
+
24
+ # Executes the command. Broadcasts these events:
25
+ #
26
+ # - :ok when everything is valid and the mutation operation is successful.
27
+ # - :error if the form wasn't valid or the mutation operation was not successful.
28
+ #
29
+ # Returns nothing.
30
+ def call
31
+ # arguments used inside the graphql operation
32
+ args = {
33
+ message_id: message_id,
34
+ signed_data: sign_message(message_id, { polling_station_id: polling_station_id })
35
+ }
36
+
37
+ begin
38
+ response = graphql.query do
39
+ mutation do
40
+ vote(messageId: args[:message_id], signedData: args[:signed_data]) do
41
+ pendingMessage do
42
+ messageId
43
+ status
44
+ end
45
+ error
46
+ end
47
+ end
48
+ end
49
+
50
+ return broadcast(:error, response.data.vote.error) if response.data.vote.error.present?
51
+
52
+ broadcast(:ok, response.data.vote.pending_message)
53
+ rescue Graphlient::Errors::FaradayServerError
54
+ broadcast(:error, "something went wrong")
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ attr_reader :election_id, :voter_id, :polling_station_id
61
+ end
62
+ end
63
+ end
64
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-bulletin_board
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Morcillo
8
8
  - Svenja Schäfer
9
9
  - Leonardo Diez
10
10
  - Agustí B.R.
11
- autorequire:
11
+ autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-04-14 00:00:00.000000000 Z
14
+ date: 2021-04-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -186,11 +186,12 @@ files:
186
186
  - lib/decidim/bulletin_board/version.rb
187
187
  - lib/decidim/bulletin_board/voter/cast_vote.rb
188
188
  - lib/decidim/bulletin_board/voter/get_pending_message_status.rb
189
+ - lib/decidim/bulletin_board/voter/in_person_vote.rb
189
190
  homepage: https://github.com/decidim/decidim-bulletin-board
190
191
  licenses:
191
192
  - AGPL-3.0
192
193
  metadata: {}
193
- post_install_message:
194
+ post_install_message:
194
195
  rdoc_options: []
195
196
  require_paths:
196
197
  - lib
@@ -206,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
207
  version: '0'
207
208
  requirements: []
208
209
  rubygems_version: 3.0.3
209
- signing_key:
210
+ signing_key:
210
211
  specification_version: 4
211
212
  summary: ''
212
213
  test_files: []