decidim-bulletin_board 0.16.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -14
- data/decidim-bulletin_board.gemspec +0 -1
- data/lib/decidim/bulletin_board/authority/create_election.rb +18 -3
- data/lib/decidim/bulletin_board/client.rb +9 -0
- data/lib/decidim/bulletin_board/version.rb +1 -1
- data/lib/decidim/bulletin_board/voter/cast_vote.rb +3 -3
- data/lib/decidim/bulletin_board/voter/in_person_vote.rb +64 -0
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a424e34a19f270011f18eb535740d904e54ab0687f6158d117d1f99358aded14
|
4
|
+
data.tar.gz: a6b12f1e42b5b4522e5f5f570d03f14e5ac5025acd371d5d78f0d9606a2ae7a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d11e0d4149f85fcb553f7266a93e6598fa4b6945a8aad2296c5bfa529664f1e2a0dc1131c4c6c8468b592e23e832f419122082078b543f3645521f1376dcc13
|
7
|
+
data.tar.gz: 4cd041f2cd08e2c7ae2e707259d67c4dfd8bc1474a265d1b407e07093b1b3e65ae001bdfeb1b275b24eb01eed08a659276d957182ea257d0abfa148698e559ff
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
decidim-bulletin_board (0.
|
4
|
+
decidim-bulletin_board (0.19.0)
|
5
5
|
byebug (~> 11.0)
|
6
6
|
graphlient (~> 0.4.0)
|
7
7
|
jwt (~> 2.2.2)
|
8
|
-
mimemagic (~> 0.3.7)
|
9
8
|
rails (>= 5.0.0)
|
10
9
|
wisper (~> 2.0.0)
|
11
10
|
|
@@ -76,19 +75,27 @@ GEM
|
|
76
75
|
ast (2.4.1)
|
77
76
|
builder (3.2.4)
|
78
77
|
byebug (11.1.3)
|
79
|
-
concurrent-ruby (1.1.
|
78
|
+
concurrent-ruby (1.1.8)
|
79
|
+
connection_pool (2.2.5)
|
80
80
|
crack (0.4.5)
|
81
81
|
rexml
|
82
82
|
crass (1.0.6)
|
83
83
|
diff-lcs (1.4.4)
|
84
84
|
erubi (1.10.0)
|
85
|
+
excon (0.80.1)
|
85
86
|
faker (2.15.1)
|
86
87
|
i18n (>= 1.6, < 2)
|
87
|
-
faraday (1.
|
88
|
+
faraday (1.4.0)
|
89
|
+
faraday-excon (~> 1.0)
|
88
90
|
faraday-net_http (~> 1.0)
|
91
|
+
faraday-net_http_persistent (~> 1.0)
|
89
92
|
multipart-post (>= 1.2, < 3)
|
90
|
-
ruby2_keywords
|
93
|
+
ruby2_keywords (>= 0.0.4)
|
94
|
+
faraday-excon (1.0.0)
|
95
|
+
excon (>= 0.27.4)
|
91
96
|
faraday-net_http (1.0.1)
|
97
|
+
faraday-net_http_persistent (1.0.3)
|
98
|
+
net-http-persistent (>= 3.1)
|
92
99
|
faraday_middleware (1.0.0)
|
93
100
|
faraday (~> 1.0)
|
94
101
|
globalid (0.4.2)
|
@@ -97,30 +104,29 @@ GEM
|
|
97
104
|
faraday (>= 1.0)
|
98
105
|
faraday_middleware
|
99
106
|
graphql-client
|
100
|
-
graphql (1.12.
|
107
|
+
graphql (1.12.8)
|
101
108
|
graphql-client (0.16.0)
|
102
109
|
activesupport (>= 3.0)
|
103
110
|
graphql (~> 1.8)
|
104
111
|
hashdiff (1.0.1)
|
105
|
-
i18n (1.8.
|
112
|
+
i18n (1.8.10)
|
106
113
|
concurrent-ruby (~> 1.0)
|
107
114
|
jwt (2.2.2)
|
108
|
-
loofah (2.9.
|
115
|
+
loofah (2.9.1)
|
109
116
|
crass (~> 1.0.2)
|
110
117
|
nokogiri (>= 1.5.9)
|
111
118
|
mail (2.7.1)
|
112
119
|
mini_mime (>= 0.1.1)
|
113
120
|
marcel (1.0.1)
|
114
121
|
method_source (1.0.0)
|
115
|
-
mimemagic (0.3.10)
|
116
|
-
nokogiri (~> 1)
|
117
|
-
rake
|
118
122
|
mini_mime (1.0.3)
|
119
123
|
mini_portile2 (2.5.0)
|
120
124
|
minitest (5.14.4)
|
121
125
|
multipart-post (2.1.1)
|
126
|
+
net-http-persistent (4.0.1)
|
127
|
+
connection_pool (~> 2.2)
|
122
128
|
nio4r (2.5.7)
|
123
|
-
nokogiri (1.11.
|
129
|
+
nokogiri (1.11.3)
|
124
130
|
mini_portile2 (~> 2.5.0)
|
125
131
|
racc (~> 1.4)
|
126
132
|
parallel (1.20.1)
|
@@ -158,7 +164,7 @@ GEM
|
|
158
164
|
rake (>= 0.8.7)
|
159
165
|
thor (~> 1.0)
|
160
166
|
rainbow (3.0.0)
|
161
|
-
rake (13.0.
|
167
|
+
rake (13.0.3)
|
162
168
|
regexp_parser (2.0.0)
|
163
169
|
rexml (3.2.4)
|
164
170
|
rspec (3.9.0)
|
@@ -231,4 +237,4 @@ DEPENDENCIES
|
|
231
237
|
wisper-rspec (~> 1.1.0)
|
232
238
|
|
233
239
|
BUNDLED WITH
|
234
|
-
2.2.
|
240
|
+
2.2.15
|
@@ -50,12 +50,14 @@ 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
|
-
start_date: election_data[:start_date].
|
56
|
-
end_date: election_data[:end_date].
|
56
|
+
start_date: election_data[:start_date].strftime("%FT%T%:z"),
|
57
|
+
end_date: election_data[:end_date].strftime("%FT%T%:z"),
|
57
58
|
candidates: candidates,
|
58
|
-
contests: contests
|
59
|
+
contests: contests,
|
60
|
+
ballot_styles: ballot_styles
|
59
61
|
}
|
60
62
|
}
|
61
63
|
end
|
@@ -93,6 +95,10 @@ module Decidim
|
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
98
|
+
def polling_stations
|
99
|
+
election_data[:polling_stations] || []
|
100
|
+
end
|
101
|
+
|
96
102
|
def contests
|
97
103
|
election_data[:questions].each_with_index.map do |question, index|
|
98
104
|
{
|
@@ -128,6 +134,15 @@ module Decidim
|
|
128
134
|
end
|
129
135
|
end
|
130
136
|
|
137
|
+
def ballot_styles
|
138
|
+
election_data[:ballot_styles].map do |ballot_style_id, question_ids|
|
139
|
+
{
|
140
|
+
object_id: ballot_style_id.to_s,
|
141
|
+
contests: question_ids
|
142
|
+
}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
131
146
|
def default_text(field)
|
132
147
|
field[default_locale]
|
133
148
|
end
|
@@ -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 }
|
@@ -7,7 +7,9 @@ module Decidim
|
|
7
7
|
class CastVote < Decidim::BulletinBoard::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
|
-
#
|
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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-bulletin_board
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Morcillo
|
@@ -11,22 +11,8 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-04-
|
14
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: mimemagic
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
requirements:
|
20
|
-
- - "~>"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.3.7
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.3.7
|
30
16
|
- !ruby/object:Gem::Dependency
|
31
17
|
name: rails
|
32
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,6 +186,7 @@ files:
|
|
200
186
|
- lib/decidim/bulletin_board/version.rb
|
201
187
|
- lib/decidim/bulletin_board/voter/cast_vote.rb
|
202
188
|
- lib/decidim/bulletin_board/voter/get_pending_message_status.rb
|
189
|
+
- lib/decidim/bulletin_board/voter/in_person_vote.rb
|
203
190
|
homepage: https://github.com/decidim/decidim-bulletin-board
|
204
191
|
licenses:
|
205
192
|
- AGPL-3.0
|