decidim-bulletin_board 0.6.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/CHANGELOG.md +64 -0
- data/Gemfile.lock +8 -7
- data/app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js +16 -41063
- data/lib/decidim/bulletin_board/authority.rb +5 -2
- data/lib/decidim/bulletin_board/authority/create_election.rb +22 -16
- data/lib/decidim/bulletin_board/authority/end_vote.rb +57 -0
- data/lib/decidim/bulletin_board/authority/get_election_status.rb +12 -11
- data/lib/decidim/bulletin_board/authority/publish_results.rb +57 -0
- data/lib/decidim/bulletin_board/authority/start_key_ceremony.rb +57 -0
- data/lib/decidim/bulletin_board/authority/start_tally.rb +57 -0
- data/lib/decidim/bulletin_board/authority/start_vote.rb +57 -0
- data/lib/decidim/bulletin_board/client.rb +51 -18
- data/lib/decidim/bulletin_board/command.rb +9 -9
- data/lib/decidim/bulletin_board/graphql/bb_schema.json +505 -136
- 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 +14 -3
- data/lib/decidim/bulletin_board/voter/get_pending_message_status.rb +41 -0
- metadata +8 -4
- data/lib/decidim/bulletin_board/authority/close_ballot_box.rb +0 -51
- data/lib/decidim/bulletin_board/authority/open_ballot_box.rb +0 -51
@@ -14,6 +14,11 @@ module Decidim
|
|
14
14
|
@encrypted_vote = encrypted_vote
|
15
15
|
end
|
16
16
|
|
17
|
+
# Returns the message_id related to the operation
|
18
|
+
def message_id
|
19
|
+
@message_id ||= build_message_id(unique_election_id(election_id), "vote.cast", voter_id)
|
20
|
+
end
|
21
|
+
|
17
22
|
# Executes the command. Broadcasts these events:
|
18
23
|
#
|
19
24
|
# - :ok when everything is valid and the mutation operation is successful.
|
@@ -21,14 +26,18 @@ module Decidim
|
|
21
26
|
#
|
22
27
|
# Returns nothing.
|
23
28
|
def call
|
24
|
-
|
25
|
-
|
29
|
+
# arguments used inside the graphql operation
|
30
|
+
args = {
|
31
|
+
message_id: message_id,
|
32
|
+
signed_data: sign_message(message_id, { content: encrypted_vote })
|
33
|
+
}
|
26
34
|
|
27
35
|
begin
|
28
36
|
response = client.query do
|
29
37
|
mutation do
|
30
|
-
vote(messageId: message_id, signedData: signed_data) do
|
38
|
+
vote(messageId: args[:message_id], signedData: args[:signed_data]) do
|
31
39
|
pendingMessage do
|
40
|
+
messageId
|
32
41
|
status
|
33
42
|
end
|
34
43
|
error
|
@@ -46,6 +55,8 @@ module Decidim
|
|
46
55
|
|
47
56
|
private
|
48
57
|
|
58
|
+
delegate :cast_vote_message_id, to: :class
|
59
|
+
|
49
60
|
attr_reader :election_id, :voter_id, :encrypted_vote
|
50
61
|
end
|
51
62
|
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,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.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Morcillo
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-01
|
14
|
+
date: 2021-02-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -167,10 +167,13 @@ files:
|
|
167
167
|
- decidim-bulletin_board.gemspec
|
168
168
|
- lib/decidim/bulletin_board.rb
|
169
169
|
- lib/decidim/bulletin_board/authority.rb
|
170
|
-
- lib/decidim/bulletin_board/authority/close_ballot_box.rb
|
171
170
|
- lib/decidim/bulletin_board/authority/create_election.rb
|
171
|
+
- lib/decidim/bulletin_board/authority/end_vote.rb
|
172
172
|
- lib/decidim/bulletin_board/authority/get_election_status.rb
|
173
|
-
- lib/decidim/bulletin_board/authority/
|
173
|
+
- lib/decidim/bulletin_board/authority/publish_results.rb
|
174
|
+
- lib/decidim/bulletin_board/authority/start_key_ceremony.rb
|
175
|
+
- lib/decidim/bulletin_board/authority/start_tally.rb
|
176
|
+
- lib/decidim/bulletin_board/authority/start_vote.rb
|
174
177
|
- lib/decidim/bulletin_board/client.rb
|
175
178
|
- lib/decidim/bulletin_board/command.rb
|
176
179
|
- lib/decidim/bulletin_board/engine.rb
|
@@ -181,6 +184,7 @@ files:
|
|
181
184
|
- lib/decidim/bulletin_board/version.rb
|
182
185
|
- lib/decidim/bulletin_board/voter.rb
|
183
186
|
- lib/decidim/bulletin_board/voter/cast_vote.rb
|
187
|
+
- lib/decidim/bulletin_board/voter/get_pending_message_status.rb
|
184
188
|
homepage: https://github.com
|
185
189
|
licenses:
|
186
190
|
- AGPL-3.0
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module BulletinBoard
|
5
|
-
module Authority
|
6
|
-
# This command uses the GraphQL client to request the closing of the ballot box.
|
7
|
-
class CloseBallotBox < Decidim::BulletinBoard::Command
|
8
|
-
# Public: Initializes the command.
|
9
|
-
#
|
10
|
-
# election_id - The local election identifier
|
11
|
-
def initialize(election_id)
|
12
|
-
@election_id = election_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 query operation was not successful.
|
19
|
-
#
|
20
|
-
# Returns nothing.
|
21
|
-
def call
|
22
|
-
message_id = message_id(unique_election_id(election_id), "close_ballot_box")
|
23
|
-
signed_data = sign_message(message_id, {})
|
24
|
-
|
25
|
-
begin
|
26
|
-
response = client.query do
|
27
|
-
mutation do
|
28
|
-
closeBallotBox(messageId: message_id, signedData: signed_data) do
|
29
|
-
election do
|
30
|
-
status
|
31
|
-
end
|
32
|
-
error
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
return broadcast(:error, response.data.close_ballot_box.error) if response.data.close_ballot_box.error.present?
|
38
|
-
|
39
|
-
broadcast(:ok, response.data.close_ballot_box.election)
|
40
|
-
rescue Graphlient::Errors::ServerError
|
41
|
-
broadcast(:error, "Sorry, something went wrong")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
attr_reader :election_id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module BulletinBoard
|
5
|
-
module Authority
|
6
|
-
# This command uses the GraphQL client to request the opening of the ballot box.
|
7
|
-
class OpenBallotBox < Decidim::BulletinBoard::Command
|
8
|
-
# Public: Initializes the command.
|
9
|
-
#
|
10
|
-
# election_id - The local election identifier
|
11
|
-
def initialize(election_id)
|
12
|
-
@election_id = election_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 query operation was not successful.
|
19
|
-
#
|
20
|
-
# Returns nothing.
|
21
|
-
def call
|
22
|
-
message_id = message_id(unique_election_id(election_id), "open_ballot_box")
|
23
|
-
signed_data = sign_message(message_id, {})
|
24
|
-
|
25
|
-
begin
|
26
|
-
response = client.query do
|
27
|
-
mutation do
|
28
|
-
openBallotBox(messageId: message_id, signedData: signed_data) do
|
29
|
-
election do
|
30
|
-
status
|
31
|
-
end
|
32
|
-
error
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
return broadcast(:error, response.data.open_ballot_box.error) if response.data.open_ballot_box.error.present?
|
38
|
-
|
39
|
-
broadcast(:ok, response.data.open_ballot_box.election)
|
40
|
-
rescue Graphlient::Errors::ServerError
|
41
|
-
broadcast(:error, "Sorry, something went wrong")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
attr_reader :election_id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|