decidim-direct_verifications 0.17.6 → 0.17.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -4
- data/app/assets/config/direct_verifications_admin_manifest.js +1 -0
- data/app/assets/javascripts/decidim/direct_verifications/verification/admin/direct_verifications_admin.js.es6 +7 -0
- data/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb +28 -18
- data/app/controllers/decidim/direct_verifications/verification/admin/stats_controller.rb +38 -0
- data/app/views/decidim/direct_verifications/verification/admin/direct_verifications/index.html.erb +9 -5
- data/app/views/decidim/direct_verifications/verification/admin/stats/index.html.erb +35 -0
- data/config/locales/ca.yml +14 -2
- data/config/locales/en.yml +13 -2
- data/config/locales/es.yml +14 -2
- data/lib/decidim/direct_verifications.rb +2 -0
- data/lib/decidim/direct_verifications/config.rb +23 -0
- data/lib/decidim/direct_verifications/user_processor.rb +1 -19
- data/lib/decidim/direct_verifications/user_stats.rb +73 -0
- data/lib/decidim/direct_verifications/verification/admin_engine.rb +6 -1
- data/lib/decidim/direct_verifications/version.rb +1 -1
- metadata +8 -3
- data/app/permissions/decidim/direct_verifications/verification/admin/permissions.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdece320908b5c93c6b1312fae64fbb23814d8c48e99bd258cdee55dcb2b37b3
|
4
|
+
data.tar.gz: 0d70c5cf75fd68c848ce52328589cce67524197f5cc95dbcbd2ff5cc7d559ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce76ca5c3dcf855eba9f1ecd0d963bfb03791a80ed9fbee729e891932a96390b94df9ca748e19f73aaefb03afd5f55b0a1b873eb470eccf3d67b9e116118d23f
|
7
|
+
data.tar.gz: 761e7647eeb5d859c17694a8c681d9538cd6ffd680071d7f9f4cbe7d3aa3c718fac5451ed9624fdfad8a0e5101cd95690a3cce3d3e514e11ba7d2fa708478082
|
data/README.md
CHANGED
@@ -6,14 +6,14 @@ A [Decidim](https://github.com/decidim/decidim) that provides a verification met
|
|
6
6
|
|
7
7
|
This plugin allows to verify users against the `Direct verification` method by default, but it is not limited to it, it can be used to directly verify users against any other method registered for the organization.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
**Other features include:**
|
9
|
+
**Features:**
|
12
10
|
|
13
11
|
1. Allows to massively register users directly in the platform prior (or independently) to verify them by sending them invite emails.
|
14
12
|
> **IMPORTANT:**<br>
|
15
13
|
> You must only use this feature if you have explicit consent from your users, otherwise you might be violating the [GDPR](https://eugdpr.org/) regulation in EU.
|
16
|
-
2.
|
14
|
+
2. Massive authroizations of users using any verification method registered for the organization **if configured**.
|
15
|
+
3. It can massively revoke authorizations given to any user with any verification method available.
|
16
|
+
4. Shows user's statuses per verification method in a simple stats table.
|
17
17
|
|
18
18
|
## Screenshot
|
19
19
|
|
@@ -48,6 +48,56 @@ And then execute:
|
|
48
48
|
bundle
|
49
49
|
```
|
50
50
|
|
51
|
+
## Using additional verification methods
|
52
|
+
|
53
|
+
You can manage other verification methods (or workflow) a part from `Direct verification`. You need to configure it in a new file in the `config/initializers` folder.
|
54
|
+
For instance, you can use this same engine to have 2 levels of permissions in the platform.
|
55
|
+
|
56
|
+
Create a file like `config/initializers/decidim_verifications.rb` with content as:
|
57
|
+
|
58
|
+
**`config/initializers/decidim_verifications.rb`:**
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
# frozen_string_literal: true
|
62
|
+
|
63
|
+
# We are using the same DirectVerifications engine without the admin part to
|
64
|
+
# create a custom verification method called "direct_verifications_managers"
|
65
|
+
Decidim::Verifications.register_workflow(:direct_verifications_managers) do |workflow|
|
66
|
+
workflow.engine = Decidim::DirectVerifications::Verification::Engine
|
67
|
+
end
|
68
|
+
|
69
|
+
# We need to tell the plugin to handle this method in addition to the default "Direct verification". Any registered workflow is valid.
|
70
|
+
Decidim::DirectVerifications.configure do |config|
|
71
|
+
config.manage_workflows = %w(direct_verifications_managers)
|
72
|
+
end
|
73
|
+
|
74
|
+
```
|
75
|
+
|
76
|
+
You will need the locales entries corresponding to your custom workflow, create as many files as languages you have in your application in `config/locales`:
|
77
|
+
|
78
|
+
**`config/locales/en.yml`:**
|
79
|
+
|
80
|
+
```yaml
|
81
|
+
en:
|
82
|
+
decidim:
|
83
|
+
authorization_handlers:
|
84
|
+
direct_verifications_managers:
|
85
|
+
name: Organization managers
|
86
|
+
explanation: Direct Verifications Subgroup explanation
|
87
|
+
```
|
88
|
+
|
89
|
+
Similarly, you can also overwrite the default title "Direct verification" by creating the key again in your locales:
|
90
|
+
|
91
|
+
```yaml
|
92
|
+
en:
|
93
|
+
decidim:
|
94
|
+
authorization_handlers:
|
95
|
+
direct_verifications:
|
96
|
+
name: Generic organization members
|
97
|
+
explanation: Direct Verifications Subgroup explanation
|
98
|
+
```
|
99
|
+
|
100
|
+
|
51
101
|
## Contributing
|
52
102
|
|
53
103
|
See [Decidim](https://github.com/decidim/decidim).
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link decidim/direct_verifications/verification/admin/direct_verifications_admin.js
|
@@ -10,16 +10,21 @@ module Decidim
|
|
10
10
|
layout "decidim/admin/users"
|
11
11
|
|
12
12
|
def index
|
13
|
-
enforce_permission_to :index,
|
13
|
+
enforce_permission_to :index, :authorization
|
14
|
+
@authorization_handler = :direct_verifications
|
15
|
+
@workflows = workflows
|
14
16
|
end
|
15
17
|
|
16
18
|
def create
|
17
|
-
enforce_permission_to :create,
|
19
|
+
enforce_permission_to :create, :authorization
|
18
20
|
|
19
21
|
@userlist = params[:userlist]
|
22
|
+
@workflows = workflows
|
20
23
|
processor = UserProcessor.new(current_organization, current_user)
|
21
24
|
processor.emails = extract_emails_to_hash @userlist
|
22
|
-
processor.authorization_handler =
|
25
|
+
processor.authorization_handler = authorization_handler(params[:authorization_handler])
|
26
|
+
stats = UserStats.new(current_organization)
|
27
|
+
stats.authorization_handler = processor.authorization_handler
|
23
28
|
if params[:register]
|
24
29
|
processor.register_users
|
25
30
|
flash[:warning] = t(".registered", count: processor.emails.count,
|
@@ -39,28 +44,17 @@ module Decidim
|
|
39
44
|
revoked: processor.processed[:revoked].count,
|
40
45
|
errors: processor.errors[:revoked].count)
|
41
46
|
else
|
47
|
+
stats.emails = processor.emails.keys
|
42
48
|
flash[:info] = t(".info", handler: t("#{processor.authorization_handler}.name", scope: "decidim.authorization_handlers"),
|
43
49
|
count: processor.emails.count,
|
44
|
-
authorized:
|
45
|
-
unconfirmed:
|
46
|
-
registered:
|
50
|
+
authorized: stats.authorized,
|
51
|
+
unconfirmed: stats.unconfirmed,
|
52
|
+
registered: stats.registered)
|
47
53
|
render(action: :index) && return
|
48
54
|
end
|
49
55
|
redirect_to direct_verifications_path
|
50
56
|
end
|
51
57
|
|
52
|
-
def permission_class_chain
|
53
|
-
[
|
54
|
-
Decidim::DirectVerifications::Verification::Admin::Permissions,
|
55
|
-
Decidim::Admin::Permissions,
|
56
|
-
Decidim::Permissions
|
57
|
-
]
|
58
|
-
end
|
59
|
-
|
60
|
-
def permission_scope
|
61
|
-
:admin
|
62
|
-
end
|
63
|
-
|
64
58
|
private
|
65
59
|
|
66
60
|
def extract_emails_to_hash(txt)
|
@@ -72,6 +66,22 @@ module Decidim
|
|
72
66
|
]
|
73
67
|
end .to_h
|
74
68
|
end
|
69
|
+
|
70
|
+
def authorization_handler(authorization_handler)
|
71
|
+
@authorization_handler = authorization_handler.presence || :direct_verifications
|
72
|
+
end
|
73
|
+
|
74
|
+
def configured_workflows
|
75
|
+
return Decidim::DirectVerifications.config.manage_workflows if Decidim::DirectVerifications.config
|
76
|
+
["direct_verifications"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def workflows
|
80
|
+
workflows = configured_workflows & current_organization.available_authorizations.map.to_a
|
81
|
+
workflows.map do |a|
|
82
|
+
[t("#{a}.name", scope: "decidim.authorization_handlers"), a]
|
83
|
+
end
|
84
|
+
end
|
75
85
|
end
|
76
86
|
end
|
77
87
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DirectVerifications
|
5
|
+
module Verification
|
6
|
+
module Admin
|
7
|
+
class StatsController < Decidim::Admin::ApplicationController
|
8
|
+
include NeedsPermission
|
9
|
+
|
10
|
+
layout "decidim/admin/users"
|
11
|
+
|
12
|
+
def index
|
13
|
+
enforce_permission_to :index, :authorization
|
14
|
+
stats = UserStats.new(current_organization)
|
15
|
+
@stats = {
|
16
|
+
t(".global") => stats_hash(stats)
|
17
|
+
}
|
18
|
+
current_organization.available_authorizations.map do |a|
|
19
|
+
stats.authorization_handler = a
|
20
|
+
@stats[t("#{a}.name", scope: "decidim.authorization_handlers")] = stats_hash(stats)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def stats_hash(stats)
|
27
|
+
{
|
28
|
+
registered: stats.registered,
|
29
|
+
authorized: stats.authorized,
|
30
|
+
unconfirmed: stats.unconfirmed,
|
31
|
+
authorized_unconfirmed: stats.authorized_unconfirmed
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/app/views/decidim/direct_verifications/verification/admin/direct_verifications/index.html.erb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
1
|
<div class="card">
|
3
2
|
<div class="card-divider">
|
4
3
|
<h2 class="card-title">
|
5
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">
|
@@ -13,6 +13,9 @@
|
|
13
13
|
<label>
|
14
14
|
<%= check_box_tag :register %>
|
15
15
|
<%= t('admin.new.register', scope: 'decidim.direct_verifications.verification') %>
|
16
|
+
<div data-alert class="callout alert hide">
|
17
|
+
<%= t('admin.direct_verifications.gdpr_disclaimer', scope: 'decidim.direct_verifications.verification') %>
|
18
|
+
</div>
|
16
19
|
</label>
|
17
20
|
<label>
|
18
21
|
<%= radio_button_tag :authorize, 'in' %>
|
@@ -27,10 +30,9 @@
|
|
27
30
|
<%= t('admin.new.check', scope: 'decidim.direct_verifications.verification') %>
|
28
31
|
</label>
|
29
32
|
|
30
|
-
<%= label_tag :
|
31
|
-
|
32
|
-
|
33
|
-
}, :direct_verifications) %>
|
33
|
+
<%= label_tag :authorization_handler, t('admin.new.authorization_handler', scope: 'decidim.direct_verifications.verification') %>
|
34
|
+
|
35
|
+
<%= select_tag :authorization_handler, options_for_select(@workflows, @authorization_handler) %>
|
34
36
|
|
35
37
|
<%= submit_tag t('admin.new.submit', scope: 'decidim.direct_verifications.verification'), class: 'button' %>
|
36
38
|
|
@@ -38,3 +40,5 @@
|
|
38
40
|
|
39
41
|
</div>
|
40
42
|
</div>
|
43
|
+
|
44
|
+
<%= javascript_include_tag "decidim/direct_verifications/verification/admin/direct_verifications_admin" %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title">
|
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
|
+
</h2>
|
7
|
+
</div>
|
8
|
+
<div class="card-section">
|
9
|
+
<table class="table-list">
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th><%= t("admin.new.authorization_handler", scope: 'decidim.direct_verifications.verification') %></th>
|
13
|
+
<th><%= t(".registered") %></th>
|
14
|
+
<th><%= t(".authorized") %></th>
|
15
|
+
<th><%= t(".unconfirmed") %></th>
|
16
|
+
<th><%= t(".authorized_unconfirmed") %></th>
|
17
|
+
<th></th>
|
18
|
+
</tr>
|
19
|
+
</thead>
|
20
|
+
<tbody>
|
21
|
+
<% @stats.each do |a, s| %>
|
22
|
+
<tr>
|
23
|
+
<td>
|
24
|
+
<%= a %>
|
25
|
+
</td>
|
26
|
+
<td><%= s[:registered] %></td>
|
27
|
+
<td><%= s[:authorized] %></td>
|
28
|
+
<td><%= s[:unconfirmed] %></td>
|
29
|
+
<td><%= s[:authorized_unconfirmed] %></td>
|
30
|
+
</tr>
|
31
|
+
<% end %>
|
32
|
+
</tbody>
|
33
|
+
</table>
|
34
|
+
</div>
|
35
|
+
</div>
|
data/config/locales/ca.yml
CHANGED
@@ -32,10 +32,15 @@ ca:
|
|
32
32
|
detectats, %{errors} errors)
|
33
33
|
revoked: S'ha revocat correctament la verificació de %{revoked} usuaris
|
34
34
|
utilitzant [%{handler}] (%{count} detectats, %{errors} errors)
|
35
|
+
gdpr_disclaimer: Feu-ho sota la vostra responsabilitat. Recordeu que heu
|
36
|
+
de tenir el consentiment explícit dels vostres usuaris per registrar-los.
|
37
|
+
En cas contrari, estareu infringint la regulació GDPR als països de
|
38
|
+
la UE.
|
35
39
|
index:
|
40
|
+
stats: Estadístiques d'usuaris
|
36
41
|
title: Inscriu i autoritza usuaris
|
37
42
|
new:
|
38
|
-
authorization_handler:
|
43
|
+
authorization_handler: Mètode de verificació
|
39
44
|
authorize: Autoritza els usuaris
|
40
45
|
check: Comprova l'estat dels usuaris
|
41
46
|
info: Introdueix aquí els emails, un per línia. Si els emails estan precedits
|
@@ -43,7 +48,14 @@ ca:
|
|
43
48
|
register: Registra els usuaris a la plataforma (si existeixen s'ignoraran)
|
44
49
|
revoke: Revoca l'autorització dels usuaris
|
45
50
|
submit: Envia i processa el llistat
|
46
|
-
textarea:
|
51
|
+
textarea: Llista d''emails
|
52
|
+
stats:
|
53
|
+
index:
|
54
|
+
authorized: Verificats
|
55
|
+
authorized_unconfirmed: Verificats però no confirmats
|
56
|
+
global: "- Qualsevol mètode de verificació -"
|
57
|
+
registered: Registrats
|
58
|
+
unconfirmed: No confirmats
|
47
59
|
authorizations:
|
48
60
|
new:
|
49
61
|
no_action: Aquest mètode requereix que un administrador us verifiqui
|
data/config/locales/en.yml
CHANGED
@@ -31,10 +31,14 @@ en:
|
|
31
31
|
detected, %{errors} errors) "
|
32
32
|
revoked: Verification from %{revoked} users have been revoked using
|
33
33
|
[%{handler}] (%{count} detected, %{errors} errors)
|
34
|
+
gdpr_disclaimer: Do this under your responsibility. Remember that you
|
35
|
+
need to have explicit consent from your users in order to register them.
|
36
|
+
Otherwise you will be infringing the GDPR regulation in EU countries.
|
34
37
|
index:
|
38
|
+
stats: User stats
|
35
39
|
title: Register and authorize users
|
36
40
|
new:
|
37
|
-
authorization_handler:
|
41
|
+
authorization_handler: Verification method
|
38
42
|
authorize: Authorize users
|
39
43
|
check: Check users status
|
40
44
|
info: Enter the emails here, one per line. If the emails are preceded
|
@@ -42,7 +46,14 @@ en:
|
|
42
46
|
register: Register users in the platform (if they exist they will be ignored)
|
43
47
|
revoke: Revoke authorization from users
|
44
48
|
submit: Send and process the list
|
45
|
-
textarea:
|
49
|
+
textarea: Emails list
|
50
|
+
stats:
|
51
|
+
index:
|
52
|
+
authorized: Authorized
|
53
|
+
authorized_unconfirmed: Authorized but unconfirmed
|
54
|
+
global: "- Any verification method -"
|
55
|
+
registered: Registered
|
56
|
+
unconfirmed: Unconfirmed
|
46
57
|
authorizations:
|
47
58
|
new:
|
48
59
|
no_action: This method requires an administrator that verifies you
|
data/config/locales/es.yml
CHANGED
@@ -32,10 +32,15 @@ es:
|
|
32
32
|
detectados, %{errors} errores)
|
33
33
|
revoked: Se ha revocado correctament la verificación de %{revoked} usuarios
|
34
34
|
usando [%{handler}] (%{count} detectados, %{errors} errores)
|
35
|
+
gdpr_disclaimer: Haga esto bajo su responsabilidad. Recuerde que debe
|
36
|
+
contar con el consentimiento explícito de sus usuarios para poder registrarlos.
|
37
|
+
De lo contrario, estará infringiendo la regulación GDPR en los países
|
38
|
+
de la UE.
|
35
39
|
index:
|
40
|
+
stats: Estadísticas de usuarios
|
36
41
|
title: Inscribe y autoriza usuarios
|
37
42
|
new:
|
38
|
-
authorization_handler:
|
43
|
+
authorization_handler: Método de verificación
|
39
44
|
authorize: Autoriza los usuarios
|
40
45
|
check: Comprueba el estado de los usuarios
|
41
46
|
info: Introduce aquí los emails, uno por linea. Si los emails están precedidos
|
@@ -43,7 +48,14 @@ es:
|
|
43
48
|
register: Registra los usuarios a la plataforma (si existen se ignorarán)
|
44
49
|
revoke: Revoca la autorización de los usuarios
|
45
50
|
submit: Envía y procesa el listado
|
46
|
-
textarea:
|
51
|
+
textarea: Lista de emails
|
52
|
+
stats:
|
53
|
+
index:
|
54
|
+
authorized: Verificados
|
55
|
+
authorized_unconfirmed: Verificados pero sin confirmar
|
56
|
+
global: "- Cualquier método de verificación -"
|
57
|
+
registered: Registrados
|
58
|
+
unconfirmed: Sin confirmar
|
47
59
|
authorizations:
|
48
60
|
new:
|
49
61
|
no_action: Este método requiere que un administrador os verifique
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "direct_verifications/version"
|
4
|
+
require_relative "direct_verifications/config"
|
4
5
|
require_relative "direct_verifications/user_processor"
|
6
|
+
require_relative "direct_verifications/user_stats"
|
5
7
|
require_relative "direct_verifications/verification"
|
6
8
|
|
7
9
|
module Decidim
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DirectVerifications
|
5
|
+
class << self
|
6
|
+
attr_accessor :config
|
7
|
+
def configure
|
8
|
+
yield self.config ||= Config.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Config
|
13
|
+
attr_reader :manage_workflows
|
14
|
+
def manage_workflows=(manage_workflows)
|
15
|
+
@manage_workflows.concat(manage_workflows).uniq!
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@manage_workflows = ["direct_verifications"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -43,7 +43,7 @@ module Decidim
|
|
43
43
|
@emails.each do |email, _name|
|
44
44
|
if (u = find_user(email))
|
45
45
|
auth = authorization(u)
|
46
|
-
next
|
46
|
+
next unless !auth.granted? || auth.expired?
|
47
47
|
Verification::ConfirmUserAuthorization.call(auth, authorize_form(u)) do
|
48
48
|
on(:ok) do
|
49
49
|
add_processed :authorized, email
|
@@ -77,24 +77,6 @@ module Decidim
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def total(type)
|
81
|
-
if type == :registered
|
82
|
-
return User.where(email: @emails.keys, decidim_organization_id: @organization.id)
|
83
|
-
.count
|
84
|
-
end
|
85
|
-
if type == :unconfirmed
|
86
|
-
return User.where(email: @emails.keys, decidim_organization_id: @organization.id)
|
87
|
-
.where(confirmed_at: nil).count
|
88
|
-
end
|
89
|
-
if type == :authorized
|
90
|
-
return Decidim::Authorization.joins(:user)
|
91
|
-
.where(name: authorization_handler)
|
92
|
-
.where("decidim_users.email IN (:emails) AND decidim_users.decidim_organization_id=:org",
|
93
|
-
emails: @emails.keys, org: @organization.id).count
|
94
|
-
end
|
95
|
-
0
|
96
|
-
end
|
97
|
-
|
98
80
|
private
|
99
81
|
|
100
82
|
def find_user(email)
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DirectVerifications
|
5
|
+
class UserStats
|
6
|
+
def initialize(organization)
|
7
|
+
@organization = organization
|
8
|
+
@authorization_handler = ""
|
9
|
+
@emails = []
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :organization, :authorization_handler
|
13
|
+
attr_accessor :emails
|
14
|
+
|
15
|
+
def authorization_handler=(name)
|
16
|
+
@workflow_manifest = nil
|
17
|
+
@authorization_handler = name
|
18
|
+
end
|
19
|
+
|
20
|
+
def registered
|
21
|
+
registered_users.count
|
22
|
+
end
|
23
|
+
|
24
|
+
def unconfirmed
|
25
|
+
registered_users.where("decidim_users.confirmed_at IS NULL").count
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorized
|
29
|
+
authorized_users.count
|
30
|
+
end
|
31
|
+
|
32
|
+
def authorized_unconfirmed
|
33
|
+
authorized_users.where("decidim_users.confirmed_at IS NULL").count
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def registered_users
|
39
|
+
if authorization_handler.empty?
|
40
|
+
filter = { decidim_organization_id: organization.id }
|
41
|
+
filter[:email] = emails unless emails.empty?
|
42
|
+
return User.where(filter)
|
43
|
+
end
|
44
|
+
authorized_users(false)
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorized_users(strict = true)
|
48
|
+
q = Decidim::Authorization.joins(:user)
|
49
|
+
unless authorization_handler.empty?
|
50
|
+
q = q.where(name: authorization_handler)
|
51
|
+
if strict
|
52
|
+
q = q.where.not(granted_at: nil)
|
53
|
+
q = q.where("decidim_authorizations.granted_at >= :date", date: Time.current - expires_in) if expires_in
|
54
|
+
end
|
55
|
+
end
|
56
|
+
q = q.where("decidim_users.decidim_organization_id=:org", org: organization.id)
|
57
|
+
return q if emails.empty?
|
58
|
+
q.where("decidim_users.email IN (:emails)", emails: emails)
|
59
|
+
end
|
60
|
+
|
61
|
+
def expires_in
|
62
|
+
return unless workflow_manifest
|
63
|
+
return if workflow_manifest.expires_in.zero?
|
64
|
+
workflow_manifest.expires_in
|
65
|
+
end
|
66
|
+
|
67
|
+
def workflow_manifest
|
68
|
+
return if authorization_handler.empty?
|
69
|
+
@workflow_manifest ||= Decidim::Verifications.find_workflow_manifest(authorization_handler)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -8,10 +8,15 @@ module Decidim
|
|
8
8
|
paths["db/migrate"] = nil
|
9
9
|
|
10
10
|
routes do
|
11
|
-
resources :direct_verifications, only: [:index, :create]
|
11
|
+
resources :direct_verifications, only: [:index, :create, :stats]
|
12
|
+
resources :stats, only: [:index]
|
12
13
|
|
13
14
|
root to: "direct_verifications#index"
|
14
15
|
end
|
16
|
+
|
17
|
+
initializer "decidim_direct_verifications.admin_assets" do |app|
|
18
|
+
app.config.assets.precompile += %w(direct_verifications_admin_manifest.js)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-direct_verifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.7
|
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: 2019-04-
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-admin
|
@@ -49,20 +49,25 @@ files:
|
|
49
49
|
- LICENSE-AGPLv3.txt
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
|
+
- app/assets/config/direct_verifications_admin_manifest.js
|
53
|
+
- app/assets/javascripts/decidim/direct_verifications/verification/admin/direct_verifications_admin.js.es6
|
52
54
|
- app/commands/decidim/direct_verifications/verification/confirm_user_authorization.rb
|
53
55
|
- app/commands/decidim/direct_verifications/verification/destroy_user_authorization.rb
|
54
56
|
- app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb
|
57
|
+
- app/controllers/decidim/direct_verifications/verification/admin/stats_controller.rb
|
55
58
|
- app/controllers/decidim/direct_verifications/verification/authorizations_controller.rb
|
56
59
|
- app/forms/decidim/direct_verifications/verification/direct_verifications_form.rb
|
57
|
-
- app/permissions/decidim/direct_verifications/verification/admin/permissions.rb
|
58
60
|
- app/views/decidim/direct_verifications/verification/admin/direct_verifications/index.html.erb
|
61
|
+
- app/views/decidim/direct_verifications/verification/admin/stats/index.html.erb
|
59
62
|
- app/views/devise/mailer/direct_invite.html.erb
|
60
63
|
- app/views/devise/mailer/direct_invite.text.erb
|
61
64
|
- config/locales/ca.yml
|
62
65
|
- config/locales/en.yml
|
63
66
|
- config/locales/es.yml
|
64
67
|
- lib/decidim/direct_verifications.rb
|
68
|
+
- lib/decidim/direct_verifications/config.rb
|
65
69
|
- lib/decidim/direct_verifications/user_processor.rb
|
70
|
+
- lib/decidim/direct_verifications/user_stats.rb
|
66
71
|
- lib/decidim/direct_verifications/verification.rb
|
67
72
|
- lib/decidim/direct_verifications/verification/admin.rb
|
68
73
|
- lib/decidim/direct_verifications/verification/admin_engine.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module DirectVerifications
|
5
|
-
module Verification
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities related to direct_verifications for a logged in admin user.
|
8
|
-
class Permissions < Decidim::DefaultPermissions
|
9
|
-
def permissions
|
10
|
-
return permission_action if permission_action.scope != :admin
|
11
|
-
if user.organization.available_authorizations.include?("direct_verifications")
|
12
|
-
allow! if permission_action.subject == Decidim::DirectVerifications::UserProcessor
|
13
|
-
permission_action
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|