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 +4 -4
- data/CHANGELOG.md +12 -0
- data/app/controllers/concerns/decidim/decidim_awesome/needs_hashcash.rb +1 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +1 -1
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations_base.rb +2 -2
- data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +1 -3
- data/app/presenters/concerns/decidim/decidim_awesome/menu_item_presenter_override.rb +1 -1
- data/app/validators/concerns/decidim/decidim_awesome/etiquette_validator_override.rb +35 -6
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +3 -3
- data/lib/decidim/decidim_awesome/checksums.yml +1 -0
- data/lib/decidim/decidim_awesome/config.rb +19 -5
- data/lib/decidim/decidim_awesome/engine.rb +1 -1
- data/lib/decidim/decidim_awesome/map_component/engine.rb +1 -1
- data/lib/decidim/decidim_awesome/menu_hacker.rb +2 -2
- data/lib/decidim/decidim_awesome/system_checker.rb +4 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/proposal_form_examples.rb +2 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +4 -6
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/package.json +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a93fd5654a7ea63af02a37299d1857ed3b125c83d3ad7b0ee5cb4338c476e00
|
|
4
|
+
data.tar.gz: 7dc357b32b4d3929ba184cab95a79cd9191639b45952ac0e3fa1ba2f92d686e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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"
|
data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations_base.rb
CHANGED
|
@@ -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
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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(:
|
|
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?(:
|
|
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.
|
|
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.
|
|
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
|
-
#
|
|
177
|
-
valid = @vars.
|
|
178
|
-
|
|
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
|
|
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
|
|
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("
|
|
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
|
-
|
|
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
|
-
|
|
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",
|
|
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(
|
|
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
|
-
#
|
|
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(
|
|
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(
|
|
139
|
+
expect(page).to have_content("Dashboard")
|
|
142
140
|
end
|
|
143
141
|
|
|
144
142
|
it "allows the assemblies page" do
|
data/package.json
CHANGED
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"prettier": "@decidim/prettier-config",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@decidim/dev": "0.29.
|
|
38
|
-
"@decidim/eslint-config": "0.29.
|
|
39
|
-
"@decidim/prettier-config": "0.29.
|
|
40
|
-
"@decidim/stylelint-config": "0.29.
|
|
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.
|
|
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-
|
|
11
|
+
date: 2025-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: active_hashcash
|