decidim-decidim_awesome 0.14.2 → 0.14.3
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 +14 -0
- data/app/cells/concerns/decidim/decidim_awesome/proposals/proposal_vote_cell_override.rb +21 -0
- data/app/cells/concerns/decidim/decidim_awesome/proposals/proposal_votes_count_cell_override.rb +30 -0
- data/app/cells/concerns/decidim/decidim_awesome/voting/voting_cards_proposal_vote_cell_override.rb +19 -0
- data/app/cells/decidim/data_consent/category.erb +5 -5
- data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +2 -2
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_vote/not_allowed.erb +16 -0
- data/app/commands/decidim/decidim_awesome/admin/create_awesome_authorization_group.rb +43 -0
- data/app/commands/decidim/decidim_awesome/admin/create_awesome_authorization_members.rb +50 -0
- data/app/commands/decidim/decidim_awesome/admin/create_cookie_item_preset.rb +8 -6
- data/app/commands/decidim/decidim_awesome/admin/update_awesome_authorization_group.rb +45 -0
- data/app/commands/decidim/decidim_awesome/admin/update_awesome_authorization_properties.rb +38 -0
- data/app/commands/decidim/decidim_awesome/admin/update_cookie_item.rb +12 -2
- data/app/controllers/concerns/decidim/decidim_awesome/needs_thread_variables.rb +36 -0
- data/app/controllers/decidim/decidim_awesome/admin/awesome_authorization_properties_controller.rb +44 -0
- data/app/controllers/decidim/decidim_awesome/admin/awesome_authorization_users_controller.rb +64 -0
- data/app/controllers/decidim/decidim_awesome/admin/awesome_authorizations_controller.rb +90 -0
- data/app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb +1 -1
- data/app/forms/decidim/decidim_awesome/admin/awesome_authorization_group_form.rb +15 -0
- data/app/forms/decidim/decidim_awesome/admin/awesome_authorization_members_form.rb +45 -0
- data/app/forms/decidim/decidim_awesome/admin/awesome_authorization_properties_form.rb +41 -0
- data/app/forms/decidim/decidim_awesome/awesome_authorization_handler.rb +39 -0
- data/app/helpers/concerns/decidim/decidim_awesome/admin/settings_helper_override.rb +54 -0
- data/app/helpers/concerns/decidim/decidim_awesome/verifications/application_helper_override.rb +28 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +2 -1
- data/app/jobs/decidim/decidim_awesome/sync_awesome_authorization_group_job.rb +19 -0
- data/app/jobs/decidim/decidim_awesome/sync_awesome_authorization_user_job.rb +16 -0
- data/app/models/concerns/decidim/decidim_awesome/has_authorization_groups.rb +13 -0
- data/app/models/decidim/decidim_awesome/authorization_group.rb +66 -0
- data/app/models/decidim/decidim_awesome/authorization_member.rb +46 -0
- data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +3 -1
- data/app/packs/src/decidim/decidim_awesome/admin/awesome_authorizations_multiselect.js +19 -0
- data/app/packs/src/decidim/decidim_awesome/admin/controllers/votes_by_status.js +54 -0
- data/app/packs/src/decidim/decidim_awesome/admin/landing_menu_admin.js +41 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +4 -0
- data/app/permissions/concerns/decidim/decidim_awesome/proposals/permissions_override.rb +48 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +4 -1
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +24 -9
- data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +2 -1
- data/app/services/decidim/decidim_awesome/awesome_authorization_authorizer.rb +44 -0
- data/app/services/decidim/decidim_awesome/proposals/votes_by_proposal_status.rb +42 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorization_properties/index.html.erb +31 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorization_users/index.html.erb +49 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorization_users/new.html.erb +39 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorizations/_awesome_authorization_cards.html.erb +24 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorizations/_form.html.erb +12 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorizations/_list_authorization_groups.html.erb +61 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorizations/edit.html.erb +18 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorizations/index.html.erb +32 -0
- data/app/views/decidim/decidim_awesome/admin/awesome_authorizations/new.html.erb +19 -0
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/cookie_categories/new.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +2 -1
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +3 -2
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +1 -5
- data/app/views/decidim/decidim_awesome/awesome_authorization_handler/_form.html.erb +5 -0
- data/app/views/decidim/decidim_awesome/proposals/votes/_not_allowed.html.erb +1 -0
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +5 -1
- data/config/i18n-tasks.yml +5 -0
- data/config/locales/ca.yml +577 -186
- data/config/locales/cs.yml +61 -2
- data/config/locales/de.yml +537 -170
- data/config/locales/en.yml +150 -15
- data/config/locales/es.yml +579 -206
- data/config/locales/eu.yml +0 -2
- data/config/locales/fr.yml +598 -185
- data/config/locales/it.yml +531 -167
- data/config/locales/ja.yml +0 -2
- data/config/locales/pt-BR.yml +524 -169
- data/config/locales/pt.yml +525 -167
- data/config/locales/zz_dynamic_locales.rb +26 -0
- data/db/migrate/20260630160000_create_decidim_awesome_authorization_groups.rb +13 -0
- data/db/migrate/20260630160001_create_decidim_awesome_authorization_members.rb +15 -0
- data/lib/decidim/decidim_awesome/admin_engine.rb +9 -1
- data/lib/decidim/decidim_awesome/awesome.rb +15 -0
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +25 -0
- data/lib/decidim/decidim_awesome/checksums.yml +31 -0
- data/lib/decidim/decidim_awesome/engine.rb +71 -2
- data/lib/decidim/decidim_awesome/menu.rb +34 -2
- data/lib/decidim/decidim_awesome/test/factories.rb +20 -0
- data/lib/decidim/decidim_awesome/test/initializer.rb +2 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +13 -0
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/lib/decidim/decidim_awesome/voting_manifest.rb +8 -3
- metadata +44 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31452817d0be4914eed1dd89206dae3da650e3c475928a72573d47ab112c845f
|
|
4
|
+
data.tar.gz: fd8b114966df8f4a93300ba081ac87e5bf59d572186c179a23dd7ada2d13718b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 217d456c8e991103aca2dc8ec505b5eaa3f30c516a7875149643484b91db4eabeac1550b48408f04bb1d414a1344c6b5045693e8a1056999ff5468be46533b0a
|
|
7
|
+
data.tar.gz: 47df9e655b54468206c5dd1c8e56d8927cae9279e9d54f211ac6e6c1c1bce25dcd28342a868a52be5fe3b2df8869df53fda5773386a7c1af9f418ee99bb1d152
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
CHANGELOG
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
unreleased
|
|
5
|
+
-------
|
|
6
|
+
|
|
7
|
+
v0.14.3
|
|
8
|
+
-------
|
|
9
|
+
Compatibility:
|
|
10
|
+
- Decidim 0.31.x
|
|
11
|
+
|
|
12
|
+
Features:
|
|
13
|
+
- Add the integrated awesome authorization handler ([#612](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/612))
|
|
14
|
+
- Add the ability to vote by "Non answered" proposals ([#590](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/590))
|
|
15
|
+
- Some fixes in updating cookies settings the ordering in the awesome global menu
|
|
16
|
+
|
|
4
17
|
v0.14.2
|
|
5
18
|
-------
|
|
6
19
|
|
|
@@ -14,6 +27,7 @@ Features:
|
|
|
14
27
|
- Add Rich Text content block for landing pages ([#543](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/543))
|
|
15
28
|
- Add a new cookie policy/category manager ([#521](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/521))
|
|
16
29
|
- Fix proposal creation in admin when custom fields are enabled for Decidim >= 0.31.3
|
|
30
|
+
- Allow admins to restrict proposal voting to selected proposal states per step ([#572](https://github.com/decidim-ice/decidim-module-decidim_awesome/issues/572))
|
|
17
31
|
|
|
18
32
|
v0.14.1
|
|
19
33
|
-------
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Proposals
|
|
6
|
+
module ProposalVoteCellOverride
|
|
7
|
+
extend ActiveSupport::Concern
|
|
8
|
+
|
|
9
|
+
included do
|
|
10
|
+
alias_method :awesome_original_show, :show
|
|
11
|
+
|
|
12
|
+
def show
|
|
13
|
+
return render(:not_allowed) if awesome_voting_restricted_by_status?(resource)
|
|
14
|
+
|
|
15
|
+
awesome_original_show
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/app/cells/concerns/decidim/decidim_awesome/proposals/proposal_votes_count_cell_override.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Proposals
|
|
6
|
+
# Renders the votes count view defined by the active voting manifest
|
|
7
|
+
# instead of the default one
|
|
8
|
+
module ProposalVotesCountCellOverride
|
|
9
|
+
def show
|
|
10
|
+
view = awesome_voting_manifest_for(component)&.show_votes_count_view
|
|
11
|
+
return super if view.nil?
|
|
12
|
+
|
|
13
|
+
return render(partial: view, formats: [:html], locals: { proposal: resource, from_proposals_list: from_proposals_list? }) if view.present?
|
|
14
|
+
|
|
15
|
+
awesome_hidden_votes_count_placeholder
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
# Hidden placeholder kept in the DOM so update_buttons_and_counters.js.erb
|
|
21
|
+
# can update the votes count without raising a console error.
|
|
22
|
+
def awesome_hidden_votes_count_placeholder
|
|
23
|
+
return if current_settings.votes_hidden?
|
|
24
|
+
|
|
25
|
+
content_tag(:span, progress, style: "display: none", id: element_id)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/app/cells/concerns/decidim/decidim_awesome/voting/voting_cards_proposal_vote_cell_override.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Voting
|
|
6
|
+
# Prepended into VotingCardsProposalVoteCell so that when the proposal is
|
|
7
|
+
# restricted by the "votes by proposal status" filter we render the
|
|
8
|
+
# same :not_allowed template used by the standard ProposalVoteCell,
|
|
9
|
+
# instead of the voting cards UI.
|
|
10
|
+
module VotingCardsProposalVoteCellOverride
|
|
11
|
+
def show
|
|
12
|
+
return render(:not_allowed) if awesome_voting_restricted_by_status?(resource)
|
|
13
|
+
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
<%= icon "close-line", class: "cookies__category-toggle-icon" %>
|
|
14
14
|
</label>
|
|
15
15
|
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</h3>
|
|
16
|
+
<h3 id="accordion-title-<%= category["slug"] %>" class="cookies__category-trigger-title">
|
|
17
|
+
<%= category["title"] %>
|
|
18
|
+
</h3>
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
<div id="accordion-trigger-<%= category["slug"] %>" role="group" data-controls="accordion-panel-<%= category["slug"] %>" aria-labelledby="accordion-title-<%= category["slug"] %>">
|
|
21
|
+
<span aria-hidden="true">
|
|
22
22
|
<%= icon "arrow-down-s-line", class: "cookies__category-trigger-arrow" %>
|
|
23
23
|
<%= icon "arrow-up-s-line", class: "cookies__category-trigger-arrow" %>
|
|
24
24
|
</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<section class="map-block home__section">
|
|
2
|
-
<%= content_tag(
|
|
1
|
+
<section class="map-block home__section content-block">
|
|
2
|
+
<%= content_tag(:h2, section_title, class: "mb-[20px]") if section_title.present? %>
|
|
3
3
|
|
|
4
4
|
<%= awesome_map_for global_map_components do %>
|
|
5
5
|
<%= render partial: "decidim/decidim_awesome/map_component/map/map_template.html", locals: { taxonomies: all_taxonomies, map_height: model.settings.map_height } %>
|
|
@@ -47,7 +47,7 @@ module Decidim
|
|
|
47
47
|
return if model.settings.title.blank?
|
|
48
48
|
return if model.settings.title.values.join.blank?
|
|
49
49
|
|
|
50
|
-
content_tag :h3, class: "section-heading" do
|
|
50
|
+
content_tag :h3, class: "h3 section-heading" do
|
|
51
51
|
translated_attribute(model.settings.title)
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% if !current_settings.votes_hidden? && (current_component.participatory_space.can_participate?(current_user) || current_user&.admin?) %>
|
|
2
|
+
<% progress = resource.proposal_votes_count || 0 %>
|
|
3
|
+
<% total = resource.maximum_votes || 0 %>
|
|
4
|
+
<%= cell(
|
|
5
|
+
"decidim/progress_bar",
|
|
6
|
+
progress,
|
|
7
|
+
total:,
|
|
8
|
+
units_name: "decidim.proposals.proposals.votes_count.count",
|
|
9
|
+
element_id: "proposal-#{resource.id}-votes-count",
|
|
10
|
+
class: total.positive? ? "card__proposals-votes-limited" : "card__proposals-votes-unlimited"
|
|
11
|
+
) %>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div id="proposal-<%= resource.id %>-vote-button" class="card__proposals-votes-container">
|
|
15
|
+
<span class="help-text italic"><%= t("decidim.decidim_awesome.proposals.votes.blocked_by_status") %></span>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Admin
|
|
6
|
+
class CreateAwesomeAuthorizationGroup < Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# form - The form object with the authorization group data
|
|
10
|
+
def initialize(form)
|
|
11
|
+
@form = form
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Executes the command. Broadcasts these events:
|
|
15
|
+
#
|
|
16
|
+
# - :ok when everything is valid.
|
|
17
|
+
# - :invalid if we couldn't proceed.
|
|
18
|
+
#
|
|
19
|
+
# Returns nothing.
|
|
20
|
+
def call
|
|
21
|
+
return broadcast(:invalid, form.errors.full_messages.join("; ")) if form.invalid?
|
|
22
|
+
|
|
23
|
+
create_authorization_group!
|
|
24
|
+
|
|
25
|
+
broadcast(:ok, authorization_group)
|
|
26
|
+
rescue StandardError => e
|
|
27
|
+
broadcast(:invalid, e.message)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
attr_reader :form, :authorization_group
|
|
33
|
+
|
|
34
|
+
def create_authorization_group!
|
|
35
|
+
@authorization_group = form.current_organization.awesome_authorization_groups.create!(
|
|
36
|
+
name: form.name,
|
|
37
|
+
purpose: form.purpose
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Admin
|
|
6
|
+
class CreateAwesomeAuthorizationMembers < Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# form - The form object containing the authorization group and emails.
|
|
10
|
+
def initialize(form)
|
|
11
|
+
@form = form
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Executes the command. Broadcasts these events:
|
|
15
|
+
#
|
|
16
|
+
# - :ok when all members were added or already existed.
|
|
17
|
+
# - :invalid if some members could not be created.
|
|
18
|
+
#
|
|
19
|
+
# Returns nothing.
|
|
20
|
+
def call
|
|
21
|
+
authorization_group.members.destroy_all if form.remove_previous_members
|
|
22
|
+
|
|
23
|
+
previous_members_count = authorization_group.members.count
|
|
24
|
+
authorization_group.members.insert_all( # rubocop:disable Rails/SkipsModelValidations
|
|
25
|
+
form.data.map { |email| { email: email.strip.downcase } },
|
|
26
|
+
unique_by: :index_auth_members_group_email
|
|
27
|
+
)
|
|
28
|
+
created_count = authorization_group.members.count - previous_members_count
|
|
29
|
+
|
|
30
|
+
if created_count.zero? && form.remove_previous_members.blank?
|
|
31
|
+
return broadcast(:invalid,
|
|
32
|
+
I18n.t("decidim.decidim_awesome.admin.awesome_authorization_users.update.empty"))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
broadcast(:ok, created_count)
|
|
36
|
+
rescue StandardError => e
|
|
37
|
+
broadcast(:invalid, e.message)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
attr_reader :form
|
|
43
|
+
|
|
44
|
+
def authorization_group
|
|
45
|
+
form.authorization_group
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -11,7 +11,8 @@ module Decidim
|
|
|
11
11
|
def initialize(forms, category_slug)
|
|
12
12
|
@forms = forms
|
|
13
13
|
@category_slug = category_slug
|
|
14
|
-
@
|
|
14
|
+
@organization = forms.first.current_organization
|
|
15
|
+
@config = AwesomeConfig.find_or_initialize_by(organization: @organization, var: :cookie_management)
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
# Executes the command. Broadcasts these events:
|
|
@@ -31,7 +32,8 @@ module Decidim
|
|
|
31
32
|
|
|
32
33
|
UpdateCookieItem.call(form_with_context, category_slug) do
|
|
33
34
|
on(:ok) do
|
|
34
|
-
|
|
35
|
+
category["items"] ||= {}
|
|
36
|
+
category["items"].merge!(form.name => form.to_params)
|
|
35
37
|
end
|
|
36
38
|
on(:invalid) do |error_message|
|
|
37
39
|
errors << "#{form.name}: #{error_message.presence || form.errors.full_messages.join(", ")}"
|
|
@@ -50,12 +52,12 @@ module Decidim
|
|
|
50
52
|
|
|
51
53
|
attr_reader :forms, :category_slug
|
|
52
54
|
|
|
53
|
-
def
|
|
54
|
-
@
|
|
55
|
+
def store
|
|
56
|
+
@store ||= CookieManagementStore.new(@organization, @config.value || {})
|
|
55
57
|
end
|
|
56
58
|
|
|
57
|
-
def
|
|
58
|
-
@
|
|
59
|
+
def category
|
|
60
|
+
@category ||= store.categories[category_slug]
|
|
59
61
|
end
|
|
60
62
|
end
|
|
61
63
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Admin
|
|
6
|
+
class UpdateAwesomeAuthorizationGroup < Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# form - The form object with the authorization group data
|
|
10
|
+
# authorization_group - The authorization group to update
|
|
11
|
+
def initialize(form, authorization_group)
|
|
12
|
+
@form = form
|
|
13
|
+
@authorization_group = authorization_group
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Executes the command. Broadcasts these events:
|
|
17
|
+
#
|
|
18
|
+
# - :ok when everything is valid.
|
|
19
|
+
# - :invalid if we couldn't proceed.
|
|
20
|
+
#
|
|
21
|
+
# Returns nothing.
|
|
22
|
+
def call
|
|
23
|
+
return broadcast(:invalid, form.errors.full_messages.join("; ")) if form.invalid?
|
|
24
|
+
|
|
25
|
+
update_authorization_group!
|
|
26
|
+
|
|
27
|
+
broadcast(:ok, authorization_group)
|
|
28
|
+
rescue StandardError => e
|
|
29
|
+
broadcast(:invalid, e.message)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
attr_reader :form, :authorization_group
|
|
35
|
+
|
|
36
|
+
def update_authorization_group!
|
|
37
|
+
authorization_group.update!(
|
|
38
|
+
name: form.name,
|
|
39
|
+
purpose: form.purpose
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Admin
|
|
6
|
+
class UpdateAwesomeAuthorizationProperties < Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# form - A AwesomeAuthorizationPropertiesForm form
|
|
10
|
+
def initialize(form)
|
|
11
|
+
@form = form
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_reader :form
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
return broadcast(:invalid, form.errors.full_messages.join("; ")) if form.invalid?
|
|
18
|
+
|
|
19
|
+
config = Decidim::DecidimAwesome::AwesomeConfig.find_or_initialize_by(var: :awesome_authorization_handler, organization: form.current_organization)
|
|
20
|
+
|
|
21
|
+
if form.empty?
|
|
22
|
+
config.destroy! if config.persisted?
|
|
23
|
+
else
|
|
24
|
+
config.value = {
|
|
25
|
+
name: form.name,
|
|
26
|
+
explanation: form.explanation
|
|
27
|
+
}
|
|
28
|
+
config.save!
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
broadcast(:ok)
|
|
32
|
+
rescue StandardError => e
|
|
33
|
+
broadcast(:invalid, e.message)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -12,7 +12,7 @@ module Decidim
|
|
|
12
12
|
def initialize(form, category_slug)
|
|
13
13
|
@form = form
|
|
14
14
|
@category_slug = category_slug
|
|
15
|
-
@config = AwesomeConfig.
|
|
15
|
+
@config = AwesomeConfig.find_or_initialize_by(organization: form.current_organization, var: :cookie_management)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
attr_reader :form, :category_slug, :config
|
|
@@ -25,7 +25,11 @@ module Decidim
|
|
|
25
25
|
# Returns nothing.
|
|
26
26
|
def call
|
|
27
27
|
return broadcast(:invalid) if form.invalid?
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
config.value ||= {}
|
|
30
|
+
return broadcast(:invalid) unless store.categories[category_slug]
|
|
31
|
+
|
|
32
|
+
config.value[category_slug] ||= { "slug" => category_slug, "items" => {} }
|
|
29
33
|
|
|
30
34
|
config.value[category_slug]["items"] ||= {}
|
|
31
35
|
# Handle slug change by deleting old key
|
|
@@ -39,6 +43,12 @@ module Decidim
|
|
|
39
43
|
rescue StandardError => e
|
|
40
44
|
broadcast(:invalid, e.message)
|
|
41
45
|
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def store
|
|
50
|
+
@store ||= CookieManagementStore.new(form.current_organization, config.value)
|
|
51
|
+
end
|
|
42
52
|
end
|
|
43
53
|
end
|
|
44
54
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module NeedsThreadVariables
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
around_action :with_thread_variables
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def with_thread_variables
|
|
15
|
+
set_thread_variables
|
|
16
|
+
yield
|
|
17
|
+
ensure
|
|
18
|
+
clear_thread_variables
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def set_thread_variables
|
|
22
|
+
return unless respond_to?(:current_organization)
|
|
23
|
+
|
|
24
|
+
config = Decidim::DecidimAwesome::AwesomeConfig.find_by(
|
|
25
|
+
organization: current_organization,
|
|
26
|
+
var: :awesome_authorization_handler
|
|
27
|
+
)
|
|
28
|
+
Thread.current[:awesome_authorization_handler] = config&.value
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def clear_thread_variables
|
|
32
|
+
Thread.current[:awesome_authorization_handler] = nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/app/controllers/decidim/decidim_awesome/admin/awesome_authorization_properties_controller.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Admin
|
|
6
|
+
class AwesomeAuthorizationPropertiesController < DecidimAwesome::Admin::ApplicationController
|
|
7
|
+
helper ConfigConstraintsHelpers
|
|
8
|
+
|
|
9
|
+
before_action do
|
|
10
|
+
enforce_permission_to :edit_config, :awesome_authorization_handler
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def index
|
|
14
|
+
@form = form(AwesomeAuthorizationPropertiesForm).from_params(current_properties)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create
|
|
18
|
+
@form = form(AwesomeAuthorizationPropertiesForm).from_params(params)
|
|
19
|
+
|
|
20
|
+
UpdateAwesomeAuthorizationProperties.call(@form) do
|
|
21
|
+
on(:ok) do
|
|
22
|
+
flash[:notice] = I18n.t("awesome_authorization_properties.create.success", scope: "decidim.decidim_awesome.admin")
|
|
23
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorizations_path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
on(:invalid) do |error|
|
|
27
|
+
flash.now[:alert] = I18n.t("awesome_authorization_properties.create.error", error:, scope: "decidim.decidim_awesome.admin")
|
|
28
|
+
render :index
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def current_properties
|
|
36
|
+
value = AwesomeConfig.find_by(var: :awesome_authorization_handler, organization: current_organization)&.value
|
|
37
|
+
return {} unless value.is_a?(Hash)
|
|
38
|
+
|
|
39
|
+
value.slice("name", "explanation")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "csv"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module DecidimAwesome
|
|
7
|
+
module Admin
|
|
8
|
+
class AwesomeAuthorizationUsersController < DecidimAwesome::Admin::ApplicationController
|
|
9
|
+
include Decidim::Admin::Filterable
|
|
10
|
+
helper ConfigConstraintsHelpers
|
|
11
|
+
|
|
12
|
+
before_action do
|
|
13
|
+
enforce_permission_to :edit_config, :awesome_authorization_handler
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
helper_method :authorization_group, :authorization_members
|
|
17
|
+
|
|
18
|
+
def index; end
|
|
19
|
+
|
|
20
|
+
def new
|
|
21
|
+
@form = form(AwesomeAuthorizationMembersForm).instance
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create
|
|
25
|
+
@form = form(AwesomeAuthorizationMembersForm).from_params(params, authorization_group:)
|
|
26
|
+
|
|
27
|
+
CreateAwesomeAuthorizationMembers.call(@form) do
|
|
28
|
+
on(:ok) do |created_count|
|
|
29
|
+
Decidim::DecidimAwesome::SyncAwesomeAuthorizationGroupJob.perform_later(authorization_group.id)
|
|
30
|
+
flash[:notice] = I18n.t("decidim.decidim_awesome.admin.awesome_authorization_users.create.success", count: created_count)
|
|
31
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorization_users_path(authorization_group)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
on(:invalid) do |error|
|
|
35
|
+
flash.now[:alert] = I18n.t("decidim.decidim_awesome.admin.awesome_authorization_users.create.error", error: error)
|
|
36
|
+
render :new
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def destroy
|
|
42
|
+
Decidim::DecidimAwesome::SyncAwesomeAuthorizationGroupJob.perform_later(authorization_group.id)
|
|
43
|
+
authorization_group.members.find(params[:id]).destroy!
|
|
44
|
+
flash[:notice] = I18n.t("decidim.decidim_awesome.admin.awesome_authorization_users.destroy.success")
|
|
45
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorization_users_path(authorization_group)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def base_query
|
|
51
|
+
authorization_group.members.order(:email)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def authorization_group
|
|
55
|
+
@authorization_group ||= current_organization.awesome_authorization_groups.find(params[:awesome_authorization_id])
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def authorization_members
|
|
59
|
+
@authorization_members ||= paginate(base_query)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module DecidimAwesome
|
|
5
|
+
module Admin
|
|
6
|
+
class AwesomeAuthorizationsController < DecidimAwesome::Admin::ApplicationController
|
|
7
|
+
helper ConfigConstraintsHelpers
|
|
8
|
+
helper_method :available?, :authorization_groups
|
|
9
|
+
|
|
10
|
+
before_action do
|
|
11
|
+
enforce_permission_to :edit_config, :awesome_authorization_handler
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def index; end
|
|
15
|
+
|
|
16
|
+
def edit
|
|
17
|
+
@form = form(AwesomeAuthorizationGroupForm).from_model(authorization_group)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def new
|
|
21
|
+
@form = form(AwesomeAuthorizationGroupForm).instance
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create
|
|
25
|
+
@form = form(AwesomeAuthorizationGroupForm).from_params(params)
|
|
26
|
+
|
|
27
|
+
CreateAwesomeAuthorizationGroup.call(@form) do
|
|
28
|
+
on(:ok) do
|
|
29
|
+
flash[:notice] = I18n.t("decidim.decidim_awesome.admin.awesome_authorizations.create.success")
|
|
30
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorizations_path
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
on(:invalid) do |error|
|
|
34
|
+
flash.now[:alert] = I18n.t("decidim.decidim_awesome.admin.awesome_authorizations.create.error", error:)
|
|
35
|
+
render :new
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def update
|
|
41
|
+
@form = form(AwesomeAuthorizationGroupForm).from_params(params)
|
|
42
|
+
|
|
43
|
+
UpdateAwesomeAuthorizationGroup.call(@form, authorization_group) do
|
|
44
|
+
on(:ok) do
|
|
45
|
+
flash[:notice] = I18n.t("decidim.decidim_awesome.admin.awesome_authorizations.update.success")
|
|
46
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorizations_path
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
on(:invalid) do |error|
|
|
50
|
+
flash.now[:alert] = I18n.t("decidim.decidim_awesome.admin.awesome_authorizations.update.error", error:)
|
|
51
|
+
render :edit
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def destroy
|
|
57
|
+
users_to_sync = authorization_group.granted_in_group.to_a
|
|
58
|
+
|
|
59
|
+
authorization_group.destroy!
|
|
60
|
+
users_to_sync.each do |user|
|
|
61
|
+
Decidim::DecidimAwesome::SyncAwesomeAuthorizationUserJob.perform_later(user.id)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
flash[:notice] = I18n.t("decidim.decidim_awesome.admin.awesome_authorizations.destroy.success")
|
|
65
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorizations_path
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def sync
|
|
69
|
+
Decidim::DecidimAwesome::SyncAwesomeAuthorizationGroupJob.perform_later(authorization_group.id)
|
|
70
|
+
flash[:notice] = I18n.t("decidim.decidim_awesome.admin.awesome_authorizations.sync.success")
|
|
71
|
+
redirect_to decidim_admin_decidim_awesome.awesome_authorizations_path
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def available?
|
|
77
|
+
@available ||= current_organization.available_authorizations.include?("awesome_authorization_handler")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def authorization_groups
|
|
81
|
+
@authorization_groups ||= current_organization.awesome_authorization_groups
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def authorization_group
|
|
85
|
+
@authorization_group ||= authorization_groups.find(params[:id])
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -7,7 +7,7 @@ module Decidim
|
|
|
7
7
|
include TranslatableAttributes
|
|
8
8
|
|
|
9
9
|
attribute :authorization_handlers, { String => Object }
|
|
10
|
-
attribute :authorization_handlers_names,
|
|
10
|
+
attribute :authorization_handlers_names, [String]
|
|
11
11
|
attribute :authorization_handlers_options, { String => Object }
|
|
12
12
|
translatable_attribute :force_authorization_help_text, String, default: {}
|
|
13
13
|
|