decidim-cdtb 0.4.0 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 153977aa97421818ceebb2f5bd934c01df29717da6b03cec2d3e596868cf482b
4
- data.tar.gz: 4b0f14017084367cb8665ffcca4fe4ea9c6db70667cdf9d253366cd667819991
3
+ metadata.gz: 4341e4535e244e11f06f3e3454ff7ab9654a39946a0d1b2f706820cc0f10abe9
4
+ data.tar.gz: 819ad70dea665494e389aac694e9591fab463a485215b76efb28df255800585c
5
5
  SHA512:
6
- metadata.gz: a7c0f4ec00c7d921a2182de07d3601f7c99027ebdcbda6550d7d19007d98051b5c0e1864da1aa45a377b0b5206146032fc42b19338ad5857c501ba2840451df1
7
- data.tar.gz: ee1d931e38468fadd1cfbc0b0e1f1504358f37da6a99f8c46ba6666989cb0a59c644d8ac6c5d4a63e24cca812676ce8f418637332f2488aee774f4fa0e2f8ff7
6
+ metadata.gz: 7c4e229cd063bc8e6dcdae11d7bcd1463c7c1f1f827e3053de05f821e31b038d41d21833505d30e78c105625d55290e297c55332085ac756adaf36edc21c246a
7
+ data.tar.gz: 15de2cc51a4bb5f2da4289742e64f8f34a78aaa145f9db29cf8fed94bee1292cf85f318a930702c6970a96da49494022cdfbe65fa0acf8a90969e4f1c798dae4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.2] - 2025-04-23 (minor - Sant Jordi)
4
+
5
+ - Add task to export the list of admins.
6
+
7
+ ## [0.4.1] - 2025-02-10 (patch - Afamada i enfadada)
8
+
9
+ - Fix error in disabling/enabling emails on remove users task
10
+
3
11
  ## [0.4.0] - 2025-02-10 (minor - Llefiscós però deliciós)
4
12
 
5
13
  - Add task to move images to hero content block in participatory spaces
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- decidim-cdtb (0.4.0)
4
+ decidim-cdtb (0.4.2)
5
5
  decidim (>= 0.27.0)
6
6
  rails (>= 6)
7
7
  ruby-progressbar
data/README.md CHANGED
@@ -221,11 +221,26 @@ bundle exec rake cdtb:participatory_spaces:add_content_blocks[['extra_data relat
221
221
 
222
222
  ```
223
223
 
224
+ ##### Usually executed when upgrading to Decidim 0.28
225
+
226
+ To add extra_data and related_documents to content blocks in participatory spaces
227
+
228
+ ```
229
+ bundle exec rake cdtb:participatory_spaces:add_content_blocks[extra_data]
230
+ bundle exec rake cdtb:participatory_spaces:add_content_blocks[related_documents]
231
+ ```
232
+
233
+ To move images to a new content block in participatory spaces
234
+
235
+ ```
236
+ bundle exec rake cdtb:participatory_spaces:move_images_to_content_block
237
+ ```
238
+
224
239
  #### Move banner images to hero content block
225
240
 
226
241
  In previous versions of Decidim (0.27 and previous) banner images are in participatory space configuration. Now, this image is in a content block but for old spaces are in configuration yet.
227
242
 
228
- This task move the banner image to a hero content block.
243
+ This task moves the banner image to a hero content block.
229
244
 
230
245
  Spaces supported:
231
246
 
@@ -24,9 +24,9 @@ module Decidim
24
24
  def do_execution(context)
25
25
  progress_bar = context[:progress_bar]
26
26
 
27
- users_with_email_on_moderations = Decidim::User.where(email_on_moderations: true)
27
+ emails_on_moderations = Decidim::User.where(email_on_moderations: true).pluck(:email)
28
28
 
29
- disable_email_moderations(users_with_email_on_moderations)
29
+ disable_email_moderations(emails_on_moderations)
30
30
 
31
31
  CSV.foreach(@csv_path, headers: true, col_sep: ",") do |row|
32
32
  user = Decidim::User.find_by(id: row[0])
@@ -40,7 +40,7 @@ module Decidim
40
40
  progress_bar.increment
41
41
  end
42
42
  ensure
43
- enable_email_moderations(users_with_email_on_moderations)
43
+ enable_email_moderations(emails_on_moderations)
44
44
  end
45
45
  # rubocop:enable Metrics/AbcSize
46
46
 
@@ -50,18 +50,22 @@ module Decidim
50
50
 
51
51
  private
52
52
 
53
- def disable_email_moderations(users)
53
+ def disable_email_moderations(users_emails)
54
54
  log_task_step("Disabling email on moderations...")
55
55
 
56
+ users = Decidim::User.where(email: users_emails)
57
+
56
58
  users.find_each do |user|
57
59
  user.email_on_moderations = false
58
60
  user.save(validate: false)
59
61
  end
60
62
  end
61
63
 
62
- def enable_email_moderations(users)
64
+ def enable_email_moderations(users_emails)
63
65
  log_task_step("Enabling email on moderations...")
64
66
 
67
+ users = Decidim::User.where(email: users_emails)
68
+
65
69
  users.find_each do |user|
66
70
  user.email_on_moderations = true
67
71
  user.save(validate: false)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Cdtb
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.2"
6
6
  DECIDIM_MIN_VERSION = ">= 0.27.0"
7
7
  end
8
8
  end
data/lib/decidim/cdtb.rb CHANGED
@@ -11,6 +11,8 @@ module Decidim
11
11
 
12
12
  class Error < StandardError; end
13
13
 
14
+ STRFTIME_FORMAT= "%d/%m/%Y %H:%M:%S"
15
+
14
16
  config_accessor :spam_words do
15
17
  %w[viagra sex game free crypto crack xxx luck girls vip download]
16
18
  end
data/lib/tasks/users.rake CHANGED
@@ -19,5 +19,36 @@ namespace :cdtb do
19
19
  service = ::Decidim::Cdtb::Users::Remover.new(args.csv_path, args.reporter_user_email)
20
20
  service.execute!
21
21
  end
22
+
23
+ desc <<~EODESC
24
+ Exports the list of admins to a CSV file. If +org_id+ is set, filters by that organization.
25
+ EODESC
26
+ task :list_admins, %i[org_id] => [:environment] do |_taks, args|
27
+ organization_id= args.org_id
28
+
29
+ query= Decidim::User.includes(:organization).where(admin: true)
30
+ filename= "admins"
31
+
32
+ if organization_id.present?
33
+ query= query.where(organization_id: organization_id)
34
+ filename+= "-org#{organization_id}"
35
+ end
36
+
37
+ CSV.open("#{filename}.csv", "wb") do |csv|
38
+ csv << ["ID", "Organization ID", "Organization", "Name", "Email", "Created at", "Last sign in at"]
39
+
40
+ query.find_each do |admin|
41
+ csv << [
42
+ admin.id,
43
+ admin.organization.id,
44
+ admin.organization.name,
45
+ admin.name,
46
+ admin.email,
47
+ admin.created_at.strftime(Decidim::Cdtb::STRFTIME_FORMAT),
48
+ admin.last_sign_in_at&.strftime(Decidim::Cdtb::STRFTIME_FORMAT)
49
+ ]
50
+ end
51
+ end
52
+ end
22
53
  end
23
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-cdtb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Valls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
11
+ date: 2025-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim