decidim-direct_verifications 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d0c77bd7a23a324cffa17539eedb6d2fd8bfbcfafe08f0b77cbc75035d59262
4
- data.tar.gz: 8d0f5a889569f909f2b8d6dafaf59959c7b7523ba2e9d5659dbe319b201de993
3
+ metadata.gz: 42d98e0b62840fec678713b3538cc6c6bc10c1a76e813e02e0ce6a848b65924e
4
+ data.tar.gz: 811a6783064250e01d8bed38e68495a341774ce7a86c1927e65719263c465f6a
5
5
  SHA512:
6
- metadata.gz: d15873f3e2da17204d2de7e5b880288c5c4643414ae0eb847a646588855c4e2def9b641235ffb0231afabddba618524ede04baec25366af6efda6c4f88d87b9d
7
- data.tar.gz: 1ccce49b7915f7d6fc67ec7ed057dfcbf5d2a061ffc5bc624832462afe1d9bc0382f39f2efe3e4b309c7533e0846161711a443155fe5fae7c0bc57d3ecf31ed4
6
+ metadata.gz: 96b417c297794fa7c6e8cef31d7627b0cfe961e10005a3f6eaa57a42f46830d408f021f850ff949daa1756884cb814985af6f0a789c566403faca55d80f4804b
7
+ data.tar.gz: b0ca0ef2dc79844b1d3d1ff48284debe43c32d0f581fb33ef868d9a9707f46ff82dc30914670c1ce0a8ad9e7e5d27dde577bb05f2327df2f489a7336643af90b
@@ -15,15 +15,17 @@ module Decidim
15
15
  def call
16
16
  return broadcast(:invalid) unless form.valid?
17
17
 
18
+ save_or_upload_file!
18
19
  case action
19
20
  when :register
20
- register_users_async
21
+ register_users_async(remove_file: true)
22
+ when :authorize
23
+ authorize_users_async(remove_file: true)
21
24
  when :register_and_authorize
22
25
  register_users_async
23
- file.rewind
24
- authorize_users_async
26
+ authorize_users_async(remove_file: true)
25
27
  when :revoke
26
- revoke_users_async
28
+ revoke_users_async(remove_file: true)
27
29
  end
28
30
 
29
31
  broadcast(:ok)
@@ -33,16 +35,25 @@ module Decidim
33
35
 
34
36
  attr_reader :form, :file, :organization, :user, :action
35
37
 
36
- def register_users_async
37
- RegisterUsersJob.perform_later(file.read, organization, user, form.authorization_handler)
38
+ def register_users_async(options = {})
39
+ RegisterUsersJob.perform_later(secure_name, organization, user, form.authorization_handler, options)
40
+ end
41
+
42
+ def revoke_users_async(options = {})
43
+ RevokeUsersJob.perform_later(secure_name, organization, user, form.authorization_handler, options)
44
+ end
45
+
46
+ def authorize_users_async(options = {})
47
+ AuthorizeUsersJob.perform_later(secure_name, organization, user, form.authorization_handler, options)
38
48
  end
39
49
 
40
- def revoke_users_async
41
- RevokeUsersJob.perform_later(file.read, organization, user, form.authorization_handler)
50
+ def save_or_upload_file!
51
+ file.instance_variable_set(:@original_filename, secure_name)
52
+ CsvUploader.new(organization).store!(file)
42
53
  end
43
54
 
44
- def authorize_users_async
45
- AuthorizeUsersJob.perform_later(file.read, organization, user, form.authorization_handler)
55
+ def secure_name
56
+ @secure_name ||= "#{SecureRandom.uuid}#{File.extname(file.tempfile)}"
46
57
  end
47
58
  end
48
59
  end
@@ -10,6 +10,8 @@ module Decidim
10
10
  def index
11
11
  enforce_permission_to :index, :authorization
12
12
  @authorizations = collection.includes(:user)
13
+ .page(params[:page])
14
+ .per(15)
13
15
  end
14
16
 
15
17
  def destroy
@@ -8,7 +8,9 @@ module Decidim
8
8
  class NullSession; end
9
9
 
10
10
  def process_users
11
+ Rails.logger.info "AuthorizeUsersJob: Authorizing #{emails.count} emails"
11
12
  emails.each do |email, data|
13
+ Rails.logger.debug "AuthorizeUsersJob: Authorizing #{email}"
12
14
  AuthorizeUser.new(
13
15
  email,
14
16
  data,
@@ -10,20 +10,36 @@ module Decidim
10
10
  class BaseImportJob < ApplicationJob
11
11
  queue_as :default
12
12
 
13
- def perform(userslist, organization, current_user, authorization_handler)
14
- @emails = Parsers::MetadataParser.new(userslist).to_h
13
+ def perform(filename, organization, current_user, authorization_handler, options = {})
14
+ @filename = filename
15
15
  @organization = organization
16
16
  @current_user = current_user
17
- @instrumenter = Instrumenter.new(current_user)
18
17
  @authorization_handler = authorization_handler
19
18
 
20
- process_users
21
- send_email_notification
19
+ begin
20
+ @emails = Parsers::MetadataParser.new(userslist).to_h
21
+ @instrumenter = Instrumenter.new(current_user)
22
+
23
+ Rails.logger.info "BaseImportJob: Processing file #{filename}"
24
+ process_users
25
+ send_email_notification
26
+ rescue StandardError => e
27
+ Rails.logger.error "BaseImportJob Error: #{e.message} #{e.backtrace.filter { |f| f =~ /direct_verifications/ }}"
28
+ end
29
+ remove_file! if options.fetch(:remove_file, false)
22
30
  end
23
31
 
24
32
  private
25
33
 
26
- attr_reader :emails, :organization, :current_user, :instrumenter, :authorization_handler
34
+ attr_reader :uploader, :filename, :emails, :organization, :current_user, :instrumenter, :authorization_handler
35
+
36
+ def userslist
37
+ return @userslist if @userslist
38
+
39
+ @uploader = CsvUploader.new(organization)
40
+ @uploader.retrieve_from_store!(filename)
41
+ @userslist = @uploader.file.read.force_encoding("UTF-8")
42
+ end
27
43
 
28
44
  def send_email_notification
29
45
  ImportMailer.finished_processing(
@@ -33,6 +49,10 @@ module Decidim
33
49
  authorization_handler
34
50
  ).deliver_now
35
51
  end
52
+
53
+ def remove_file!
54
+ uploader.remove!
55
+ end
36
56
  end
37
57
  end
38
58
  end
@@ -6,6 +6,7 @@ module Decidim
6
6
  module DirectVerifications
7
7
  class RegisterUsersJob < BaseImportJob
8
8
  def process_users
9
+ Rails.logger.info "RegisterUsersJob: Registering #{emails.count} emails"
9
10
  emails.each do |email, data|
10
11
  RegisterUser.new(email, data, organization, current_user, instrumenter).call
11
12
  end
@@ -4,6 +4,7 @@ module Decidim
4
4
  module DirectVerifications
5
5
  class RevokeUsersJob < BaseImportJob
6
6
  def process_users
7
+ Rails.logger.info "RevokeUsersJob: Revoking #{emails.count} emails"
7
8
  emails.each do |email, _name|
8
9
  RevokeUser.new(email, organization, instrumenter, authorization_handler).call
9
10
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DirectVerifications
5
+ class CsvUploader < ApplicationUploader
6
+ # Override the directory where uploaded files will be stored.
7
+ def store_dir
8
+ default_path = "uploads/direct-verifications/"
9
+
10
+ return File.join(Decidim.base_uploads_path, default_path) if Decidim.base_uploads_path.present?
11
+
12
+ default_path
13
+ end
14
+ end
15
+ end
16
+ end
@@ -37,6 +37,7 @@
37
37
  <% end %>
38
38
  </tbody>
39
39
  </table>
40
+ <%= paginate @authorizations, theme: "decidim" %>
40
41
  </div>
41
42
  </div>
42
43
  </div>
@@ -1,4 +1,3 @@
1
- ---
2
1
  ca:
3
2
  decidim:
4
3
  admin:
@@ -11,10 +10,10 @@ ca:
11
10
  admin:
12
11
  direct_verifications:
13
12
  help:
14
- - 'Permet la introducció massiva de participants per tal de:'
15
- - Registrar-les directament a la organització amb l'enviament d'invitacions
16
- - Verificar-les amb qualsevol mètode de verificació actiu
17
- - Revocar la verificació amb qualsevol mètode de verificació actiu
13
+ - 'Permet la introducció massiva de participants per tal de:'
14
+ - Registrar-les directament a la organització amb l'enviament d'invitacions
15
+ - Verificar-les amb qualsevol mètode de verificació actiu
16
+ - Revocar la verificació amb qualsevol mètode de verificació actiu
18
17
  direct_verifications:
19
18
  explanation: Verificació manual per part de les administradores de l'organització
20
19
  name: Verificació directa
@@ -31,33 +30,21 @@ ca:
31
30
  user_name: Nom de la participant
32
31
  direct_verifications:
33
32
  create:
34
- authorized: S'han verificat correctament %{authorized} participants utilitzant
35
- [%{handler}] (%{count} detectats, %{errors} errors)
36
- info: S'han detectat %{count} participants, de les quals %{registered} estan
37
- registrades, %{authorized} autoritzades utilitzant [%{handler}] (%{unconfirmed}
38
- sense confirmar)
33
+ authorized: "S'han verificat correctament %{authorized} participants utilitzant [%{handler}] (%{count} detectats, %{errors} errors)"
34
+ info: "S'han detectat %{count} participants, de les quals %{registered} estan registrades, %{authorized} autoritzades utilitzant [%{handler}] (%{unconfirmed} sense confirmar)"
39
35
  missing_header: Si us plau, proporcioneu una fila d'encapçalament
40
- registered: S'han registrat correctament %{registered} participants (%{count}
41
- detectades, %{errors} errors)
42
- revoked: S'ha revocat correctament la verificació de %{revoked} participants
43
- utilitzant [%{handler}] (%{count} detectades, %{errors} errors)
44
- gdpr_disclaimer: Feu-ho sota la vostra responsabilitat. Recordeu que heu
45
- de tenir el consentiment explícit de les vostres participants per a registrar-les.
46
- En cas contrari, estareu infringint la regulació GDPR als països de
47
- la UE.
36
+ registered: "S'han registrat correctament %{registered} participants (%{count} detectades, %{errors} errors)"
37
+ revoked: S'ha revocat correctament la verificació de %{revoked} participants utilitzant [%{handler}] (%{count} detectades, %{errors} errors)
38
+ gdpr_disclaimer: Feu-ho sota la vostra responsabilitat. Recordeu que heu de tenir el consentiment explícit de les vostres participants per a registrar-les. En cas contrari, estareu infringint la regulació GDPR als països de la UE.
48
39
  imports:
49
40
  create:
50
41
  error: No s'ha pogut importar el fitxer
51
42
  success: S'ha importat el fitxer. Rebràs un email quan totes les participants hagin estat importades.
52
43
  mailer:
53
- authorized: "%{successful} participants han estat verificades utilitzant
54
- [%{handler}] (%{count} detectades, %{errors} errors)"
55
- info: "%{count} participants detectades, de les quals %{registered} estan registrades,
56
- %{authorized} autoritzades utilitzant [%{handler}] (%{unconfirmed} sense confirmar)"
57
- registered: "%{successful} participants han estat registrades (%{count}
58
- detectades, %{errors} errors) "
59
- revoked: S'ha revocat correctament la verificació de %{successful} participants utilitzant
60
- [%{handler}] (%{count} detectades, %{errors} errors)
44
+ authorized: "%{successful} participants han estat verificades utilitzant [%{handler}] (%{count} detectades, %{errors} errors)"
45
+ info: "%{count} participants detectades, de les quals %{registered} estan registrades, %{authorized} autoritzades utilitzant [%{handler}] (%{unconfirmed} sense confirmar)"
46
+ registered: "%{successful} participants han estat registrades (%{count} detectades, %{errors} errors) "
47
+ revoked: S'ha revocat correctament la verificació de %{successful} participants utilitzant [%{handler}] (%{count} detectades, %{errors} errors)
61
48
  subject: Resultats de la importació
62
49
  new:
63
50
  file: Fitxer CSV amb dades de participants
@@ -71,9 +58,7 @@ ca:
71
58
  authorization_handler: Mètode de verificació
72
59
  authorize: Autoritza les participants
73
60
  check: Comprova l'estat de les participants
74
- info_html: Pots <a href=%{link}>importar un fitxer CSV</a> o introduir els emails
75
- aquí, un per línia. Si els emails estan precedits
76
- per un text, aquest s'interpretarà com el nom de la participant
61
+ info_html: Pots <a href=%{link}>importar un fitxer CSV</a> o introduir els emails aquí, un per línia. Si els emails estan precedits per un text, aquest s'interpretarà com el nom de la participant
77
62
  register: Registra les participants a la plataforma (si existeixen s'ignoraran)
78
63
  revoke: Revoca l'autorització de les participants
79
64
  submit: Envia i processa el llistat
@@ -1,4 +1,3 @@
1
- ---
2
1
  cs:
3
2
  decidim:
4
3
  admin:
@@ -11,10 +10,10 @@ cs:
11
10
  admin:
12
11
  direct_verifications:
13
12
  help:
14
- - 'Umožňuje masivní zavedení uživatelů:'
15
- - Přímá registrace v organizaci a odeslání pozvánek
16
- - Ověřit je pomocí jakékoliv metody aktivního ověření
17
- - Zrušit jejich ověření pomocí jakékoli metody aktivního ověření
13
+ - 'Umožňuje masivní zavedení uživatelů:'
14
+ - Přímá registrace v organizaci a odeslání pozvánek
15
+ - Ověřit je pomocí jakékoliv metody aktivního ověření
16
+ - Zrušit jejich ověření pomocí jakékoli metody aktivního ověření
18
17
  direct_verifications:
19
18
  explanation: Ruční ověření správcem organizace
20
19
  name: Přímé ověření
@@ -31,17 +30,26 @@ cs:
31
30
  user_name: Uživatelské jméno
32
31
  direct_verifications:
33
32
  create:
34
- authorized: "%{authorized} uživatelů bylo úspěšně ověřeno pomocí [%{handler}]
35
- (%{count} detekováno, %{errors} chyb)"
36
- info: Zjištěno %{count} uživatelů, z nichž %{registered} jsou registrováni,
37
- %{authorized} autorizováni pomocí [%{handler}] (%{unconfirmed} nepotvrzeno)
38
- registered: "%{registered} uživatelů bylo úspěšně zaregistrováno (%{count}
39
- detekováno, %{errors} chyb) "
40
- revoked: Ověření od %{revoked} uživatelů bylo zrušeno pomocí [%{handler}]
41
- (%{count} detekováno, %{errors} chyb)
42
- gdpr_disclaimer: Udělejte to v rámci vaší odpovědnosti. Nezapomeňte, že
43
- potřebujete mít výslovný souhlas svých uživatelů, abyste je mohli zaregistrovat.
44
- V opačném případě můžete porušovat nařízení o GDPR v zemích EU.
33
+ authorized: "%{authorized} uživatelů bylo úspěšně ověřeno pomocí [%{handler}] (%{count} detekováno, %{errors} chyb)"
34
+ info: "Zjištěno %{count} uživatelů, z nichž %{registered} jsou registrováni, %{authorized} autorizováni pomocí [%{handler}] (%{unconfirmed} nepotvrzeno)"
35
+ missing_header: Zadejte řádek záhlaví
36
+ registered: "%{registered} uživatelů bylo úspěšně zaregistrováno (%{count} detekováno, %{errors} chyb) "
37
+ revoked: Ověření od %{revoked} uživatelů bylo zrušeno pomocí [%{handler}] (%{count} detekováno, %{errors} chyb)
38
+ gdpr_disclaimer: Udělejte to v rámci vaší odpovědnosti. Nezapomeňte, že potřebujete mít výslovný souhlas svých uživatelů, abyste je mohli zaregistrovat. V opačném případě můžete porušovat nařízení o GDPR v zemích EU.
39
+ imports:
40
+ create:
41
+ error: Při importu souboru došlo k chybě
42
+ success: Soubor byl úspěšně nahrán. budou importováni všichni účastníci, pošleme vám e-mail.
43
+ mailer:
44
+ authorized: "%{successful} účastníků bylo úspěšně ověřeno pomocí [%{handler}] (%{count} detekováno, %{errors} chyby)"
45
+ info: "%{count} účastníků detekováno, z toho %{registered} jsou registrováni, %{authorized} povoleno pomocí [%{handler}] (%{unconfirmed} nepotvrzeno)"
46
+ registered: "%{successful} účastníků bylo úspěšně registrováno (%{count} detekováno, %{errors} chyb) "
47
+ revoked: Ověření od %{successful} účastníků bylo zrušeno pomocí [%{handler}] (%{count} detekováno, %{errors} chyby)
48
+ subject: Výsledky importu souboru
49
+ new:
50
+ file: Soubor CSV s daty účastníků
51
+ info: Importovat CSV soubor s účastníkem na řádku, který zkopíruje formát z příkladu
52
+ submit: Nahrát soubor
45
53
  index:
46
54
  authorizations: Autorizovaní uživatelé
47
55
  stats: Statistiky uživatelů
@@ -50,8 +58,7 @@ cs:
50
58
  authorization_handler: Ověřovací metoda
51
59
  authorize: Autorizovat uživatele
52
60
  check: Zkontrolovat stav uživatelů
53
- info: Zadejte e-maily zde, jeden na řádek. Pokud e-mailům předchází text,
54
- bude interpretován jako jméno uživatele
61
+ info_html: Můžete <a href=%{link}>importovat CSV</a> nebo zde zadat e-maily, jedno na řádek. Pokud e-mailům předchází text, bude interpretován jako jméno účastníka.
55
62
  register: Registrovat uživatele na platformě (pokud existují, budou ignorováni)
56
63
  revoke: Zrušit autorizaci od uživatelů
57
64
  submit: Odeslat a zpracovat seznam
@@ -1,4 +1,3 @@
1
- ---
2
1
  es:
3
2
  decidim:
4
3
  admin:
@@ -11,10 +10,10 @@ es:
11
10
  admin:
12
11
  direct_verifications:
13
12
  help:
14
- - 'Permite la introducción masiva de participantes con el fin de:'
15
- - Registrarlas directamente en la organización con el envío de invitaciones
16
- - Verificarlas con cualquier método de verificación activo
17
- - Revocar la verificación con cualquier método de verificación activo
13
+ - 'Permite la introducción masiva de participantes con el fin de:'
14
+ - Registrarlas directamente en la organización con el envío de invitaciones
15
+ - Verificarlas con cualquier método de verificación activo
16
+ - Revocar la verificación con cualquier método de verificación activo
18
17
  direct_verifications:
19
18
  explanation: Verificación manual por parte de las administradoras de la organización
20
19
  name: Verificación directa
@@ -31,33 +30,21 @@ es:
31
30
  user_name: Nombre de la participante
32
31
  direct_verifications:
33
32
  create:
34
- authorized: Se han verificado correctamente %{authorized} participantes usando
35
- [%{handler}] (%{count} detectadas, %{errors} errores)
36
- info: Se han detectado %{count} participantes, de las cuales %{registered}
37
- están registradas, %{authorized} autorizadas usando [%{handler}] (%{unconfirmed}
38
- sin confirmar)
33
+ authorized: "Se han verificado correctamente %{authorized} participantes usando [%{handler}] (%{count} detectadas, %{errors} errores)"
34
+ info: "Se han detectado %{count} participantes, de las cuales %{registered} están registradas, %{authorized} autorizadas usando [%{handler}] (%{unconfirmed} sin confirmar)"
39
35
  missing_header: Por favor, proporciona una fila de encabezamiento
40
- registered: Se han registrado correctamente %{registered} participantes (%{count}
41
- detectadas, %{errors} errores)
42
- revoked: Se ha revocado correctamente la verificación de %{revoked} participantes
43
- usando [%{handler}] (%{count} detectadas, %{errors} errores)
44
- gdpr_disclaimer: Haz esto bajo tu responsabilidad. Recuerda que debes
45
- contar con el consentimiento explícito de las participantes para poder registrarlas.
46
- De lo contrario, estarás infringiendo la regulación GDPR en los países
47
- de la UE.
36
+ registered: "Se han registrado correctamente %{registered} participantes (%{count} detectadas, %{errors} errores)"
37
+ revoked: Se ha revocado correctamente la verificación de %{revoked} participantes usando [%{handler}] (%{count} detectadas, %{errors} errores)
38
+ gdpr_disclaimer: Haz esto bajo tu responsabilidad. Recuerda que debes contar con el consentimiento explícito de las participantes para poder registrarlas. De lo contrario, estarás infringiendo la regulación GDPR en los países de la UE.
48
39
  imports:
49
40
  create:
50
41
  error: Ha habido un error al importar el archivo.
51
42
  success: Se ha importado el archivo. Recibirás un email cuando todas las participantes hayan sido importadas.
52
43
  mailer:
53
- authorized: "%{successful} participantes han sido verificadas usando
54
- [%{handler}] (%{count} detectades, %{errors} errores)"
55
- info: "%{count} participantes detectadas, de las cuales %{registered} están registradas,
56
- %{authorized} autorizadas usando [%{handler}] (%{unconfirmed} sin confirmar)"
57
- registered: "%{successful} participantes han sido registradas (%{count}
58
- detectadas, %{errors} errores) "
59
- revoked: Se ha revocado correctamente la verificación de %{successful} participantes usando
60
- [%{handler}] (%{count} detectadas, %{errors} errores)
44
+ authorized: "%{successful} participantes han sido verificadas usando [%{handler}] (%{count} detectades, %{errors} errores)"
45
+ info: "%{count} participantes detectadas, de las cuales %{registered} están registradas, %{authorized} autorizadas usando [%{handler}] (%{unconfirmed} sin confirmar)"
46
+ registered: "%{successful} participantes han sido registradas (%{count} detectadas, %{errors} errores) "
47
+ revoked: Se ha revocado correctamente la verificación de %{successful} participantes usando [%{handler}] (%{count} detectadas, %{errors} errores)
61
48
  subject: Resultados de la importación
62
49
  new:
63
50
  file: Archivo CSV con datos de participantes
@@ -71,8 +58,7 @@ es:
71
58
  authorization_handler: Método de verificación
72
59
  authorize: Autoriza las participantes
73
60
  check: Comprueba el estado de las participantes
74
- info_html: Puedes <a href=%{link}>importar un fichero CSV</a> o introducir aquí los emails, uno por linea. Si los emails están precedidos
75
- por un texto, éste se interpretará como el nombre de la participante
61
+ info_html: Puedes <a href=%{link}>importar un fichero CSV</a> o introducir aquí los emails, uno por linea. Si los emails están precedidos por un texto, éste se interpretará como el nombre de la participante
76
62
  register: Registra las participantes a la plataforma (si existen se ignorarán)
77
63
  revoke: Revoca la autorización de las participantes
78
64
  submit: Envía y procesa el listado
@@ -1,4 +1,3 @@
1
- ---
2
1
  fr:
3
2
  decidim:
4
3
  admin:
@@ -11,10 +10,10 @@ fr:
11
10
  admin:
12
11
  direct_verifications:
13
12
  help:
14
- - 'Permet l''introduction massive des utilisateurs afin de :'
15
- - Inscription directe au sein de l'organisation et envoie des invitations
16
- - Vérifiez-les avec n'importe quelle méthode de vérification active
17
- - Révoquer leur vérification dans toute méthode de vérification active
13
+ - 'Permet l''introduction massive des utilisateurs afin de :'
14
+ - Inscription directe au sein de l'organisation et envoie des invitations
15
+ - Vérifiez-les avec n'importe quelle méthode de vérification active
16
+ - Révoquer leur vérification dans toute méthode de vérification active
18
17
  direct_verifications:
19
18
  explanation: Vérification manuelle par les administrateurs de l'organisation
20
19
  name: Vérification directe
@@ -31,19 +30,26 @@ fr:
31
30
  user_name: Nom de l'utilisateur
32
31
  direct_verifications:
33
32
  create:
34
- authorized: "%{authorized} utilisateurs ont été vérifiés avec succès
35
- en utilisant [%{handler}] (%{count} détectés, %{errors} erreurs)"
36
- info: "%{count} utilisateurs détectés, dont %{registered} sont enregistrés,
37
- %{authorized} autorisés à utiliser [%{handler}] (%{unconfirmed} non
38
- confirmés)"
39
- registered: "%{registered} utilisateurs ont été enregistrés avec succès
40
- (%{count} détectés, %{errors} erreurs) "
41
- revoked: La vérification de %{revoked} utilisateurs ont été révoqués
42
- en utilisant [%{handler}] (%{count} détectés, %{errors} erreurs)
43
- gdpr_disclaimer: Faites-le sous votre responsabilité. N'oubliez pas que
44
- vous devez avoir le consentement explicite de vos utilisateurs afin
45
- de les enregistrer. Dans le cas contraire, vous enfreindrez le règlement
46
- du RGPD dans les pays de l'UE.
33
+ authorized: "%{authorized} utilisateurs ont été vérifiés avec succès en utilisant [%{handler}] (%{count} détectés, %{errors} erreurs)"
34
+ info: "%{count} utilisateurs détectés, dont %{registered} sont enregistrés, %{authorized} autorisés à utiliser [%{handler}] (%{unconfirmed} non confirmés)"
35
+ missing_header: Please, provide a header row
36
+ registered: "%{registered} utilisateurs ont été enregistrés avec succès (%{count} détectés, %{errors} erreurs) "
37
+ revoked: La vérification de %{revoked} utilisateurs ont été révoqués en utilisant [%{handler}] (%{count} détectés, %{errors} erreurs)
38
+ gdpr_disclaimer: Faites-le sous votre responsabilité. N'oubliez pas que vous devez avoir le consentement explicite de vos utilisateurs afin de les enregistrer. Dans le cas contraire, vous enfreindrez le règlement du RGPD dans les pays de l'UE.
39
+ imports:
40
+ create:
41
+ error: There was an error importing the file
42
+ success: File successfully uploaded. We'll email you when all participants are imported.
43
+ mailer:
44
+ authorized: "%{successful} participants have been successfully verified using [%{handler}] (%{count} detected, %{errors} errors)"
45
+ info: "%{count} participants detected, of which %{registered} are registered, %{authorized} authorized using [%{handler}] (%{unconfirmed} unconfirmed)"
46
+ registered: "%{successful} participants have been successfully registered (%{count} detected, %{errors} errors) "
47
+ revoked: Verification from %{successful} participants have been revoked using [%{handler}] (%{count} detected, %{errors} errors)
48
+ subject: File import results
49
+ new:
50
+ file: CSV file with participants data
51
+ info: Import a CSV file with a participant entry per line copying the format from the example below
52
+ submit: Upload file
47
53
  index:
48
54
  authorizations: Utilisateurs autorisés
49
55
  stats: Statistiques des utilisateurs
@@ -52,10 +58,8 @@ fr:
52
58
  authorization_handler: Méthode de vérification
53
59
  authorize: Utilisateurs autorisés
54
60
  check: Vérifier le statut des utilisateurs
55
- info: Entrez les e-mails ici, un par ligne. Si les e-mails sont précédés
56
- d'un texte, il sera interprété comme le nom de l'utilisateur
57
- register: Inscrire des utilisateurs sur la plateforme (si ils existent,
58
- ils seront ignorés)
61
+ info_html: You can <a href=%{link}>import a CSV</a> or enter the emails here, one per line. If the emails are preceded by a text, it will be interpreted as the participant's name.
62
+ register: Inscrire des utilisateurs sur la plateforme (si ils existent, ils seront ignorés)
59
63
  revoke: Révoquer l'autorisation des utilisateurs
60
64
  submit: Envoyer et traiter la liste
61
65
  textarea: Liste d'emails
@@ -10,9 +10,9 @@ module Decidim
10
10
 
11
11
  def header
12
12
  @header ||= begin
13
- header_row = lines[0].chomp
14
- header_row = tokenize(header_row)
15
- normalize_header(header_row)
13
+ raise InputParserError, I18n.t("#{I18N_SCOPE}.create.missing_header") if lines.count <= 1
14
+
15
+ tokenize(lines[0].chomp).map { |h| h.to_s.downcase }
16
16
  end
17
17
  end
18
18
 
@@ -25,6 +25,8 @@ module Decidim
25
25
 
26
26
  hash = {}
27
27
  header.each_with_index do |column, index|
28
+ next if column.blank?
29
+
28
30
  value = tokens[index]
29
31
  next if value&.include?(email)
30
32
 
@@ -40,14 +42,6 @@ module Decidim
40
42
  token&.strip
41
43
  end
42
44
  end
43
-
44
- def normalize_header(line)
45
- line.map do |field|
46
- raise InputParserError, I18n.t("#{I18N_SCOPE}.create.missing_header") if field.nil?
47
-
48
- field.to_sym.downcase
49
- end
50
- end
51
45
  end
52
46
  end
53
47
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # This holds the decidim-direct_verifications version.
5
5
  module DirectVerifications
6
- VERSION = "1.0.1"
6
+ VERSION = "1.0.2"
7
7
  DECIDIM_VERSION = "0.24.3"
8
8
  MIN_DECIDIM_VERSION = ">= 0.23.0"
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-direct_verifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Vergés
@@ -70,6 +70,7 @@ files:
70
70
  - app/jobs/decidim/direct_verifications/revoke_users_job.rb
71
71
  - app/mailers/decidim/direct_verifications/import_mailer.rb
72
72
  - app/mailers/decidim/direct_verifications/stats.rb
73
+ - app/uploaders/decidim/direct_verifications/csv_uploader.rb
73
74
  - app/views/decidim/direct_verifications/import_mailer/finished_processing.html.erb
74
75
  - app/views/decidim/direct_verifications/import_mailer/finished_processing.text.erb
75
76
  - app/views/decidim/direct_verifications/verification/admin/authorizations/index.html.erb