decidim-cleaner 0.1.0 → 1.0.0

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: c1e9caaddab424c8f9e7f90ae9b768821eb59a2c4084920087b753d23113bb78
4
- data.tar.gz: 357866aea4f46dbc6cce35b2a2824f2ace75f9488704ae982e1a9855132c1a87
3
+ metadata.gz: d719f430907247b84a0cc288639ab222c6120d27e6dc407d6b04f5547fe82a2e
4
+ data.tar.gz: f176026b4e7218680433e383c266587ce6fa47ea360ac42972452bc4e4446b73
5
5
  SHA512:
6
- metadata.gz: b19b452a1070f8d826a5dd71989cad8eee27cfac1c90c58bced93c916e10553d5a5694c24728291d00f0c1017e049db0227cfc2168ac7e6f56b319c41342f0ee
7
- data.tar.gz: 717d7ad9eed4605e7700bdf7e4175042c01812296f2bc1ff2ad3ab95cdc204e85cec95ac0a23eceb8db60bc86c93847aa71e90f3499db2771d696a26e3da48e1
6
+ metadata.gz: 148df6e0913bb0965c4660449f332a647bac902d1ce35c902880ac7e11b4ce07515bef36b7b92d238e2259ba6dc9f4a4d9f956e24e070bcd4ddb4205f8146048
7
+ data.tar.gz: '073996a639f9961296aea2a95329e400441524e5a088f04fcfa6bf130d81be7658fc29ed4a66d3e5fbbf4b34c38e77f067c48eb0ad03782df06c9eab1bc42823'
@@ -17,18 +17,23 @@ module Decidim
17
17
  end
18
18
 
19
19
  def send_warning(users)
20
- users.each do |user|
20
+ users.find_each do |user|
21
+ next if user.deleted?
22
+
21
23
  InactiveUsersMailer.warning_inactive(user).deliver_now
22
24
  Rails.logger.info "Inactive warning sent to #{user.email}"
23
25
  end
24
26
  end
25
27
 
26
28
  def delete_user_and_send_email(users)
27
- users.each do |user|
29
+ users.find_each do |user|
30
+ next if user.deleted?
31
+
28
32
  InactiveUsersMailer.warning_deletion(user).deliver_now
29
33
  Rails.logger.info "Deletion warning sent to #{user.email}"
30
- user.delete
31
- Rails.logger.info "User #{user.email} deleted"
34
+
35
+ Decidim::DestroyAccount.call(user, Decidim::DeleteAccountForm.from_params({ delete_reason: I18n.t("decidim.cleaner.delete_reason") }))
36
+ Rails.logger.info "User with id #{user.id} destroyed"
32
37
  end
33
38
  end
34
39
  end
@@ -1,10 +1,15 @@
1
1
  ---
2
2
 
3
3
  base_locale: en
4
- locales: [en]
4
+ locales: [en, fr]
5
5
 
6
6
  ignore_unused:
7
- - "decidim.components.cleaner.name"
7
+ - activemodel.attributes.organization.delete_admin_logs
8
+ - activemodel.attributes.organization.delete_admin_logs_after
9
+ - activemodel.attributes.organization.delete_inactive_users
10
+ - activemodel.attributes.organization.delete_inactive_users_after
11
+ - activemodel.attributes.organization.delete_inactive_users_email_after
12
+ - decidim.admin.menu.clean
8
13
 
9
14
  ignore_missing:
10
- - decidim.participatory_processes.scopes.global
15
+
@@ -7,11 +7,16 @@ en:
7
7
  delete_admin_logs_after: Delete admin logs after (days, default 365)
8
8
  delete_inactive_users: Enable inactive users deletion
9
9
  delete_inactive_users_after: Delete inactive users after (days, default 390)
10
- delete_inactive_users_email_after: Send email to inactive users before deletion (days, default 365)
10
+ delete_inactive_users_email_after: Send email to inactive users before deletion
11
+ (days, default 365)
11
12
  decidim:
12
13
  admin:
13
14
  menu:
14
15
  clean: Data cleaner
16
+ organization:
17
+ update:
18
+ error: There was a problem updating this organization.
19
+ success: Organization updated successfully.
15
20
  cleaner:
16
21
  admin:
17
22
  organization_cleaner:
@@ -20,19 +25,19 @@ en:
20
25
  form:
21
26
  admin_log_cleaner_title: Admin log
22
27
  inactive_users_cleaner_title: Inactive users
28
+ delete_reason: User deleted because of inactivity
23
29
  inactive_users_mailer:
24
30
  warning_deletion:
25
- body_1: You are inactive since %{days} days on <a href="%{organization_url}"> %{organization_name} </a>.
31
+ body_1: You are inactive since %{days} days on <a href="%{organization_url}">
32
+ %{organization_name} </a>.
26
33
  body_2: As a result, your account has been deleted.
27
34
  greetings: Greetings,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
28
35
  hello: Hello
29
36
  subject: Your account has been deleted
30
37
  warning_inactive:
31
38
  body_1: You are inactive since %{days} days on %{organization_name}.
32
- body_2: <a href="%{organization_url}">If no reaction within %{remaining_days} days </a>, your account will be deleted.
39
+ body_2: <a href="%{organization_url}">If no reaction within %{remaining_days}
40
+ days </a>, your account will be deleted.
33
41
  greetings: Greetings,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
34
42
  hello: Hello
35
43
  subject: Your account is inactive
36
- components:
37
- cleaner:
38
- name: Cleaner
@@ -4,14 +4,21 @@ fr:
4
4
  attributes:
5
5
  organization:
6
6
  delete_admin_logs: Activer la suppression de l'historique d'administration
7
- delete_admin_logs_after: Supprimer l'historique d'administration après (jours, par défaut 365)
7
+ delete_admin_logs_after: Supprimer l'historique d'administration après (jours,
8
+ par défaut 365)
8
9
  delete_inactive_users: Activer la suppression des utilisateurs inactifs
9
- delete_inactive_users_after: Supprimer les utilisateurs inactifs après (jours, par défaut 390)
10
- delete_inactive_users_email_after: Envoyer un courriel aux utilisateurs inactifs avant la suppression (jours, par défaut 365)
10
+ delete_inactive_users_after: Supprimer les utilisateurs inactifs après (jours,
11
+ par défaut 390)
12
+ delete_inactive_users_email_after: Envoyer un courriel aux utilisateurs inactifs
13
+ avant la suppression (jours, par défaut 365)
11
14
  decidim:
12
15
  admin:
13
16
  menu:
14
17
  clean: Nettoyeur de données
18
+ organization:
19
+ update:
20
+ error: Une erreur est survenue lors de la mise à jour de l'organisation
21
+ success: L'organisation a été mise à jour avec succès
15
22
  cleaner:
16
23
  admin:
17
24
  organization_cleaner:
@@ -20,19 +27,19 @@ fr:
20
27
  form:
21
28
  admin_log_cleaner_title: Historique d'administration
22
29
  inactive_users_cleaner_title: Utilisateurs inactifs
30
+ delete_reason: Utilisateur supprimé pour inactivité
23
31
  inactive_users_mailer:
24
32
  warning_deletion:
25
- body_1: Vous êtes inactif depuis %{days} jours sur <a href="%{organization_url}"> %{organization_name} </a>.
33
+ body_1: Vous êtes inactif depuis %{days} jours sur <a href="%{organization_url}">
34
+ %{organization_name} </a>.
26
35
  body_2: Par conséquent, votre compte a été supprimé.
27
36
  greetings: Cordialement,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
28
37
  hello: Bonjour
29
38
  subject: Votre compte a été supprimé
30
39
  warning_inactive:
31
40
  body_1: Vous êtes inactif depuis %{days} jours sur %{organization_name}.
32
- body_2: <a href="%{organization_url}">Si aucune réaction dans les %{remaining_days} jours</a>, votre compte sera supprimé.
41
+ body_2: <a href="%{organization_url}">Si aucune réaction dans les %{remaining_days}
42
+ jours</a>, votre compte sera supprimé.
33
43
  greetings: Cordialement,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
34
44
  hello: Bonjour
35
45
  subject: Votre compte est inactif
36
- components:
37
- cleaner:
38
- name: Nettoyeur
@@ -9,6 +9,10 @@ module Decidim
9
9
  paths["db/migrate"] = nil
10
10
  paths["lib/tasks"] = nil
11
11
 
12
+ def load_seed
13
+ nil
14
+ end
15
+
12
16
  initializer "decidim_admin.admin_settings_menu" do
13
17
  Decidim.menu :admin_settings_menu do |menu|
14
18
  menu.add_item :clean_organization,
@@ -19,10 +23,6 @@ module Decidim
19
23
  active: is_active_link?(decidim_admin.edit_organization_cleaner_path)
20
24
  end
21
25
  end
22
-
23
- def load_seed
24
- nil
25
- end
26
26
  end
27
27
  end
28
28
  end
@@ -8,10 +8,6 @@ module Decidim
8
8
  # This is the engine that runs on the public interface of cleaner.
9
9
  class Engine < ::Rails::Engine
10
10
  isolate_namespace Decidim::Cleaner
11
-
12
- initializer "Cleaner.webpacker.assets_path" do
13
- Decidim.register_assets_path File.expand_path("app/packs", root)
14
- end
15
11
  end
16
12
  end
17
13
  end
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  module Decidim
4
5
  # This holds the decidim-meetings version.
5
6
  module Cleaner
6
7
  def self.version
7
- "0.1.0"
8
+ "1.0.0"
8
9
  end
9
10
 
10
11
  def self.decidim_version
11
- "0.28.0.dev"
12
+ "0.26"
12
13
  end
13
14
  end
14
15
  end
16
+ # :nocov:
@@ -3,7 +3,6 @@
3
3
  require "decidim/cleaner/admin"
4
4
  require "decidim/cleaner/engine"
5
5
  require "decidim/cleaner/admin_engine"
6
- require "decidim/cleaner/component"
7
6
 
8
7
  module Decidim
9
8
  # This namespace holds the logic of the `Cleaner` module.
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  namespace :decidim_cleaner do
4
5
  desc "Warns and deletes inactive users"
5
6
  task clean_inactive_users: :environment do
@@ -11,3 +12,4 @@ namespace :decidim_cleaner do
11
12
  Decidim::Cleaner::CleanAdminLogsJob.perform_now
12
13
  end
13
14
  end
15
+ # :nocov:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quentinchampenois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-13 00:00:00.000000000 Z
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.28.0.dev
19
+ version: '0.26'
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.28.0.dev
26
+ version: '0.26'
27
27
  description: Clean outdated data in Decidim's database.
28
28
  email:
29
29
  - 26109239+Quentinchampenois@users.noreply.github.com
@@ -37,22 +37,15 @@ files:
37
37
  - app/commands/decidim/cleaner/admin/update_organization_cleaner.rb
38
38
  - app/controllers/decidim/cleaner/admin/application_controller.rb
39
39
  - app/controllers/decidim/cleaner/admin/organization_cleaner_controller.rb
40
- - app/controllers/decidim/cleaner/application_controller.rb
41
40
  - app/forms/decidim/cleaner/admin/organization_cleaner_form.rb
42
- - app/helpers/decidim/cleaner/application_helper.rb
43
41
  - app/jobs/decidim/cleaner/clean_admin_logs_job.rb
44
42
  - app/jobs/decidim/cleaner/clean_inactive_users_job.rb
45
43
  - app/mailers/decidim/cleaner/inactive_users_mailer.rb
46
- - app/models/decidim/cleaner/application_record.rb
47
- - app/packs/entrypoints/decidim_cleaner.js
48
- - app/packs/images/decidim/cleaner/icon.svg
49
- - app/packs/stylesheets/decidim/cleaner/cleaner.scss
50
44
  - app/permissions/decidim/cleaner/admin/permissions.rb
51
45
  - app/views/decidim/cleaner/admin/organization_cleaner/_form.html.erb
52
46
  - app/views/decidim/cleaner/admin/organization_cleaner/edit.html.erb
53
47
  - app/views/decidim/cleaner/inactive_users_mailer/warning_deletion.html.erb
54
48
  - app/views/decidim/cleaner/inactive_users_mailer/warning_inactive.html.erb
55
- - config/assets.rb
56
49
  - config/i18n-tasks.yml
57
50
  - config/locales/en.yml
58
51
  - config/locales/fr.yml
@@ -62,7 +55,6 @@ files:
62
55
  - lib/decidim/cleaner.rb
63
56
  - lib/decidim/cleaner/admin.rb
64
57
  - lib/decidim/cleaner/admin_engine.rb
65
- - lib/decidim/cleaner/component.rb
66
58
  - lib/decidim/cleaner/engine.rb
67
59
  - lib/decidim/cleaner/test/factories.rb
68
60
  - lib/decidim/cleaner/version.rb
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Cleaner
5
- # This controller is the abstract class from which all other controllers of
6
- # this engine inherit.
7
- #
8
- # Note that it inherits from `Decidim::Components::BaseController`, which
9
- # override its layout and provide all kinds of useful methods.
10
- class ApplicationController < Decidim::Components::BaseController
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Cleaner
5
- # Custom helpers, scoped to the cleaner engine.
6
- #
7
- module ApplicationHelper
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Cleaner
5
- # Abstract class from which all models in this engine inherit.
6
- class ApplicationRecord < ActiveRecord::Base
7
- self.abstract_class = true
8
- end
9
- end
10
- end
@@ -1,2 +0,0 @@
1
- // Images
2
- require.context("../images", true)
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 35"><path d="M17.5 35A17.5 17.5 0 1 1 35 17.5 17.52 17.52 0 0 1 17.5 35zm0-33.06A15.56 15.56 0 1 0 33.06 17.5 15.57 15.57 0 0 0 17.5 1.94zm9.5 13.7H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zm0 3.68H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zM22.26 23H8a1 1 0 0 1 0-1.94h14.26a1 1 0 0 1 0 1.94z"/></svg>
@@ -1 +0,0 @@
1
- /* css for decidim_cleaner */
data/config/assets.rb DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- base_path = File.expand_path("..", __dir__)
4
-
5
- Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
- Decidim::Webpacker.register_entrypoints(
7
- decidim_cleaner: "#{base_path}/app/packs/entrypoints/decidim_cleaner.js"
8
- )
9
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/cleaner/cleaner")
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "decidim/components/namer"
4
-
5
- Decidim.register_component(:cleaner) do |component|
6
- component.engine = Decidim::Cleaner::Engine
7
- component.admin_engine = Decidim::Cleaner::AdminEngine
8
- component.icon = "decidim/cleaner/icon.svg"
9
-
10
- # component.on(:before_destroy) do |instance|
11
- # # Code executed before removing the component
12
- # end
13
-
14
- # These actions permissions can be configured in the admin panel
15
- # component.actions = %w()
16
-
17
- # component.settings(:global) do |settings|
18
- # # Add your global settings
19
- # # Available types: :integer, :boolean
20
- # # settings.attribute :vote_limit, type: :integer, default: 0
21
- # end
22
-
23
- # component.settings(:step) do |settings|
24
- # # Add your settings per step
25
- # end
26
-
27
- # component.register_resource(:some_resource) do |resource|
28
- # # Register a optional resource that can be references from other resources.
29
- # resource.model_class_name = "Decidim::Cleaner::SomeResource"
30
- # resource.template = "decidim/cleaner/some_resources/linked_some_resources"
31
- # end
32
-
33
- # component.register_stat :some_stat do |context, start_at, end_at|
34
- # # Register some stat number to the application
35
- # end
36
-
37
- # component.seeds do |participatory_space|
38
- # # Add some seeds for this component
39
- # end
40
- end