decidim-verifications 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +101 -0
  3. data/Rakefile +3 -0
  4. data/app/commands/decidim/verifications/authorize_user.rb +61 -0
  5. data/app/commands/decidim/verifications/confirm_user_authorization.rb +49 -0
  6. data/app/commands/decidim/verifications/perform_authorization_step.rb +48 -0
  7. data/app/controllers/decidim/verifications/authorizations_controller.rb +91 -0
  8. data/app/controllers/decidim/verifications/id_documents/admin/confirmations_controller.rb +48 -0
  9. data/app/controllers/decidim/verifications/id_documents/admin/pending_authorizations_controller.rb +28 -0
  10. data/app/controllers/decidim/verifications/id_documents/admin/rejections_controller.rb +37 -0
  11. data/app/controllers/decidim/verifications/id_documents/authorizations_controller.rb +82 -0
  12. data/app/controllers/decidim/verifications/postal_letter/admin/pending_authorizations_controller.rb +27 -0
  13. data/app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb +41 -0
  14. data/app/controllers/decidim/verifications/postal_letter/authorizations_controller.rb +74 -0
  15. data/app/forms/decidim/verifications/id_documents/information_form.rb +50 -0
  16. data/app/forms/decidim/verifications/id_documents/information_rejection_form.rb +15 -0
  17. data/app/forms/decidim/verifications/id_documents/upload_form.rb +20 -0
  18. data/app/forms/decidim/verifications/postal_letter/address_form.rb +28 -0
  19. data/app/forms/decidim/verifications/postal_letter/confirmation_form.rb +19 -0
  20. data/app/forms/decidim/verifications/postal_letter/postage_form.rb +34 -0
  21. data/app/presenters/decidim/verifications/id_documents/authorization_presenter.rb +20 -0
  22. data/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb +59 -0
  23. data/app/queries/decidim/verifications/authorizations.rb +41 -0
  24. data/app/services/decidim/authorization_handler.rb +112 -0
  25. data/app/services/decidim/dummy_authorization_handler.rb +27 -0
  26. data/app/uploaders/decidim/verifications/attachment_uploader.rb +16 -0
  27. data/app/views/decidim/verifications/authorizations/first_login.html.erb +22 -0
  28. data/app/views/decidim/verifications/authorizations/index.html.erb +78 -0
  29. data/app/views/decidim/verifications/authorizations/new.html.erb +33 -0
  30. data/app/views/decidim/verifications/id_documents/admin/confirmations/new.html.erb +26 -0
  31. data/app/views/decidim/verifications/id_documents/admin/pending_authorizations/index.html.erb +32 -0
  32. data/app/views/decidim/verifications/id_documents/authorizations/edit.html.erb +53 -0
  33. data/app/views/decidim/verifications/id_documents/authorizations/new.html.erb +35 -0
  34. data/app/views/decidim/verifications/postal_letter/admin/pending_authorizations/index.html.erb +50 -0
  35. data/app/views/decidim/verifications/postal_letter/authorizations/edit.html.erb +37 -0
  36. data/app/views/decidim/verifications/postal_letter/authorizations/new.html.erb +27 -0
  37. data/config/locales/ca.yml +126 -0
  38. data/config/locales/en.yml +126 -0
  39. data/config/locales/es.yml +126 -0
  40. data/config/locales/eu.yml +125 -0
  41. data/config/locales/fi.yml +125 -0
  42. data/config/locales/fr.yml +125 -0
  43. data/config/locales/it.yml +125 -0
  44. data/config/locales/nl.yml +125 -0
  45. data/config/locales/pl.yml +125 -0
  46. data/config/locales/pt.yml +125 -0
  47. data/config/locales/ru.yml +5 -0
  48. data/config/locales/uk.yml +41 -0
  49. data/db/migrate/20171030133426_move_authorizations_to_new_api.rb +66 -0
  50. data/lib/decidim/verifications.rb +26 -0
  51. data/lib/decidim/verifications/adapter.rb +88 -0
  52. data/lib/decidim/verifications/dummy.rb +5 -0
  53. data/lib/decidim/verifications/engine.rb +24 -0
  54. data/lib/decidim/verifications/id_documents.rb +6 -0
  55. data/lib/decidim/verifications/id_documents/admin.rb +12 -0
  56. data/lib/decidim/verifications/id_documents/admin_engine.rb +21 -0
  57. data/lib/decidim/verifications/id_documents/engine.rb +18 -0
  58. data/lib/decidim/verifications/id_documents/workflow.rb +6 -0
  59. data/lib/decidim/verifications/postal_letter.rb +6 -0
  60. data/lib/decidim/verifications/postal_letter/admin.rb +12 -0
  61. data/lib/decidim/verifications/postal_letter/admin_engine.rb +21 -0
  62. data/lib/decidim/verifications/postal_letter/engine.rb +18 -0
  63. data/lib/decidim/verifications/postal_letter/workflow.rb +6 -0
  64. data/lib/decidim/verifications/registry.rb +39 -0
  65. data/lib/decidim/verifications/version.rb +10 -0
  66. data/lib/decidim/verifications/workflow_manifest.rb +56 -0
  67. data/lib/decidim/verifications/workflows.rb +58 -0
  68. metadata +152 -0
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This holds the decidim-verifications version.
5
+ module Verifications
6
+ def self.version
7
+ "0.8.0"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Verifications
5
+ #
6
+ # This class serves as a DSL to declaratively specify a verification method.
7
+ #
8
+ # To define a direct verification method, you need to specify the `form`
9
+ # attribute as a `Rectify::Form` that will be valid if the authorization is
10
+ # valid.
11
+ #
12
+ # To define a deferred verification method, you need specify the `engine`
13
+ # attribute as a full `Rails::Engine` (and optionally another engine for the
14
+ # admin side as the `admin_engine` attribute). The verification will succeed
15
+ # once the engine creates a valid authorization for the method with the
16
+ # `granted_at` column set in DB.
17
+ #
18
+ # Note that whereas direct methods can be used for "on the fly"
19
+ # verification, deferred methods require the authorization status to be
20
+ # persisted into DB. That's the reason why only direct methods can be used
21
+ # for user impersonation, for example, since they require continuous "on the
22
+ # fly" verification by the impersonating user.
23
+ #
24
+ class WorkflowManifest
25
+ include ActiveModel::Model
26
+ include Virtus.model
27
+
28
+ attribute :engine, Rails::Engine
29
+ attribute :admin_engine, Rails::Engine
30
+ attribute :form, String
31
+
32
+ validate :engine_or_form
33
+
34
+ attribute :name, String
35
+ validates :name, presence: true
36
+
37
+ def engine_or_form
38
+ engine || form
39
+ end
40
+
41
+ def type
42
+ form ? "direct" : "multistep"
43
+ end
44
+
45
+ alias key name
46
+
47
+ def fullname
48
+ I18n.t("#{key}.name", scope: "decidim.authorization_handlers")
49
+ end
50
+
51
+ def description
52
+ "#{fullname} (#{I18n.t(type, scope: "decidim.authorization_handlers")})"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Verifications
5
+ autoload :Adapter, "decidim/verifications/adapter"
6
+ autoload :Registry, "decidim/verifications/registry"
7
+
8
+ #
9
+ # Provides direct access to the verification registry
10
+ #
11
+ class << self
12
+ delegate :clear_workflows, to: :registry
13
+
14
+ #
15
+ # Restores registered verification workflows to the array being passed in
16
+ #
17
+ # Useful for testing.
18
+ #
19
+ def reset_workflows(*manifests)
20
+ registry.reset_workflows(*manifests)
21
+ end
22
+
23
+ #
24
+ # Registers a new verification workflow using the workflow manifest API
25
+ #
26
+ def register_workflow(name, &block)
27
+ registry.register_workflow(name, &block)
28
+ end
29
+
30
+ #
31
+ # Finds a verification workflow by name
32
+ #
33
+ def find_workflow_manifest(name)
34
+ workflows.find { |workflow| workflow.name == name.to_s }
35
+ end
36
+
37
+ #
38
+ # Collection of registered verification workflows
39
+ #
40
+ def workflows
41
+ registry.workflow_collection
42
+ end
43
+
44
+ #
45
+ # Collection of registered verification workflows having an admin engine
46
+ #
47
+ def admin_workflows
48
+ workflows.select(&:admin_engine)
49
+ end
50
+
51
+ private
52
+
53
+ def registry
54
+ @registry ||= Registry.new
55
+ end
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decidim-verifications
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
+ platform: ruby
6
+ authors:
7
+ - David Rodriguez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: decidim-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: decidim-admin
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: decidim-dev
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.0
55
+ description: Several verification methods for your decidim instance
56
+ email:
57
+ - deivid.rodriguez@riseup.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.md
63
+ - Rakefile
64
+ - app/commands/decidim/verifications/authorize_user.rb
65
+ - app/commands/decidim/verifications/confirm_user_authorization.rb
66
+ - app/commands/decidim/verifications/perform_authorization_step.rb
67
+ - app/controllers/decidim/verifications/authorizations_controller.rb
68
+ - app/controllers/decidim/verifications/id_documents/admin/confirmations_controller.rb
69
+ - app/controllers/decidim/verifications/id_documents/admin/pending_authorizations_controller.rb
70
+ - app/controllers/decidim/verifications/id_documents/admin/rejections_controller.rb
71
+ - app/controllers/decidim/verifications/id_documents/authorizations_controller.rb
72
+ - app/controllers/decidim/verifications/postal_letter/admin/pending_authorizations_controller.rb
73
+ - app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb
74
+ - app/controllers/decidim/verifications/postal_letter/authorizations_controller.rb
75
+ - app/forms/decidim/verifications/id_documents/information_form.rb
76
+ - app/forms/decidim/verifications/id_documents/information_rejection_form.rb
77
+ - app/forms/decidim/verifications/id_documents/upload_form.rb
78
+ - app/forms/decidim/verifications/postal_letter/address_form.rb
79
+ - app/forms/decidim/verifications/postal_letter/confirmation_form.rb
80
+ - app/forms/decidim/verifications/postal_letter/postage_form.rb
81
+ - app/presenters/decidim/verifications/id_documents/authorization_presenter.rb
82
+ - app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb
83
+ - app/queries/decidim/verifications/authorizations.rb
84
+ - app/services/decidim/authorization_handler.rb
85
+ - app/services/decidim/dummy_authorization_handler.rb
86
+ - app/uploaders/decidim/verifications/attachment_uploader.rb
87
+ - app/views/decidim/verifications/authorizations/first_login.html.erb
88
+ - app/views/decidim/verifications/authorizations/index.html.erb
89
+ - app/views/decidim/verifications/authorizations/new.html.erb
90
+ - app/views/decidim/verifications/id_documents/admin/confirmations/new.html.erb
91
+ - app/views/decidim/verifications/id_documents/admin/pending_authorizations/index.html.erb
92
+ - app/views/decidim/verifications/id_documents/authorizations/edit.html.erb
93
+ - app/views/decidim/verifications/id_documents/authorizations/new.html.erb
94
+ - app/views/decidim/verifications/postal_letter/admin/pending_authorizations/index.html.erb
95
+ - app/views/decidim/verifications/postal_letter/authorizations/edit.html.erb
96
+ - app/views/decidim/verifications/postal_letter/authorizations/new.html.erb
97
+ - config/locales/ca.yml
98
+ - config/locales/en.yml
99
+ - config/locales/es.yml
100
+ - config/locales/eu.yml
101
+ - config/locales/fi.yml
102
+ - config/locales/fr.yml
103
+ - config/locales/it.yml
104
+ - config/locales/nl.yml
105
+ - config/locales/pl.yml
106
+ - config/locales/pt.yml
107
+ - config/locales/ru.yml
108
+ - config/locales/uk.yml
109
+ - db/migrate/20171030133426_move_authorizations_to_new_api.rb
110
+ - lib/decidim/verifications.rb
111
+ - lib/decidim/verifications/adapter.rb
112
+ - lib/decidim/verifications/dummy.rb
113
+ - lib/decidim/verifications/engine.rb
114
+ - lib/decidim/verifications/id_documents.rb
115
+ - lib/decidim/verifications/id_documents/admin.rb
116
+ - lib/decidim/verifications/id_documents/admin_engine.rb
117
+ - lib/decidim/verifications/id_documents/engine.rb
118
+ - lib/decidim/verifications/id_documents/workflow.rb
119
+ - lib/decidim/verifications/postal_letter.rb
120
+ - lib/decidim/verifications/postal_letter/admin.rb
121
+ - lib/decidim/verifications/postal_letter/admin_engine.rb
122
+ - lib/decidim/verifications/postal_letter/engine.rb
123
+ - lib/decidim/verifications/postal_letter/workflow.rb
124
+ - lib/decidim/verifications/registry.rb
125
+ - lib/decidim/verifications/version.rb
126
+ - lib/decidim/verifications/workflow_manifest.rb
127
+ - lib/decidim/verifications/workflows.rb
128
+ homepage: https://github.com/decidim/decidim
129
+ licenses:
130
+ - AGPL-3.0
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.6.13
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Verifications plugin for decidim
152
+ test_files: []