decidim-bulletin_board 0.5.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/Gemfile.lock +124 -10
- data/app/assets/config/decidim_bulletin_board_manifest.js +1 -0
- data/app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.dev.js +18038 -0
- data/app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js +16 -0
- data/decidim-bulletin_board.gemspec +4 -4
- data/lib/decidim/bulletin_board.rb +1 -0
- data/lib/decidim/bulletin_board/authority.rb +2 -0
- data/lib/decidim/bulletin_board/authority/publish_results.rb +51 -0
- data/lib/decidim/bulletin_board/authority/start_tally.rb +51 -0
- data/lib/decidim/bulletin_board/client.rb +32 -9
- data/lib/decidim/bulletin_board/command.rb +9 -9
- data/lib/decidim/bulletin_board/engine.rb +15 -0
- data/lib/decidim/bulletin_board/graphql/bb_schema.json +390 -98
- data/lib/decidim/bulletin_board/graphql/client.rb +1 -1
- data/lib/decidim/bulletin_board/version.rb +1 -1
- data/lib/decidim/bulletin_board/voter.rb +1 -0
- data/lib/decidim/bulletin_board/voter/cast_vote.rb +7 -1
- data/lib/decidim/bulletin_board/voter/get_pending_message_status.rb +41 -0
- metadata +17 -20
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
class Client
|
8
8
|
def self.client
|
9
9
|
@client ||= Graphlient::Client.new(BulletinBoard.server,
|
10
|
-
schema_path: "
|
10
|
+
schema_path: File.join(__dir__, "bb_schema.json"),
|
11
11
|
headers: {
|
12
12
|
"Authorization" => BulletinBoard.api_key
|
13
13
|
})
|
@@ -21,7 +21,7 @@ module Decidim
|
|
21
21
|
#
|
22
22
|
# Returns nothing.
|
23
23
|
def call
|
24
|
-
message_id =
|
24
|
+
message_id = cast_vote_message_id(election_id, voter_id)
|
25
25
|
signed_data = sign_message(message_id, { content: encrypted_vote })
|
26
26
|
|
27
27
|
begin
|
@@ -44,8 +44,14 @@ module Decidim
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.cast_vote_message_id(election_id, voter_id)
|
48
|
+
message_id(unique_election_id(election_id), "vote.cast", voter_id)
|
49
|
+
end
|
50
|
+
|
47
51
|
private
|
48
52
|
|
53
|
+
delegate :cast_vote_message_id, to: :class
|
54
|
+
|
49
55
|
attr_reader :election_id, :voter_id, :encrypted_vote
|
50
56
|
end
|
51
57
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
module Voter
|
6
|
+
# This command uses the GraphQL client to get the status of a specific pending message.
|
7
|
+
class GetPendingMessageStatus < Decidim::BulletinBoard::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(message_id)
|
12
|
+
@message_id = message_id
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid and the query operation is successful.
|
18
|
+
# - :error if the form wasn't valid or the query operation was not successful.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
message_id = @message_id
|
23
|
+
|
24
|
+
begin
|
25
|
+
response = client.query do
|
26
|
+
query do
|
27
|
+
pendingMessage(messageId: message_id) do
|
28
|
+
status
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
broadcast(:ok, response.data.pending_message.status)
|
34
|
+
rescue Graphlient::Errors::ServerError
|
35
|
+
broadcast(:error, "Sorry, something went wrong")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,32 +1,20 @@
|
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Morcillo
|
8
8
|
- Svenja Schäfer
|
9
|
-
|
9
|
+
- Leonardo Diez
|
10
|
+
- Agustí B.R.
|
11
|
+
autorequire:
|
10
12
|
bindir: exe
|
11
13
|
cert_chain: []
|
12
|
-
date:
|
14
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
13
15
|
dependencies:
|
14
16
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - ">="
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 5.0.0
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 5.0.0
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: activesupport
|
17
|
+
name: rails
|
30
18
|
requirement: !ruby/object:Gem::Requirement
|
31
19
|
requirements:
|
32
20
|
- - ">="
|
@@ -155,6 +143,8 @@ description: ''
|
|
155
143
|
email:
|
156
144
|
- david@codegram.com
|
157
145
|
- svenja@codegram.com
|
146
|
+
- leo@codegram.com
|
147
|
+
- agusti@codegram.com
|
158
148
|
executables: []
|
159
149
|
extensions: []
|
160
150
|
extra_rdoc_files: []
|
@@ -170,6 +160,9 @@ files:
|
|
170
160
|
- Gemfile.lock
|
171
161
|
- README.md
|
172
162
|
- Rakefile
|
163
|
+
- app/assets/config/decidim_bulletin_board_manifest.js
|
164
|
+
- app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.dev.js
|
165
|
+
- app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js
|
173
166
|
- bin/console
|
174
167
|
- bin/setup
|
175
168
|
- decidim-bulletin_board.gemspec
|
@@ -179,8 +172,11 @@ files:
|
|
179
172
|
- lib/decidim/bulletin_board/authority/create_election.rb
|
180
173
|
- lib/decidim/bulletin_board/authority/get_election_status.rb
|
181
174
|
- lib/decidim/bulletin_board/authority/open_ballot_box.rb
|
175
|
+
- lib/decidim/bulletin_board/authority/publish_results.rb
|
176
|
+
- lib/decidim/bulletin_board/authority/start_tally.rb
|
182
177
|
- lib/decidim/bulletin_board/client.rb
|
183
178
|
- lib/decidim/bulletin_board/command.rb
|
179
|
+
- lib/decidim/bulletin_board/engine.rb
|
184
180
|
- lib/decidim/bulletin_board/graphql/bb_schema.json
|
185
181
|
- lib/decidim/bulletin_board/graphql/client.rb
|
186
182
|
- lib/decidim/bulletin_board/jwk_utils.rb
|
@@ -188,11 +184,12 @@ files:
|
|
188
184
|
- lib/decidim/bulletin_board/version.rb
|
189
185
|
- lib/decidim/bulletin_board/voter.rb
|
190
186
|
- lib/decidim/bulletin_board/voter/cast_vote.rb
|
187
|
+
- lib/decidim/bulletin_board/voter/get_pending_message_status.rb
|
191
188
|
homepage: https://github.com
|
192
189
|
licenses:
|
193
190
|
- AGPL-3.0
|
194
191
|
metadata: {}
|
195
|
-
post_install_message:
|
192
|
+
post_install_message:
|
196
193
|
rdoc_options: []
|
197
194
|
require_paths:
|
198
195
|
- lib
|
@@ -208,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
205
|
version: '0'
|
209
206
|
requirements: []
|
210
207
|
rubygems_version: 3.0.3
|
211
|
-
signing_key:
|
208
|
+
signing_key:
|
212
209
|
specification_version: 4
|
213
210
|
summary: ''
|
214
211
|
test_files: []
|