decidim-file_authorization_handler 0.28.2.0 → 0.30.1.3
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 +20 -0
- data/app/controllers/decidim/file_authorization_handler/admin/censuses_controller.rb +10 -0
- data/app/jobs/decidim/file_authorization_handler/remove_duplicates_job.rb +0 -2
- data/app/services/ephemeral_file_authorization_handler.rb +18 -0
- data/app/services/file_authorization_handler.rb +2 -2
- data/app/views/decidim/file_authorization_handler/admin/censuses/show.html.erb +1 -1
- data/config/locales/ca.yml +7 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/es.yml +7 -0
- data/lib/decidim/file_authorization_handler/engine.rb +11 -6
- data/lib/decidim/file_authorization_handler/version.rb +2 -2
- metadata +12 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5300c259d13967c0aeae37a9efa24fc1c6b49cae5ed8d488a16cbae74a95b44b
|
|
4
|
+
data.tar.gz: 43c12dc6425fa9e1608f95effd41d1ca67495a0206eca6e820c758c5b3e5b6f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a9c656fdd6d3cfc19c74b2379a8bb8a7691d9a7562b31f7609990673c6ee51c14d2dbfa440a6c8fe4e035c0a7a766e41981ddeb93e2cc986d9c571259dc1326
|
|
7
|
+
data.tar.gz: 2c2bd57ab8f753831f833d5765b17ef59ade68f2573f80b8f207da9ee69d4faaa400a39621f1ceb5fd3d9f5134900e6388a326d2af2a911b291799ced553104f
|
data/README.md
CHANGED
|
@@ -22,6 +22,18 @@ uploaded.
|
|
|
22
22
|
Uploading the file to a temporary storage system and processing it in
|
|
23
23
|
background is kept out of the scope for the first release.
|
|
24
24
|
|
|
25
|
+
### Ephemeral authorization handler
|
|
26
|
+
|
|
27
|
+
The optional ephemeral authorization workflow can be enabled by setting the
|
|
28
|
+
`ENABLE_EPHEMERAL_FILE_AUTHORIZATION_HANDLER` environment variable to `true`:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
ENABLE_EPHEMERAL_FILE_AUTHORIZATION_HANDLER=true
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The regular `file_authorization_handler` workflow is always available.
|
|
35
|
+
When `ENABLE_EPHEMERAL_FILE_AUTHORIZATION_HANDLER=true`, the `ephemeral_file_authorization_handler` workflow is also registered. Ephemeral authorizations expire after one hour and can be renewed every five minutes. The option is disabled by default.
|
|
36
|
+
|
|
25
37
|
### CSV file format
|
|
26
38
|
|
|
27
39
|
The CSV file format is not configurable, but is extendable. The plugin expects a comma separated
|
|
@@ -102,6 +114,14 @@ Finally, add the following line to your `config/routes.rb` file:
|
|
|
102
114
|
mount Decidim::FileAuthorizationHandler::AdminEngine => '/admin'
|
|
103
115
|
```
|
|
104
116
|
|
|
117
|
+
## Create development_app
|
|
118
|
+
Run:
|
|
119
|
+
```bash
|
|
120
|
+
bin/rails decidim:generate_external_development_app
|
|
121
|
+
bin/rails decidim_file_authorization_handler:install:migrations
|
|
122
|
+
bin/rails db:migrate
|
|
123
|
+
```
|
|
124
|
+
|
|
105
125
|
## Run tests
|
|
106
126
|
|
|
107
127
|
Node 16.9.1 is required!
|
|
@@ -12,6 +12,10 @@ module Decidim
|
|
|
12
12
|
def create
|
|
13
13
|
enforce_permission_to :create, :authorization
|
|
14
14
|
if params[:file]
|
|
15
|
+
unless csv_file?(params[:file])
|
|
16
|
+
flash[:alert] = t(".invalid_format")
|
|
17
|
+
return redirect_to censuses_path
|
|
18
|
+
end
|
|
15
19
|
data = CsvData.new(params[:file].path)
|
|
16
20
|
# rubocop: disable Rails/SkipsModelValidations
|
|
17
21
|
CensusDatum.insert_all(current_organization, data.values, data.headers[2..])
|
|
@@ -28,6 +32,12 @@ module Decidim
|
|
|
28
32
|
CensusDatum.clear(current_organization)
|
|
29
33
|
redirect_to censuses_path, notice: t(".success")
|
|
30
34
|
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def csv_file?(file)
|
|
39
|
+
File.extname(file.original_filename).casecmp(".csv").zero? && file.content_type == "text/csv"
|
|
40
|
+
end
|
|
31
41
|
end
|
|
32
42
|
end
|
|
33
43
|
end
|
|
@@ -5,7 +5,6 @@ module Decidim
|
|
|
5
5
|
class RemoveDuplicatesJob < ApplicationJob
|
|
6
6
|
queue_as :default
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Style/HashSyntax
|
|
9
8
|
def perform(organization)
|
|
10
9
|
duplicated_census(organization).pluck(:id_document).each do |id_document|
|
|
11
10
|
CensusDatum.inside(organization)
|
|
@@ -15,7 +14,6 @@ module Decidim
|
|
|
15
14
|
.each(&:delete)
|
|
16
15
|
end
|
|
17
16
|
end
|
|
18
|
-
# rubocop:enable Style/HashSyntax
|
|
19
17
|
|
|
20
18
|
private
|
|
21
19
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# A subclass of FileAuthorizationHandler for ephemeral verification workflows.
|
|
4
|
+
# It excludes tos_agreement from form_attributes because the verifications view
|
|
5
|
+
# already renders it as a proper checkbox via the _tos_acceptance_field partial.
|
|
6
|
+
#
|
|
7
|
+
# The class name matches the workflow registration name (:ephemeral_file_authorization_handler)
|
|
8
|
+
# so that handler_name is consistent across the hidden field, the authorization record,
|
|
9
|
+
# and the permission check.
|
|
10
|
+
class EphemeralFileAuthorizationHandler < FileAuthorizationHandler
|
|
11
|
+
def form_attributes
|
|
12
|
+
attributes.except(*%w(id user tos_agreement)).keys
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def handler_name
|
|
16
|
+
+"ephemeral_file_authorization_handler"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -16,7 +16,7 @@ class FileAuthorizationHandler < Decidim::AuthorizationHandler
|
|
|
16
16
|
# Customized constructor to support decidim-initiatives.
|
|
17
17
|
def initialize(params)
|
|
18
18
|
params[:id_document] = params.delete(:document_number) unless params.has_key?(:id_document)
|
|
19
|
-
super
|
|
19
|
+
super
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def metadata
|
|
@@ -43,7 +43,7 @@ class FileAuthorizationHandler < Decidim::AuthorizationHandler
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def authorized?
|
|
46
|
-
|
|
46
|
+
true if census_for_user
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def unique_id
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
<%= form_tag censuses_path, multipart: true, class: 'form' do %>
|
|
38
38
|
<%= label_tag :name, t('admin.new.file', scope: 'decidim.file_authorization_handler') %>
|
|
39
|
-
<%= file_field_tag :file %>
|
|
39
|
+
<%= file_field_tag :file, accept: ".csv" %>
|
|
40
40
|
<%= submit_tag t('admin.new.submit', scope: 'decidim.file_authorization_handler'), class: 'button button__sm button__secondary hollow tiny button--title' %>
|
|
41
41
|
<% end %>
|
|
42
42
|
</div>
|
data/config/locales/ca.yml
CHANGED
|
@@ -12,6 +12,12 @@ ca:
|
|
|
12
12
|
year: Any
|
|
13
13
|
decidim:
|
|
14
14
|
authorization_handlers:
|
|
15
|
+
ephemeral_file_authorization_handler:
|
|
16
|
+
explanation: Autoritza el teu compte d'usuari contra el cens de la Organització
|
|
17
|
+
fields:
|
|
18
|
+
birthdate: Data de naixement
|
|
19
|
+
name: Cens Organització
|
|
20
|
+
type: CSV
|
|
15
21
|
file_authorization_handler:
|
|
16
22
|
name: Cens Organització
|
|
17
23
|
explanation: Autoritza el teu compte d'usuari contra el cens de la Organització
|
|
@@ -32,6 +38,7 @@ ca:
|
|
|
32
38
|
censuses:
|
|
33
39
|
create:
|
|
34
40
|
success: S'han importat amb èxit %{count} elements (%{errors} errors)
|
|
41
|
+
invalid_format: "Format de fitxer no vàlid. Només s'admeten fitxers CSV."
|
|
35
42
|
destroy:
|
|
36
43
|
success: S'han esborrat totes les dades censals
|
|
37
44
|
menu:
|
data/config/locales/en.yml
CHANGED
|
@@ -12,6 +12,12 @@ en:
|
|
|
12
12
|
year: Year
|
|
13
13
|
decidim:
|
|
14
14
|
authorization_handlers:
|
|
15
|
+
ephemeral_file_authorization_handler:
|
|
16
|
+
explanation: Authorize your user account against Organization's Census
|
|
17
|
+
fields:
|
|
18
|
+
birthdate: Birthdate
|
|
19
|
+
name: Organization's Census
|
|
20
|
+
type: CSV
|
|
15
21
|
file_authorization_handler:
|
|
16
22
|
name: Organization's Census
|
|
17
23
|
explanation: Authorize your user account against Organization's Census
|
|
@@ -32,6 +38,7 @@ en:
|
|
|
32
38
|
censuses:
|
|
33
39
|
create:
|
|
34
40
|
success: Successfully imported %{count} items (%{errors} errors)
|
|
41
|
+
invalid_format: "Invalid file format. Only CSV files are accepted."
|
|
35
42
|
destroy:
|
|
36
43
|
success: All census data have been deleted
|
|
37
44
|
menu:
|
data/config/locales/es.yml
CHANGED
|
@@ -12,6 +12,12 @@ es:
|
|
|
12
12
|
year: Año
|
|
13
13
|
decidim:
|
|
14
14
|
authorization_handlers:
|
|
15
|
+
ephemeral_file_authorization_handler:
|
|
16
|
+
explanation: Autoriza tu cuenta de usuario contra el Censo de la Organización
|
|
17
|
+
fields:
|
|
18
|
+
birthdate: Fecha de nacimiento
|
|
19
|
+
name: Censo de la Organización
|
|
20
|
+
type: CSV
|
|
15
21
|
file_authorization_handler:
|
|
16
22
|
name: Censo de la Organización
|
|
17
23
|
explanation: Autoriza tu cuenta de usuario contra el Censo de la Organización
|
|
@@ -32,6 +38,7 @@ es:
|
|
|
32
38
|
censuses:
|
|
33
39
|
create:
|
|
34
40
|
success: Se han importado con éxito %{count} elementos (%{errors} errores)
|
|
41
|
+
invalid_format: "Formato de archivo no válido. Solo se admiten ficheros CSV."
|
|
35
42
|
destroy:
|
|
36
43
|
success: Se han borrado todos los datos censales
|
|
37
44
|
menu:
|
|
@@ -6,16 +6,21 @@ module Decidim
|
|
|
6
6
|
class Engine < ::Rails::Engine
|
|
7
7
|
isolate_namespace Decidim::FileAuthorizationHandler
|
|
8
8
|
|
|
9
|
-
initializer "decidim_census.add_irregular_inflection" do |_app|
|
|
10
|
-
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
11
|
-
inflect.irregular "census", "census"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
9
|
initializer "decidim_census.add_authorization_handlers" do |_app|
|
|
16
10
|
Decidim::Verifications.register_workflow(:file_authorization_handler) do |workflow|
|
|
17
11
|
workflow.form = "FileAuthorizationHandler"
|
|
18
12
|
end
|
|
13
|
+
|
|
14
|
+
next unless ENV.fetch("ENABLE_EPHEMERAL_FILE_AUTHORIZATION_HANDLER", "false") == "true"
|
|
15
|
+
|
|
16
|
+
# Enable Ephemeral Verification
|
|
17
|
+
Decidim::Verifications.register_workflow(:ephemeral_file_authorization_handler) do |workflow|
|
|
18
|
+
workflow.ephemeral = true
|
|
19
|
+
workflow.form = "EphemeralFileAuthorizationHandler"
|
|
20
|
+
workflow.expires_in = 1.hour
|
|
21
|
+
workflow.renewable = true
|
|
22
|
+
workflow.time_between_renewals = 5.minutes
|
|
23
|
+
end
|
|
19
24
|
end
|
|
20
25
|
end
|
|
21
26
|
end
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module FileAuthorizationHandler
|
|
5
|
-
DECIDIM_VERSION = "0.
|
|
5
|
+
DECIDIM_VERSION = "0.30.1"
|
|
6
6
|
|
|
7
7
|
# Uses the latest matching Decidim version for
|
|
8
8
|
# - major, minor and patch
|
|
9
9
|
# - the optional extra number is related to this module's patches
|
|
10
|
-
VERSION = "#{DECIDIM_VERSION}.
|
|
10
|
+
VERSION = "#{DECIDIM_VERSION}.3".freeze
|
|
11
11
|
end
|
|
12
12
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-file_authorization_handler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.30.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Gómez
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-08-27 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: decidim
|
|
@@ -18,56 +18,42 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - "~>"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.
|
|
21
|
+
version: 0.30.1
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - "~>"
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 0.
|
|
28
|
+
version: 0.30.1
|
|
29
29
|
- !ruby/object:Gem::Dependency
|
|
30
30
|
name: decidim-admin
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
|
33
33
|
- - "~>"
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 0.
|
|
35
|
+
version: 0.30.1
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
|
40
40
|
- - "~>"
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 0.
|
|
43
|
-
- !ruby/object:Gem::Dependency
|
|
44
|
-
name: rails
|
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
|
46
|
-
requirements:
|
|
47
|
-
- - ">="
|
|
48
|
-
- !ruby/object:Gem::Version
|
|
49
|
-
version: '5.2'
|
|
50
|
-
type: :runtime
|
|
51
|
-
prerelease: false
|
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
-
requirements:
|
|
54
|
-
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: '5.2'
|
|
42
|
+
version: 0.30.1
|
|
57
43
|
- !ruby/object:Gem::Dependency
|
|
58
44
|
name: decidim-dev
|
|
59
45
|
requirement: !ruby/object:Gem::Requirement
|
|
60
46
|
requirements:
|
|
61
47
|
- - "~>"
|
|
62
48
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: 0.
|
|
49
|
+
version: 0.30.1
|
|
64
50
|
type: :development
|
|
65
51
|
prerelease: false
|
|
66
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
67
53
|
requirements:
|
|
68
54
|
- - "~>"
|
|
69
55
|
- !ruby/object:Gem::Version
|
|
70
|
-
version: 0.
|
|
56
|
+
version: 0.30.1
|
|
71
57
|
description: Census uploads via csv files
|
|
72
58
|
email:
|
|
73
59
|
- hola@marsbased.com
|
|
@@ -86,6 +72,7 @@ files:
|
|
|
86
72
|
- app/models/decidim/file_authorization_handler/csv_data.rb
|
|
87
73
|
- app/models/decidim/file_authorization_handler/status.rb
|
|
88
74
|
- app/permissions/decidim/file_authorization_handler/admin/permissions.rb
|
|
75
|
+
- app/services/ephemeral_file_authorization_handler.rb
|
|
89
76
|
- app/services/file_authorization_handler.rb
|
|
90
77
|
- app/views/decidim/file_authorization_handler/admin/censuses/_upload_info.html.erb
|
|
91
78
|
- app/views/decidim/file_authorization_handler/admin/censuses/show.html.erb
|
|
@@ -111,16 +98,16 @@ require_paths:
|
|
|
111
98
|
- lib
|
|
112
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
100
|
requirements:
|
|
114
|
-
- - "
|
|
101
|
+
- - ">="
|
|
115
102
|
- !ruby/object:Gem::Version
|
|
116
|
-
version:
|
|
103
|
+
version: 3.3.4
|
|
117
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
105
|
requirements:
|
|
119
106
|
- - ">="
|
|
120
107
|
- !ruby/object:Gem::Version
|
|
121
108
|
version: '0'
|
|
122
109
|
requirements: []
|
|
123
|
-
rubygems_version: 3.
|
|
110
|
+
rubygems_version: 3.5.11
|
|
124
111
|
signing_key:
|
|
125
112
|
specification_version: 4
|
|
126
113
|
summary: CSV document + birth date verifier
|