decidim-bulletin_board 0.8.2 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/CHANGELOG.md +41 -1
  4. data/Gemfile.lock +59 -62
  5. data/app/assets/config/{decidim_bulletin_board_manifest.js → manifest.js} +0 -0
  6. data/app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js +279 -2
  7. data/bin/release +10 -0
  8. data/lib/decidim/bulletin_board.rb +13 -17
  9. data/lib/decidim/bulletin_board/authority/create_election.rb +121 -16
  10. data/lib/decidim/bulletin_board/authority/end_vote.rb +57 -0
  11. data/lib/decidim/bulletin_board/authority/get_election_results.rb +63 -0
  12. data/lib/decidim/bulletin_board/authority/get_election_status.rb +12 -11
  13. data/lib/decidim/bulletin_board/authority/publish_results.rb +22 -16
  14. data/lib/decidim/bulletin_board/authority/start_key_ceremony.rb +57 -0
  15. data/lib/decidim/bulletin_board/authority/start_tally.rb +22 -16
  16. data/lib/decidim/bulletin_board/authority/start_vote.rb +57 -0
  17. data/lib/decidim/bulletin_board/client.rb +58 -48
  18. data/lib/decidim/bulletin_board/command.rb +11 -26
  19. data/lib/decidim/bulletin_board/graphql/bb_schema.json +205 -87
  20. data/lib/decidim/bulletin_board/graphql/factory.rb +18 -0
  21. data/lib/decidim/bulletin_board/settings.rb +49 -0
  22. data/lib/decidim/bulletin_board/version.rb +1 -1
  23. data/lib/decidim/bulletin_board/voter/cast_vote.rb +13 -8
  24. data/lib/decidim/bulletin_board/voter/get_pending_message_status.rb +1 -1
  25. metadata +13 -12
  26. data/app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.dev.js +0 -18045
  27. data/lib/decidim/bulletin_board/authority.rb +0 -8
  28. data/lib/decidim/bulletin_board/authority/close_ballot_box.rb +0 -51
  29. data/lib/decidim/bulletin_board/authority/open_ballot_box.rb +0 -51
  30. data/lib/decidim/bulletin_board/graphql/client.rb +0 -18
  31. data/lib/decidim/bulletin_board/voter.rb +0 -4
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "decidim/bulletin_board/authority/create_election"
4
- require "decidim/bulletin_board/authority/get_election_status"
5
- require "decidim/bulletin_board/authority/open_ballot_box"
6
- require "decidim/bulletin_board/authority/close_ballot_box"
7
- require "decidim/bulletin_board/authority/start_tally"
8
- require "decidim/bulletin_board/authority/publish_results"
@@ -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
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module BulletinBoard
5
- module Graphql
6
- # The Bulletin Board GraphQL Client
7
- class Client
8
- def self.client
9
- @client ||= Graphlient::Client.new(BulletinBoard.server,
10
- schema_path: File.join(__dir__, "bb_schema.json"),
11
- headers: {
12
- "Authorization" => BulletinBoard.api_key
13
- })
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "decidim/bulletin_board/voter/cast_vote"
4
- require "decidim/bulletin_board/voter/get_pending_message_status"