decidim-decidim_awesome 0.12.5 → 0.12.6

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: c6040a5cab606622ed2cc0b108db81f7c5f9d248d912ddc4114134d23558570b
4
- data.tar.gz: ac4149f478ec1d884a20b5f5501b76a466fe1f53f345814800dcb29f73817b75
3
+ metadata.gz: 7a93fd5654a7ea63af02a37299d1857ed3b125c83d3ad7b0ee5cb4338c476e00
4
+ data.tar.gz: 7dc357b32b4d3929ba184cab95a79cd9191639b45952ac0e3fa1ba2f92d686e5
5
5
  SHA512:
6
- metadata.gz: 28a535597361b171cf5144df3036ee4cf2d84c43eb5847570224348521533081dba61c8f8354af6ddefe7403a109003bd03e645159d838e2379bca202299f1f3
7
- data.tar.gz: edbb6c2b87af2a4f4ddb3b81ec5ffd40b92932847c3c12de4b4e0f9b3dcb7c3101926dc30d50f93779e1c97284e4a3f659f7e72b2150f7657cb2feed93abe406
6
+ metadata.gz: 65a509ac8bc9497765bc86c514ffcbfc1eee346cbf06336e0a1216f413bdcee369677694b2d2a5c7277a699142b0f588cb5c58b13ac59af4161d0cf4b7eb55ca
7
+ data.tar.gz: 033ca4c1fb845cdfb0cc7b2d84b261c283716a406462673611a25f91ee62487c1f75797063913e7f518d0175fab2b87f9ea0f4e0ad4154f94963d70a6001a4cb
data/CHANGELOG.md CHANGED
@@ -1,8 +1,20 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ v0.12.6
5
+ -------
6
+
7
+ Compatibility:
8
+ - Decidim 0.29.x
9
+
10
+ Fixes:
11
+ - Fix changing locale when Hashcash is active. Make Hashcash respond only to session & registration controllers.
12
+ - Fix crash when non-installed modules in system checker.
13
+ - Fix some variables not respecting the context where configured (auto_save_forms, validate_caps, etc)
14
+
4
15
  v0.12.5
5
16
  -------
17
+
6
18
  Compatibility:
7
19
  - Decidim 0.29.x
8
20
 
@@ -30,6 +30,7 @@ module Decidim
30
30
 
31
31
  # Dynamically configures the gem https://github.com/BaseSecrete/active_hashcash
32
32
  def set_hashcash_bits
33
+ return unless %w(registrations sessions).include?(controller_name)
33
34
  return if user_signed_in?
34
35
 
35
36
  ActiveHashcash.bits = if controller_name == "registrations"
@@ -79,7 +79,7 @@ module Decidim
79
79
  position: item.position,
80
80
  target: item.try(:target),
81
81
  visibility: item.try(:visibility),
82
- native?: !item.respond_to?(:overrided?)
82
+ native?: !item.respond_to?(:overridden?)
83
83
  )
84
84
  end
85
85
 
@@ -11,11 +11,11 @@ module Decidim
11
11
  end
12
12
 
13
13
  def minimum_title_length
14
- awesome_config.config[:validate_title_min_length].to_i
14
+ awesome_config.config[:validate_title_min_length].nil? ? awesome_config.defaults[:validate_title_min_length].to_i : awesome_config.config[:validate_title_min_length].to_i
15
15
  end
16
16
 
17
17
  def minimum_body_length
18
- awesome_config.config[:validate_body_min_length].to_i
18
+ awesome_config.config[:validate_body_min_length].nil? ? awesome_config.defaults[:validate_body_min_length].to_i : awesome_config.config[:validate_body_min_length].to_i
19
19
  end
20
20
 
21
21
  def custom_fields
@@ -32,9 +32,7 @@ document.addEventListener("DOMContentLoaded", () => {
32
32
  // '[type="hidden"]',
33
33
  '[name="utf8"]',
34
34
  '[name="authenticity_token"]',
35
- "[disabled]",
36
- // there are problems with matrix questions
37
- '[type="checkbox"]'
35
+ "[disabled]"
38
36
  ]
39
37
  });
40
38
 
@@ -25,7 +25,7 @@ module Decidim
25
25
  end
26
26
 
27
27
  def hacked_not_overriding?
28
- !(@menu_item.is_a?(Decidim::MenuItem) || @menu_item.overrided?)
28
+ !(@menu_item.is_a?(Decidim::MenuItem) || @menu_item.overridden?)
29
29
  end
30
30
  end
31
31
  end
@@ -6,34 +6,63 @@ module Decidim
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
+ alias_method :original_validate_caps, :validate_caps
10
+ alias_method :original_validate_marks, :validate_marks
11
+ alias_method :original_validate_caps_first, :validate_caps_first
12
+
9
13
  private
10
14
 
11
15
  def validate_caps(record, attribute, value)
12
- percent = awesome_config(record, "validate_#{attribute}_max_caps_percent").to_f
16
+ awesome_config = awesome_config(record, "validate_#{attribute_without_locale(attribute)}_max_caps_percent")
17
+
18
+ # original method does not take into account accents or anything else than A-Z
19
+ # return original_validate_caps_first(record, attribute, value) if awesome_config.nil?
20
+ percent = if awesome_config.nil?
21
+ 50
22
+ else
23
+ awesome_config.to_f
24
+ end
13
25
  return if value.scan(/[[:upper:]]/).length < value.length * percent / 100
14
26
 
15
27
  record.errors.add(attribute, options[:message] || I18n.t("too_much_caps", scope: "decidim.decidim_awesome.validators", percent: percent.round))
16
28
  end
17
29
 
18
30
  def validate_marks(record, attribute, value)
19
- marks = awesome_config(record, "validate_#{attribute}_max_marks_together").to_i + 1
31
+ awesome_config = awesome_config(record, "validate_#{attribute_without_locale(attribute)}_max_marks_together")
32
+
33
+ marks = if awesome_config.nil?
34
+ 2
35
+ else
36
+ awesome_config.to_i + 1
37
+ end
20
38
  return if value.scan(/[!?¡¿]{#{marks},}/).empty?
21
39
 
22
40
  record.errors.add(attribute, options[:message] || :too_many_marks)
23
41
  end
24
42
 
25
43
  def validate_caps_first(record, attribute, value)
26
- return unless awesome_config(record, "validate_#{attribute}_start_with_caps")
44
+ awesome_config = awesome_config(record, "validate_#{attribute_without_locale(attribute)}_start_with_caps")
45
+
46
+ # original method does not take into account accents or anything else than A-Z
47
+ # return original_validate_caps_first(record, attribute, value) if awesome_config.nil?
48
+ return unless awesome_config || awesome_config.nil?
27
49
  return if value.scan(/\A[[:lower:]]{1}/).empty?
28
50
 
29
51
  record.errors.add(attribute, options[:message] || :must_start_with_caps)
30
52
  end
31
53
 
54
+ def record_awesome_config(record)
55
+ record.try(:awesome_config)
56
+ end
57
+
32
58
  def awesome_config(record, var)
33
- config = record.try(:awesome_config)&.config
34
- return unless config.is_a?(Hash)
59
+ record_awesome_config(record)&.config&.[](var.to_sym)
60
+ end
61
+
62
+ def attribute_without_locale(attribute)
63
+ return attribute unless Decidim.available_locales.map { |locale| "_#{locale}" }.any? { |str| attribute.ends_with?(str) }
35
64
 
36
- config[var.to_sym]
65
+ attribute.to_s[0...-3]
37
66
  end
38
67
  end
39
68
  end
@@ -18,7 +18,7 @@
18
18
  </thead>
19
19
  <tbody>
20
20
  <% current_items.each do |item| %>
21
- <tr<%= " class=menu_hack-addition" if item.try(:overrided?) == false %>>
21
+ <tr<%= " class=menu_hack-addition" if item.try(:overridden?) == false %>>
22
22
  <td><%= item.label %></td>
23
23
  <td><%= item.url %></td>
24
24
  <td><%= item.position %></td>
@@ -26,8 +26,8 @@
26
26
  <td><%= visibility_options.invert[item.try(:visibility)] %></td>
27
27
  <td class="table-list__actions">
28
28
  <%= icon_link_to "pencil-line", decidim_admin_decidim_awesome.edit_menu_hack_path(params[:menu_id], md5(item.url)), t(".edit"), class: "action-icon--edit" %>
29
- <% if item.respond_to?(:overrided?) %>
30
- <%= icon_link_to "close-circle-line", decidim_admin_decidim_awesome.menu_hack_path(params[:menu_id], md5(item.url)), t(".remove#{"_hack" if item.overrided?}"), method: :delete, class: "action-icon--remove", data: { confirm: t(".confirm_destroy") } %>
29
+ <% if item.respond_to?(:overridden?) %>
30
+ <%= icon_link_to "close-circle-line", decidim_admin_decidim_awesome.menu_hack_path(params[:menu_id], md5(item.url)), t(".remove#{"_hack" if item.overridden?}"), method: :delete, class: "action-icon--remove", data: { confirm: t(".confirm_destroy") } %>
31
31
  <% else %>
32
32
  <span class="action-icon">
33
33
  <%= icon "close-circle-line", class: "action-icon action-icon--disabled", role: "img" %>
@@ -28,6 +28,7 @@ decidim-core:
28
28
  decidim-0.29.1: f04f0f5112499a86079119d5f9ae8487
29
29
  /app/helpers/decidim/amendments_helper.rb:
30
30
  decidim-0.29.1: 36072334cba7a58841a6b2fb007d24a6
31
+ decidim-0.29.6: 3cab6a4df40449d985366f46c94db57a
31
32
  /app/presenters/decidim/admin_log/component_presenter.rb:
32
33
  decidim-0.29.1: 77e80d527727acdf117a0c4517a69a7c
33
34
  /app/forms/decidim/account_form.rb:
@@ -7,6 +7,7 @@ module Decidim
7
7
  def initialize(organization)
8
8
  @organization = organization
9
9
  @vars = AwesomeConfig.for_organization(organization).includes(:constraints)
10
+ @saved_vars = @vars.map(&:var).map(&:to_sym)
10
11
  @context = {
11
12
  participatory_space_manifest: nil,
12
13
  participatory_space_slug: nil,
@@ -17,7 +18,7 @@ module Decidim
17
18
  @sub_configs = {}
18
19
  end
19
20
 
20
- attr_reader :context, :organization, :vars, :application_context
21
+ attr_reader :context, :organization, :vars, :application_context, :saved_vars
21
22
  attr_writer :defaults
22
23
 
23
24
  def defaults
@@ -75,7 +76,7 @@ module Decidim
75
76
  valid = @vars.to_h { |v| [v.var.to_sym, v.value] }
76
77
 
77
78
  map_defaults do |key, val|
78
- valid.has_key?(key) ? valid[key] : val
79
+ valid[key].nil? ? val : valid[key]
79
80
  end
80
81
  end
81
82
 
@@ -86,6 +87,11 @@ module Decidim
86
87
  )
87
88
  end
88
89
 
90
+ # Checks if some var has been configured for the organization (not using defaults)
91
+ def saved?(var)
92
+ @saved_vars.include?(var.to_sym)
93
+ end
94
+
89
95
  # Checks if some config setting is enabled in a certain context
90
96
  def enabled_in_context?(setting)
91
97
  config[setting]
@@ -172,10 +178,18 @@ module Decidim
172
178
  end
173
179
  end
174
180
 
181
+ # calculates the config according to the current context
182
+ # - if some var is not valid in the current context, it will be nil
183
+ # Certain keys may want to know if this is a legit value or it is simply not valid in the current context
184
+ # Fot that, use the saved?(var) method
175
185
  def calculate_config
176
- # filter vars compliant with current context
177
- valid = @vars.filter { |item| enabled_for_organization?(item.var) && valid_in_context?(item.all_constraints) }
178
- .to_h { |v| [v.var.to_sym, v.value] }
186
+ # set values to vars according to the current context
187
+ valid = @vars.to_h do |item|
188
+ [
189
+ item.var.to_sym,
190
+ enabled_for_organization?(item.var) && valid_in_context?(item.all_constraints) ? item.value : nil
191
+ ]
192
+ end
179
193
 
180
194
  map_defaults do |key, val|
181
195
  valid.has_key?(key) ? valid[key] : val
@@ -111,7 +111,7 @@ module Decidim
111
111
 
112
112
  # Late registering of components to take into account initializer values
113
113
  DecidimAwesome.registered_components.each do |manifest, block|
114
- next if DecidimAwesome.disabled_components.include?(manifest)
114
+ next if DecidimAwesome.disabled_components&.include?(manifest)
115
115
  next if Decidim.find_component_manifest(manifest)
116
116
 
117
117
  Decidim.register_component(manifest, &block)
@@ -16,7 +16,7 @@ module Decidim
16
16
 
17
17
  initializer "decidim_decidim_awesome.content_blocks" do |_app|
18
18
  # do not register this if awesome_map is disabled
19
- next if DecidimAwesome.disabled_components.include?(:awesome_map)
19
+ next if DecidimAwesome.disabled_components&.include?(:awesome_map)
20
20
 
21
21
  # === Home Map block ===
22
22
  Decidim.content_blocks.register(:homepage, :awesome_map) do |content_block|
@@ -20,7 +20,7 @@ module Decidim
20
20
  menu_overrides.each do |item|
21
21
  default = default_items.find { |i| i.url.gsub(/\?.*/, "") == item.url }
22
22
  if default
23
- item.send("overrided?=", true)
23
+ item.send("overridden?=", true)
24
24
  item[:original_active] = default.active
25
25
  @items.reject! { |i| i.url.gsub(/\?.*/, "") == item.url }
26
26
  end
@@ -58,7 +58,7 @@ module Decidim
58
58
  visibility: item["visibility"],
59
59
  visible?: visible?(item),
60
60
  target: item["target"],
61
- overrided?: false
61
+ overridden?: false
62
62
  )
63
63
  end
64
64
  end
@@ -11,7 +11,10 @@ module Decidim
11
11
 
12
12
  # rubocop:disable Rails/DynamicFindBy
13
13
  checksums = YAML.load_file("#{__dir__}/checksums.yml")
14
- @overrides = checksums.map do |package, files|
14
+
15
+ @overrides = checksums.filter_map do |package, files|
16
+ next unless Decidim::DependencyResolver.instance.needed?(package)
17
+
15
18
  props = {
16
19
  spec: ::Gem::Specification.find_by_name(package),
17
20
  files: files.transform_values(&:values)
@@ -40,6 +40,7 @@ shared_context "with a custom fields enabled" do
40
40
  let!(:private_constraint) { create(:config_constraint, awesome_config: private_config_helper, settings: { "participatory_space_manifest" => "participatory_processes" }) }
41
41
  let(:slug) { participatory_space.slug }
42
42
  end
43
+
43
44
  shared_examples "starts with caps" do |prop|
44
45
  let!(:config) { create(:awesome_config, organization:, var: "validate_#{prop}_start_with_caps", value: enabled) }
45
46
  let!(:constraint) do
@@ -138,7 +139,7 @@ shared_examples "max caps percent" do |prop|
138
139
  context "when scoped under different context" do
139
140
  let(:slug) { "another-slug" }
140
141
 
141
- it_behaves_like "invalid percentage", 25
142
+ it_behaves_like "invalid percentage", 50
142
143
 
143
144
  context "when has less than 25% caps" do
144
145
  let(prop.to_sym) { "Í only have some CÁPS" }
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- welcome_text = "Dashboard"
4
-
5
3
  shared_examples "redirects to index" do |_link|
6
4
  it "display index page" do
7
5
  expect(page).to have_content("You are not authorized to perform this action")
8
- expect(page).to have_content(welcome_text)
6
+ expect(page).to have_content("Dashboard")
9
7
  expect(page).to have_current_path(decidim_admin.root_path, ignore_query: true)
10
8
  end
11
9
  end
@@ -111,12 +109,12 @@ shared_examples "allows all admin routes" do
111
109
  visit decidim_admin.root_path
112
110
  # this is a workaround to wait for the page to load
113
111
  # it seems that the test might fail randomly otherwise
114
- # underlaying issue is unknown, maybe capybara is faster clicking than ruby is at storing class variables?
112
+ # underlying issue is unknown, maybe capybara is faster clicking than ruby is at storing class variables?
115
113
  sleep 0.1
116
114
  end
117
115
 
118
116
  it "allows the admin root page" do
119
- expect(page).to have_content(welcome_text)
117
+ expect(page).to have_content("Dashboard")
120
118
  end
121
119
 
122
120
  it "allows the assemblies page" do
@@ -138,7 +136,7 @@ shared_examples "allows scoped admin routes" do
138
136
  end
139
137
 
140
138
  it "allows the admin root page" do
141
- expect(page).to have_content(welcome_text)
139
+ expect(page).to have_content("Dashboard")
142
140
  end
143
141
 
144
142
  it "allows the assemblies page" do
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # This holds the decidim-decidim_awesome version.
5
5
  module DecidimAwesome
6
- VERSION = "0.12.5"
6
+ VERSION = "0.12.6"
7
7
  COMPAT_DECIDIM_VERSION = [">= 0.29.1", "< 0.30"].freeze
8
8
  end
9
9
  end
data/package.json CHANGED
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "prettier": "@decidim/prettier-config",
36
36
  "devDependencies": {
37
- "@decidim/dev": "0.29.4",
38
- "@decidim/eslint-config": "0.29.4",
39
- "@decidim/prettier-config": "0.29.4",
40
- "@decidim/stylelint-config": "0.29.4",
37
+ "@decidim/dev": "0.29.5",
38
+ "@decidim/eslint-config": "0.29.5",
39
+ "@decidim/prettier-config": "0.29.5",
40
+ "@decidim/stylelint-config": "0.29.5",
41
41
  "postcss-scss": "^4.0.9"
42
42
  },
43
43
  "dependencies": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-decidim_awesome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5
4
+ version: 0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Vergés
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_hashcash