decidim-decidim_awesome 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +134 -15
- data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +4 -24
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +9 -5
- data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +1 -1
- data/app/commands/concerns/decidim/decidim_awesome/proposals/admin/update_proposal_override.rb +31 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +26 -0
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +4 -3
- data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +6 -3
- data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +43 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -2
- data/app/controllers/concerns/decidim/decidim_awesome/limit_pending_amendments.rb +35 -0
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +9 -22
- data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
- data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +7 -3
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +8 -5
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +3 -1
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +0 -2
- data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +76 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +0 -2
- data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +12 -4
- data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +8 -1
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +21 -0
- data/app/forms/{decidim → concerns/decidim}/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +35 -9
- data/app/helpers/{decidim → concerns/decidim}/decidim_awesome/amendments_helper_override.rb +17 -7
- data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +126 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +5 -26
- data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +22 -0
- data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +38 -9
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +5 -1
- data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +35 -1
- data/app/overrides/decidim/proposals/admin/proposals/show/add_private_body.html.erb.deface +7 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/replace_body.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/show/limit_amendments_modal.html.erb.deface +5 -0
- data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -1
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +5 -3
- data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +5 -4
- data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +30 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_application.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/editors/editor.js +1 -6
- data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +18 -9
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +35 -26
- data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +31 -15
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +12 -7
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +69 -25
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +34 -27
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +2 -2
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +3 -3
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +28 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -2
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +15 -15
- data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +3 -3
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +3 -3
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +187 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +47 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +7 -7
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +14 -3
- data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
- data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +30 -0
- data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
- data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +1 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
- data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +42 -0
- data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
- data/app/types/concerns/decidim/decidim_awesome/{proposal_type_override.rb → add_proposal_type_vote_weights.rb} +3 -1
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +52 -48
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +16 -8
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +35 -15
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +22 -22
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +14 -13
- data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +28 -29
- data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
- data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
- data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +16 -0
- data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +10 -2
- data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +21 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +1 -73
- data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
- data/config/i18n-tasks.yml +22 -3
- data/config/locales/ca.yml +97 -9
- data/config/locales/cs.yml +109 -6
- data/config/locales/de.yml +92 -6
- data/config/locales/en.yml +102 -8
- data/config/locales/es.yml +96 -8
- data/config/locales/eu.yml +15 -1
- data/config/locales/fr.yml +94 -6
- data/config/locales/hu.yml +53 -4
- data/config/locales/it.yml +16 -6
- data/config/locales/ja.yml +94 -6
- data/config/locales/lt.yml +0 -2
- data/config/locales/nl.yml +9 -4
- data/config/locales/pt-BR.yml +16 -7
- data/config/locales/ro-RO.yml +11 -2
- data/config/locales/sv.yml +17 -6
- data/db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
- data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
- data/lib/decidim/decidim_awesome/admin_engine.rb +22 -6
- data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
- data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +52 -0
- data/lib/decidim/decidim_awesome/awesome.rb +45 -8
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +5 -1
- data/lib/decidim/decidim_awesome/checksums.yml +23 -0
- data/lib/decidim/decidim_awesome/custom_fields.rb +8 -0
- data/lib/decidim/decidim_awesome/engine.rb +143 -52
- data/lib/decidim/decidim_awesome/lock.rb +47 -0
- data/lib/decidim/decidim_awesome/menu.rb +146 -0
- data/lib/decidim/decidim_awesome/test/initializer.rb +4 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/{box_label_editor.rb → box_label_editor_examples.rb} +1 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +20 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +24 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +2 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +3 -5
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +78 -12
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/package.json +2 -2
- metadata +52 -13
- data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
- /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +0 -0
- /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_presenter_override.rb +0 -0
@@ -4,6 +4,7 @@ require "rails"
|
|
4
4
|
require "deface"
|
5
5
|
require "decidim/core"
|
6
6
|
require "decidim/decidim_awesome/awesome_helpers"
|
7
|
+
require "decidim/decidim_awesome/menu"
|
7
8
|
|
8
9
|
module Decidim
|
9
10
|
module DecidimAwesome
|
@@ -26,46 +27,66 @@ module Decidim
|
|
26
27
|
helper Decidim::LayoutHelper if respond_to?(:helper)
|
27
28
|
end
|
28
29
|
# Include additional helpers globally
|
29
|
-
|
30
|
+
ActiveSupport.on_load(:action_view) { include Decidim::DecidimAwesome::AwesomeHelpers }
|
30
31
|
# Also for cells
|
31
32
|
Decidim::ViewModel.include(Decidim::DecidimAwesome::AwesomeHelpers)
|
32
33
|
|
33
34
|
# Override EtiquetteValidator
|
34
|
-
EtiquetteValidator.include(Decidim::DecidimAwesome::EtiquetteValidatorOverride) if DecidimAwesome.enabled?(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
EtiquetteValidator.include(Decidim::DecidimAwesome::EtiquetteValidatorOverride) if DecidimAwesome.enabled?(:validate_title_max_caps_percent,
|
36
|
+
:validate_title_max_marks_together,
|
37
|
+
:validate_title_start_with_caps,
|
38
|
+
:validate_body_max_caps_percent,
|
39
|
+
:validate_body_max_marks_together,
|
40
|
+
:validate_body_start_with_caps)
|
40
41
|
|
41
42
|
# Custom fields need to deal with several places
|
42
|
-
if DecidimAwesome.enabled?(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
if DecidimAwesome.enabled?(:proposal_custom_fields,
|
44
|
+
:proposal_private_custom_fields,
|
45
|
+
:validate_title_min_length,
|
46
|
+
:validate_title_max_caps_percent,
|
47
|
+
:validate_title_max_marks_together,
|
48
|
+
:validate_title_start_with_caps,
|
49
|
+
:validate_body_min_length,
|
50
|
+
:validate_body_max_caps_percent,
|
51
|
+
:validate_body_max_marks_together,
|
52
|
+
:validate_body_start_with_caps)
|
51
53
|
Decidim::Proposals::ProposalWizardCreateStepForm.include(Decidim::DecidimAwesome::Proposals::ProposalWizardCreateStepFormOverride)
|
52
54
|
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields)
|
57
|
+
Decidim::Proposals::ProposalWizardCreateStepForm.include(Decidim::DecidimAwesome::Proposals::ProposalFormOverride)
|
58
|
+
Decidim::Proposals::Admin::ProposalForm.include(Decidim::DecidimAwesome::Proposals::ProposalFormOverride)
|
59
|
+
Decidim::Proposals::ProposalPresenter.include(Decidim::DecidimAwesome::Proposals::ProposalPresenterOverride)
|
60
|
+
Decidim::Proposals::CreateProposal.include(Decidim::DecidimAwesome::Proposals::CreateProposalOverride)
|
61
|
+
Decidim::Proposals::CreateCollaborativeDraft.include(Decidim::DecidimAwesome::Proposals::CreateCollaborativeDraftOverride)
|
62
|
+
Decidim::Proposals::Admin::CreateProposal.include(Decidim::DecidimAwesome::Proposals::CreateProposalOverride)
|
63
|
+
Decidim::Proposals::UpdateProposal.include(Decidim::DecidimAwesome::Proposals::UpdateProposalOverride)
|
64
|
+
Decidim::Proposals::UpdateCollaborativeDraft.include(Decidim::DecidimAwesome::Proposals::UpdateCollaborativeDraftOverride)
|
65
|
+
Decidim::Proposals::Admin::UpdateProposal.include(Decidim::DecidimAwesome::Proposals::Admin::UpdateProposalOverride)
|
66
|
+
Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::AddProposalTypeCustomFields)
|
67
|
+
end
|
68
|
+
|
69
|
+
if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields, :weighted_proposal_voting)
|
70
|
+
# add vote weight/private_body to proposals
|
71
|
+
Decidim::Proposals::Proposal.include(Decidim::DecidimAwesome::HasProposalExtraFields)
|
72
|
+
Decidim::Proposals::CollaborativeDraft.include(Decidim::DecidimAwesome::HasProposalExtraFields)
|
73
|
+
end
|
56
74
|
|
57
75
|
if DecidimAwesome.enabled?(:weighted_proposal_voting)
|
58
76
|
# add vote weight to proposal vote
|
59
77
|
Decidim::Proposals::ProposalVote.include(Decidim::DecidimAwesome::HasVoteWeight)
|
60
|
-
|
61
|
-
Decidim::Proposals::Proposal.include(Decidim::DecidimAwesome::HasProposalExtraFields)
|
62
|
-
Decidim::Proposals::ProposalSerializer.include(Decidim::DecidimAwesome::ProposalSerializerOverride)
|
63
|
-
Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::ProposalTypeOverride)
|
78
|
+
Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::AddProposalTypeVoteWeights)
|
64
79
|
Decidim::Proposals::ProposalMCell.include(Decidim::DecidimAwesome::ProposalMCellOverride)
|
65
80
|
end
|
66
81
|
|
67
|
-
|
68
|
-
Decidim::
|
82
|
+
# override user's admin property
|
83
|
+
Decidim::User.include(Decidim::DecidimAwesome::UserOverride) if DecidimAwesome.enabled?(:scoped_admins)
|
84
|
+
|
85
|
+
if DecidimAwesome.enabled?(:menu, :content_block_main_menu)
|
86
|
+
# Decidim::ContentBlocks::GlobalMenuCell.include(Decidim::DecidimAwesome::GlobalMenuCellOverride)
|
87
|
+
Decidim::MenuPresenter.include(Decidim::DecidimAwesome::MenuPresenterOverride)
|
88
|
+
Decidim::MenuItemPresenter.include(Decidim::DecidimAwesome::MenuItemPresenterOverride)
|
89
|
+
end
|
69
90
|
|
70
91
|
# Late registering of components to take into account initializer values
|
71
92
|
DecidimAwesome.registered_components.each do |manifest, block|
|
@@ -79,18 +100,24 @@ module Decidim
|
|
79
100
|
initializer "decidim_decidim_awesome.overrides", after: "decidim.action_controller" do
|
80
101
|
config.to_prepare do
|
81
102
|
# redirect unauthorized scoped admins to allowed places or custom redirects if configured
|
82
|
-
Decidim::ErrorsController.include(Decidim::DecidimAwesome::NotFoundRedirect) if DecidimAwesome.enabled?(
|
103
|
+
Decidim::ErrorsController.include(Decidim::DecidimAwesome::NotFoundRedirect) if DecidimAwesome.enabled?(:scoped_admins, :custom_redirects)
|
83
104
|
|
84
105
|
# Custom fields need to deal with several places
|
85
|
-
if DecidimAwesome.enabled?(:proposal_custom_fields)
|
106
|
+
if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields)
|
86
107
|
Decidim::Proposals::ApplicationHelper.include(Decidim::DecidimAwesome::Proposals::ApplicationHelperOverride)
|
87
108
|
Decidim::AmendmentsHelper.include(Decidim::DecidimAwesome::AmendmentsHelperOverride)
|
88
109
|
end
|
110
|
+
if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields, :weighted_proposal_voting)
|
111
|
+
Decidim::Proposals::ProposalSerializer.include(Decidim::DecidimAwesome::Proposals::ProposalSerializerOverride)
|
112
|
+
Decidim::AdminLog::ComponentPresenter.include(Decidim::DecidimAwesome::AdminLog::ComponentPresenterOverride)
|
113
|
+
end
|
89
114
|
|
90
115
|
if DecidimAwesome.enabled?(:weighted_proposal_voting)
|
91
116
|
Decidim::Proposals::ProposalVotesController.include(Decidim::DecidimAwesome::Proposals::ProposalVotesControllerOverride)
|
92
117
|
end
|
93
118
|
|
119
|
+
Decidim::AmendmentsController.include(Decidim::DecidimAwesome::LimitPendingAmendments) if DecidimAwesome.enabled?(:allow_limiting_amendments)
|
120
|
+
|
94
121
|
Decidim::Proposals::ProposalsController.include(Decidim::DecidimAwesome::Proposals::OrderableOverride) if DecidimAwesome.enabled?(:additional_proposal_sortings)
|
95
122
|
end
|
96
123
|
end
|
@@ -99,14 +126,61 @@ module Decidim
|
|
99
126
|
app.config.middleware.insert_after Decidim::Middleware::CurrentOrganization, Decidim::DecidimAwesome::CurrentConfig
|
100
127
|
end
|
101
128
|
|
102
|
-
initializer "decidim_decidim_awesome.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
settings.attribute
|
129
|
+
initializer "decidim_decidim_awesome.additional_proposal_options" do |_app|
|
130
|
+
Decidim.component_registry.find(:proposals).tap do |component|
|
131
|
+
component.settings(:global) do |settings|
|
132
|
+
if DecidimAwesome.enabled?(:additional_proposal_sortings)
|
133
|
+
settings.attribute(
|
134
|
+
:default_sort_order,
|
135
|
+
type: :select,
|
136
|
+
default: "default",
|
137
|
+
choices: -> { (POSSIBLE_SORT_ORDERS + DecidimAwesome.possible_additional_proposal_sortings).uniq }
|
138
|
+
)
|
139
|
+
end
|
140
|
+
if DecidimAwesome.enabled?(:allow_limiting_amendments)
|
141
|
+
DecidimAwesome.hash_append!(
|
142
|
+
settings.attributes,
|
143
|
+
:amendments_enabled,
|
144
|
+
:limit_pending_amendments,
|
145
|
+
Decidim::SettingsManifest::Attribute.new(type: :boolean, default: DecidimAwesome.allow_limiting_amendments)
|
146
|
+
)
|
107
147
|
end
|
148
|
+
end
|
149
|
+
|
150
|
+
if DecidimAwesome.enabled?(:additional_proposal_sortings)
|
108
151
|
component.settings(:step) do |settings|
|
109
|
-
settings.attribute
|
152
|
+
settings.attribute(
|
153
|
+
:default_sort_order,
|
154
|
+
type: :select,
|
155
|
+
include_blank: true,
|
156
|
+
choices: -> { (POSSIBLE_SORT_ORDERS + DecidimAwesome.possible_additional_proposal_sortings).uniq }
|
157
|
+
)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
if DecidimAwesome.enabled?(:proposal_private_custom_fields)
|
162
|
+
# Add to the "proposals" component an exporter that is not
|
163
|
+
# included in open-data to be able to export all private fields
|
164
|
+
# from the administration without exposing data to the frontend.
|
165
|
+
component.exports :awesome_private_proposals do |exports|
|
166
|
+
exports.collection do |component_instance, user|
|
167
|
+
space = component_instance.participatory_space
|
168
|
+
|
169
|
+
collection = Decidim::Proposals::Proposal
|
170
|
+
.published
|
171
|
+
.not_hidden
|
172
|
+
.where(component: component_instance)
|
173
|
+
.includes(:scope, :category, :component)
|
174
|
+
|
175
|
+
if space.user_roles(:valuator).where(user: user).any?
|
176
|
+
collection.with_valuation_assigned_to(user, space)
|
177
|
+
else
|
178
|
+
collection
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
exports.include_in_open_data = false
|
183
|
+
exports.serializer Decidim::DecidimAwesome::Proposals::PrivateProposalSerializer
|
110
184
|
end
|
111
185
|
end
|
112
186
|
end
|
@@ -132,26 +206,43 @@ module Decidim
|
|
132
206
|
next unless component
|
133
207
|
|
134
208
|
component.settings(:global) do |settings|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
209
|
+
DecidimAwesome.hash_append!(
|
210
|
+
settings.attributes,
|
211
|
+
:can_accumulate_supports_beyond_threshold,
|
212
|
+
:awesome_voting_manifest,
|
213
|
+
Decidim::SettingsManifest::Attribute.new(
|
214
|
+
type: :select,
|
215
|
+
default: "",
|
216
|
+
choices: -> { ["default"] + Decidim::DecidimAwesome.voting_registry.manifests.map(&:name) },
|
217
|
+
readonly: lambda { |context|
|
218
|
+
Decidim::Proposals::Proposal.where(component: context[:component]).where.not(proposal_votes_count: -Float::INFINITY..0).any?
|
219
|
+
}
|
220
|
+
)
|
221
|
+
)
|
222
|
+
DecidimAwesome.hash_append!(
|
223
|
+
settings.attributes,
|
224
|
+
:awesome_voting_manifest,
|
225
|
+
:voting_cards_box_title,
|
226
|
+
Decidim::SettingsManifest::Attribute.new(type: :string, translated: true)
|
227
|
+
)
|
228
|
+
DecidimAwesome.hash_append!(
|
229
|
+
settings.attributes,
|
230
|
+
:voting_cards_box_title,
|
231
|
+
:voting_cards_show_modal_help,
|
232
|
+
Decidim::SettingsManifest::Attribute.new(type: :boolean, default: true)
|
233
|
+
)
|
234
|
+
DecidimAwesome.hash_append!(
|
235
|
+
settings.attributes,
|
236
|
+
:voting_cards_show_modal_help,
|
237
|
+
:voting_cards_show_abstain,
|
238
|
+
Decidim::SettingsManifest::Attribute.new(type: :boolean, default: false)
|
239
|
+
)
|
240
|
+
DecidimAwesome.hash_append!(
|
241
|
+
settings.attributes,
|
242
|
+
:voting_cards_show_abstain,
|
243
|
+
:voting_cards_instructions,
|
244
|
+
Decidim::SettingsManifest::Attribute.new(type: :text, translated: true, editor: true)
|
245
|
+
)
|
155
246
|
end
|
156
247
|
end
|
157
248
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class Lock
|
6
|
+
def initialize(organization, lock_time: DecidimAwesome.lock_time)
|
7
|
+
@organization = organization
|
8
|
+
@lock_time = lock_time
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :resource, :organization, :lock_time
|
12
|
+
|
13
|
+
def get!(resource)
|
14
|
+
@resource = resource
|
15
|
+
if config
|
16
|
+
config.update!(updated_at: Time.current)
|
17
|
+
else
|
18
|
+
AwesomeConfig.create!(var: var, organization: organization)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def release!(resource)
|
23
|
+
@resource = resource
|
24
|
+
config.destroy! if config
|
25
|
+
end
|
26
|
+
|
27
|
+
def locked?(resource)
|
28
|
+
@resource = resource
|
29
|
+
return false unless config
|
30
|
+
return true if config.reload.updated_at > lock_time.ago
|
31
|
+
|
32
|
+
config.destroy!
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def config
|
37
|
+
AwesomeConfig.find_by(var: var, organization: organization)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def var
|
43
|
+
"lock-#{resource.class.name.underscore}_#{resource.id}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class Menu
|
6
|
+
class << self
|
7
|
+
def register_awesome_admin_menu!
|
8
|
+
Decidim.menu :awesome_admin_menu do |menu|
|
9
|
+
menu.add_item :editors,
|
10
|
+
I18n.t("menu.editors", scope: "decidim.decidim_awesome.admin"),
|
11
|
+
decidim_admin_decidim_awesome.config_path(:editors),
|
12
|
+
position: 1,
|
13
|
+
icon_name: "text",
|
14
|
+
if: menus[:editors]
|
15
|
+
|
16
|
+
menu.add_item :proposals,
|
17
|
+
I18n.t("menu.proposals", scope: "decidim.decidim_awesome.admin"),
|
18
|
+
decidim_admin_decidim_awesome.config_path(:proposals),
|
19
|
+
position: 2,
|
20
|
+
icon_name: "document",
|
21
|
+
if: menus[:proposals]
|
22
|
+
|
23
|
+
menu.add_item :surveys,
|
24
|
+
I18n.t("menu.surveys", scope: "decidim.decidim_awesome.admin"),
|
25
|
+
decidim_admin_decidim_awesome.config_path(:surveys),
|
26
|
+
position: 3,
|
27
|
+
icon_name: "spreadsheet",
|
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(:styles),
|
33
|
+
position: 4,
|
34
|
+
icon_name: "brush",
|
35
|
+
if: menus[:styles]
|
36
|
+
|
37
|
+
menu.add_item :proposal_custom_fields,
|
38
|
+
I18n.t("menu.proposal_custom_fields", scope: "decidim.decidim_awesome.admin"),
|
39
|
+
decidim_admin_decidim_awesome.config_path(:proposal_custom_fields),
|
40
|
+
position: 5,
|
41
|
+
icon_name: "layers",
|
42
|
+
if: menus[:proposal_custom_fields],
|
43
|
+
submenu: { target_menu: :custom_fields_submenu }
|
44
|
+
|
45
|
+
menu.add_item :admins,
|
46
|
+
I18n.t("menu.admins", scope: "decidim.decidim_awesome.admin"),
|
47
|
+
decidim_admin_decidim_awesome.config_path(:admins),
|
48
|
+
position: 6,
|
49
|
+
icon_name: "people",
|
50
|
+
if: menus[:admins]
|
51
|
+
|
52
|
+
menu.add_item :menu_hacks,
|
53
|
+
I18n.t("menu.menu_hacks", scope: "decidim.decidim_awesome.admin"),
|
54
|
+
decidim_admin_decidim_awesome.menu_hacks_path,
|
55
|
+
position: 7,
|
56
|
+
icon_name: "menu",
|
57
|
+
if: menus[:menu_hacks]
|
58
|
+
|
59
|
+
menu.add_item :custom_redirects,
|
60
|
+
I18n.t("menu.custom_redirects", scope: "decidim.decidim_awesome.admin"),
|
61
|
+
decidim_admin_decidim_awesome.custom_redirects_path,
|
62
|
+
position: 8,
|
63
|
+
icon_name: "share-boxed",
|
64
|
+
if: menus[:custom_redirects]
|
65
|
+
|
66
|
+
menu.add_item :livechat,
|
67
|
+
I18n.t("menu.livechat", scope: "decidim.decidim_awesome.admin"),
|
68
|
+
decidim_admin_decidim_awesome.config_path(:livechat),
|
69
|
+
position: 9,
|
70
|
+
icon_name: "chat",
|
71
|
+
if: menus[:livechat]
|
72
|
+
|
73
|
+
menu.add_item :maintenance,
|
74
|
+
I18n.t("maintenance", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
75
|
+
decidim_admin_decidim_awesome.maintenance_path(:private_data),
|
76
|
+
position: 10,
|
77
|
+
icon_name: "pulse",
|
78
|
+
submenu: { target_menu: :maintenance_submenu }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def register_custom_fields_submenu!
|
83
|
+
Decidim.menu :custom_fields_submenu do |menu|
|
84
|
+
menu.add_item :proposal_custom_fields,
|
85
|
+
I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"),
|
86
|
+
decidim_admin_decidim_awesome.config_path(:proposal_custom_fields),
|
87
|
+
position: 5.1,
|
88
|
+
icon_name: "lock-unlocked",
|
89
|
+
if: menus[:proposal_custom_fields]
|
90
|
+
|
91
|
+
menu.add_item :proposal_private_custom_fields,
|
92
|
+
I18n.t("proposal_private_custom_fields", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"),
|
93
|
+
decidim_admin_decidim_awesome.config_path(:proposal_private_custom_fields),
|
94
|
+
position: 5.2,
|
95
|
+
icon_name: "lock-locked",
|
96
|
+
if: menus[:proposal_private_custom_fields]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def register_maintenance_admin_menu!
|
101
|
+
Decidim.menu :maintenance_submenu do |menu|
|
102
|
+
menu.add_item :private_data,
|
103
|
+
I18n.t("private_data", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
104
|
+
decidim_admin_decidim_awesome.maintenance_path(:private_data),
|
105
|
+
position: 10,
|
106
|
+
icon_name: "lock-locked"
|
107
|
+
|
108
|
+
menu.add_item :checks,
|
109
|
+
I18n.t("checks", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
|
110
|
+
decidim_admin_decidim_awesome.checks_maintenance_index_path,
|
111
|
+
position: 10,
|
112
|
+
icon_name: "pulse"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def menus
|
117
|
+
@menus ||= {
|
118
|
+
editors: config_enabled?(:allow_images_in_full_editor, :allow_images_in_small_editor, :allow_videos_in_editors),
|
119
|
+
proposals: config_enabled?(
|
120
|
+
:allow_images_in_proposals,
|
121
|
+
:validate_title_min_length, :validate_title_max_caps_percent,
|
122
|
+
:validate_title_max_marks_together, :validate_title_start_with_caps,
|
123
|
+
:validate_body_min_length, :validate_body_max_caps_percent,
|
124
|
+
:validate_body_max_marks_together, :validate_body_start_with_caps
|
125
|
+
),
|
126
|
+
surveys: config_enabled?(:auto_save_forms),
|
127
|
+
styles: config_enabled?(:scoped_styles),
|
128
|
+
proposal_custom_fields: config_enabled?(:proposal_custom_fields),
|
129
|
+
proposal_private_custom_fields: config_enabled?(:proposal_private_custom_fields),
|
130
|
+
admins: config_enabled?(:scoped_admins),
|
131
|
+
menu_hacks: config_enabled?(:menu, :home_content_block_menu),
|
132
|
+
menu_hacks_menu: config_enabled?(:menu),
|
133
|
+
menu_hacks_home_content_block_menu: config_enabled?(:home_content_block_menu),
|
134
|
+
custom_redirects: config_enabled?(:custom_redirects),
|
135
|
+
livechat: config_enabled?(:intergram_for_admins, :intergram_for_public)
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
# ensure boolean value
|
140
|
+
def config_enabled?(*vars)
|
141
|
+
DecidimAwesome.enabled?(*vars)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -13,6 +13,7 @@ Decidim::DecidimAwesome.configure do |config|
|
|
13
13
|
:intergram_for_public,
|
14
14
|
:scoped_styles,
|
15
15
|
:proposal_custom_fields,
|
16
|
+
:proposal_private_custom_fields,
|
16
17
|
:menu,
|
17
18
|
:scoped_admins,
|
18
19
|
:custom_redirects,
|
@@ -25,7 +26,9 @@ Decidim::DecidimAwesome.configure do |config|
|
|
25
26
|
:validate_body_max_marks_together,
|
26
27
|
:validate_body_start_with_caps,
|
27
28
|
:weighted_proposal_voting,
|
28
|
-
:
|
29
|
+
:additional_proposal_sortings,
|
30
|
+
:allow_limiting_amendments,
|
31
|
+
:proposal_private_custom_fields
|
29
32
|
].each do |conf|
|
30
33
|
config.send("#{conf}=", :disabled)
|
31
34
|
end
|
@@ -92,7 +92,7 @@ shared_examples "edits box label inline" do |test_case, key|
|
|
92
92
|
|
93
93
|
case test_case
|
94
94
|
when :css
|
95
|
-
sleep
|
95
|
+
sleep 2
|
96
96
|
page.execute_script('document.querySelector("[data-key=a_new_label] .CodeMirror").CodeMirror.setValue("body {background: lilac;}");')
|
97
97
|
find("*[type=submit]").click
|
98
98
|
expect(page).to have_admin_callout("updated successfully")
|
@@ -27,7 +27,8 @@ shared_examples "do not have menu link" do |item|
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
shared_examples "forbids disabled feature" do
|
30
|
+
shared_examples "forbids disabled feature without redirect" do
|
31
|
+
render_views
|
31
32
|
let(:feature) { :menu }
|
32
33
|
let(:features) { [feature] }
|
33
34
|
before do
|
@@ -36,7 +37,24 @@ shared_examples "forbids disabled feature" do
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
it "
|
40
|
+
it "fails with error" do
|
41
|
+
action
|
42
|
+
|
43
|
+
expect(response.body).to eq("no permissions for #{feature}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
shared_examples "forbids disabled feature with redirect" do
|
48
|
+
render_views
|
49
|
+
let(:feature) { :menu }
|
50
|
+
let(:features) { [feature] }
|
51
|
+
before do
|
52
|
+
features.each do |feat|
|
53
|
+
allow(Decidim::DecidimAwesome.config).to receive(feat).and_return(:disabled)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "fails with error" do
|
40
58
|
action
|
41
59
|
|
42
60
|
expect(flash[:alert]).not_to be_empty
|