decidim-cleaner 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +59 -0
- data/Rakefile +40 -0
- data/app/commands/decidim/cleaner/admin/update_organization_cleaner.rb +56 -0
- data/app/controllers/decidim/cleaner/admin/application_controller.rb +26 -0
- data/app/controllers/decidim/cleaner/admin/organization_cleaner_controller.rb +36 -0
- data/app/controllers/decidim/cleaner/application_controller.rb +13 -0
- data/app/forms/decidim/cleaner/admin/organization_cleaner_form.rb +21 -0
- data/app/helpers/decidim/cleaner/application_helper.rb +10 -0
- data/app/jobs/decidim/cleaner/clean_admin_logs_job.rb +17 -0
- data/app/jobs/decidim/cleaner/clean_inactive_users_job.rb +36 -0
- data/app/mailers/decidim/cleaner/inactive_users_mailer.rb +33 -0
- data/app/models/decidim/cleaner/application_record.rb +10 -0
- data/app/packs/entrypoints/decidim_cleaner.js +2 -0
- data/app/packs/images/decidim/cleaner/icon.svg +1 -0
- data/app/packs/stylesheets/decidim/cleaner/cleaner.scss +1 -0
- data/app/permissions/decidim/cleaner/admin/permissions.rb +23 -0
- data/app/views/decidim/cleaner/admin/organization_cleaner/_form.html.erb +39 -0
- data/app/views/decidim/cleaner/admin/organization_cleaner/edit.html.erb +6 -0
- data/app/views/decidim/cleaner/inactive_users_mailer/warning_deletion.html.erb +7 -0
- data/app/views/decidim/cleaner/inactive_users_mailer/warning_inactive.html.erb +7 -0
- data/config/assets.rb +9 -0
- data/config/i18n-tasks.yml +10 -0
- data/config/locales/en.yml +38 -0
- data/config/locales/fr.yml +38 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20230106105014_add_delete_admin_logs_to_organization.rb +8 -0
- data/db/migrate/20230110150032_add_delete_inactive_users_to_organization.rb +9 -0
- data/lib/decidim/cleaner/admin.rb +10 -0
- data/lib/decidim/cleaner/admin_engine.rb +28 -0
- data/lib/decidim/cleaner/component.rb +40 -0
- data/lib/decidim/cleaner/engine.rb +17 -0
- data/lib/decidim/cleaner/test/factories.rb +11 -0
- data/lib/decidim/cleaner/version.rb +14 -0
- data/lib/decidim/cleaner.rb +12 -0
- data/lib/tasks/decidim_cleaner_tasks.rake +13 -0
- metadata +98 -0
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Decidim::Cleaner
|
2
|
+
|
3
|
+
Clean outdated data in Decidim's database.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
This module provides tasks designed to cleanup the outdated data directly in database.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "decidim-cleaner"
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
bundle
|
21
|
+
bundle exec rails decidim_cleaner:install:migrations
|
22
|
+
bundle exec rails db:migrate
|
23
|
+
```
|
24
|
+
|
25
|
+
You can then add to your 'config/sidekiq.yml' file:
|
26
|
+
|
27
|
+
```yaml
|
28
|
+
:schedule:
|
29
|
+
CleanAdminLogs:
|
30
|
+
cron: "0 9 0 * * *"
|
31
|
+
class: Decidim::Cleaner::CleanAdminLogsJob
|
32
|
+
queue: scheduled
|
33
|
+
CleanInactiveUsers:
|
34
|
+
cron: "0 9 0 * * *"
|
35
|
+
class: Decidim::Cleaner::CleanInactiveUsersJob
|
36
|
+
queue: scheduled
|
37
|
+
```
|
38
|
+
|
39
|
+
## Available tasks
|
40
|
+
|
41
|
+
- [ ] **Delete inactive users**
|
42
|
+
- Cron task that checks for user accounts where `last_sign_in_at` is superior to environment variable `CLEANER_USER_INACTIVITY_LIMIT`. If true, deletes inactive user from the database.
|
43
|
+
|
44
|
+
- [ ] **Delete old admin logs**
|
45
|
+
- Cron task that checks for admin logs where `created_at` is anterior to the time you configured in the back office. If true, deletes old admin logs from the database.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Contributions are welcome !
|
50
|
+
|
51
|
+
We expect the contributions to follow the [Decidim's contribution guide](https://github.com/decidim/decidim/blob/develop/CONTRIBUTING.adoc).
|
52
|
+
|
53
|
+
## Security
|
54
|
+
|
55
|
+
Security is very important to us. If you have any issue regarding security, please disclose the information responsibly by sending an email to __security [at] opensourcepolitics [dot] eu__ and not by creating a Github issue.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/dev/common_rake"
|
4
|
+
|
5
|
+
def install_module(path)
|
6
|
+
Dir.chdir(path) do
|
7
|
+
system("bundle exec rake decidim_cleaner:install:migrations")
|
8
|
+
system("bundle exec rake db:migrate")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def seed_db(path)
|
13
|
+
Dir.chdir(path) do
|
14
|
+
system("bundle exec rake db:seed")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Generates a dummy app for testing"
|
19
|
+
task test_app: "decidim:generate_external_test_app" do
|
20
|
+
ENV["RAILS_ENV"] = "test"
|
21
|
+
install_module("spec/decidim_dummy_app")
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Generates a development app"
|
25
|
+
task :development_app do
|
26
|
+
Bundler.with_original_env do
|
27
|
+
generate_decidim_app(
|
28
|
+
"development_app",
|
29
|
+
"--app_name",
|
30
|
+
"#{base_app_name}_development_app",
|
31
|
+
"--path",
|
32
|
+
"..",
|
33
|
+
"--recreate_db",
|
34
|
+
"--demo"
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
install_module("development_app")
|
39
|
+
seed_db("development_app")
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic for updating the current
|
7
|
+
# organization cleaner.
|
8
|
+
class UpdateOrganizationCleaner < Decidim::Command
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
# organization - The Organization that will be updated.
|
12
|
+
# form - A form object with the params.
|
13
|
+
def initialize(organization, form)
|
14
|
+
@organization = organization
|
15
|
+
@form = form
|
16
|
+
end
|
17
|
+
|
18
|
+
# Executes the command. Broadcasts these events:
|
19
|
+
#
|
20
|
+
# - :ok when everything is valid.
|
21
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
22
|
+
#
|
23
|
+
# Returns nothing.
|
24
|
+
def call
|
25
|
+
return broadcast(:invalid) if form.invalid?
|
26
|
+
|
27
|
+
return broadcast(:ok, @organization) if update_organization
|
28
|
+
|
29
|
+
broadcast(:invalid)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :form, :organization
|
35
|
+
|
36
|
+
def update_organization
|
37
|
+
@organization = Decidim.traceability.update!(
|
38
|
+
organization,
|
39
|
+
form.current_user,
|
40
|
+
attributes
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def attributes
|
45
|
+
{
|
46
|
+
delete_admin_logs: form.delete_admin_logs,
|
47
|
+
delete_admin_logs_after: form.delete_admin_logs_after,
|
48
|
+
delete_inactive_users: form.delete_inactive_users,
|
49
|
+
delete_inactive_users_after: form.delete_inactive_users_after,
|
50
|
+
delete_inactive_users_email_after: form.delete_inactive_users_email_after
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
module Admin
|
6
|
+
# This controller is the abstract class from which all other controllers of
|
7
|
+
# this engine inherit.
|
8
|
+
#
|
9
|
+
# Note that it inherits from `Decidim::Admin::Components::BaseController`, which
|
10
|
+
# override its layout and provide all kinds of useful methods.
|
11
|
+
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
|
+
def permission_class_chain
|
13
|
+
[::Decidim::Cleaner::Admin::Permissions] + super
|
14
|
+
end
|
15
|
+
|
16
|
+
def user_not_authorized_path
|
17
|
+
decidim.root_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_has_no_permission_path
|
21
|
+
decidim.root_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
module Admin
|
6
|
+
# Controller that allows managing the appearance of the organization.
|
7
|
+
class OrganizationCleanerController < Decidim::Admin::ApplicationController
|
8
|
+
include Decidim::Admin::Engine.routes.url_helpers
|
9
|
+
layout "decidim/admin/settings"
|
10
|
+
|
11
|
+
def edit
|
12
|
+
enforce_permission_to :update, :organization, organization: current_organization
|
13
|
+
@form = form(OrganizationCleanerForm).from_model(current_organization)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
enforce_permission_to :update, :organization, organization: current_organization
|
18
|
+
@form = form(OrganizationCleanerForm).from_params(params)
|
19
|
+
|
20
|
+
UpdateOrganizationCleaner.call(current_organization, @form) do
|
21
|
+
on(:ok) do
|
22
|
+
flash[:notice] = I18n.t("organization.update.success", scope: "decidim.admin")
|
23
|
+
|
24
|
+
redirect_to Decidim::Admin::Engine.routes.url_helpers.edit_organization_cleaner_path
|
25
|
+
end
|
26
|
+
|
27
|
+
on(:invalid) do
|
28
|
+
flash.now[:alert] = I18n.t("organization.update.error", scope: "decidim.admin")
|
29
|
+
render :edit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
module Admin
|
6
|
+
# A form object used to update the current organization cleaner from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class OrganizationCleanerForm < Form
|
10
|
+
mimic :organization
|
11
|
+
|
12
|
+
attribute :delete_admin_logs, Boolean
|
13
|
+
attribute :delete_admin_logs_after, Integer
|
14
|
+
|
15
|
+
attribute :delete_inactive_users, Boolean
|
16
|
+
attribute :delete_inactive_users_after, Integer
|
17
|
+
attribute :delete_inactive_users_email_after, Integer
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
class CleanAdminLogsJob < ApplicationJob
|
6
|
+
queue_as :scheduled
|
7
|
+
|
8
|
+
def perform
|
9
|
+
Decidim::Organization.find_each do |organization|
|
10
|
+
next unless organization.delete_admin_logs?
|
11
|
+
|
12
|
+
Decidim::ActionLog.where(organization:).where("created_at < ?", Time.zone.now - (organization.delete_admin_logs_after || 365).days).delete_all
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
class CleanInactiveUsersJob < ApplicationJob
|
6
|
+
queue_as :scheduled
|
7
|
+
|
8
|
+
def perform
|
9
|
+
Decidim::Organization.find_each do |organization|
|
10
|
+
next unless organization.delete_inactive_users?
|
11
|
+
|
12
|
+
send_warning(Decidim::User.where(organization:)
|
13
|
+
.where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_email_after || 365).days)
|
14
|
+
.where("last_sign_in_at > ?", Time.zone.now - (organization.delete_inactive_users_email_after || 365).days - 1.day))
|
15
|
+
delete_user_and_send_email(Decidim::User.where(organization:).where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_after || 390).days))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def send_warning(users)
|
20
|
+
users.each do |user|
|
21
|
+
InactiveUsersMailer.warning_inactive(user).deliver_now
|
22
|
+
Rails.logger.info "Inactive warning sent to #{user.email}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_user_and_send_email(users)
|
27
|
+
users.each do |user|
|
28
|
+
InactiveUsersMailer.warning_deletion(user).deliver_now
|
29
|
+
Rails.logger.info "Deletion warning sent to #{user.email}"
|
30
|
+
user.delete
|
31
|
+
Rails.logger.info "User #{user.email} deleted"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
# A custom mailer for Decidim so we can notify users
|
6
|
+
# when their account was blocked
|
7
|
+
class InactiveUsersMailer < Decidim::ApplicationMailer
|
8
|
+
def warning_inactive(user)
|
9
|
+
with_user(user) do
|
10
|
+
@user = user
|
11
|
+
@organization = user.organization
|
12
|
+
subject = I18n.t(
|
13
|
+
"decidim.cleaner.inactive_users_mailer.warning_inactive.subject",
|
14
|
+
organization_name: @organization.name
|
15
|
+
)
|
16
|
+
mail(to: user.email, subject:)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def warning_deletion(user)
|
21
|
+
with_user(user) do
|
22
|
+
@user = user
|
23
|
+
@organization = user.organization
|
24
|
+
subject = I18n.t(
|
25
|
+
"decidim.cleaner.inactive_users_mailer.warning_deletion.subject",
|
26
|
+
organization_name: @organization.name
|
27
|
+
)
|
28
|
+
mail(to: user.email, subject:)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
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>
|
@@ -0,0 +1 @@
|
|
1
|
+
/* css for decidim_cleaner */
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
module Admin
|
6
|
+
class Permissions < Decidim::DefaultPermissions
|
7
|
+
def permissions
|
8
|
+
return permission_action if permission_action.scope != :admin
|
9
|
+
return permission_action unless user&.admin?
|
10
|
+
|
11
|
+
allow! if can_access?
|
12
|
+
|
13
|
+
permission_action
|
14
|
+
end
|
15
|
+
|
16
|
+
def can_access?
|
17
|
+
permission_action.subject == :cleaner &&
|
18
|
+
permission_action.action == :read
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title"><%= t ".admin_log_cleaner_title" %></h2>
|
4
|
+
</div>
|
5
|
+
<div class="card-section">
|
6
|
+
<div class="row">
|
7
|
+
<div class="columns xlarge-6 slug">
|
8
|
+
<%= form.check_box :delete_admin_logs %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="columns xlarge-6">
|
12
|
+
<%= form.number_field :delete_admin_logs_after %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div class="card">
|
19
|
+
<div class="card-divider">
|
20
|
+
<h2 class="card-title"><%= t ".inactive_users_cleaner_title" %></h2>
|
21
|
+
</div>
|
22
|
+
<div class="card-section">
|
23
|
+
<div class="row">
|
24
|
+
<div class="columns xlarge-6 slug">
|
25
|
+
<%= form.check_box :delete_inactive_users %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="columns xlarge-6">
|
29
|
+
<%= form.number_field :delete_inactive_users_email_after %>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class="columns xlarge-6">
|
33
|
+
<%= form.number_field :delete_inactive_users_after %>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= decidim_form_for(@form, html: { class: "form edit_organization_cleaner" }, url:"/admin/organization/cleaner" , method: :put) do |f| %>
|
2
|
+
<%= render partial: "form", object: f %>
|
3
|
+
<div class="button--double form-general-submit">
|
4
|
+
<%= f.submit t(".update") %>
|
5
|
+
</div>
|
6
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p class="email-greeting"><%= t ".hello" %></p>
|
2
|
+
|
3
|
+
<p class="email-instructions"><%= t(".body_1", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host), days: @organization.delete_inactive_users_after||390).html_safe %></p>
|
4
|
+
|
5
|
+
<p class="email-instructions"><%= t ".body_2" %></p>
|
6
|
+
|
7
|
+
<p class="email-closing"><%= t(".greetings", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %></p>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p class="email-greeting"><%= t ".hello" %></p>
|
2
|
+
|
3
|
+
<p class="email-instructions"><%= t ".body_1", organization_name: h(@organization.name), days: @organization.delete_inactive_users_email_after %></p>
|
4
|
+
|
5
|
+
<p class="email-instructions"><%= t(".body_2", remaining_days: (@organization.delete_inactive_users_after||390) - (@organization.delete_inactive_users_email_after||365), organization_url: decidim.root_url(host: @organization.host)).html_safe %></p>
|
6
|
+
|
7
|
+
<p class="email-closing"><%= t(".greetings", organization_name: h(@organization.name), organization_url: decidim.root_url(host: @organization.host)).html_safe %></p>
|
data/config/assets.rb
ADDED
@@ -0,0 +1,9 @@
|
|
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")
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
activemodel:
|
4
|
+
attributes:
|
5
|
+
organization:
|
6
|
+
delete_admin_logs: Enable admin logs deletion
|
7
|
+
delete_admin_logs_after: Delete admin logs after (days, default 365)
|
8
|
+
delete_inactive_users: Enable inactive users deletion
|
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)
|
11
|
+
decidim:
|
12
|
+
admin:
|
13
|
+
menu:
|
14
|
+
clean: Data cleaner
|
15
|
+
cleaner:
|
16
|
+
admin:
|
17
|
+
organization_cleaner:
|
18
|
+
edit:
|
19
|
+
update: Update
|
20
|
+
form:
|
21
|
+
admin_log_cleaner_title: Admin log
|
22
|
+
inactive_users_cleaner_title: Inactive users
|
23
|
+
inactive_users_mailer:
|
24
|
+
warning_deletion:
|
25
|
+
body_1: You are inactive since %{days} days on <a href="%{organization_url}"> %{organization_name} </a>.
|
26
|
+
body_2: As a result, your account has been deleted.
|
27
|
+
greetings: Greetings,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
|
28
|
+
hello: Hello
|
29
|
+
subject: Your account has been deleted
|
30
|
+
warning_inactive:
|
31
|
+
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.
|
33
|
+
greetings: Greetings,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
|
34
|
+
hello: Hello
|
35
|
+
subject: Your account is inactive
|
36
|
+
components:
|
37
|
+
cleaner:
|
38
|
+
name: Cleaner
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
fr:
|
3
|
+
activemodel:
|
4
|
+
attributes:
|
5
|
+
organization:
|
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)
|
8
|
+
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)
|
11
|
+
decidim:
|
12
|
+
admin:
|
13
|
+
menu:
|
14
|
+
clean: Nettoyeur de données
|
15
|
+
cleaner:
|
16
|
+
admin:
|
17
|
+
organization_cleaner:
|
18
|
+
edit:
|
19
|
+
update: Mettre à jour
|
20
|
+
form:
|
21
|
+
admin_log_cleaner_title: Historique d'administration
|
22
|
+
inactive_users_cleaner_title: Utilisateurs inactifs
|
23
|
+
inactive_users_mailer:
|
24
|
+
warning_deletion:
|
25
|
+
body_1: Vous êtes inactif depuis %{days} jours sur <a href="%{organization_url}"> %{organization_name} </a>.
|
26
|
+
body_2: Par conséquent, votre compte a été supprimé.
|
27
|
+
greetings: Cordialement,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
|
28
|
+
hello: Bonjour
|
29
|
+
subject: Votre compte a été supprimé
|
30
|
+
warning_inactive:
|
31
|
+
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é.
|
33
|
+
greetings: Cordialement,<br/>%{organization_name}<br/><a href="%{organization_url}">%{organization_url}</a>
|
34
|
+
hello: Bonjour
|
35
|
+
subject: Votre compte est inactif
|
36
|
+
components:
|
37
|
+
cleaner:
|
38
|
+
name: Nettoyeur
|
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_litteral: true
|
4
|
+
|
5
|
+
Decidim::Admin::Engine.routes.draw do
|
6
|
+
resource :organization, controller: "organization" do
|
7
|
+
resource :cleaner, only: [:edit, :update], controller: "/decidim/cleaner/admin/organization_cleaner"
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddDeleteAdminLogsToOrganization < ActiveRecord::Migration[6.1]
|
4
|
+
def change
|
5
|
+
add_column :decidim_organizations, :delete_admin_logs, :boolean, default: false, null: false
|
6
|
+
add_column :decidim_organizations, :delete_admin_logs_after, :integer
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddDeleteInactiveUsersToOrganization < ActiveRecord::Migration[6.1]
|
4
|
+
def change
|
5
|
+
add_column :decidim_organizations, :delete_inactive_users, :boolean, default: false, null: false
|
6
|
+
add_column :decidim_organizations, :delete_inactive_users_email_after, :integer
|
7
|
+
add_column :decidim_organizations, :delete_inactive_users_after, :integer
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Cleaner
|
5
|
+
# This is the engine that runs on the public interface of `Cleaner`.
|
6
|
+
class AdminEngine < ::Rails::Engine
|
7
|
+
isolate_namespace Decidim::Cleaner::Admin
|
8
|
+
|
9
|
+
paths["db/migrate"] = nil
|
10
|
+
paths["lib/tasks"] = nil
|
11
|
+
|
12
|
+
initializer "decidim_admin.admin_settings_menu" do
|
13
|
+
Decidim.menu :admin_settings_menu do |menu|
|
14
|
+
menu.add_item :clean_organization,
|
15
|
+
I18n.t("menu.clean", scope: "decidim.admin"),
|
16
|
+
decidim_admin.edit_organization_cleaner_path,
|
17
|
+
position: 1.8,
|
18
|
+
if: allowed_to?(:update, :organization, organization: current_organization),
|
19
|
+
active: is_active_link?(decidim_admin.edit_organization_cleaner_path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_seed
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|