decidim-file_authorization_handler 0.28.2.0 → 0.31.6.1
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 +8 -0
- data/app/controllers/decidim/file_authorization_handler/admin/censuses_controller.rb +15 -0
- data/app/jobs/decidim/file_authorization_handler/remove_duplicates_job.rb +0 -2
- data/app/models/decidim/file_authorization_handler/census_datum.rb +1 -1
- data/app/services/file_authorization_handler.rb +3 -3
- data/app/views/decidim/file_authorization_handler/admin/censuses/new.html.erb +26 -0
- data/app/views/decidim/file_authorization_handler/admin/censuses/show.html.erb +15 -33
- data/config/locales/ca.yml +3 -1
- data/config/locales/en.yml +3 -1
- data/config/locales/es.yml +4 -2
- data/lib/decidim/file_authorization_handler/admin_engine.rb +1 -1
- data/lib/decidim/file_authorization_handler/engine.rb +0 -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: 94f5b784d3c2b3056f62b7675f565cf9c697eb6cee0e48a5ddb67de43a44317b
|
|
4
|
+
data.tar.gz: c622e0561eabfe6267258c4cf31131c35cc8171274fbcf2f28cb4105ada2ff5a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12b90762a42d545049b9bb34d53a04f6d3849e7896da9fd45e09578b2e3b30b18d140855a0bf1fe48f4e221f7a46480aacbcbc10bbef92fc6a5ff0ecef829a4f
|
|
7
|
+
data.tar.gz: 3455c7254cb35b833cd8c92373decd9563ac7713fe806927cbf1932fe06d44e9940e1ea81161012c2fae425fcb9fc1ae8bc09b90c20de3be2238df3a12cd71b1
|
data/README.md
CHANGED
|
@@ -102,6 +102,14 @@ Finally, add the following line to your `config/routes.rb` file:
|
|
|
102
102
|
mount Decidim::FileAuthorizationHandler::AdminEngine => '/admin'
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
## Create development_app
|
|
106
|
+
Run:
|
|
107
|
+
```bash
|
|
108
|
+
bin/rails decidim:generate_external_development_app
|
|
109
|
+
bin/rails decidim_file_authorization_handler:install:migrations
|
|
110
|
+
bin/rails db:migrate
|
|
111
|
+
```
|
|
112
|
+
|
|
105
113
|
## Run tests
|
|
106
114
|
|
|
107
115
|
Node 16.9.1 is required!
|
|
@@ -9,9 +9,18 @@ module Decidim
|
|
|
9
9
|
@status = Status.new(current_organization)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def new
|
|
13
|
+
enforce_permission_to :create, :authorization
|
|
14
|
+
@status = Status.new(current_organization)
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
def create
|
|
13
18
|
enforce_permission_to :create, :authorization
|
|
14
19
|
if params[:file]
|
|
20
|
+
unless csv_file?(params[:file])
|
|
21
|
+
flash[:alert] = t(".invalid_format")
|
|
22
|
+
return redirect_to censuses_path
|
|
23
|
+
end
|
|
15
24
|
data = CsvData.new(params[:file].path)
|
|
16
25
|
# rubocop: disable Rails/SkipsModelValidations
|
|
17
26
|
CensusDatum.insert_all(current_organization, data.values, data.headers[2..])
|
|
@@ -28,6 +37,12 @@ module Decidim
|
|
|
28
37
|
CensusDatum.clear(current_organization)
|
|
29
38
|
redirect_to censuses_path, notice: t(".success")
|
|
30
39
|
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def csv_file?(file)
|
|
44
|
+
File.extname(file.original_filename).casecmp(".csv").zero? && file.content_type == "text/csv"
|
|
45
|
+
end
|
|
31
46
|
end
|
|
32
47
|
end
|
|
33
48
|
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
|
|
|
@@ -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,13 +43,13 @@ 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
|
|
50
50
|
return nil unless organization
|
|
51
51
|
|
|
52
|
-
Digest::SHA256.hexdigest("#{census_for_user&.id_document}-#{organization.id}-#{
|
|
52
|
+
Digest::SHA256.hexdigest("#{census_for_user&.id_document}-#{organization.id}-#{ENV.fetch("SECRET_KEY_BASE", nil)}")
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def census_for_user
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<% add_decidim_page_title(t("admin.new.title", scope: "decidim.file_authorization_handler")) %>
|
|
2
|
+
<div class="item_show__header">
|
|
3
|
+
<h2 class="item_show__header-title">
|
|
4
|
+
<%= t("admin.new.title", scope: "decidim.file_authorization_handler") %>
|
|
5
|
+
</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="card-section">
|
|
8
|
+
<div class="row column">
|
|
9
|
+
<%= render partial: "upload_info" %>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div class="row column">
|
|
13
|
+
<%= form_tag censuses_path, multipart: true, class: "form" do %>
|
|
14
|
+
<div class="font-semibold">
|
|
15
|
+
<%= label_tag :name, t("admin.new.file", scope: "decidim.file_authorization_handler") %>
|
|
16
|
+
<%= file_field_tag :file, accept: ".csv" %>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div class="item__edit-sticky">
|
|
20
|
+
<div class="item__edit-sticky-container">
|
|
21
|
+
<%= submit_tag t("admin.new.submit", scope: "decidim.file_authorization_handler"), class: "button button__sm button__secondary" %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<% end %>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
@@ -1,44 +1,26 @@
|
|
|
1
1
|
<% add_decidim_page_title(t("admin.show.title", scope: "decidim.file_authorization_handler")) %>
|
|
2
2
|
|
|
3
3
|
<div class="card">
|
|
4
|
+
<div class="item_show__header item_show__header--with-action-options">
|
|
5
|
+
<h1 class="item_show__header-title">
|
|
6
|
+
<%= t("admin.show.title", scope: "decidim.file_authorization_handler") %>
|
|
7
|
+
<%= link_to t("admin.show.import_csv", scope: "decidim.file_authorization_handler"), new_censuses_path, class: "button button__sm button__transparent-secondary" %>
|
|
8
|
+
<% if @status.count > 0 %>
|
|
9
|
+
<%= link_to t("admin.destroy.title", scope: "decidim.file_authorization_handler"),
|
|
10
|
+
censuses_path,
|
|
11
|
+
method: :delete,
|
|
12
|
+
class: "button button__sm button__secondary alert hollow tiny button--title destroy",
|
|
13
|
+
data: { confirm: t("admin.destroy.confirm", scope: "decidim.file_authorization_handler") } %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</h1>
|
|
16
|
+
</div>
|
|
4
17
|
<div class="card-section p-4">
|
|
5
|
-
<div class="item_show__header">
|
|
6
|
-
<h1 class="item_show__header-title">
|
|
7
|
-
<%= t("admin.show.title", scope: "decidim.file_authorization_handler") %>
|
|
8
|
-
<% if @status.count > 0 %>
|
|
9
|
-
<%= link_to t('decidim.file_authorization_handler.admin.destroy.title'),
|
|
10
|
-
censuses_path,
|
|
11
|
-
method: :delete,
|
|
12
|
-
class: 'button button__sm button__secondary alert hollow tiny button--title destroy',
|
|
13
|
-
data: { confirm: t('decidim.file_authorization_handler.admin.destroy.confirm') } %>
|
|
14
|
-
<% end %>
|
|
15
|
-
</h1>
|
|
16
|
-
</div>
|
|
17
18
|
<% if @status.count > 0 %>
|
|
18
|
-
<p><%= t(
|
|
19
|
+
<p><%= t("admin.show.data", scope: "decidim.file_authorization_handler", count: @status.count,
|
|
19
20
|
due_date: l(@status.last_import_at, format: :long)) %>
|
|
20
21
|
</p>
|
|
21
22
|
<% else %>
|
|
22
|
-
<p><%= t(
|
|
23
|
+
<p><%= t("admin.show.empty", scope: "decidim.file_authorization_handler") %></p>
|
|
23
24
|
<% end %>
|
|
24
25
|
</div>
|
|
25
|
-
|
|
26
|
-
<div id="wrapper-action-view">
|
|
27
|
-
<div class="card-section p-4">
|
|
28
|
-
<div class="item_show__header">
|
|
29
|
-
|
|
30
|
-
<h1 class="item_show__header-title">
|
|
31
|
-
<%= t("admin.new.title", scope: "decidim.file_authorization_handler") %><div class="card-section p-4">
|
|
32
|
-
</h1>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<%= render "upload_info" %>
|
|
36
|
-
|
|
37
|
-
<%= form_tag censuses_path, multipart: true, class: 'form' do %>
|
|
38
|
-
<%= label_tag :name, t('admin.new.file', scope: 'decidim.file_authorization_handler') %>
|
|
39
|
-
<%= file_field_tag :file %>
|
|
40
|
-
<%= submit_tag t('admin.new.submit', scope: 'decidim.file_authorization_handler'), class: 'button button__sm button__secondary hollow tiny button--title' %>
|
|
41
|
-
<% end %>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
26
|
</div>
|
data/config/locales/ca.yml
CHANGED
|
@@ -32,14 +32,16 @@ ca:
|
|
|
32
32
|
censuses:
|
|
33
33
|
create:
|
|
34
34
|
success: S'han importat amb èxit %{count} elements (%{errors} errors)
|
|
35
|
+
invalid_format: "Format de fitxer no vàlid. Només s'admeten fitxers CSV."
|
|
35
36
|
destroy:
|
|
36
37
|
success: S'han esborrat totes les dades censals
|
|
37
38
|
menu:
|
|
38
39
|
census: Pujar cens
|
|
39
40
|
show:
|
|
40
41
|
title: Dades del cens carregat
|
|
42
|
+
import_csv: Importa un CSV
|
|
41
43
|
data: Hi ha un total de %{count} registres carregats. La última càrrega va ser el dia %{due_date}
|
|
42
|
-
empty: Encara no hi ha dades censals carregades. Utilitza el
|
|
44
|
+
empty: Encara no hi ha dades censals carregades. Utilitza el botó "Importa un CSV" de dalt per importar un fitxer CSV.
|
|
43
45
|
new:
|
|
44
46
|
title: Pujar un nou cens
|
|
45
47
|
file: Arxiu excel .csv amb les dades del cens
|
data/config/locales/en.yml
CHANGED
|
@@ -32,14 +32,16 @@ en:
|
|
|
32
32
|
censuses:
|
|
33
33
|
create:
|
|
34
34
|
success: Successfully imported %{count} items (%{errors} errors)
|
|
35
|
+
invalid_format: "Invalid file format. Only CSV files are accepted."
|
|
35
36
|
destroy:
|
|
36
37
|
success: All census data have been deleted
|
|
37
38
|
menu:
|
|
38
39
|
census: Upload census
|
|
39
40
|
show:
|
|
40
41
|
title: Current census data
|
|
42
|
+
import_csv: Import CSV
|
|
41
43
|
data: There are %{count} records loaded in total. Last upload date was on %{due_date}
|
|
42
|
-
empty: There are no census data. Use the
|
|
44
|
+
empty: There are no census data. Use the "Import CSV" button above to import it using a CSV file.
|
|
43
45
|
new:
|
|
44
46
|
title: Upload a new census
|
|
45
47
|
file: Excel .csv file with census data
|
data/config/locales/es.yml
CHANGED
|
@@ -19,7 +19,7 @@ es:
|
|
|
19
19
|
fields:
|
|
20
20
|
birthdate: Fecha de nacimiento
|
|
21
21
|
file_authorization_handler:
|
|
22
|
-
|
|
22
|
+
upload_info:
|
|
23
23
|
format: 'Debe ser un fichero generado por excel y exportado en formato CSV con dos columnas:'
|
|
24
24
|
errors:
|
|
25
25
|
messages:
|
|
@@ -32,14 +32,16 @@ es:
|
|
|
32
32
|
censuses:
|
|
33
33
|
create:
|
|
34
34
|
success: Se han importado con éxito %{count} elementos (%{errors} errores)
|
|
35
|
+
invalid_format: "Formato de archivo no válido. Solo se admiten ficheros CSV."
|
|
35
36
|
destroy:
|
|
36
37
|
success: Se han borrado todos los datos censales
|
|
37
38
|
menu:
|
|
38
39
|
census: Subir censo
|
|
39
40
|
show:
|
|
40
41
|
title: Datos de censo actuales
|
|
42
|
+
import_csv: Importar CSV
|
|
41
43
|
data: Hay un total de %{count} registros cargados. La última carga fue el día %{due_date}
|
|
42
|
-
empty: No hay datos censales. Usa el
|
|
44
|
+
empty: No hay datos censales. Usa el botón "Importar CSV" de arriba para importar un fichero CSV.
|
|
43
45
|
new:
|
|
44
46
|
title: Subir un nuevo censo
|
|
45
47
|
file: Archivo excel .csv con los datos del censo
|
|
@@ -6,7 +6,7 @@ module Decidim
|
|
|
6
6
|
isolate_namespace Decidim::FileAuthorizationHandler::Admin
|
|
7
7
|
|
|
8
8
|
routes do
|
|
9
|
-
resource :censuses, only: [:show, :create, :destroy]
|
|
9
|
+
resource :censuses, only: [:show, :new, :create, :destroy]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
initializer "decidim_file_authorization.add_admin_menu" do
|
|
@@ -6,12 +6,6 @@ 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"
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module FileAuthorizationHandler
|
|
5
|
-
DECIDIM_VERSION = "0.
|
|
5
|
+
DECIDIM_VERSION = "0.31.6"
|
|
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}.1".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.31.6.1
|
|
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-04 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.31.6
|
|
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.31.6
|
|
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.31.6
|
|
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.31.6
|
|
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.31.6
|
|
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.31.6
|
|
71
57
|
description: Census uploads via csv files
|
|
72
58
|
email:
|
|
73
59
|
- hola@marsbased.com
|
|
@@ -88,6 +74,7 @@ files:
|
|
|
88
74
|
- app/permissions/decidim/file_authorization_handler/admin/permissions.rb
|
|
89
75
|
- app/services/file_authorization_handler.rb
|
|
90
76
|
- app/views/decidim/file_authorization_handler/admin/censuses/_upload_info.html.erb
|
|
77
|
+
- app/views/decidim/file_authorization_handler/admin/censuses/new.html.erb
|
|
91
78
|
- app/views/decidim/file_authorization_handler/admin/censuses/show.html.erb
|
|
92
79
|
- app/views/layouts/file_authorization_handler/application.html.erb
|
|
93
80
|
- config/locales/ca.yml
|
|
@@ -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
|