decidim-direct_verifications 0.20 → 0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb +58 -36
- data/app/views/decidim/direct_verifications/verification/admin/direct_verifications/index.html.erb +17 -17
- data/app/views/decidim/direct_verifications/verification/admin/stats/index.html.erb +3 -3
- data/lib/decidim/direct_verifications/tests/verification_controller_examples.rb +39 -29
- data/lib/decidim/direct_verifications/version.rb +3 -3
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbf6bc3adf56db3268520dc976ecf5e24791667d27d41e43f43be7a1de122b15
|
4
|
+
data.tar.gz: 63bc2221b993503c21037f62195021967eed48f3d0d35ce1f25ceb2bd27e899a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c90a4d69fd3640640efb62102de8a218ba2f57e01725bb89f81a6c7adc384c0e937ded80f8049b2448cc2b60eedfa37c71f24bdf74288c9d4efe63c69a5dccb1
|
7
|
+
data.tar.gz: fee38887199f7a345e64a62f7389262785435d6686aef02ee39a75359314dbc9b9d43465689d122c3b539811c2fde2abce0917e08584a73be4077e33c6cdfd22
|
data/README.md
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
![[CI] Test](https://github.com/Platoniq/decidim-verifications-direct_verifications/workflows/%5BCI%5D%20Test/badge.svg)
|
4
4
|
[](https://codeclimate.com/github/Platoniq/decidim-verifications-direct_verifications/maintainability)
|
5
|
-
[](https://codecov.io/gh/Platoniq/decidim-verifications-direct_verifications)
|
7
6
|
|
8
7
|
A [Decidim](https://github.com/decidim/decidim) that provides a verification method called `Direct verification`. Works only on the admin side, final users do not intervene in the verification process.
|
9
8
|
|
@@ -6,57 +6,75 @@ module Decidim
|
|
6
6
|
module Admin
|
7
7
|
class DirectVerificationsController < Decidim::Admin::ApplicationController
|
8
8
|
include NeedsPermission
|
9
|
+
helper_method :workflows, :current_authorization_handler
|
9
10
|
|
10
11
|
layout "decidim/admin/users"
|
11
12
|
|
12
13
|
def index
|
13
14
|
enforce_permission_to :index, :authorization
|
14
|
-
@authorization_handler = :direct_verifications
|
15
|
-
@workflows = workflows
|
16
15
|
end
|
17
16
|
|
18
17
|
def create
|
19
18
|
enforce_permission_to :create, :authorization
|
20
19
|
|
21
|
-
@
|
22
|
-
@
|
23
|
-
processor =
|
24
|
-
processor.
|
25
|
-
|
26
|
-
stats =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
if params[:authorize] == "in"
|
35
|
-
processor.authorize_users
|
36
|
-
flash[:notice] = t(".authorized", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
37
|
-
count: processor.emails.count,
|
38
|
-
authorized: processor.processed[:authorized].count,
|
39
|
-
errors: processor.errors[:authorized].count)
|
40
|
-
elsif params[:authorize] == "out"
|
41
|
-
processor.revoke_users
|
42
|
-
flash[:notice] = t(".revoked", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
43
|
-
count: processor.emails.count,
|
44
|
-
revoked: processor.processed[:revoked].count,
|
45
|
-
errors: processor.errors[:revoked].count)
|
46
|
-
else
|
47
|
-
stats.emails = processor.emails.keys
|
48
|
-
flash[:info] = t(".info", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
49
|
-
count: processor.emails.count,
|
50
|
-
authorized: stats.authorized,
|
51
|
-
unconfirmed: stats.unconfirmed,
|
52
|
-
registered: stats.registered)
|
53
|
-
render(action: :index) && return
|
54
|
-
end
|
20
|
+
@userslist = params[:userlist]
|
21
|
+
@processor = UserProcessor.new(current_organization, current_user)
|
22
|
+
@processor.emails = extract_emails_to_hash @userslist
|
23
|
+
@processor.authorization_handler = current_authorization_handler
|
24
|
+
@stats = UserStats.new(current_organization)
|
25
|
+
@stats.authorization_handler = @processor.authorization_handler
|
26
|
+
register_users
|
27
|
+
authorize_users
|
28
|
+
revoke_users
|
29
|
+
|
30
|
+
render(action: :index) && return if show_users_info
|
31
|
+
|
55
32
|
redirect_to direct_verifications_path
|
56
33
|
end
|
57
34
|
|
58
35
|
private
|
59
36
|
|
37
|
+
def register_users
|
38
|
+
return unless params[:register]
|
39
|
+
|
40
|
+
@processor.register_users
|
41
|
+
flash[:warning] = t(".registered", count: @processor.emails.count,
|
42
|
+
registered: @processor.processed[:registered].count,
|
43
|
+
errors: @processor.errors[:registered].count)
|
44
|
+
end
|
45
|
+
|
46
|
+
def authorize_users
|
47
|
+
return unless params[:authorize] == "in"
|
48
|
+
|
49
|
+
@processor.authorize_users
|
50
|
+
flash[:notice] = t(".authorized", handler: t("#{@processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
51
|
+
count: @processor.emails.count,
|
52
|
+
authorized: @processor.processed[:authorized].count,
|
53
|
+
errors: @processor.errors[:authorized].count)
|
54
|
+
end
|
55
|
+
|
56
|
+
def revoke_users
|
57
|
+
return unless params[:authorize] == "out"
|
58
|
+
|
59
|
+
@processor.revoke_users
|
60
|
+
flash[:notice] = t(".revoked", handler: t("#{@processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
61
|
+
count: @processor.emails.count,
|
62
|
+
revoked: @processor.processed[:revoked].count,
|
63
|
+
errors: @processor.errors[:revoked].count)
|
64
|
+
end
|
65
|
+
|
66
|
+
def show_users_info
|
67
|
+
return if params[:authorize]
|
68
|
+
|
69
|
+
@stats.emails = @processor.emails.keys
|
70
|
+
flash.now[:info] = t(".info", handler: t("#{@processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
71
|
+
count: @processor.emails.count,
|
72
|
+
authorized: @stats.authorized,
|
73
|
+
unconfirmed: @stats.unconfirmed,
|
74
|
+
registered: @stats.registered)
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
60
78
|
def extract_emails_to_hash(txt)
|
61
79
|
reg = /([A-Z0-9+._-]+@[A-Z0-9._-]+\.[A-Z0-9_-]+)\b/i
|
62
80
|
emails = {}
|
@@ -73,6 +91,10 @@ module Decidim
|
|
73
91
|
@authorization_handler = authorization_handler.presence || :direct_verifications
|
74
92
|
end
|
75
93
|
|
94
|
+
def current_authorization_handler
|
95
|
+
authorization_handler(params[:authorization_handler])
|
96
|
+
end
|
97
|
+
|
76
98
|
def configured_workflows
|
77
99
|
return Decidim::DirectVerifications.config.manage_workflows if Decidim::DirectVerifications.config
|
78
100
|
|
data/app/views/decidim/direct_verifications/verification/admin/direct_verifications/index.html.erb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
<div class="card">
|
2
2
|
<div class="card-divider">
|
3
3
|
<h2 class="card-title">
|
4
|
-
<%= t(
|
5
|
-
<%= link_to t("admin.index.stats", scope:
|
4
|
+
<%= t("admin.index.title", scope: "decidim.direct_verifications.verification") %>
|
5
|
+
<%= link_to t("admin.index.stats", scope: "decidim.direct_verifications.verification"), stats_path, class: "button tiny button--title" %>
|
6
6
|
</h2>
|
7
7
|
</div>
|
8
8
|
<div class="card-section">
|
9
|
-
<p><%= t(
|
10
|
-
<%= form_tag direct_verifications_path, multipart: true, class:
|
11
|
-
<%= label_tag :userlist, t(
|
12
|
-
<%= text_area_tag :userlist, @
|
9
|
+
<p><%= t("decidim.direct_verifications.verification.admin.new.info") %></p>
|
10
|
+
<%= form_tag direct_verifications_path, multipart: true, class: "form" do %>
|
11
|
+
<%= label_tag :userlist, t("admin.new.textarea", scope: "decidim.direct_verifications.verification") %>
|
12
|
+
<%= text_area_tag :userlist, @userslist, rows: 10 %>
|
13
13
|
<label>
|
14
14
|
<%= check_box_tag :register %>
|
15
|
-
<%= t(
|
15
|
+
<%= t("admin.new.register", scope: "decidim.direct_verifications.verification") %>
|
16
16
|
<div data-alert class="callout alert hide">
|
17
|
-
<%= t(
|
17
|
+
<%= t("admin.direct_verifications.gdpr_disclaimer", scope: "decidim.direct_verifications.verification") %>
|
18
18
|
</div>
|
19
19
|
</label>
|
20
20
|
<label>
|
21
|
-
<%= radio_button_tag :authorize,
|
22
|
-
<%= t(
|
21
|
+
<%= radio_button_tag :authorize, "in" %>
|
22
|
+
<%= t("admin.new.authorize", scope: "decidim.direct_verifications.verification") %>
|
23
23
|
</label>
|
24
24
|
<label>
|
25
|
-
<%= radio_button_tag :authorize,
|
26
|
-
<%= t(
|
25
|
+
<%= radio_button_tag :authorize, "out" %>
|
26
|
+
<%= t("admin.new.revoke", scope: "decidim.direct_verifications.verification") %>
|
27
27
|
</label>
|
28
28
|
<label>
|
29
|
-
<%= radio_button_tag :authorize,
|
30
|
-
<%= t(
|
29
|
+
<%= radio_button_tag :authorize, "check", true %>
|
30
|
+
<%= t("admin.new.check", scope: "decidim.direct_verifications.verification") %>
|
31
31
|
</label>
|
32
32
|
|
33
|
-
<%= label_tag :authorization_handler, t(
|
33
|
+
<%= label_tag :authorization_handler, t("admin.new.authorization_handler", scope: "decidim.direct_verifications.verification") %>
|
34
34
|
|
35
|
-
<%= select_tag :authorization_handler, options_for_select(
|
35
|
+
<%= select_tag :authorization_handler, options_for_select(workflows, current_authorization_handler) %>
|
36
36
|
|
37
|
-
<%= submit_tag t(
|
37
|
+
<%= submit_tag t("admin.new.submit", scope: "decidim.direct_verifications.verification"), class: "button" %>
|
38
38
|
|
39
39
|
<% end %>
|
40
40
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<div class="card">
|
2
2
|
<div class="card-divider">
|
3
3
|
<h2 class="card-title">
|
4
|
-
<%= t(
|
5
|
-
<%= link_to t("admin.index.title", scope:
|
4
|
+
<%= t("admin.index.stats", scope: "decidim.direct_verifications.verification") %>
|
5
|
+
<%= link_to t("admin.index.title", scope: "decidim.direct_verifications.verification"), direct_verifications_path, class: "button tiny button--title" %>
|
6
6
|
</h2>
|
7
7
|
</div>
|
8
8
|
<div class="card-section">
|
9
9
|
<table class="table-list">
|
10
10
|
<thead>
|
11
11
|
<tr>
|
12
|
-
<th><%= t("admin.new.authorization_handler", scope:
|
12
|
+
<th><%= t("admin.new.authorization_handler", scope: "decidim.direct_verifications.verification") %></th>
|
13
13
|
<th><%= t(".registered") %></th>
|
14
14
|
<th><%= t(".authorized") %></th>
|
15
15
|
<th><%= t(".unconfirmed") %></th>
|
@@ -4,52 +4,60 @@ shared_examples_for "checking users" do |params|
|
|
4
4
|
context "when check without mails" do
|
5
5
|
it "renders the index with info message" do
|
6
6
|
params[:userlist] = ""
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
perform_enqueued_jobs do
|
8
|
+
post :create, params: params
|
9
|
+
expect(flash[:info]).not_to be_empty
|
10
|
+
expect(flash[:info]).to include("0 users detected")
|
11
|
+
expect(subject).to render_template("decidim/direct_verifications/verification/admin/direct_verifications/index")
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
context "when check with mails" do
|
15
17
|
it "renders the index with info message" do
|
16
18
|
params[:userlist] = "mail@example.com"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
perform_enqueued_jobs do
|
20
|
+
post :create, params: params
|
21
|
+
expect(flash[:info]).not_to be_empty
|
22
|
+
expect(flash[:info]).to include("1 users detected")
|
23
|
+
expect(subject).to render_template("decidim/direct_verifications/verification/admin/direct_verifications/index")
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
29
|
shared_examples_for "registering users" do |params|
|
26
|
-
context "when
|
30
|
+
context "when there are valid emails" do
|
27
31
|
it "creates warning message" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
perform_enqueued_jobs do
|
33
|
+
post :create, params: params
|
34
|
+
expect(flash[:warning]).not_to be_empty
|
35
|
+
expect(flash[:warning]).to include("1 detected")
|
36
|
+
expect(flash[:warning]).to include("0 errors")
|
37
|
+
expect(flash[:warning]).to include("1 users")
|
38
|
+
expect(flash[:warning]).to include("registered")
|
39
|
+
end
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
44
|
shared_examples_for "authorizing users" do |params|
|
39
|
-
context "when
|
45
|
+
context "when there are valid emails" do
|
40
46
|
it "creates notice message" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
perform_enqueued_jobs do
|
48
|
+
post :create, params: params
|
49
|
+
expect(flash[:notice]).not_to be_empty
|
50
|
+
expect(flash[:notice]).to include("1 detected")
|
51
|
+
expect(flash[:notice]).to include("0 errors")
|
52
|
+
expect(flash[:notice]).to include("1 users")
|
53
|
+
expect(flash[:notice]).to include("verified")
|
54
|
+
end
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
|
51
59
|
shared_examples_for "revoking users" do |params|
|
52
|
-
context "when
|
60
|
+
context "when there are valid emails" do
|
53
61
|
it "creates notice message" do
|
54
62
|
create(
|
55
63
|
:authorization,
|
@@ -57,12 +65,14 @@ shared_examples_for "revoking users" do |params|
|
|
57
65
|
name: verification_type,
|
58
66
|
user: authorized_user
|
59
67
|
)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
68
|
+
perform_enqueued_jobs do
|
69
|
+
post :create, params: params
|
70
|
+
expect(flash[:notice]).not_to be_empty
|
71
|
+
expect(flash[:notice]).to include("1 detected")
|
72
|
+
expect(flash[:notice]).to include("0 errors")
|
73
|
+
expect(flash[:notice]).to include("1 users")
|
74
|
+
expect(flash[:notice]).to include("revoked")
|
75
|
+
end
|
66
76
|
end
|
67
77
|
end
|
68
78
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
# This holds the decidim-direct_verifications version.
|
5
5
|
module DirectVerifications
|
6
|
-
VERSION = "0.
|
7
|
-
DECIDIM_VERSION = "0.
|
8
|
-
MIN_DECIDIM_VERSION = "
|
6
|
+
VERSION = "0.21"
|
7
|
+
DECIDIM_VERSION = "0.21"
|
8
|
+
MIN_DECIDIM_VERSION = "~> 0.21.0"
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-direct_verifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.21'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Vergés
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-admin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.21.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.21.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: decidim-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.21.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.21.0
|
41
41
|
description: Provides a verification method that also registers users directly in
|
42
42
|
the platform. Can be used to mass verificate user with other verification handlers
|
43
43
|
email:
|