decidim-core 0.29.0 → 0.29.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/activity_cell.rb +0 -3
  3. data/app/cells/decidim/author/show.erb +5 -4
  4. data/app/cells/decidim/author_cell.rb +26 -0
  5. data/app/cells/decidim/card_s/show.erb +5 -3
  6. data/app/cells/decidim/content_blocks/stats_cell.rb +1 -1
  7. data/app/cells/decidim/diff_cell.rb +4 -0
  8. data/app/cells/decidim/endorsement_buttons_cell.rb +1 -1
  9. data/app/cells/decidim/newsletter_templates/image_text_cta_cell.rb +1 -1
  10. data/app/cells/decidim/translation_bar/show.erb +2 -2
  11. data/app/cells/decidim/translation_bar_cell.rb +1 -1
  12. data/app/commands/decidim/amendable/create_draft.rb +1 -0
  13. data/app/commands/decidim/destroy_account.rb +3 -0
  14. data/app/controllers/concerns/decidim/devise_authentication_methods.rb +1 -1
  15. data/app/controllers/concerns/decidim/direct_upload.rb +82 -0
  16. data/app/controllers/decidim/doorkeeper/credentials_controller.rb +1 -1
  17. data/app/controllers/decidim/links_controller.rb +1 -1
  18. data/app/controllers/decidim/profiles_controller.rb +4 -0
  19. data/app/forms/decidim/upload_validation_form.rb +1 -1
  20. data/app/helpers/concerns/decidim/user_role_checker.rb +46 -0
  21. data/app/helpers/decidim/cta_button_helper.rb +1 -1
  22. data/app/helpers/decidim/layout_helper.rb +28 -0
  23. data/app/helpers/decidim/map_helper.rb +6 -1
  24. data/app/helpers/decidim/sanitize_helper.rb +11 -2
  25. data/app/helpers/decidim/scopes_helper.rb +3 -2
  26. data/app/models/decidim/action_log.rb +11 -1
  27. data/app/models/decidim/attachment.rb +1 -1
  28. data/app/packs/src/decidim/append_redirect_url_to_modals.js +24 -14
  29. data/app/packs/src/decidim/direct_uploads/upload_field.js +21 -8
  30. data/app/packs/src/decidim/direct_uploads/upload_modal.js +3 -0
  31. data/app/packs/src/decidim/index.js +3 -0
  32. data/app/packs/src/decidim/remote_tooltips.js +38 -0
  33. data/app/packs/src/decidim/toggle.js +1 -1
  34. data/app/packs/src/decidim/tooltips.js +42 -22
  35. data/app/packs/stylesheets/decidim/_buttons.scss +1 -1
  36. data/app/packs/stylesheets/decidim/_labels.scss +1 -1
  37. data/app/packs/stylesheets/decidim/_modal_update.scss +4 -0
  38. data/app/packs/stylesheets/decidim/_profile.scss +1 -1
  39. data/app/packs/stylesheets/decidim/_progress-bar.scss +1 -1
  40. data/app/packs/stylesheets/decidim/legacy/conference-diploma.scss +2 -1
  41. data/app/presenters/decidim/attachment_presenter.rb +1 -1
  42. data/app/queries/decidim/last_activity.rb +16 -5
  43. data/app/services/decidim/base_diff_renderer.rb +26 -2
  44. data/app/services/decidim/email_notification_generator.rb +14 -5
  45. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
  46. data/app/views/decidim/offline/show.html.erb +1 -1
  47. data/app/views/decidim/pages/_tabbed.html.erb +2 -2
  48. data/app/views/layouts/decidim/_head.html.erb +1 -1
  49. data/app/views/layouts/decidim/header/_menu_breadcrumb_mobile_tablet.html.erb +1 -1
  50. data/config/locales/ar.yml +16 -1
  51. data/config/locales/bg.yml +0 -1
  52. data/config/locales/bn-BD.yml +1 -0
  53. data/config/locales/bs-BA.yml +98 -0
  54. data/config/locales/ca.yml +14 -10
  55. data/config/locales/cs.yml +7 -1
  56. data/config/locales/de.yml +20 -16
  57. data/config/locales/el.yml +7 -1
  58. data/config/locales/en.yml +5 -1
  59. data/config/locales/es-MX.yml +6 -2
  60. data/config/locales/es-PY.yml +6 -2
  61. data/config/locales/es.yml +12 -8
  62. data/config/locales/eu.yml +202 -185
  63. data/config/locales/fi-plain.yml +5 -1
  64. data/config/locales/fi.yml +40 -36
  65. data/config/locales/fr-CA.yml +7 -3
  66. data/config/locales/fr.yml +6 -2
  67. data/config/locales/ga-IE.yml +9 -0
  68. data/config/locales/gl.yml +8 -1
  69. data/config/locales/hu.yml +3 -4
  70. data/config/locales/id-ID.yml +8 -0
  71. data/config/locales/is-IS.yml +8 -1
  72. data/config/locales/it.yml +19 -0
  73. data/config/locales/ja.yml +18 -16
  74. data/config/locales/lb.yml +9 -0
  75. data/config/locales/lt.yml +5 -2
  76. data/config/locales/lv.yml +8 -0
  77. data/config/locales/nl.yml +10 -1
  78. data/config/locales/no.yml +9 -0
  79. data/config/locales/pl.yml +1 -2
  80. data/config/locales/pt-BR.yml +244 -1
  81. data/config/locales/pt.yml +14 -0
  82. data/config/locales/ro-RO.yml +319 -180
  83. data/config/locales/ru.yml +8 -0
  84. data/config/locales/sk.yml +9 -1
  85. data/config/locales/sv.yml +541 -96
  86. data/config/locales/tr-TR.yml +10 -1
  87. data/config/locales/uk.yml +8 -1
  88. data/config/locales/zh-CN.yml +9 -0
  89. data/config/locales/zh-TW.yml +8 -1
  90. data/config/routes.rb +1 -0
  91. data/decidim-core.gemspec +4 -1
  92. data/lib/decidim/api/functions/component_list.rb +1 -1
  93. data/lib/decidim/api/functions/participatory_space_finder_base.rb +11 -1
  94. data/lib/decidim/api/interfaces/participatory_space_interface.rb +1 -1
  95. data/lib/decidim/api/types/component_type.rb +7 -0
  96. data/lib/decidim/api/types/user_group_type.rb +4 -0
  97. data/lib/decidim/api/types/user_type.rb +4 -0
  98. data/lib/decidim/attributes/rich_text.rb +38 -0
  99. data/lib/decidim/attributes/time_with_zone.rb +11 -1
  100. data/lib/decidim/attributes.rb +2 -0
  101. data/lib/decidim/content_parsers/blob_parser.rb +93 -0
  102. data/lib/decidim/content_parsers.rb +1 -0
  103. data/lib/decidim/content_renderers/blob_renderer.rb +90 -0
  104. data/lib/decidim/content_renderers.rb +1 -0
  105. data/lib/decidim/core/engine.rb +35 -1
  106. data/lib/decidim/core/test/factories.rb +28 -0
  107. data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +1 -1
  108. data/lib/decidim/core/test/shared_examples/comments_examples.rb +25 -2
  109. data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +107 -9
  110. data/lib/decidim/core/version.rb +1 -1
  111. data/lib/decidim/core.rb +11 -0
  112. data/lib/decidim/diffy_extension.rb +18 -0
  113. data/lib/decidim/form_builder.rb +1 -1
  114. data/lib/decidim/map/autocomplete.rb +1 -0
  115. data/lib/decidim/organization_settings.rb +4 -1
  116. data/lib/decidim/participatory_space_user.rb +4 -0
  117. data/lib/decidim/query_extensions.rb +0 -26
  118. data/lib/decidim/settings_manifest.rb +2 -0
  119. data/lib/decidim/translatable_attributes.rb +6 -1
  120. data/lib/decidim/view_model.rb +1 -1
  121. data/lib/tasks/upgrade/decidim_attachments.rake +14 -0
  122. data/lib/tasks/upgrade/decidim_fix_categorization.rake +34 -8
  123. metadata +30 -7
@@ -500,6 +500,16 @@ shared_examples "comments" do
500
500
  expect(page).to have_css("span.comments-count", text: "#{commentable.comments.count} comments")
501
501
  expect(page.find("#add-comment-#{commentable.commentable_type.demodulize}-#{commentable.id}").value).to be_empty
502
502
  end
503
+
504
+ it "shows the entry in last activities" do
505
+ visit decidim.last_activities_path
506
+ expect(page).to have_content("New comment: #{content}")
507
+
508
+ within "#filters" do
509
+ find("a", class: "filter", text: "Comment", match: :first).click
510
+ end
511
+ expect(page).to have_content("New comment: #{content}")
512
+ end
503
513
  end
504
514
 
505
515
  context "when user adds a new comment with a link" do
@@ -609,7 +619,7 @@ shared_examples "comments" do
609
619
  end
610
620
 
611
621
  context "when the user has verified organizations" do
612
- let(:user_group) { create(:user_group, :verified) }
622
+ let(:user_group) { create(:user_group, :verified, organization:) }
613
623
  let(:content) { "This is a new comment" }
614
624
 
615
625
  before do
@@ -737,6 +747,20 @@ shared_examples "comments" do
737
747
  expect(page).to have_content("Edited")
738
748
  end
739
749
  end
750
+
751
+ it "has only one edit modal" do
752
+ expect(page).to have_css("#editCommentModal#{comment.id}", visible: :hidden, count: 1)
753
+ 3.times do |index|
754
+ sleep 2
755
+ within "#comment_#{comment.id}" do
756
+ page.find("[id^='dropdown-trigger']").click
757
+ click_on "Edit"
758
+ end
759
+ fill_in "edit_comment_#{comment.id}", with: " This comment has been edited #{1 + index} times"
760
+ click_on "Send"
761
+ end
762
+ expect(page).to have_css("#editCommentModal#{comment.id}", visible: :all, count: 1)
763
+ end
740
764
  end
741
765
  end
742
766
  end
@@ -1021,7 +1045,6 @@ shared_examples "comments blocked" do
1021
1045
  end
1022
1046
 
1023
1047
  context "when authenticated" do
1024
- let!(:organization) { create(:organization) }
1025
1048
  let!(:user) { create(:user, :confirmed, organization:) }
1026
1049
  let!(:comments) { create_list(:comment, 3, commentable:) }
1027
1050
 
@@ -25,7 +25,7 @@ shared_examples "Endorse resource system specs" do
25
25
  end
26
26
 
27
27
  context "when endorsements are not enabled" do
28
- let(:component_traits) { [:with_votes_enabled, :with_endorsements_disabled] }
28
+ let(:component_traits) { [:with_endorsements_disabled] }
29
29
 
30
30
  context "when the user is not logged in" do
31
31
  it "does not show the endorse resource button and counts" do
@@ -51,17 +51,17 @@ shared_examples "Endorse resource system specs" do
51
51
 
52
52
  it "shows the endorsements count and the endorse button is disabled" do
53
53
  visit_resource
54
- expect(page).to have_css("[data-buttons] button[disabled='true']")
54
+ expect(page).to have_css("#resource-#{resource.id}-endorsement-block button[disabled='true']")
55
55
  end
56
56
  end
57
57
 
58
58
  context "when endorsements are enabled" do
59
- let(:component_traits) { [:with_votes_enabled, :with_endorsements_enabled] }
59
+ let(:component_traits) { [:with_endorsements_enabled] }
60
60
 
61
61
  context "when the user is not logged in" do
62
62
  it "is given the option to sign in" do
63
63
  visit_resource
64
- within "[data-buttons]", match: :first do
64
+ within "#resource-#{resource.id}-endorsement-block" do
65
65
  click_on "Like"
66
66
  end
67
67
 
@@ -77,7 +77,7 @@ shared_examples "Endorse resource system specs" do
77
77
  context "when the resource is not endorsed yet" do
78
78
  it "is able to endorse the resource" do
79
79
  visit_resource
80
- within "[data-buttons]" do
80
+ within "#resource-#{resource.id}-endorsement-block" do
81
81
  click_on "Like"
82
82
  expect(page).to have_button("Dislike")
83
83
  end
@@ -89,7 +89,7 @@ shared_examples "Endorse resource system specs" do
89
89
 
90
90
  it "is not able to endorse it again" do
91
91
  visit_resource
92
- within "[data-buttons]" do
92
+ within "#resource-#{resource.id}-endorsement-block" do
93
93
  expect(page).to have_button("Dislike")
94
94
  expect(page).to have_no_button("Like")
95
95
  end
@@ -97,7 +97,7 @@ shared_examples "Endorse resource system specs" do
97
97
 
98
98
  it "is able to undo the endorsement" do
99
99
  visit_resource
100
- within "[data-buttons]" do
100
+ within "#resource-#{resource.id}-endorsement-block" do
101
101
  click_on "Dislike"
102
102
  expect(page).to have_button("Like")
103
103
  end
@@ -124,7 +124,7 @@ shared_examples "Endorse resource system specs" do
124
124
  context "when user is NOT verified" do
125
125
  it "is NOT able to endorse" do
126
126
  visit_resource
127
- within "[data-buttons]", match: :first do
127
+ within "#resource-#{resource.id}-endorsement-block" do
128
128
  click_on "Like"
129
129
  end
130
130
  expect(page).to have_css("#authorizationModal", visible: :visible)
@@ -142,13 +142,111 @@ shared_examples "Endorse resource system specs" do
142
142
 
143
143
  it "IS able to endorse", :slow do
144
144
  visit_resource
145
- within "[data-buttons]", match: :first do
145
+ within "#resource-#{resource.id}-endorsement-block" do
146
146
  click_on "Like"
147
147
  end
148
148
  expect(page).to have_button("Dislike")
149
149
  end
150
150
  end
151
151
  end
152
+
153
+ context "when user being a part of a group" do
154
+ let(:component_traits) { [:with_endorsements_enabled] }
155
+ let!(:user_group) do
156
+ create(
157
+ :user_group,
158
+ :verified,
159
+ name: "Tester's Organization",
160
+ nickname: "test_org",
161
+ email: "t.mail.org@example.org",
162
+ users: [user],
163
+ organization:
164
+ )
165
+ end
166
+
167
+ before do
168
+ organization.update(user_groups_enabled:)
169
+ login_as user, scope: :user
170
+ visit_resource
171
+ end
172
+
173
+ context "when organization is not allowing user groups" do
174
+ let(:user_groups_enabled) { false }
175
+
176
+ it "is able to endorse the resource" do
177
+ within "#resource-#{resource.id}-endorsement-block" do
178
+ click_on "Like"
179
+ expect(page).to have_button("Dislike")
180
+ end
181
+ end
182
+ end
183
+
184
+ context "when organization allows user groups" do
185
+ let(:user_groups_enabled) { true }
186
+
187
+ it "opens a modal where you select identity as a user or a group" do
188
+ click_on "Like"
189
+ expect(page).to have_content("Select identity")
190
+ expect(page).to have_content("Tester's Organization")
191
+ expect(page).to have_content(user.name)
192
+ end
193
+
194
+ def add_likes
195
+ click_on "Like"
196
+ within "#user-identities" do
197
+ click_on "Tester's Organization"
198
+ click_on user.name
199
+ click_on "Done"
200
+ end
201
+ visit_resource
202
+ click_on "Dislike"
203
+ end
204
+
205
+ context "when both identities picked" do
206
+ it "likes the post as a group and a user" do
207
+ add_likes
208
+
209
+ within ".identities-modal__list" do
210
+ expect(page).to have_css(".is-selected", count: 2)
211
+ end
212
+ end
213
+ end
214
+
215
+ context "when like cancelled as a user" do
216
+ it "does not cancel group like" do
217
+ add_likes
218
+ find(".is-selected", match: :first).click
219
+ click_on "Done"
220
+ visit current_path
221
+ click_on "Like"
222
+
223
+ within ".identities-modal__list" do
224
+ expect(page).to have_css(".is-selected", count: 1)
225
+ within ".is-selected" do
226
+ expect(page).to have_content("Tester's Organization")
227
+ end
228
+ end
229
+ end
230
+ end
231
+
232
+ context "when like cancelled as a group" do
233
+ it "does not cancel user like" do
234
+ add_likes
235
+ page.all(".is-selected")[1].click
236
+ click_on "Done"
237
+ visit current_path
238
+ click_on "Dislike"
239
+
240
+ within ".identities-modal__list" do
241
+ expect(page).to have_css(".is-selected", count: 1)
242
+ within ".is-selected" do
243
+ expect(page).to have_text(user.name, exact: true)
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
249
+ end
152
250
  end
153
251
  end
154
252
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-core version.
5
5
  module Core
6
6
  def self.version
7
- "0.29.0"
7
+ "0.29.2"
8
8
  end
9
9
  end
10
10
  end
data/lib/decidim/core.rb CHANGED
@@ -551,6 +551,17 @@ module Decidim
551
551
  "/"
552
552
  end
553
553
 
554
+ # This is the maximum time that the cache will be stored. If nil, the cache will be stored indefinitely.
555
+ # Currently, cache is applied in the Cells where the method `cache_hash` is defined.
556
+ config_accessor :cache_expiry_time do
557
+ 24.hours
558
+ end
559
+
560
+ # Same as before, but specifically for cell displaying stats
561
+ config_accessor :stats_cache_expiry_time do
562
+ 10.minutes
563
+ end
564
+
554
565
  # Enable/Disable the service worker
555
566
  config_accessor :service_worker_enabled do
556
567
  Rails.env.exclude?("development")
@@ -13,6 +13,24 @@ module Decidim
13
13
  str = wrap_lines(@diff.map { |line| wrap_line(line) })
14
14
  ActionView::Base.new(ActionView::LookupContext.new(nil), {}, nil).sanitize(str, tags: TAGS)
15
15
  end
16
+
17
+ private
18
+
19
+ def wrap_line(line)
20
+ cleaned = clean_line(line)
21
+ case line
22
+ when /^(---|\+\+\+|\\\\)/
23
+ " <li class=\"diff-comment\"><div>#{line.chomp}</div></li>"
24
+ when /^\+/
25
+ " <li class=\"ins\"><ins>#{cleaned}</ins></li>"
26
+ when /^-/
27
+ " <li class=\"del\"><del>#{cleaned}</del></li>"
28
+ when /^ /
29
+ " <li class=\"unchanged\"><div>#{cleaned}</div></li>"
30
+ when /^@@/
31
+ " <li class=\"diff-block-info\"><div>#{line.chomp}</div></li>"
32
+ end
33
+ end
16
34
  end
17
35
 
18
36
  # Adding a new method to Diffy::Format so we can pass the
@@ -390,7 +390,7 @@ module Decidim
390
390
  # options - A Hash with options to build the field. See upload method for
391
391
  # more detailed information.
392
392
  def attachment(attribute, options = {})
393
- object_attachment = object.attachment.present?
393
+ object_attachment = object.respond_to?(:attachment) && object.attachment.present?
394
394
  record = object_attachment ? object.attachment : object
395
395
  options = {
396
396
  titled: options[:multiple],
@@ -42,6 +42,7 @@ module Decidim
42
42
  @autocomplete_utility ||= Decidim::Map.autocomplete(
43
43
  organization: @template.current_organization
44
44
  )
45
+
45
46
  return text_field(attribute, options) unless @autocomplete_utility
46
47
 
47
48
  # Decidim::Map::Autocomplete::Builder
@@ -105,7 +105,7 @@ module Decidim
105
105
  "upload" => {
106
106
  "allowed_file_extensions" => {
107
107
  "default" => %w(jpg jpeg png webp pdf rtf txt),
108
- "admin" => %w(jpg jpeg png webp pdf doc docx xls xlsx ppt pptx ppx rtf txt odt ott odf otg ods ots),
108
+ "admin" => %w(jpg jpeg png webp pdf doc docx xls xlsx ppt pptx ppx rtf txt odt ott odf otg ods ots csv json md),
109
109
  "image" => %w(jpg jpeg png webp)
110
110
  },
111
111
  "allowed_content_types" => {
@@ -125,7 +125,10 @@ module Decidim
125
125
  application/vnd.oasis.opendocument
126
126
  application/pdf
127
127
  application/rtf
128
+ application/json
129
+ text/markdown
128
130
  text/plain
131
+ text/csv
129
132
  )
130
133
  },
131
134
  "maximum_file_size" => {
@@ -37,6 +37,10 @@ module Decidim
37
37
  raise "Not implemented"
38
38
  end
39
39
 
40
+ def self.order_by_name
41
+ includes(:user).order("decidim_users.name ASC")
42
+ end
43
+
40
44
  private
41
45
 
42
46
  # Private: check if the process and the user have the same organization
@@ -10,22 +10,6 @@ module Decidim
10
10
  #
11
11
  # Returns nothing.
12
12
  def self.included(type)
13
- type.field :participatory_processes,
14
- [Decidim::ParticipatoryProcesses::ParticipatoryProcessType],
15
- null: true,
16
- description: "Lists all participatory_processes" do
17
- argument :filter, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputFilter, "This argument lets you filter the results", required: false
18
- argument :order, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputSort, "This argument lets you order the results", required: false
19
- end
20
-
21
- type.field :participatory_process,
22
- Decidim::ParticipatoryProcesses::ParticipatoryProcessType,
23
- null: true,
24
- description: "Finds a participatory_process" do
25
- argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
26
- argument :slug, String, "The slug of the participatory process", required: false
27
- end
28
-
29
13
  type.field :component, Decidim::Core::ComponentInterface, null: true do
30
14
  description "Lists the components this space contains."
31
15
  argument :id, GraphQL::Types::ID, required: true, description: "The ID of the component to be found"
@@ -62,16 +46,6 @@ module Decidim
62
46
  end
63
47
  end
64
48
 
65
- def participatory_processes(filter: {}, order: {})
66
- manifest = Decidim.participatory_space_manifests.select { |m| m.name == :participatory_processes }.first
67
- Decidim::Core::ParticipatorySpaceListBase.new(manifest:).call(object, { filter:, order: }, context)
68
- end
69
-
70
- def participatory_process(id: nil, slug: nil)
71
- manifest = Decidim.participatory_space_manifests.select { |m| m.name == :participatory_processes }.first
72
- Decidim::Core::ParticipatorySpaceFinderBase.new(manifest:).call(object, { id:, slug: }, context)
73
- end
74
-
75
49
  def component(id: {})
76
50
  component = Decidim::Component.published.find_by(id:)
77
51
  component&.organization == context[:current_organization] ? component : nil
@@ -116,6 +116,8 @@ module Decidim
116
116
  validates :type, inclusion: { in: TYPES.keys }
117
117
 
118
118
  def type_class
119
+ return Decidim::Attributes::RichText if type == :text && editor == true
120
+
119
121
  TYPES[type][:klass]
120
122
  end
121
123
 
@@ -34,6 +34,7 @@ module Decidim
34
34
  # end
35
35
  #
36
36
  # Returns nothing.
37
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
37
38
  def translatable_attribute(name, type, **)
38
39
  attribute(name, { String => Object }, default: {})
39
40
 
@@ -41,6 +42,8 @@ module Decidim
41
42
  attribute_name = "#{name}_#{locale}".gsub("-", "__")
42
43
  attribute(attribute_name, type, **)
43
44
 
45
+ value_type = attribute_types[attribute_name.to_s]
46
+
44
47
  define_method attribute_name do
45
48
  field = public_send(name) || {}
46
49
  value =
@@ -51,7 +54,6 @@ module Decidim
51
54
  # changed and the old value is still stored against the record.
52
55
  field
53
56
  end
54
- value_type = self.class.attribute_types[attribute_name.to_s]
55
57
  value_type ? value_type.cast(value) : value
56
58
  end
57
59
 
@@ -60,12 +62,15 @@ module Decidim
60
62
  final = super(value)
61
63
  return unless final # Do not set the `nil` values for the parent hash
62
64
 
65
+ final = value_type.serialize(final) if value_type
66
+
63
67
  public_send("#{name}=", field.merge(locale => final))
64
68
  end
65
69
 
66
70
  yield(attribute_name, locale) if block_given?
67
71
  end
68
72
  end
73
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
69
74
 
70
75
  def locales
71
76
  Decidim.available_locales
@@ -91,7 +91,7 @@ module Decidim
91
91
  end
92
92
 
93
93
  def cache_expiry_time
94
- nil
94
+ Decidim.cache_expiry_time
95
95
  end
96
96
 
97
97
  def decidim
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :upgrade do
5
+ desc "Cleanup the orphaned blobs attachments"
6
+ task :attachments_cleanup, [:clean_up_unattached_blobs_after_in_minutes] => :environment do |_task, args|
7
+ args.with_defaults(clean_up_unattached_blobs_after_in_minutes: 60)
8
+
9
+ clean_up_unattached_blobs_after_in_minutes = args[:clean_up_unattached_blobs_after_in_minutes].to_i
10
+
11
+ ActiveStorage::Blob.unattached.where(created_at: ..clean_up_unattached_blobs_after_in_minutes.minutes.ago).find_each(batch_size: 100, &:purge_later)
12
+ end
13
+ end
14
+ end
@@ -8,9 +8,18 @@ namespace :decidim do
8
8
  :"decidim:upgrade:clean:searchable_resources",
9
9
  :"decidim:upgrade:clean:notifications",
10
10
  :"decidim:upgrade:clean:follows",
11
- :"decidim:upgrade:clean:action_logs"
11
+ :"decidim:upgrade:clean:action_logs",
12
+ :"decidim:upgrade:clean:clean_deleted_users",
13
+ :"decidim:upgrade:clean:fix_blocked_user_notification"
12
14
  ]
13
15
 
16
+ desc "Remove data from deleted users"
17
+ task clean_deleted_users: :environment do
18
+ logger = Logger.new($stdout)
19
+ logger.info("=== Removing extra data from deleted users")
20
+ Decidim::User.where.not(deleted_at: nil).update_all(personal_url: "", about: "", notifications_sending_frequency: "none") # rubocop:disable Rails/SkipsModelValidations
21
+ end
22
+
14
23
  desc "Removes any action logs belonging to invalid resources"
15
24
  task :action_logs, [] => :environment do
16
25
  puts "=== Deleting Action logs\n"
@@ -100,15 +109,32 @@ namespace :decidim do
100
109
  end
101
110
  puts "===== Deleted #{invalid} invalid resources\n"
102
111
  end
103
- end
104
112
 
105
- desc "Removes orphan categorizations"
106
- task fix_orphan_categorizations: :environment do
107
- logger = Logger.new($stdout)
108
- logger.info("Removing orphan categorizations...")
113
+ desc "Removes orphan categorizations"
114
+ task fix_orphan_categorizations: :environment do
115
+ logger = Logger.new($stdout)
116
+ logger.info("Removing orphan categorizations...")
117
+
118
+ Decidim::Categorization.find_each do |categorization|
119
+ categorization.destroy if categorization.categorizable.nil?
120
+ end
121
+ end
122
+
123
+ desc "Update all blocked users notifications_sending_frequency setting"
124
+ task fix_blocked_user_notification: :environment do
125
+ logger.info("=== Updating all blocked users notifications_sending_frequency ...")
126
+ blocked_users = 0
127
+ Decidim::User.blocked.where.not("notifications_sending_frequency = ?", "none").find_each do |blocked_user|
128
+ unless blocked_user.notifications_sending_frequency == "none"
129
+ blocked_user.update(notifications_sending_frequency: "none")
130
+ blocked_users += 1
131
+ end
132
+ end
133
+ logger.info("===== Updated #{blocked_users} blocked users")
134
+ end
109
135
 
110
- Decidim::Categorization.find_each do |categorization|
111
- categorization.destroy if categorization.categorizable.nil?
136
+ def logger
137
+ @logger ||= Logger.new($stdout)
112
138
  end
113
139
  end
114
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.29.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-09-10 00:00:00.000000000 Z
13
+ date: 2025-02-12 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: concurrent-ruby
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 1.3.4
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: active_link_to
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -758,28 +772,28 @@ dependencies:
758
772
  requirements:
759
773
  - - '='
760
774
  - !ruby/object:Gem::Version
761
- version: 0.29.0
775
+ version: 0.29.2
762
776
  type: :development
763
777
  prerelease: false
764
778
  version_requirements: !ruby/object:Gem::Requirement
765
779
  requirements:
766
780
  - - '='
767
781
  - !ruby/object:Gem::Version
768
- version: 0.29.0
782
+ version: 0.29.2
769
783
  - !ruby/object:Gem::Dependency
770
784
  name: decidim-dev
771
785
  requirement: !ruby/object:Gem::Requirement
772
786
  requirements:
773
787
  - - '='
774
788
  - !ruby/object:Gem::Version
775
- version: 0.29.0
789
+ version: 0.29.2
776
790
  type: :development
777
791
  prerelease: false
778
792
  version_requirements: !ruby/object:Gem::Requirement
779
793
  requirements:
780
794
  - - '='
781
795
  - !ruby/object:Gem::Version
782
- version: 0.29.0
796
+ version: 0.29.2
783
797
  description: Adds core features so other engines can hook into the framework.
784
798
  email:
785
799
  - josepjaume@gmail.com
@@ -1173,6 +1187,7 @@ files:
1173
1187
  - app/constraints/decidim/current_component.rb
1174
1188
  - app/controllers/concerns/decidim/devise_authentication_methods.rb
1175
1189
  - app/controllers/concerns/decidim/devise_controllers.rb
1190
+ - app/controllers/concerns/decidim/direct_upload.rb
1176
1191
  - app/controllers/concerns/decidim/disable_redirection_to_external_host.rb
1177
1192
  - app/controllers/concerns/decidim/filter_resource.rb
1178
1193
  - app/controllers/concerns/decidim/flaggable.rb
@@ -1312,6 +1327,7 @@ files:
1312
1327
  - app/forms/decidim/user_interest_scope_form.rb
1313
1328
  - app/forms/decidim/user_interests_form.rb
1314
1329
  - app/helpers/concerns/decidim/flash_helper_extensions.rb
1330
+ - app/helpers/concerns/decidim/user_role_checker.rb
1315
1331
  - app/helpers/decidim/account_helper.rb
1316
1332
  - app/helpers/decidim/action_authorization_helper.rb
1317
1333
  - app/helpers/decidim/amendments_helper.rb
@@ -1673,6 +1689,7 @@ files:
1673
1689
  - app/packs/src/decidim/notifications_actions.js
1674
1690
  - app/packs/src/decidim/password_toggler.js
1675
1691
  - app/packs/src/decidim/remote_modal.js
1692
+ - app/packs/src/decidim/remote_tooltips.js
1676
1693
  - app/packs/src/decidim/responsive_horizontal_tabs.js
1677
1694
  - app/packs/src/decidim/results_listing.js
1678
1695
  - app/packs/src/decidim/scroll_to_last_child.js
@@ -2137,6 +2154,8 @@ files:
2137
2154
  - config/locales/ar.yml
2138
2155
  - config/locales/bg-BG.yml
2139
2156
  - config/locales/bg.yml
2157
+ - config/locales/bn-BD.yml
2158
+ - config/locales/bs-BA.yml
2140
2159
  - config/locales/ca.yml
2141
2160
  - config/locales/cs-CZ.yml
2142
2161
  - config/locales/cs.yml
@@ -2640,6 +2659,7 @@ files:
2640
2659
  - lib/decidim/attributes/localized_date.rb
2641
2660
  - lib/decidim/attributes/model.rb
2642
2661
  - lib/decidim/attributes/object.rb
2662
+ - lib/decidim/attributes/rich_text.rb
2643
2663
  - lib/decidim/attributes/symbol.rb
2644
2664
  - lib/decidim/attributes/time_with_zone.rb
2645
2665
  - lib/decidim/authorable.rb
@@ -2663,6 +2683,7 @@ files:
2663
2683
  - lib/decidim/content_blocks/has_related_components.rb
2664
2684
  - lib/decidim/content_parsers.rb
2665
2685
  - lib/decidim/content_parsers/base_parser.rb
2686
+ - lib/decidim/content_parsers/blob_parser.rb
2666
2687
  - lib/decidim/content_parsers/hashtag_parser.rb
2667
2688
  - lib/decidim/content_parsers/inline_images_parser.rb
2668
2689
  - lib/decidim/content_parsers/link_parser.rb
@@ -2674,6 +2695,7 @@ files:
2674
2695
  - lib/decidim/content_processor.rb
2675
2696
  - lib/decidim/content_renderers.rb
2676
2697
  - lib/decidim/content_renderers/base_renderer.rb
2698
+ - lib/decidim/content_renderers/blob_renderer.rb
2677
2699
  - lib/decidim/content_renderers/hashtag_renderer.rb
2678
2700
  - lib/decidim/content_renderers/link_renderer.rb
2679
2701
  - lib/decidim/content_renderers/resource_renderer.rb
@@ -2966,6 +2988,7 @@ files:
2966
2988
  - lib/tasks/decidim_tasks.rake
2967
2989
  - lib/tasks/decidim_webpacker_tasks.rake
2968
2990
  - lib/tasks/upgrade/decidim_active_storage_migration_tasks.rake
2991
+ - lib/tasks/upgrade/decidim_attachments.rake
2969
2992
  - lib/tasks/upgrade/decidim_content_blocks_tasks.rake
2970
2993
  - lib/tasks/upgrade/decidim_deduplicate_endorsements.rake
2971
2994
  - lib/tasks/upgrade/decidim_fix_categorization.rake
@@ -2976,7 +2999,7 @@ files:
2976
2999
  - lib/tasks/upgrade/decidim_user_moderation.rake
2977
3000
  homepage: https://decidim.org
2978
3001
  licenses:
2979
- - AGPL-3.0
3002
+ - AGPL-3.0-or-later
2980
3003
  metadata:
2981
3004
  bug_tracker_uri: https://github.com/decidim/decidim/issues
2982
3005
  documentation_uri: https://docs.decidim.org/