decidim-decidim_awesome 0.12.0 → 0.12.4
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 +45 -0
- data/README.md +25 -15
- data/Rakefile +12 -0
- data/app/cells/concerns/decidim/decidim_awesome/global_menu_cell_override.rb +14 -2
- data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +5 -4
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +3 -3
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/vote_block_for.erb +1 -1
- data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +39 -5
- data/app/commands/decidim/decidim_awesome/admin/create_authorization_group.rb +42 -0
- data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +10 -14
- data/app/commands/decidim/decidim_awesome/admin/create_menu_hack.rb +9 -8
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +3 -8
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +4 -8
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +3 -7
- data/app/commands/decidim/decidim_awesome/admin/destroy_authorization_group.rb +37 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +10 -9
- data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +8 -7
- data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +7 -13
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +7 -10
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +6 -11
- data/app/commands/decidim/decidim_awesome/admin/update_config.rb +12 -1
- data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +11 -11
- data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +10 -8
- data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +0 -28
- data/app/controllers/concerns/decidim/decidim_awesome/enforce_access_authorizations.rb +49 -0
- data/app/controllers/concerns/decidim/decidim_awesome/needs_hashcash.rb +43 -0
- data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/admin/admin_authorizations_controller.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +0 -4
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +2 -1
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +1 -2
- data/app/controllers/decidim/decidim_awesome/admin/force_authorizations_controller.rb +44 -0
- data/app/controllers/decidim/decidim_awesome/admin/hashcash_controller.rb +39 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +1 -1
- data/app/controllers/decidim/decidim_awesome/admin/{maintenance_controller.rb → private_data_controller.rb} +9 -9
- data/app/controllers/decidim/decidim_awesome/required_authorizations_controller.rb +51 -13
- data/app/controllers/decidim/decidim_awesome/utils_controller.rb +17 -0
- data/app/forms/concerns/decidim/decidim_awesome/proposals/admin/proposal_form_customizations.rb +59 -0
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations.rb +28 -28
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations_base.rb +36 -0
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +7 -1
- data/app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb +66 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +23 -24
- data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +2 -0
- data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +2 -1
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +21 -18
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +4 -2
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +1 -1
- data/app/overrides/decidim/assemblies/admin/assemblies/_form/add_visibility_callout.html.erb.deface +3 -0
- data/app/overrides/decidim/conferences/admin/conferences/_form/add_visibility_callout.html.erb.deface +3 -0
- data/app/overrides/decidim/devise/registrations/new/add_hashcash.html.erb.deface +3 -0
- data/app/overrides/decidim/devise/sessions/new/add_hashcash.html.erb.deface +3 -0
- data/app/overrides/decidim/participatory_processes/admin/participatory_process_groups/_form/add_visibility_callout.html.erb.deface +3 -0
- data/app/overrides/decidim/participatory_processes/admin/participatory_processes/_form/add_visibility_callout.html.erb.deface +3 -0
- data/app/overrides/decidim/shared/_login_modal/add_hashcash.html.erb.deface +3 -0
- data/app/overrides/layouts/decidim/_head/add_awesome_custom_styles.html.erb.deface +3 -0
- data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +0 -2
- data/app/packs/entrypoints/decidim_decidim_awesome_hashcash.js +4 -0
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +25 -6
- data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +4 -2
- data/app/packs/src/decidim/decidim_awesome/admin/verifications.js +6 -3
- data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +0 -1
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +6 -6
- data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +3 -3
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +1 -113
- data/app/packs/src/decidim/decidim_awesome/proposals/images.js +1 -1
- data/app/packs/src/vendor/form_builder_langs/ar-SA.lang +111 -0
- data/app/packs/src/vendor/form_builder_langs/ar-TN.lang +94 -0
- data/app/packs/src/vendor/form_builder_langs/ca-ES.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/cs-CZ.lang +105 -0
- data/app/packs/src/vendor/form_builder_langs/da-DK.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/de-DE.lang +109 -0
- data/app/packs/src/vendor/form_builder_langs/el-GR.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/en-US.lang +117 -0
- data/app/packs/src/vendor/form_builder_langs/es-ES.lang +103 -0
- data/app/packs/src/vendor/form_builder_langs/fa-IR.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/fi-FI.lang +107 -0
- data/app/packs/src/vendor/form_builder_langs/fr-FR.lang +117 -0
- data/app/packs/src/vendor/form_builder_langs/he-IL.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/hi-IN.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/hu-HU.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/id-ID.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/it-IT.lang +107 -0
- data/app/packs/src/vendor/form_builder_langs/ja-JP.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/my-MM.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/nb-NO.lang +94 -0
- data/app/packs/src/vendor/form_builder_langs/nl-NL.lang +94 -0
- data/app/packs/src/vendor/form_builder_langs/pl-PL.lang +122 -0
- data/app/packs/src/vendor/form_builder_langs/pt-BR.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/pu-IN.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/qz-MM.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/ro-RO.lang +94 -0
- data/app/packs/src/vendor/form_builder_langs/ru-RU.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/sl-SI.lang +110 -0
- data/app/packs/src/vendor/form_builder_langs/th-TH.lang +111 -0
- data/app/packs/src/vendor/form_builder_langs/tr-TR.lang +115 -0
- data/app/packs/src/vendor/form_builder_langs/uk-UA.lang +108 -0
- data/app/packs/src/vendor/form_builder_langs/vi-VN.lang +94 -0
- data/app/packs/src/vendor/form_builder_langs/zh-CN.lang +100 -0
- data/app/packs/src/vendor/form_builder_langs/zh-TW.lang +94 -0
- data/app/packs/src/vendor/hashcash.js +83 -0
- data/app/packs/src/vendor/sha1.js +143 -0
- data/app/packs/src/vendor/stamp.js +50 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +6 -1
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +5 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +1 -2
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +2 -12
- data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +2 -2
- data/app/queries/decidim/decidim_awesome/space_constraint_finder.rb +43 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +3 -2
- data/app/services/decidim/decidim_awesome/access_authorization_service.rb +79 -0
- data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +2 -1
- data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +4 -4
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/callout.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/conflict.html.erb +4 -4
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/edit.html.erb +6 -5
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +6 -6
- data/app/views/decidim/decidim_awesome/admin/config/_authorization_options_form.html.erb +19 -0
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +3 -3
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +4 -3
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +4 -4
- data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_styles.html.erb +3 -3
- data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +40 -2
- data/app/views/decidim/decidim_awesome/admin/config/_form_verifications.html.erb +71 -9
- data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +5 -4
- data/app/views/decidim/decidim_awesome/admin/hashcash/_filters.html.erb +55 -0
- data/app/views/decidim/decidim_awesome/admin/hashcash/index.html.erb +33 -0
- data/app/views/decidim/decidim_awesome/admin/hashcash/ip_addresses.html.erb +29 -0
- data/app/views/decidim/decidim_awesome/admin/hashcash/show.html.erb +42 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/admin/{maintenance → private_data}/_private_data.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/admin/{maintenance/show.html.erb → private_data/index.html.erb} +2 -3
- data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/shared/_visibility_notice.html.erb +8 -0
- data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/hashcash/_hidden_field.html.erb +4 -0
- data/app/views/decidim/decidim_awesome/required_authorizations/index.html.erb +14 -4
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +2 -2
- data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +2 -11
- data/config/assets.rb +1 -0
- data/config/i18n-tasks.yml +2 -0
- data/config/locales/ca.yml +100 -37
- data/config/locales/cs.yml +100 -36
- data/config/locales/de.yml +98 -35
- data/config/locales/en.yml +117 -44
- data/config/locales/es.yml +100 -36
- data/config/locales/eu.yml +34 -39
- data/config/locales/fr.yml +77 -31
- data/config/locales/ja.yml +99 -36
- data/config/locales/sv.yml +49 -0
- data/lib/decidim/decidim_awesome/admin_engine.rb +9 -5
- data/lib/decidim/decidim_awesome/{authorizator.rb → authorizer.rb} +1 -1
- data/lib/decidim/decidim_awesome/awesome.rb +34 -24
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +14 -5
- data/lib/decidim/decidim_awesome/checksums.yml +26 -40
- data/lib/decidim/decidim_awesome/config.rb +18 -7
- data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +1 -1
- data/lib/decidim/decidim_awesome/engine.rb +14 -3
- data/lib/decidim/decidim_awesome/menu.rb +151 -138
- data/lib/decidim/decidim_awesome/middleware/current_config.rb +5 -10
- data/lib/decidim/decidim_awesome/test/initializer.rb +5 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +1 -3
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +2 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/proposal_form_examples.rb +191 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +15 -4
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -1
- data/package.json +7 -8
- metadata +86 -13
- data/app/controllers/concerns/decidim/decidim_awesome/check_login_authorizations.rb +0 -60
- data/app/packs/src/decidim/decidim_awesome/admin/verification_selects.js +0 -21
- data/config/rubocop/disabled.yml +0 -11
- data/config/rubocop/faker.yml +0 -480
- data/config/rubocop/rails.yml +0 -88
- data/config/rubocop/rspec.yml +0 -65
- data/config/rubocop/ruby.yml +0 -1210
@@ -4,162 +4,166 @@ module Decidim
|
|
4
4
|
module DecidimAwesome
|
5
5
|
class Menu
|
6
6
|
class << self
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if: menus[:surveys]
|
29
|
-
|
30
|
-
menu.add_item :styles,
|
31
|
-
I18n.t("menu.styles", scope: "decidim.decidim_awesome.admin"),
|
32
|
-
decidim_admin_decidim_awesome.config_path(:scoped_styles),
|
33
|
-
position: 4,
|
34
|
-
icon_name: "brush",
|
35
|
-
if: menus[:styles],
|
36
|
-
submenu: { target_menu: :custom_styles_submenu }
|
37
|
-
|
38
|
-
menu.add_item :custom_fields,
|
39
|
-
I18n.t("menu.proposal_custom_fields", scope: "decidim.decidim_awesome.admin"),
|
40
|
-
decidim_admin_decidim_awesome.config_path(menus[:proposal_custom_fields] ? :proposal_custom_fields : :proposal_private_custom_fields),
|
41
|
-
position: 5,
|
42
|
-
icon_name: "layers",
|
43
|
-
active: is_active_link?(decidim_admin_decidim_awesome.config_path(:proposal_custom_fields)) ||
|
44
|
-
is_active_link?(decidim_admin_decidim_awesome.config_path(:proposal_private_custom_fields)),
|
45
|
-
if: menus[:custom_fields],
|
46
|
-
submenu: { target_menu: :custom_fields_submenu }
|
47
|
-
|
48
|
-
menu.add_item :admins,
|
49
|
-
I18n.t("menu.admins", scope: "decidim.decidim_awesome.admin"),
|
50
|
-
decidim_admin_decidim_awesome.config_path(:admins),
|
51
|
-
position: 6,
|
52
|
-
icon_name: "group-line",
|
53
|
-
if: menus[:admins]
|
54
|
-
|
55
|
-
menu.add_item :menu_hacks,
|
56
|
-
I18n.t("menu.menu_hacks", scope: "decidim.decidim_awesome.admin"),
|
57
|
-
decidim_admin_decidim_awesome.menu_hacks_path(menus[:menu_hacks_menu] ? :menu : :home_content_block_menu),
|
58
|
-
position: 7,
|
59
|
-
icon_name: "menu-line",
|
60
|
-
if: menus[:menu_hacks],
|
61
|
-
active: is_active_link?(decidim_admin_decidim_awesome.menu_hacks_path(:menu)) ||
|
62
|
-
is_active_link?(decidim_admin_decidim_awesome.menu_hacks_path(:home_content_block_menu)),
|
63
|
-
submenu: { target_menu: :menu_hacks_submenu }
|
64
|
-
|
65
|
-
menu.add_item :custom_redirects,
|
66
|
-
I18n.t("menu.custom_redirects", scope: "decidim.decidim_awesome.admin"),
|
67
|
-
decidim_admin_decidim_awesome.custom_redirects_path,
|
68
|
-
position: 8,
|
69
|
-
icon_name: "external-link-line",
|
70
|
-
if: menus[:custom_redirects]
|
71
|
-
|
72
|
-
menu.add_item :livechat,
|
73
|
-
I18n.t("menu.livechat", scope: "decidim.decidim_awesome.admin"),
|
74
|
-
decidim_admin_decidim_awesome.config_path(:livechat),
|
75
|
-
position: 9,
|
76
|
-
icon_name: "chat-1-line",
|
77
|
-
if: menus[:livechat]
|
78
|
-
|
79
|
-
menu.add_item :verifications,
|
80
|
-
I18n.t("menu.verifications", scope: "decidim.decidim_awesome.admin"),
|
81
|
-
decidim_admin_decidim_awesome.config_path(:verifications),
|
82
|
-
position: 10,
|
83
|
-
icon_name: "fingerprint-line",
|
84
|
-
if: menus[:verifications]
|
85
|
-
|
86
|
-
menu.add_item :maintenance,
|
87
|
-
I18n.t("maintenance", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
88
|
-
decidim_admin_decidim_awesome.maintenance_path(:private_data),
|
89
|
-
position: 11,
|
90
|
-
icon_name: "tools-line",
|
91
|
-
active: is_active_link?(decidim_admin_decidim_awesome.maintenance_path(:private_data)) ||
|
92
|
-
is_active_link?(decidim_admin_decidim_awesome.checks_maintenance_index_path),
|
93
|
-
submenu: { target_menu: :maintenance_submenu }
|
7
|
+
def register_simple_entry(menu_registry, name, position, icon, options = {})
|
8
|
+
return if menus[name].blank?
|
9
|
+
|
10
|
+
Decidim.menu menu_registry do |menu|
|
11
|
+
i18n_key = options[:i18n_key].presence || "menu.#{name}"
|
12
|
+
extra = {}.tap do |hash|
|
13
|
+
hash[:submenu] = options[:submenu] if options[:submenu].present?
|
14
|
+
if options[:active].present?
|
15
|
+
hash[:active] = false
|
16
|
+
options[:active].each do |active_path|
|
17
|
+
hash[:active] ||= is_active_link?(decidim_admin_decidim_awesome.send(active_path[0], *active_path[1..]))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
path = main_path_for(name)
|
22
|
+
menu.add_item name,
|
23
|
+
I18n.t(i18n_key, scope: "decidim.decidim_awesome.admin"),
|
24
|
+
decidim_admin_decidim_awesome.send(path[0], path[1]),
|
25
|
+
position:,
|
26
|
+
icon_name: icon,
|
27
|
+
**extra
|
94
28
|
end
|
95
29
|
end
|
96
30
|
|
31
|
+
def main_path_for(config_var)
|
32
|
+
case config_var.to_sym
|
33
|
+
when :styles
|
34
|
+
[:config_path, [menus[:styles]]]
|
35
|
+
when :custom_fields
|
36
|
+
[:config_path, [menus[:custom_fields]]]
|
37
|
+
when :menu_hacks
|
38
|
+
[:menu_hacks_path, [menus[:menu_hacks]]]
|
39
|
+
when :custom_redirects
|
40
|
+
[:custom_redirects_path, []]
|
41
|
+
when :maintenance
|
42
|
+
[:checks_path, []]
|
43
|
+
else
|
44
|
+
[:config_path, [config_var]]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def register_awesome_admin_menu!
|
49
|
+
register_simple_entry(:awesome_admin_menu, :editors, 1, "editors-text")
|
50
|
+
register_simple_entry(:awesome_admin_menu, :proposals, 2, "documents")
|
51
|
+
register_simple_entry(:awesome_admin_menu, :surveys, 3, "surveys")
|
52
|
+
register_simple_entry(:awesome_admin_menu, :styles, 4, "brush",
|
53
|
+
submenu: { target_menu: :custom_styles_submenu },
|
54
|
+
active: [[:config_path, :scoped_styles], [:config_path, :scoped_admin_styles]])
|
55
|
+
|
56
|
+
register_simple_entry(:awesome_admin_menu, :custom_fields, 5, "layers",
|
57
|
+
i18n_key: "menu.proposal_custom_fields",
|
58
|
+
submenu: { target_menu: :custom_fields_submenu },
|
59
|
+
active: [[:config_path, :proposal_custom_fields], [:config_path, :proposal_private_custom_fields]])
|
60
|
+
|
61
|
+
register_simple_entry(:awesome_admin_menu, :admins, 6, "group-line")
|
62
|
+
|
63
|
+
register_simple_entry(:awesome_admin_menu, :menu_hacks, 7, "menu-line",
|
64
|
+
submenu: { target_menu: :menu_hacks_submenu },
|
65
|
+
active: [[:menu_hacks_path, :menu], [:menu_hacks_path, :mobile_menu], [:menu_hacks_path, :home_content_block_menu]])
|
66
|
+
|
67
|
+
register_simple_entry(:awesome_admin_menu, :custom_redirects, 8, "external-link-line")
|
68
|
+
register_simple_entry(:awesome_admin_menu, :livechat, 9, "chat-1-line")
|
69
|
+
register_simple_entry(:awesome_admin_menu, :verifications, 10, "fingerprint-line")
|
70
|
+
|
71
|
+
register_simple_entry(:awesome_admin_menu, :maintenance, 11, "tools-line",
|
72
|
+
i18n_key: "menu.maintenance.maintenance",
|
73
|
+
submenu: { target_menu: :maintenance_submenu },
|
74
|
+
active: [[:private_data_path], [:hashcashes_path], [:checks_path]])
|
75
|
+
end
|
76
|
+
|
97
77
|
def register_custom_fields_submenu!
|
98
78
|
Decidim.menu :custom_fields_submenu do |menu|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
79
|
+
if menus[:proposal_custom_fields].present?
|
80
|
+
menu.add_item :proposal_custom_fields,
|
81
|
+
I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"),
|
82
|
+
decidim_admin_decidim_awesome.config_path(:proposal_custom_fields),
|
83
|
+
position: 5.1,
|
84
|
+
icon_name: "draft-line"
|
85
|
+
end
|
86
|
+
|
87
|
+
if menus[:proposal_private_custom_fields].present?
|
88
|
+
menu.add_item :proposal_private_custom_fields,
|
89
|
+
I18n.t("proposal_private_custom_fields", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"),
|
90
|
+
decidim_admin_decidim_awesome.config_path(:proposal_private_custom_fields),
|
91
|
+
position: 5.2,
|
92
|
+
icon_name: "spy"
|
93
|
+
end
|
112
94
|
end
|
113
95
|
end
|
114
96
|
|
115
97
|
def register_custom_styles_submenu!
|
116
98
|
Decidim.menu :custom_styles_submenu do |menu|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
99
|
+
if menus[:scoped_styles].present?
|
100
|
+
menu.add_item :scoped_styles,
|
101
|
+
I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.scoped_styles"),
|
102
|
+
decidim_admin_decidim_awesome.config_path(:scoped_styles),
|
103
|
+
position: 4.1,
|
104
|
+
icon_name: "computer-line"
|
105
|
+
end
|
106
|
+
|
107
|
+
if menus[:scoped_admin_styles].present?
|
108
|
+
menu.add_item :scoped_admin_styles,
|
109
|
+
I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.scoped_admin_styles"),
|
110
|
+
decidim_admin_decidim_awesome.config_path(:scoped_admin_styles),
|
111
|
+
position: 4.2,
|
112
|
+
icon_name: "file-settings-line"
|
113
|
+
end
|
130
114
|
end
|
131
115
|
end
|
132
116
|
|
133
117
|
def register_menu_hacks_submenu!
|
134
118
|
Decidim.menu :menu_hacks_submenu do |menu|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
119
|
+
if menus[:menu_hacks_menu].present?
|
120
|
+
menu.add_item :main_menu,
|
121
|
+
I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
|
122
|
+
decidim_admin_decidim_awesome.menu_hacks_path(:menu),
|
123
|
+
position: 7.1,
|
124
|
+
icon_name: "global-line"
|
125
|
+
end
|
126
|
+
|
127
|
+
if menus[:menu_hacks_mobile_menu].present?
|
128
|
+
menu.add_item :mobile_menu,
|
129
|
+
I18n.t("mobile_menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
|
130
|
+
decidim_admin_decidim_awesome.menu_hacks_path(:mobile_menu),
|
131
|
+
position: 7.2,
|
132
|
+
icon_name: "smartphone"
|
133
|
+
end
|
134
|
+
|
135
|
+
if menus[:menu_hacks_home_content_block_menu].present?
|
136
|
+
menu.add_item :content_block_main_menu,
|
137
|
+
I18n.t("home_content_block_menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
|
138
|
+
decidim_admin_decidim_awesome.menu_hacks_path(:home_content_block_menu),
|
139
|
+
position: 7.3,
|
140
|
+
icon_name: "layout-masonry-line"
|
141
|
+
end
|
148
142
|
end
|
149
143
|
end
|
150
144
|
|
151
145
|
def register_maintenance_admin_menu!
|
152
146
|
Decidim.menu :maintenance_submenu do |menu|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
147
|
+
if config_enabled?(:proposal_private_custom_fields)
|
148
|
+
menu.add_item :private_data,
|
149
|
+
I18n.t("private_data", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
150
|
+
decidim_admin_decidim_awesome.private_data_path,
|
151
|
+
position: 10.1,
|
152
|
+
icon_name: "spy-line"
|
153
|
+
end
|
154
|
+
|
155
|
+
if config_enabled?(:hashcash_signup, :hashcash_login)
|
156
|
+
menu.add_item :hashcash,
|
157
|
+
I18n.t("hashcash", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
158
|
+
decidim_admin_decidim_awesome.hashcashes_path,
|
159
|
+
position: 10.2,
|
160
|
+
icon_name: "hashtag"
|
161
|
+
end
|
158
162
|
|
159
163
|
menu.add_item :checks,
|
160
164
|
I18n.t("checks", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
161
|
-
decidim_admin_decidim_awesome.
|
162
|
-
position: 10,
|
165
|
+
decidim_admin_decidim_awesome.checks_path,
|
166
|
+
position: 10.3,
|
163
167
|
icon_name: "pulse"
|
164
168
|
end
|
165
169
|
end
|
@@ -174,23 +178,32 @@ module Decidim
|
|
174
178
|
:validate_body_min_length, :validate_body_max_caps_percent,
|
175
179
|
:validate_body_max_marks_together, :validate_body_start_with_caps
|
176
180
|
),
|
177
|
-
surveys: config_enabled?(:auto_save_forms, :user_timezone),
|
178
|
-
styles:
|
181
|
+
surveys: config_enabled?(:auto_save_forms, :user_timezone, :hashcash_signup, :hashcash_login),
|
182
|
+
styles: first_enabled(:scoped_styles, :scoped_admin_styles),
|
179
183
|
scoped_styles: config_enabled?(:scoped_styles),
|
180
184
|
scoped_admin_styles: config_enabled?(:scoped_admin_styles),
|
181
|
-
custom_fields:
|
185
|
+
custom_fields: first_enabled(:proposal_custom_fields, :proposal_private_custom_fields),
|
182
186
|
proposal_custom_fields: config_enabled?(:proposal_custom_fields),
|
183
187
|
proposal_private_custom_fields: config_enabled?(:proposal_private_custom_fields),
|
184
188
|
admins: config_enabled?(:scoped_admins),
|
185
|
-
menu_hacks:
|
189
|
+
menu_hacks: first_enabled(:menu, :mobile_menu, :home_content_block_menu),
|
186
190
|
menu_hacks_menu: config_enabled?(:menu),
|
191
|
+
menu_hacks_mobile_menu: config_enabled?(:mobile_menu),
|
187
192
|
menu_hacks_home_content_block_menu: config_enabled?(:home_content_block_menu),
|
188
193
|
custom_redirects: config_enabled?(:custom_redirects),
|
189
194
|
livechat: config_enabled?(:intergram_for_admins, :intergram_for_public),
|
190
|
-
verifications: config_enabled?(:
|
195
|
+
verifications: config_enabled?(:force_authorizations),
|
196
|
+
maintenance: true
|
191
197
|
}
|
192
198
|
end
|
193
199
|
|
200
|
+
def first_enabled(*vars)
|
201
|
+
vars.each do |var|
|
202
|
+
return var if config_enabled?(var)
|
203
|
+
end
|
204
|
+
nil
|
205
|
+
end
|
206
|
+
|
194
207
|
# ensure boolean value
|
195
208
|
def config_enabled?(*vars)
|
196
209
|
DecidimAwesome.enabled?(*vars)
|
@@ -17,15 +17,10 @@ module Decidim
|
|
17
17
|
def call(env)
|
18
18
|
@request = Rack::Request.new(env)
|
19
19
|
if @request.env["decidim.current_organization"] && processable_path?
|
20
|
-
|
21
|
-
env["decidim_awesome.current_config"] =
|
20
|
+
# memoize for later
|
21
|
+
@config = env["decidim_awesome.current_config"] = awesome_config_instance
|
22
22
|
tamper_user_model
|
23
23
|
add_flash_message_from_request(env)
|
24
|
-
|
25
|
-
# puts "requested path: #{env["PATH_INFO"]}"
|
26
|
-
# puts "current_organization: #{@request.env["decidim.current_organization"]&.id}"
|
27
|
-
# puts "potential_admins: #{Decidim::User.awesome_potential_admins}"
|
28
|
-
# puts "scoped admins: #{Decidim::User.awesome_admins_for_current_scope}"
|
29
24
|
else
|
30
25
|
reset_user_model
|
31
26
|
end
|
@@ -35,7 +30,7 @@ module Decidim
|
|
35
30
|
|
36
31
|
private
|
37
32
|
|
38
|
-
# a workaround to set a flash message if
|
33
|
+
# a workaround to set a flash message if coming from the error controller (route not found)
|
39
34
|
def add_flash_message_from_request(env)
|
40
35
|
return unless scoped_admins_active?
|
41
36
|
return unless @request.params.has_key? "unauthorized"
|
@@ -45,7 +40,7 @@ module Decidim
|
|
45
40
|
|
46
41
|
def awesome_config_instance
|
47
42
|
@awesome_config_instance = Config.new @request.env["decidim.current_organization"]
|
48
|
-
@awesome_config_instance.context_from_request @request
|
43
|
+
@awesome_config_instance.context_from_request! @request
|
49
44
|
@awesome_config_instance
|
50
45
|
end
|
51
46
|
|
@@ -127,7 +122,7 @@ module Decidim
|
|
127
122
|
# to access certain deeper routes it requires first to click on a parent route, even without Post permissions in there
|
128
123
|
# this adds this additional routes to these cases
|
129
124
|
# For instance:
|
130
|
-
# accessing /admin/participatory_processes/
|
125
|
+
# accessing /admin/participatory_processes/some-process requires access first to /admin/participatory_processes
|
131
126
|
def additional_get_constraints(constraints)
|
132
127
|
return [] unless @request.get?
|
133
128
|
|
@@ -8,7 +8,7 @@ Decidim::DecidimAwesome.configure do |config|
|
|
8
8
|
:allow_images_in_proposals,
|
9
9
|
:auto_save_forms,
|
10
10
|
:user_timezone,
|
11
|
-
:
|
11
|
+
:force_authorizations,
|
12
12
|
:admins_available_authorizations,
|
13
13
|
:intergram_for_admins,
|
14
14
|
:intergram_for_public,
|
@@ -17,6 +17,7 @@ Decidim::DecidimAwesome.configure do |config|
|
|
17
17
|
:proposal_custom_fields,
|
18
18
|
:proposal_private_custom_fields,
|
19
19
|
:menu,
|
20
|
+
:mobile_menu,
|
20
21
|
:home_content_block_menu,
|
21
22
|
:scoped_admins,
|
22
23
|
:custom_redirects,
|
@@ -31,7 +32,9 @@ Decidim::DecidimAwesome.configure do |config|
|
|
31
32
|
:weighted_proposal_voting,
|
32
33
|
:additional_proposal_sortings,
|
33
34
|
:allow_limiting_amendments,
|
34
|
-
:proposal_private_custom_fields
|
35
|
+
:proposal_private_custom_fields,
|
36
|
+
:hashcash_signup,
|
37
|
+
:hashcash_login
|
35
38
|
].each do |conf|
|
36
39
|
config.send("#{conf}=", :disabled)
|
37
40
|
end
|
@@ -5,7 +5,7 @@ shared_examples "javascript config vars" do
|
|
5
5
|
expect(page.body).to have_content("window.DecidimAwesome")
|
6
6
|
expect(page.body).to have_content("window.DecidimAwesome.version")
|
7
7
|
expect(page.body).to have_content("window.DecidimAwesome.editorUploaderPath")
|
8
|
-
expect(page.body).to have_content("window.DecidimAwesome.
|
8
|
+
expect(page.body).to have_content("window.DecidimAwesome.i18n")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -29,7 +29,6 @@ end
|
|
29
29
|
|
30
30
|
shared_examples "forbids disabled feature without redirect" do
|
31
31
|
render_views
|
32
|
-
let(:feature) { :menu }
|
33
32
|
let(:features) { [feature] }
|
34
33
|
before do
|
35
34
|
features.each do |feat|
|
@@ -46,7 +45,6 @@ end
|
|
46
45
|
|
47
46
|
shared_examples "forbids disabled feature with redirect" do
|
48
47
|
render_views
|
49
|
-
let(:feature) { :menu }
|
50
48
|
let(:features) { [feature] }
|
51
49
|
before do
|
52
50
|
features.each do |feat|
|
@@ -46,6 +46,7 @@ shared_examples "has drag and drop" do
|
|
46
46
|
sleep 1
|
47
47
|
last_image = Decidim::DecidimAwesome::EditorImage.last
|
48
48
|
expect(last_image).to be_present
|
49
|
+
sleep 1 # some time to transform the image objectid to the signed id
|
49
50
|
content = page.execute_script("return document.querySelector('#{editor_selector}').value")
|
50
51
|
expect(content).to include(last_image.attached_uploader(:file).path)
|
51
52
|
within "form.edit_proposal" do
|
@@ -54,6 +55,6 @@ shared_examples "has drag and drop" do
|
|
54
55
|
fill_in :proposal_title, with: "This is a test proposal"
|
55
56
|
click_on "Send"
|
56
57
|
end
|
57
|
-
expect(proposal.reload.body["en"]).to include(last_image.
|
58
|
+
expect(proposal.reload.body["en"]).to include(last_image.file.blob.to_gid.to_s)
|
58
59
|
end
|
59
60
|
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_context "with a custom fields enabled" do
|
4
|
+
let(:organization) { create(:organization, available_locales: [:en]) }
|
5
|
+
let(:participatory_space) { create(:participatory_process, :with_steps, organization:) }
|
6
|
+
let(:component) { create(:proposal_component, participatory_space:) }
|
7
|
+
let(:title) { "More sidewalks and less roads" }
|
8
|
+
let(:body) { nil }
|
9
|
+
let(:private_body) { nil }
|
10
|
+
let(:body_template) { nil }
|
11
|
+
let(:author) { create(:user, organization:) }
|
12
|
+
|
13
|
+
let(:form) do
|
14
|
+
described_class.from_params(params).with_context(
|
15
|
+
current_component: component,
|
16
|
+
current_organization: component.organization,
|
17
|
+
current_participatory_space: participatory_space
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:data) { '{"type":"text","label":"Full Name","subtype":"text","className":"form-control","name":"text-1476748004559"}' }
|
22
|
+
let(:private_data) { '{"type":"text","label":"Email","subtype":"text","className":"form-control","name":"text-1476748004569"}' }
|
23
|
+
let(:custom_fields) do
|
24
|
+
{
|
25
|
+
"foo" => "[#{data}]"
|
26
|
+
}
|
27
|
+
end
|
28
|
+
let(:private_custom_fields) do
|
29
|
+
{
|
30
|
+
"bar" => "[#{private_data}]"
|
31
|
+
}
|
32
|
+
end
|
33
|
+
let!(:config) { create(:awesome_config, organization:, var: :proposal_custom_fields, value: custom_fields) }
|
34
|
+
let!(:private_config) { create(:awesome_config, organization:, var: :proposal_private_custom_fields, value: private_custom_fields) }
|
35
|
+
let(:config_helper) { create(:awesome_config, organization:, var: :proposal_custom_field_foo, value: nil) }
|
36
|
+
let(:private_config_helper) { create(:awesome_config, organization:, var: :proposal_private_custom_field_bar, value: nil) }
|
37
|
+
let!(:constraint) do
|
38
|
+
create(:config_constraint, awesome_config: config_helper, settings: { "participatory_space_manifest" => "participatory_processes", "participatory_space_slug" => slug })
|
39
|
+
end
|
40
|
+
let!(:private_constraint) { create(:config_constraint, awesome_config: private_config_helper, settings: { "participatory_space_manifest" => "participatory_processes" }) }
|
41
|
+
let(:slug) { participatory_space.slug }
|
42
|
+
end
|
43
|
+
shared_examples "starts with caps" do |prop|
|
44
|
+
let!(:config) { create(:awesome_config, organization:, var: "validate_#{prop}_start_with_caps", value: enabled) }
|
45
|
+
let!(:constraint) do
|
46
|
+
create(:config_constraint, awesome_config: config, settings: { "participatory_space_manifest" => "participatory_processes", "participatory_space_slug" => slug })
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:enabled) { false }
|
50
|
+
let(prop.to_sym) { "í don't start with caps" }
|
51
|
+
|
52
|
+
it { is_expected.to be_valid }
|
53
|
+
|
54
|
+
context "when scoped under different context" do
|
55
|
+
let(:slug) { "another-slug" }
|
56
|
+
|
57
|
+
it { is_expected.not_to be_valid }
|
58
|
+
|
59
|
+
context "when starts with caps" do
|
60
|
+
let(prop.to_sym) { "Í start with caps" }
|
61
|
+
|
62
|
+
it { is_expected.to be_valid }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when enabled" do
|
67
|
+
let(:enabled) { true }
|
68
|
+
|
69
|
+
it { is_expected.not_to be_valid }
|
70
|
+
|
71
|
+
context "when starts with caps" do
|
72
|
+
let(prop.to_sym) { "Í start with caps" }
|
73
|
+
|
74
|
+
it { is_expected.to be_valid }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
shared_examples "minimum length" do |prop|
|
80
|
+
let!(:config) { create(:awesome_config, organization:, var: "validate_#{prop}_min_length", value: min_length) }
|
81
|
+
let!(:constraint) do
|
82
|
+
create(:config_constraint, awesome_config: config, settings: { "participatory_space_manifest" => "participatory_processes", "participatory_space_slug" => slug })
|
83
|
+
end
|
84
|
+
|
85
|
+
let(:min_length) { 10 }
|
86
|
+
let(prop.to_sym) { "I am 10 yo" }
|
87
|
+
|
88
|
+
it { is_expected.to be_valid }
|
89
|
+
|
90
|
+
context "when scoped under different context" do
|
91
|
+
let(:slug) { "another-slug" }
|
92
|
+
|
93
|
+
it { is_expected.not_to be_valid }
|
94
|
+
|
95
|
+
context "when has more than 15 chars" do
|
96
|
+
let(prop.to_sym) { "I am 17 years old" }
|
97
|
+
|
98
|
+
it { is_expected.to be_valid }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "when less than allowed" do
|
103
|
+
let(:min_length) { 11 }
|
104
|
+
|
105
|
+
it { is_expected.not_to be_valid }
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when min_length is zero" do
|
109
|
+
let(:min_length) { 0 }
|
110
|
+
let(prop.to_sym) { "" }
|
111
|
+
|
112
|
+
if prop == :body
|
113
|
+
it { is_expected.to be_valid }
|
114
|
+
else
|
115
|
+
it { is_expected.not_to be_valid }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
shared_examples "max caps percent" do |prop|
|
121
|
+
let!(:config) { create(:awesome_config, organization:, var: "validate_#{prop}_max_caps_percent", value: percent) }
|
122
|
+
let!(:constraint) do
|
123
|
+
create(:config_constraint, awesome_config: config, settings: { "participatory_space_manifest" => "participatory_processes", "participatory_space_slug" => slug })
|
124
|
+
end
|
125
|
+
|
126
|
+
let(:percent) { 90 }
|
127
|
+
let(prop.to_sym) { "Í ÁM A SÈMI-CÁPS text" }
|
128
|
+
|
129
|
+
it { is_expected.to be_valid }
|
130
|
+
|
131
|
+
shared_examples "invalid percentage" do |per|
|
132
|
+
it "error message returns percentage" do
|
133
|
+
expect(form).not_to be_valid
|
134
|
+
expect(form.errors.messages.values.flatten.first).to include("over #{per}% of the text")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "when scoped under different context" do
|
139
|
+
let(:slug) { "another-slug" }
|
140
|
+
|
141
|
+
it_behaves_like "invalid percentage", 25
|
142
|
+
|
143
|
+
context "when has less than 25% caps" do
|
144
|
+
let(prop.to_sym) { "Í only have some CÁPS" }
|
145
|
+
|
146
|
+
it { is_expected.to be_valid }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context "when less than allowed" do
|
151
|
+
let(:percent) { 11 }
|
152
|
+
|
153
|
+
it_behaves_like "invalid percentage", 11
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
shared_examples "max marks together" do |prop|
|
158
|
+
let!(:config) { create(:awesome_config, organization:, var: "validate_#{prop}_max_marks_together", value: max_marks) }
|
159
|
+
let!(:constraint) do
|
160
|
+
create(:config_constraint, awesome_config: config, settings: { "participatory_space_manifest" => "participatory_processes", "participatory_space_slug" => slug })
|
161
|
+
end
|
162
|
+
|
163
|
+
let(:max_marks) { 5 }
|
164
|
+
let(prop.to_sym) { "Am I a little bit noisy??!!!" }
|
165
|
+
|
166
|
+
it { is_expected.to be_valid }
|
167
|
+
|
168
|
+
context "when scoped under different context" do
|
169
|
+
let(:slug) { "another-slug" }
|
170
|
+
|
171
|
+
it { is_expected.not_to be_valid }
|
172
|
+
|
173
|
+
context "when has only 1 mark" do
|
174
|
+
let(prop.to_sym) { "I am not noisy!" }
|
175
|
+
|
176
|
+
it { is_expected.to be_valid }
|
177
|
+
end
|
178
|
+
|
179
|
+
context "when has 2 marks" do
|
180
|
+
let(prop.to_sym) { "I am not noisy!?" }
|
181
|
+
|
182
|
+
it { is_expected.not_to be_valid }
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
context "when less than allowed" do
|
187
|
+
let(:max_marks) { 4 }
|
188
|
+
|
189
|
+
it { is_expected.not_to be_valid }
|
190
|
+
end
|
191
|
+
end
|