decidim-decidim_awesome 0.12.5 → 0.13.1

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -4
  3. data/README.md +3 -2
  4. data/Rakefile +4 -12
  5. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +1 -1
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +2 -10
  7. data/app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb +13 -0
  8. data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +1 -1
  9. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +1 -1
  10. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +1 -1
  11. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +2 -0
  12. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable.rb +2 -0
  13. data/app/controllers/concerns/decidim/decidim_awesome/needs_hashcash.rb +2 -2
  14. data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +2 -1
  15. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +1 -1
  16. data/app/controllers/decidim/decidim_awesome/required_authorizations_controller.rb +4 -0
  17. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +1 -1
  18. data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +4 -4
  19. data/app/helpers/decidim/decidim_awesome/map_helper.rb +17 -14
  20. data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +1 -1
  21. data/app/jobs/decidim/decidim_awesome/export_admin_actions_job.rb +6 -2
  22. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +21 -8
  23. data/app/overrides/decidim/devise/sessions/new/add_hashcash.html.erb.deface +1 -1
  24. data/app/overrides/decidim/proposals/proposals/_proposal_actions/limit_amendments_modal.html.erb.deface +2 -0
  25. data/app/overrides/decidim/proposals/proposals/_votes_count/replace_counter.html.erb.deface +1 -1
  26. data/app/overrides/decidim/shared/_login_modal/add_hashcash.html.erb.deface +1 -1
  27. data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +13 -10
  28. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +6 -5
  29. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +1 -1
  30. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +1 -1
  31. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +12 -12
  32. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +11 -8
  33. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +1 -1
  34. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +6 -6
  35. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +150 -71
  36. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +1 -1
  37. data/app/packs/stylesheets/decidim/decidim_awesome/admin/admin_accountability.scss +10 -6
  38. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +39 -6
  39. data/app/presenters/decidim/decidim_awesome/role_base_presenter.rb +3 -1
  40. data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +2 -2
  41. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +3 -3
  42. data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +1 -1
  43. data/app/validators/concerns/decidim/decidim_awesome/etiquette_validator_override.rb +21 -3
  44. data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +5 -8
  45. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +18 -12
  46. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +15 -11
  47. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +16 -11
  48. data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +1 -5
  49. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +4 -4
  50. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +3 -1
  51. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +2 -2
  52. data/config/i18n-tasks.yml +1 -0
  53. data/config/locales/ca.yml +8 -3
  54. data/config/locales/cs.yml +8 -3
  55. data/config/locales/de.yml +8 -3
  56. data/config/locales/en.yml +8 -2
  57. data/config/locales/es.yml +8 -3
  58. data/config/locales/eu.yml +8 -3
  59. data/config/locales/fr.yml +5 -3
  60. data/config/locales/hu.yml +0 -3
  61. data/config/locales/it.yml +0 -3
  62. data/config/locales/ja.yml +8 -3
  63. data/config/locales/lt.yml +0 -1
  64. data/config/locales/nl.yml +0 -2
  65. data/config/locales/pt-BR.yml +0 -3
  66. data/config/locales/pt-PT.yml +0 -1
  67. data/config/locales/ro-RO.yml +0 -6
  68. data/config/locales/sv.yml +0 -2
  69. data/lib/decidim/decidim_awesome/checksums.yml +29 -3
  70. data/lib/decidim/decidim_awesome/engine.rb +10 -6
  71. data/lib/decidim/decidim_awesome/map_component/component.rb +2 -1
  72. data/lib/decidim/decidim_awesome/map_component/engine.rb +2 -1
  73. data/lib/decidim/decidim_awesome/test/shared_examples/admin_accountability_contexts.rb +11 -0
  74. data/lib/decidim/decidim_awesome/version.rb +2 -2
  75. data/lib/tasks/decidim_awesome_migrate_menu_categories.rake +38 -0
  76. data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -0
  77. data/package.json +7 -8
  78. metadata +14 -12
  79. data/app/overrides/decidim/proposals/proposals/_proposal_aside/limit_amendments_modal.html.erb.deface +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6040a5cab606622ed2cc0b108db81f7c5f9d248d912ddc4114134d23558570b
4
- data.tar.gz: ac4149f478ec1d884a20b5f5501b76a466fe1f53f345814800dcb29f73817b75
3
+ metadata.gz: ea1d742ed0d0071cd93cd52b08d6756e5797eea246f5eb8e27c7d9a91d8a5a23
4
+ data.tar.gz: bb011c398f7d9c878e968eb36d36e88ce9ca3ce49ecf7c88633f6b244d4f9eda
5
5
  SHA512:
6
- metadata.gz: 28a535597361b171cf5144df3036ee4cf2d84c43eb5847570224348521533081dba61c8f8354af6ddefe7403a109003bd03e645159d838e2379bca202299f1f3
7
- data.tar.gz: edbb6c2b87af2a4f4ddb3b81ec5ffd40b92932847c3c12de4b4e0f9b3dcb7c3101926dc30d50f93779e1c97284e4a3f659f7e72b2150f7657cb2feed93abe406
6
+ metadata.gz: a86de09cbead024b599913d5bd8fc84da6dad87561862a0b5700ed281b58307fe3561c9c9316ae75e45390257b92c7baafe537d3583517b3468262e3bd387247
7
+ data.tar.gz: f04b4d49541ff525a417cc4eccf2a64e4876b9c9b703c45a34310dc1a5bdf34649870430a1d3b6f44f1dcea26474a97ae73b725ae9e0babe2d459c044c0393dc
data/CHANGELOG.md CHANGED
@@ -1,13 +1,25 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
- v0.12.5
4
+ v0.13.1
5
5
  -------
6
+
6
7
  Compatibility:
7
- - Decidim 0.29.x
8
+ - Decidim 0.30.x
8
9
 
9
10
  Fixes:
10
- - Fix nil participatory_space error in SpaceConstraintFinder [#464](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/464)
11
+ - Fix access to surveys admin controller ([#460](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/460))
12
+ - Fix nil participatory_space error in SpaceConstraintFinder [#463](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/463)
13
+ - Correct module defaults link in README [#461](https://github.com/decidim-ice/decidim-module-decidim_awesome/pull/461)
14
+
15
+ v0.13.0
16
+ -------
17
+
18
+ Compatibility:
19
+ - Decidim 0.30.x
20
+
21
+ Features:
22
+ - Upgrade to Decidim v0.30
11
23
 
12
24
  v0.12.4
13
25
  -------
@@ -49,7 +61,7 @@ v0.12.1
49
61
  Compatibility:
50
62
  - Decidim 0.29.x
51
63
 
52
- Feature:
64
+ Features:
53
65
  - Added formBuilder languages controller to avoid external CDN
54
66
  - Fix cache hash in the global menu override
55
67
  - Fix crash on updating empty boxes for scoped admins
data/README.md CHANGED
@@ -65,7 +65,7 @@ Many scopes can be defined for every tweak. If a tweak is not scoped, it will be
65
65
 
66
66
  This is a component you can add in any participatory space. It retrieves all the geolocated content in that participatory space (meetings or proposals) and displays it in a big map.
67
67
 
68
- It also provides a simple search by category, each category is assigned to a different color.
68
+ It also provides a simple search by taxonomy, each taxonomy is assigned to a different color.
69
69
 
70
70
  ![Awesome map](examples/awesome-map.png)
71
71
 
@@ -471,6 +471,7 @@ Depending on your Decidim version, choose the corresponding Awesome version to e
471
471
 
472
472
  | Awesome version | Compatible Decidim versions |
473
473
  |---|---|
474
+ | 0.13.x | 0.30.x |
474
475
  | 0.12.x | 0.29.x |
475
476
  | 0.11.x | 0.28.x |
476
477
  | 0.10.x | >= 0.26.7, >= 0.27.x |
@@ -517,7 +518,7 @@ Decidim::DecidimAwesome.configure do |config|
517
518
  end
518
519
  ```
519
520
 
520
- For a complete list of options take a look at the [module defaults](lib/decidim/decidim_awesome.rb).
521
+ For a complete list of options take a look at the [module defaults](lib/decidim/decidim_awesome/awesome.rb).
521
522
 
522
523
  ## Missing something?
523
524
 
data/Rakefile CHANGED
@@ -5,21 +5,15 @@ require "fileutils"
5
5
 
6
6
  def install_module(path)
7
7
  Dir.chdir(path) do
8
- system("bundle exec rake decidim_decidim_awesome:install:migrations")
9
- system("bundle exec rake active_hashcash:install:migrations")
10
- system("bundle exec rake db:migrate")
11
- end
12
- end
13
-
14
- def override_webpacker_config_files(path)
15
- Dir.chdir(path) do
16
- system("bundle exec rake decidim_decidim_awesome:webpacker:install")
8
+ system("bundle exec rails decidim_decidim_awesome:install:migrations")
9
+ system("bundle exec rails active_hashcash:install:migrations")
10
+ system("bundle exec rails db:migrate")
17
11
  end
18
12
  end
19
13
 
20
14
  def seed_db(path)
21
15
  Dir.chdir(path) do
22
- system("bundle exec rake db:seed")
16
+ system("bundle exec rails db:seed")
23
17
  end
24
18
  end
25
19
 
@@ -34,7 +28,6 @@ desc "Generates a dummy app for testing"
34
28
  task test_app: "decidim:generate_external_test_app" do
35
29
  ENV["RAILS_ENV"] = "test"
36
30
  install_module("spec/decidim_dummy_app")
37
- override_webpacker_config_files("spec/decidim_dummy_app")
38
31
  copy_helpers
39
32
  end
40
33
 
@@ -53,7 +46,6 @@ task :development_app do
53
46
  end
54
47
 
55
48
  install_module("development_app")
56
- override_webpacker_config_files("development_app")
57
49
  seed_db("development_app")
58
50
  end
59
51
 
@@ -2,6 +2,6 @@
2
2
  <%= content_tag("h3", section_title) if section_title.present? %>
3
3
 
4
4
  <%= awesome_map_for global_map_components do %>
5
- <%= render partial: "decidim/decidim_awesome/map_component/map/map_template.html", locals: { categories: all_categories, map_height: model.settings.map_height } %>
5
+ <%= render partial: "decidim/decidim_awesome/map_component/map/map_template.html", locals: { taxonomies: all_taxonomies, map_height: model.settings.map_height } %>
6
6
  <% end %>
7
7
  </section>
@@ -26,16 +26,8 @@ module Decidim
26
26
  true
27
27
  end
28
28
 
29
- def all_categories
30
- return if @all_categories.present?
31
-
32
- @category_ids ||= Decidim::Category.pluck(:id, :decidim_participatory_space_type, :decidim_participatory_space_id).select do |category|
33
- _id, space_type, space_id = category
34
- space = space_type.constantize.find(space_id)
35
- space.organization == current_organization
36
- end.map(&:first)
37
-
38
- @all_categories ||= Decidim::Category.where(id: @category_ids)
29
+ def all_taxonomies
30
+ Decidim::Taxonomy.find(settings.taxonomy_ids.reject(&:empty?))
39
31
  end
40
32
 
41
33
  def global_map_components
@@ -46,6 +46,19 @@
46
46
  <div><%= settings_fields.check_box :show_rejected, label: t("show_rejected", scope: i18n_scope) %></div>
47
47
  <div><%= settings_fields.check_box :menu_merge_components, label: t("menu_merge_components", scope: i18n_scope) %></div>
48
48
  </div>
49
+
50
+ <div class="row mt-6">
51
+ <%= settings_fields.select(
52
+ :taxonomy_ids,
53
+ options_from_collection_for_select(
54
+ Decidim::Taxonomy.roots.for(current_organization),
55
+ :id,
56
+ ->(taxonomy) { taxonomy.translated_name },
57
+ settings_fields.object.taxonomy_ids
58
+ ),
59
+ { label: t("taxonomies", scope: i18n_scope) },
60
+ { multiple: true }) %>
61
+ </div>
49
62
  <% end %>
50
63
 
51
64
  <style>
@@ -8,7 +8,7 @@ module Decidim
8
8
  private
9
9
 
10
10
  def proposal_items
11
- [coauthors_item, comments_count_item, endorsements_count_item, weight_count_item, state_item, emendation_item]
11
+ [coauthors_item] + taxonomy_items + [comments_count_item, endorsements_count_item, weight_count_item, state_item, emendation_item]
12
12
  end
13
13
 
14
14
  def current_vote
@@ -29,7 +29,7 @@
29
29
  </p>
30
30
  <% elsif proposal.maximum_votes_reached? && !proposal.can_accumulate_votes_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
31
31
  <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.maximum_votes_reached") %></p>
32
- <% elsif vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0 %>
32
+ <% elsif vote_limit_enabled? && remaining_votes_count_for_user <= 0 %>
33
33
  <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.no_votes_remaining") %></p>
34
34
  <% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %>
35
35
  <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.votes_blocked") %></p>
@@ -71,7 +71,7 @@ module Decidim
71
71
 
72
72
  return true if proposal.maximum_votes_reached? && !proposal.can_accumulate_votes_beyond_threshold && current_component.participatory_space.can_participate?(current_user)
73
73
 
74
- true if vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0
74
+ true if vote_limit_enabled? && remaining_votes_count_for_user <= 0
75
75
  end
76
76
 
77
77
  def voted_for_any?
@@ -8,7 +8,9 @@ module Decidim
8
8
  #
9
9
  # params - A constraint params
10
10
  def initialize(params, organization)
11
+ # rubocop:disable Style/SafeNavigationChainLength
11
12
  @text = params[:text]&.strip&.gsub(" ", "_")&.parameterize&.truncate(64)
13
+ # rubocop:enable Style/SafeNavigationChainLength
12
14
  @scope = params[:scope]
13
15
  @key = params[:key]
14
16
  @attribute = params[:attribute]
@@ -43,7 +43,9 @@ module Decidim
43
43
  end
44
44
 
45
45
  def translated_participatory_space_type_eq(item_type)
46
+ # rubocop:disable Style/SafeNavigationChainLength
46
47
  item_type.gsub("UserRole", "").safe_constantize&.model_name&.human&.pluralize || item_type
48
+ # rubocop:enable Style/SafeNavigationChainLength
47
49
  end
48
50
 
49
51
  def search_field_predicate
@@ -17,9 +17,9 @@ module Decidim
17
17
  private
18
18
 
19
19
  def awesome_hashcash_bits(zone)
20
- return false unless awesome_config["hashcash_#{zone}".to_sym]
20
+ return false unless awesome_config[:"hashcash_#{zone}"]
21
21
 
22
- awesome_config["hashcash_#{zone}_bits".to_sym]
22
+ awesome_config[:"hashcash_#{zone}_bits"]
23
23
  end
24
24
 
25
25
  def awesome_check_hashcash
@@ -43,7 +43,8 @@ module Decidim
43
43
  end
44
44
 
45
45
  def admin_role_actions
46
- @admin_role_actions ||= PaperTrailVersion.in_organization(current_organization).admin_role_actions(PaperTrailVersion.safe_admin_role_type(params[:admin_role_type]))
46
+ @admin_role_actions ||= PaperTrailVersion.in_organization(current_organization)
47
+ .admin_role_actions(PaperTrailVersion.safe_admin_role_type(params[:admin_role_type]))
47
48
  end
48
49
 
49
50
  def export_params
@@ -80,7 +80,7 @@ module Decidim
80
80
  end
81
81
 
82
82
  def current_config
83
- @current_config ||= (AwesomeConfig.find_by(var: :custom_redirects, organization: current_organization)&.value || {})
83
+ @current_config ||= AwesomeConfig.find_by(var: :custom_redirects, organization: current_organization)&.value || {}
84
84
  end
85
85
  end
86
86
  end
@@ -15,6 +15,10 @@ module Decidim
15
15
  redirect_to redirect_url if user_signed_in? && service.granted? && request.path != redirect_url
16
16
  end
17
17
 
18
+ def index
19
+ redirect_to decidim.user_session_path(redirect_url:) unless user_signed_in?
20
+ end
21
+
18
22
  def redirect_url
19
23
  @redirect_url ||= begin
20
24
  path = params[:redirect_url] || request.referer
@@ -56,7 +56,7 @@ module Decidim
56
56
  # TODO: validate non general admins are here
57
57
 
58
58
  def self.from_params(params, additional_params = {})
59
- instance = super(params, additional_params)
59
+ instance = super
60
60
  instance.valid_keys = params.keys.map(&:to_sym) || []
61
61
  instance.force_authorizations = build_force_authorizations(instance.force_authorizations)
62
62
  instance.sanitize_labels!
@@ -78,14 +78,14 @@ module Decidim
78
78
 
79
79
  body = if name == :private_body
80
80
  if form_presenter.proposal.private_body.is_a?(Hash) && locale.present?
81
- form_presenter.private_body(extras: false, all_locales: locale.present?).with_indifferent_access[locale]
81
+ form_presenter.private_body(all_locales: locale.present?).with_indifferent_access[locale]
82
82
  else
83
- form_presenter.private_body(extras: false)
83
+ form_presenter.private_body
84
84
  end
85
85
  elsif form_presenter.proposal.body.is_a?(Hash) && locale.present?
86
- form_presenter.body(extras: false, all_locales: locale.present?).with_indifferent_access[locale]
86
+ form_presenter.body(all_locales: locale.present?).with_indifferent_access[locale]
87
87
  else
88
- form_presenter.body(extras: false)
88
+ form_presenter.body
89
89
  end
90
90
 
91
91
  custom_fields.apply_xml(body) if body.present?
@@ -40,7 +40,7 @@ module Decidim
40
40
  "menu-merge-components" => global_settings.menu_merge_components,
41
41
  "menu-amendments" => global_settings.menu_amendments,
42
42
  "menu-meetings" => global_settings.menu_meetings,
43
- "menu-categories" => global_settings.menu_categories,
43
+ "menu-taxonomies" => global_settings.menu_taxonomies,
44
44
  "menu-hashtags" => global_settings.menu_hashtags,
45
45
  "show-not-answered" => step_settings&.show_not_answered,
46
46
  "show-accepted" => step_settings&.show_accepted,
@@ -72,20 +72,23 @@ module Decidim
72
72
  end
73
73
 
74
74
  # rubocop:disable Rails/HelperInstanceVariable
75
- def current_categories(categories)
76
- return @current_categories if @current_categories
75
+ def current_taxonomies(taxonomies)
76
+ return @current_taxonomies if @current_taxonomies
77
77
 
78
78
  @golden_ratio_conjugate = 0.618033988749895
79
79
  # @h = rand # use random start value
80
80
  @h = 0.41
81
- @current_categories = []
82
- categories.first_class.each do |category|
83
- append_category category
84
- category.subcategories.each do |subcat|
85
- append_category subcat
81
+ @current_taxonomies = []
82
+ taxonomies.each do |taxonomy|
83
+ append_taxonomy taxonomy
84
+ taxonomy&.children&.each do |subtax|
85
+ append_taxonomy subtax
86
+ subtax&.children&.each do |subsubtax|
87
+ append_taxonomy subsubtax
88
+ end
86
89
  end
87
90
  end
88
- @current_categories
91
+ @current_taxonomies
89
92
  end
90
93
 
91
94
  private
@@ -103,15 +106,15 @@ module Decidim
103
106
  builder
104
107
  end
105
108
 
106
- def append_category(category)
109
+ def append_taxonomy(taxonomy)
107
110
  @h += @golden_ratio_conjugate
108
111
  @h %= 1
109
112
  # r,g,b = hsv_to_rgb(@h, 0.5, 0.95)
110
113
  r, g, b = hsv_to_rgb(@h, 0.99, 0.95)
111
- @current_categories.append(
112
- id: category.id,
113
- name: translated_attribute(category.name),
114
- parent: category.parent&.id,
114
+ @current_taxonomies.append(
115
+ id: taxonomy.id,
116
+ name: translated_attribute(taxonomy.name),
117
+ parent: taxonomy.parent&.id,
115
118
  color: format("#%02x%02x%02x", r, g, b)
116
119
  )
117
120
  end
@@ -9,7 +9,7 @@ module Decidim
9
9
  def perform(resource)
10
10
  extra_fields = Decidim::DecidimAwesome::ProposalExtraField.where(
11
11
  proposal: Decidim::Proposals::Proposal.where(component: resource)
12
- ).where("private_body_updated_at < ?", DecidimAwesome.private_data_expiration_time.ago)
12
+ ).where(private_body_updated_at: ...DecidimAwesome.private_data_expiration_time.ago)
13
13
 
14
14
  extra_fields.find_each do |extra_field|
15
15
  extra_field.update(private_body: nil)
@@ -3,14 +3,18 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  class ExportAdminActionsJob < ApplicationJob
6
+ include Decidim::PrivateDownloadHelper
7
+
6
8
  queue_as :default
7
9
 
8
10
  def perform(current_user, format, collection_ids)
9
11
  collection = serialized_collection(collection_ids)
10
12
 
11
- export_data = Exporters.find_exporter(format).new(collection).export
13
+ export_data = Decidim::Exporters.find_exporter(format).new(collection).export
14
+
15
+ private_export = attach_archive(export_data, "admin_actions", current_user)
12
16
 
13
- ExportMailer.export(current_user, "admin_actions", export_data).deliver_now
17
+ ExportMailer.export(current_user, private_export).deliver_now
14
18
  end
15
19
 
16
20
  private
@@ -15,12 +15,14 @@ module Decidim
15
15
 
16
16
  scope :space_role_actions, lambda { |organization|
17
17
  role_changes = where(item_type: PaperTrailVersion.safe_user_roles, event: "create")
18
- user_ids_from_object_changes = role_changes.pluck(:object_changes).map { |change| change.match(/decidim_user_id:\n- ?\n- (\d+)/)[1].to_i }
19
- relevant_user_ids = Decidim::User.select(:id).where(id: user_ids_from_object_changes, organization:).pluck(:id)
18
+
19
+ user_ids_from_object_changes = role_changes.pluck(:object_changes).map { |change| change.fetch("decidim_user_id", []).last.to_i }
20
+ user_ids_from_object_changes.compact_blank!
21
+ relevant_user_ids = Decidim::User.where(id: user_ids_from_object_changes, organization:).pluck(:id)
20
22
  # add users that might have been completly destroyed in any organization
21
- relevant_user_ids += user_ids_from_object_changes - Decidim::User.select("id").where(id: user_ids_from_object_changes).pluck(:id)
23
+ relevant_user_ids += user_ids_from_object_changes - Decidim::User.where(id: user_ids_from_object_changes).pluck(:id)
22
24
 
23
- role_changes.where("object_changes ~ ANY (array[?])", relevant_user_ids.map { |id| "decidim_user_id:\n- ?\n- #{id}(?!\\d)" })
25
+ role_changes.where("object_changes @> ANY (array[?]::jsonb[])", relevant_user_ids.map { |id| { "decidim_user_id" => [nil, id] }.to_json })
24
26
  }
25
27
 
26
28
  scope :in_organization, lambda { |organization|
@@ -33,11 +35,15 @@ module Decidim
33
35
  base = where(item_type: "Decidim::UserBaseEntity", event: %w(create update))
34
36
  case filter
35
37
  when nil
36
- base.where("object_changes LIKE '%\nroles:\n- []\n- - %' OR object_changes LIKE '%\nadmin:\n- false\n- true%'")
38
+ base.where(
39
+ "object_changes @> ?::jsonb OR object_changes @> ?::jsonb",
40
+ { "roles" => [[], []] }.to_json,
41
+ { "admin" => [false, true] }.to_json
42
+ )
37
43
  when "admin"
38
- base.where("object_changes LIKE '%\nadmin:\n- false\n- true%'")
44
+ base.where("object_changes @> ?::jsonb", { "admin" => [false, true] }.to_json)
39
45
  else
40
- base.where("object_changes LIKE ?", "%\nroles:\n- []\n- - #{filter}\n%")
46
+ base.where("object_changes @> ?::jsonb", { "roles" => [[], [filter]] }.to_json)
41
47
  end
42
48
  end
43
49
 
@@ -64,7 +70,6 @@ module Decidim
64
70
  Arel.sql("(#{queries.join(" UNION ")})")
65
71
  end
66
72
  end
67
-
68
73
  ransacker :participatory_space_type do
69
74
  Arel.sql(%{("item_type")::text})
70
75
  end
@@ -112,6 +117,14 @@ module Decidim
112
117
  ransacker :created_at, type: :date do
113
118
  Arel.sql("date(versions.created_at)")
114
119
  end
120
+
121
+ def self.ransackable_attributes(_auth_object = nil)
122
+ %w(created_at event id item_id item_type object object_changes participatory_space_type role_type user_email user_name whodunnit)
123
+ end
124
+
125
+ def self.ransackable_associations(_auth_object = nil)
126
+ ["item"]
127
+ end
115
128
  end
116
129
  end
117
130
  end
@@ -1,3 +1,3 @@
1
- <!-- insert_top ".login__links" -->
1
+ <!-- insert_before ".form__wrapper-block" -->
2
2
 
3
3
  <%= render partial: "decidim/decidim_awesome/hashcash/hidden_field", locals: { zone: :login } %>
@@ -0,0 +1,2 @@
1
+ <!-- insert_before "erb[silent]:contains('@proposal.amendable? && allowed_to?(:edit, :proposal, proposal: @proposal)')" -->
2
+ <%= render "decidim/decidim_awesome/amendments/modal" if @proposal.emendations.not_hidden.where(decidim_amendments: { state: Decidim::Amendment.states["evaluating"] }).exists? && @proposal.amendable? %>
@@ -7,4 +7,4 @@
7
7
  <%# Hidden placeholder for votes count to avoid update_button_adn_counter.js.erb cause a javascript console error %>
8
8
  <span style="display: none" id="proposal-<%= proposal.id %>-votes-count"><%= proposal.proposal_votes_count || 0 %></span>
9
9
  <% end %>
10
- <% elsif !current_settings.votes_hidden? && current_component.participatory_space.can_participate?(current_user) %>
10
+ <% elsif !current_settings.votes_hidden? && (current_component.participatory_space.can_participate?(current_user) || current_user.admin?) %>
@@ -1,3 +1,3 @@
1
- <!-- insert_top ".login__modal-links" -->
1
+ <!-- insert_top ".login__modal-remember" -->
2
2
 
3
3
  <%= render partial: "decidim/decidim_awesome/hashcash/hidden_field", locals: { zone: :login } %>
@@ -1,10 +1,9 @@
1
1
  document.addEventListener("DOMContentLoaded", () => {
2
2
  const modalId = "LimitAmendmentsModal";
3
3
  const modalEl = document.getElementById(modalId);
4
- const amendButton = document.getElementById("amend-button");
5
4
  const limitAmendments = modalEl && JSON.parse(modalEl.dataset.limitAmendments);
6
5
 
7
- if (!amendButton || !limitAmendments || document.querySelector('a[href^="/users/sign_in"]')) {
6
+ if (!limitAmendments || document.querySelector('a[href^="/users/sign_in"]')) {
8
7
  return;
9
8
  }
10
9
 
@@ -14,15 +13,19 @@ document.addEventListener("DOMContentLoaded", () => {
14
13
  });
15
14
  });
16
15
 
17
- /**
18
- * Determines if the modal should be displayed based on its current state and data attributes.
19
- */
20
- amendButton.addEventListener("click", (event) => {
16
+ document.addEventListener("click", (event) => {
17
+ const target = event.target.closest("#amend-button");
18
+ if (!target) {
19
+ return;
20
+ }
21
+
21
22
  const modal = window.Decidim.currentDialogs[modalId];
22
- if (modal) {
23
- event.preventDefault();
24
- event.stopPropagation();
25
- modal.open();
23
+ if (!modal) {
24
+ return;
26
25
  }
26
+
27
+ event.preventDefault();
28
+ event.stopPropagation();
29
+ modal.open();
27
30
  });
28
31
  });
@@ -30,14 +30,15 @@ export default class Fetcher {
30
30
  api.fetchAll((result) => {
31
31
  if (result) {
32
32
  const collection = result.component[this.collection];
33
+ collection.edges = collection.edges.filter((edge) => edge.node !== null);
33
34
  // console.log("collection", collection)
34
-
35
+
35
36
  collection.edges.forEach((element) => {
36
37
  let node = element.node;
37
38
  if (!node) {
38
39
  return;
39
40
  }
40
-
41
+
41
42
  if (node.coordinates && node.coordinates.latitude && node.coordinates.longitude) {
42
43
  this.decorateNode(node);
43
44
  this.onNode(node)
@@ -70,7 +71,7 @@ export default class Fetcher {
70
71
  findTranslation(translations) {
71
72
  let lang = document.querySelector("html").getAttribute("lang"),
72
73
  text = "";
73
-
74
+
74
75
  translations.forEach((txt) => {
75
76
  if (txt.text) {
76
77
  if (!text || txt.locale === lang) {
@@ -127,9 +128,9 @@ export default class Fetcher {
127
128
  : tag.html), "");
128
129
  if (string) {
129
130
  return `${txt}<p>${string}</p>`;
130
- }
131
+ }
131
132
  return txt;
132
-
133
+
133
134
  }
134
135
 
135
136
  truncate(html) {
@@ -36,7 +36,7 @@ export default class MeetingsFetcher extends Fetcher {
36
36
  longitude
37
37
  }
38
38
  typeOfMeeting
39
- category {
39
+ taxonomies {
40
40
  id
41
41
  }
42
42
  }
@@ -45,7 +45,7 @@ export default class ProposalsFetcher extends Fetcher {
45
45
  id
46
46
  }
47
47
  }
48
- category {
48
+ taxonomies {
49
49
  id
50
50
  }
51
51
  }
@@ -15,7 +15,7 @@ import MeetingsController from "src/decidim/decidim_awesome/awesome_map/controll
15
15
  export default class AwesomeMap {
16
16
  constructor(map, config) {
17
17
  this.map = map;
18
- this.categories = window.AwesomeMap && window.AwesomeMap.categories || []
18
+ this.taxonomies = window.AwesomeMap && window.AwesomeMap.taxonomies || []
19
19
  this.config = $.extend({
20
20
  length: 255,
21
21
  center: null,
@@ -23,7 +23,7 @@ export default class AwesomeMap {
23
23
  menu: {
24
24
  amendments: false,
25
25
  meetings: false,
26
- categories: true,
26
+ taxonomies: true,
27
27
  hashtags: false,
28
28
  mergeComponents: false
29
29
  },
@@ -83,25 +83,25 @@ export default class AwesomeMap {
83
83
  }
84
84
  }
85
85
 
86
- getCategory(category) {
87
- let defaultCat = {
86
+ getTaxonomy(taxonomy) {
87
+ let defaultTax = {
88
88
  color: getComputedStyle(document.documentElement).getPropertyValue("--primary"),
89
89
  children: () => {},
90
90
  parent: null,
91
91
  name: null
92
92
  };
93
93
 
94
- if (category) {
95
- let id = category.id ? parseInt(category.id, 10) : parseInt(category, 10); // eslint-disable-line no-ternary, multiline-ternary
96
- let cat = this.categories.find((ct) => ct.id === id);
97
- if (cat) {
98
- cat.children = () => {
99
- return this.categories.filter((ct) => ct.parent === cat.id);
94
+ if (taxonomy) {
95
+ let id = taxonomy.id ? parseInt(taxonomy.id, 10) : parseInt(taxonomy, 10); // eslint-disable-line no-ternary, multiline-ternary
96
+ let tax = this.taxonomies.find((tx) => tx.id === id);
97
+ if (tax) {
98
+ tax.children = () => {
99
+ return this.taxonomies.filter((tx) => tx.parent === tax.id);
100
100
  }
101
- return cat;
101
+ return tax;
102
102
  }
103
103
  }
104
- return defaultCat;
104
+ return defaultTax;
105
105
  }
106
106
 
107
107
  _getController(component) {