decidim-initiatives 0.24.1 → 0.25.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +2 -0
  3. data/app/cells/decidim/initiatives/initiative_m_cell.rb +1 -3
  4. data/app/commands/decidim/initiatives/attachment_methods.rb +2 -1
  5. data/app/controllers/concerns/decidim/initiatives/admin/initiative_admin.rb +7 -0
  6. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +7 -1
  7. data/app/controllers/decidim/initiatives/admin/initiatives_permissions_controller.rb +27 -0
  8. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +0 -2
  9. data/app/controllers/decidim/initiatives/initiatives_controller.rb +4 -0
  10. data/app/controllers/decidim/initiatives/versions_controller.rb +6 -0
  11. data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +5 -1
  12. data/app/forms/decidim/initiatives/initiative_form.rb +2 -1
  13. data/app/helpers/decidim/initiatives/admin/initiatives_helper.rb +25 -0
  14. data/app/jobs/decidim/initiatives/export_initiatives_job.rb +12 -5
  15. data/app/models/decidim/initiative.rb +21 -15
  16. data/app/models/decidim/initiatives_type.rb +3 -1
  17. data/app/packs/entrypoints/decidim_initiatives.js +6 -0
  18. data/app/packs/entrypoints/decidim_initiatives_admin.js +3 -0
  19. data/app/packs/entrypoints/decidim_initiatives_initiatives_votes.js +1 -0
  20. data/app/packs/entrypoints/decidim_initiatives_initiatives_votes.scss +1 -0
  21. data/app/packs/entrypoints/decidim_initiatives_print.js +1 -0
  22. data/app/packs/entrypoints/decidim_initiatives_print.scss +1 -0
  23. data/app/{assets/images/decidim/gamification/badges/initiatives.svg → packs/images/decidim/gamification/badges/decidim_gamification_badges_initiatives.svg} +0 -0
  24. data/app/{assets/images/decidim/initiatives/icon.svg → packs/images/decidim/initiatives/decidim_initiatives.svg} +0 -0
  25. data/app/{assets/javascripts/decidim/initiatives/admin/initiatives_types.js.es6 → packs/src/decidim/initiatives/admin/initiatives_types.js} +0 -0
  26. data/app/{assets/javascripts → packs/src}/decidim/initiatives/admin/invite_users.js +2 -2
  27. data/app/packs/src/decidim/initiatives/application.js +3 -0
  28. data/app/{assets/javascripts → packs/src}/decidim/initiatives/identity_selector_dialog.js +2 -2
  29. data/app/{assets/javascripts → packs/src}/decidim/initiatives/scoped_type.js +2 -2
  30. data/app/{assets/stylesheet/decidim/initiatives/admin.css.scss → packs/stylesheets/decidim/initiatives/admin.scss} +0 -0
  31. data/app/{assets/stylesheet/decidim/initiatives/initiatives-votes.css.scss → packs/stylesheets/decidim/initiatives/initiatives-votes.scss} +0 -0
  32. data/app/{assets/stylesheet → packs/stylesheets}/decidim/initiatives/initiatives.scss +3 -3
  33. data/app/{assets/stylesheet/decidim/initiatives/popularity_item.css.scss → packs/stylesheets/decidim/initiatives/popularity_item.scss} +0 -0
  34. data/app/{assets/stylesheet/decidim/initiatives/print-initiative.css.scss → packs/stylesheets/decidim/initiatives/print-initiative.scss} +0 -0
  35. data/app/{assets/stylesheet/decidim/initiatives/statistics.css.scss → packs/stylesheets/decidim/initiatives/statistics.scss} +0 -0
  36. data/app/queries/decidim/initiatives/admin/admin_users.rb +13 -8
  37. data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +1 -1
  38. data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +19 -3
  39. data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +1 -1
  40. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +17 -14
  41. data/app/views/decidim/initiatives/admin/initiatives/show.html.erb +1 -1
  42. data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +1 -1
  43. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +1 -1
  44. data/app/views/decidim/initiatives/committee_requests/new.html.erb +2 -2
  45. data/app/views/decidim/initiatives/create_initiative/_share_committee_link.html.erb +1 -1
  46. data/app/views/decidim/initiatives/initiatives/_author.html.erb +4 -4
  47. data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +1 -1
  48. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +1 -1
  49. data/app/views/decidim/initiatives/initiatives/_form.html.erb +2 -2
  50. data/app/views/decidim/initiatives/initiatives/index.html.erb +0 -3
  51. data/app/views/decidim/initiatives/initiatives/print.html.erb +1 -1
  52. data/app/views/decidim/initiatives/initiatives/show.html.erb +2 -2
  53. data/app/views/layouts/decidim/_initiative_header.html.erb +1 -1
  54. data/app/views/layouts/decidim/admin/initiative.html.erb +4 -51
  55. data/app/views/layouts/decidim/admin/initiatives.html.erb +1 -1
  56. data/app/views/layouts/decidim/admin/initiatives_votes.pdf.erb +1 -1
  57. data/app/views/layouts/decidim/initiative_creation.html.erb +1 -1
  58. data/app/views/layouts/decidim/initiative_signature_creation.html.erb +1 -1
  59. data/config/assets.rb +12 -0
  60. data/config/locales/ar.yml +2 -5
  61. data/config/locales/ca.yml +5 -6
  62. data/config/locales/cs.yml +9 -10
  63. data/config/locales/de.yml +5 -6
  64. data/config/locales/el.yml +2 -5
  65. data/config/locales/en.yml +8 -6
  66. data/config/locales/es-MX.yml +5 -6
  67. data/config/locales/es-PY.yml +5 -6
  68. data/config/locales/es.yml +5 -6
  69. data/config/locales/eu.yml +2 -5
  70. data/config/locales/fi-plain.yml +5 -6
  71. data/config/locales/fi.yml +5 -6
  72. data/config/locales/fr-CA.yml +2 -6
  73. data/config/locales/fr-LU.yml +613 -0
  74. data/config/locales/fr.yml +2 -6
  75. data/config/locales/gl.yml +5 -5
  76. data/config/locales/hu.yml +2 -6
  77. data/config/locales/id-ID.yml +2 -5
  78. data/config/locales/is-IS.yml +2 -5
  79. data/config/locales/it.yml +120 -5
  80. data/config/locales/ja.yml +112 -20
  81. data/config/locales/lb-LU.yml +1 -0
  82. data/config/locales/lv.yml +2 -5
  83. data/config/locales/nl.yml +5 -6
  84. data/config/locales/no.yml +2 -6
  85. data/config/locales/pl.yml +6 -7
  86. data/config/locales/pt-BR.yml +187 -5
  87. data/config/locales/pt.yml +2 -5
  88. data/config/locales/ro-RO.yml +116 -5
  89. data/config/locales/ru.yml +2 -5
  90. data/config/locales/sk.yml +2 -5
  91. data/config/locales/sv.yml +6 -6
  92. data/config/locales/tr-TR.yml +2 -6
  93. data/config/locales/uk.yml +2 -5
  94. data/config/locales/zh-CN.yml +2 -6
  95. data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +1 -1
  96. data/lib/decidim/api/initiative_api_type.rb +4 -0
  97. data/lib/decidim/initiatives/admin_engine.rb +70 -25
  98. data/lib/decidim/initiatives/engine.rb +5 -11
  99. data/lib/decidim/initiatives/participatory_space.rb +16 -3
  100. data/lib/decidim/initiatives/version.rb +1 -1
  101. metadata +40 -54
  102. data/app/assets/config/admin_decidim_initiatives_manifest.js +0 -4
  103. data/app/assets/config/decidim_initiatives_manifest.css +0 -3
  104. data/app/assets/config/decidim_initiatives_manifest.js +0 -5
  105. data/app/assets/javascripts/decidim/initiatives/application.js +0 -1
  106. data/app/helpers/decidim/initiatives/admin/initiative_admin_menu_helper.rb +0 -15
  107. data/config/locales/ja-JP.yml +0 -529
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1824560912284adcc53dd8e0d131c3fc3b411bb2d13df564d5fc22d52a72a0e0
4
- data.tar.gz: 456a28502a052fcd81d7132df7df5472692a14f0c00c4e7f6f39844f204ebb8a
3
+ metadata.gz: e7bd82dc40292609012e7120b7cef37c0f2b3aaa85f4442724bd83d020ffd99f
4
+ data.tar.gz: 540b49a62f99907c409bbd367b4c7453ae72c3dbf09621560f22242357272880
5
5
  SHA512:
6
- metadata.gz: 113e7ab02ea1d87bf7ff5f94e11b489570e17f14cb955c17cd9a7467c4ad1eab9eeb9470c2880b24cc096774013ef910288fce99e4456960eff43997ff07dff2
7
- data.tar.gz: 3e4a170fc1ae65c20736abc0364683413680cc0d638ab251e2862d6959e68c91784d9d4df37f435b65c41d2f5728c6b65a3bf5e9933730b7cfed14a4dbca0b8a
6
+ metadata.gz: 4e7da10cc293557c3041ee48e48f7fb46c2d42788cff680934765ac7ec17c3428c87bf131bb382939bf8ce808327b8de062d850f1a91f1622beab85fe7961e4d
7
+ data.tar.gz: 339d5c0b27442b1a449c2893b33037162a11ce3ea37903cd4dbffb21e377ad5e594f7f22f0735baa669efd49a80a95f21c9f8a26539d2551109df21077cb730f
@@ -6,6 +6,8 @@
6
6
  <% highlighted_initiatives.each do |initiative| %>
7
7
  <div class="column">
8
8
  <%= link_to decidim_initiatives.initiative_path(initiative), class: "card card--initiative card--mini" do %>
9
+ <div aria-hidden="true" class="card__image-top"
10
+ style="background-image:url(<%= initiative.banner_image.path %>)"></div>
9
11
  <span class="show-for-sr"><%= translated_attribute initiative.title %></span>
10
12
  <div class="card__content">
11
13
  <span class="card__title card__link"><%= decidim_html_escape(translated_attribute(initiative.title)) %></span>
@@ -65,9 +65,7 @@ module Decidim
65
65
  end
66
66
 
67
67
  def image
68
- @image ||= model.attachments.find do |attachment|
69
- attachment.file.content_type.start_with?("image")
70
- end
68
+ @image ||= model.attachments.find(&:image?)
71
69
  end
72
70
 
73
71
  def resource_image_path
@@ -12,7 +12,8 @@ module Decidim
12
12
  @attachment = Attachment.new(
13
13
  title: { I18n.locale => @form.attachment.title },
14
14
  attached_to: attached_to,
15
- file: @form.attachment.file # Define attached_to before this
15
+ file: @form.attachment.file, # Define attached_to before this
16
+ content_type: @form.attachment.file.content_type
16
17
  )
17
18
  end
18
19
 
@@ -19,6 +19,13 @@ module Decidim
19
19
  participatory_space_admin_layout
20
20
 
21
21
  alias_method :current_participatory_space, :current_initiative
22
+ alias_method :current_participatory_space_manifest, :initiatives_manifest
23
+ end
24
+
25
+ private
26
+
27
+ def initiatives_manifest
28
+ @initiatives_manifest ||= Decidim.find_participatory_space_manifest(:initiatives)
22
29
  end
23
30
  end
24
31
  end
@@ -12,6 +12,7 @@ module Decidim
12
12
  include Decidim::Initiatives::TypeSelectorOptions
13
13
  include Decidim::Initiatives::Admin::Filterable
14
14
 
15
+ helper ::Decidim::Admin::ResourcePermissionsHelper
15
16
  helper Decidim::Initiatives::InitiativeHelper
16
17
  helper Decidim::Initiatives::CreateInitiativeHelper
17
18
 
@@ -125,7 +126,12 @@ module Decidim
125
126
  def export
126
127
  enforce_permission_to :export, :initiatives
127
128
 
128
- Decidim::Initiatives::ExportInitiativesJob.perform_later(current_user, params[:format] || default_format)
129
+ Decidim::Initiatives::ExportInitiativesJob.perform_later(
130
+ current_user,
131
+ current_organization,
132
+ params[:format] || default_format,
133
+ params[:collection_ids].presence&.map(&:to_i)
134
+ )
129
135
 
130
136
  flash[:notice] = t("decidim.admin.exports.notice")
131
137
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ # Controller that allows managing initiatives
7
+ # permissions in the admin panel.
8
+ class InitiativesPermissionsController < Decidim::Admin::ResourcePermissionsController
9
+ include Decidim::Initiatives::NeedsInitiative
10
+
11
+ layout "decidim/admin/initiatives"
12
+
13
+ register_permissions(::Decidim::Initiatives::Admin::InitiativesPermissionsController,
14
+ ::Decidim::Initiatives::Permissions,
15
+ ::Decidim::Admin::Permissions)
16
+
17
+ def resource
18
+ current_initiative
19
+ end
20
+
21
+ def permission_class_chain
22
+ ::Decidim.permissions_registry.chain_for(::Decidim::Initiatives::Admin::InitiativesPermissionsController)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/initiatives/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Initiatives
7
5
  module Admin
@@ -114,6 +114,10 @@ module Decidim
114
114
  @current_participatory_space ||= Initiative.find_by(id: id_from_slug(params[:slug]))
115
115
  end
116
116
 
117
+ def current_participatory_space_manifest
118
+ @current_participatory_space_manifest ||= Decidim.find_participatory_space_manifest(:initiatives)
119
+ end
120
+
117
121
  def initiatives
118
122
  @initiatives = search.results.includes(:scoped_type)
119
123
  @initiatives = reorder(@initiatives)
@@ -15,6 +15,12 @@ module Decidim
15
15
  def versioned_resource
16
16
  current_initiative
17
17
  end
18
+
19
+ private
20
+
21
+ def current_participatory_space_manifest
22
+ @current_participatory_space_manifest ||= Decidim.find_participatory_space_manifest(:initiatives)
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -32,9 +32,13 @@ module Decidim
32
32
  validates :attachments_enabled, :undo_online_signatures_enabled, :custom_signature_end_date_enabled,
33
33
  :area_enabled, :promoting_committee_enabled, inclusion: { in: [true, false] }
34
34
  validates :minimum_committee_members, numericality: { only_integer: true }, allow_nil: true
35
- validates :banner_image, presence: true, if: ->(form) { form.context.initiative_type.nil? }
35
+ validates :banner_image, presence: true, if: ->(form) { !form.persisted? && form.context.initiative_type.nil? }
36
36
  validates :document_number_authorization_handler, presence: true, if: ->(form) { form.collect_user_extra_fields? }
37
37
 
38
+ validates :banner_image, passthru: { to: Decidim::InitiativesType }
39
+
40
+ alias organization current_organization
41
+
38
42
  def minimum_committee_members=(value)
39
43
  super(value.presence)
40
44
  end
@@ -115,7 +115,8 @@ module Decidim
115
115
 
116
116
  attachment = Attachment.new(
117
117
  attached_to: attachment.try(:attached_to),
118
- file: attachment.try(:file)
118
+ file: attachment.try(:file),
119
+ content_type: attachment.try(:file)&.content_type
119
120
  )
120
121
 
121
122
  errors.add(:attachment, :file) if !attachment.save && attachment.errors.has_key?(:file)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ module InitiativesHelper
7
+ def export_dropdown(collection_ids = nil)
8
+ render partial: "decidim/initiatives/admin/exports/dropdown", locals: { collection_ids: collection_ids }
9
+ end
10
+
11
+ def export_dropdowns(query)
12
+ return export_dropdown if query.conditions.empty?
13
+
14
+ export_dropdown.concat(export_dropdown(query.result.map(&:id)))
15
+ end
16
+
17
+ def dropdown_id(collection_ids)
18
+ return "export-dropdown" if collection_ids.blank?
19
+
20
+ "export-selection-dropdown"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,18 +3,25 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  class ExportInitiativesJob < ApplicationJob
6
- queue_as :default
6
+ queue_as :exports
7
7
 
8
- def perform(user, format)
9
- export_data = Decidim::Exporters.find_exporter(format).new(collection, serializer).export
8
+ def perform(user, organization, format, collection_ids = nil)
9
+ export_data = Decidim::Exporters.find_exporter(format).new(
10
+ collection_to_export(collection_ids, organization),
11
+ serializer
12
+ ).export
10
13
 
11
14
  ExportMailer.export(user, "initiatives", export_data).deliver_now
12
15
  end
13
16
 
14
17
  private
15
18
 
16
- def collection
17
- Decidim::Initiative.all
19
+ def collection_to_export(ids, organization)
20
+ collection = Decidim::Initiative.where(organization: organization)
21
+
22
+ collection = collection.where(id: ids) if ids.present?
23
+
24
+ collection.order(id: :asc)
18
25
  end
19
26
 
20
27
  def serializer
@@ -21,6 +21,7 @@ module Decidim
21
21
  include Decidim::Searchable
22
22
  include Decidim::Initiatives::HasArea
23
23
  include Decidim::TranslatableResource
24
+ include Decidim::HasResourcePermission
24
25
 
25
26
  translatable_fields :title, :description, :answer
26
27
 
@@ -124,15 +125,18 @@ module Decidim
124
125
  Decidim::Initiatives::AdminLog::InitiativePresenter
125
126
  end
126
127
 
128
+ delegate :document_number_authorization_handler, :promoting_committee_enabled?, to: :type
129
+ delegate :type, :scope, :scope_name, to: :scoped_type, allow_nil: true
130
+
127
131
  # PUBLIC banner image
128
132
  #
129
133
  # Overrides participatory space's banner image with the banner image defined
130
134
  # for the initiative type.
131
135
  #
132
- # RETURNS string
133
- delegate :banner_image, to: :type
134
- delegate :document_number_authorization_handler, :promoting_committee_enabled?, to: :type
135
- delegate :type, :scope, :scope_name, to: :scoped_type, allow_nil: true
136
+ # RETURNS Decidim::BannerImageUploader
137
+ def banner_image
138
+ type.attached_uploader(:banner_image)
139
+ end
136
140
 
137
141
  # PUBLIC
138
142
  #
@@ -177,17 +181,6 @@ module Decidim
177
181
  user_group&.name || author.name
178
182
  end
179
183
 
180
- # PUBLIC author_avatar_url
181
- #
182
- # Returns the author's avatar URL. In case it is not defined the method
183
- # falls back to decidim/default-avatar.svg
184
- #
185
- # RETURNS STRING
186
- def author_avatar_url
187
- author.avatar&.url ||
188
- ActionController::Base.helpers.asset_path("decidim/default-avatar.svg")
189
- end
190
-
191
184
  def votes_enabled?
192
185
  published? &&
193
186
  signature_start_date <= Date.current &&
@@ -410,6 +403,10 @@ module Decidim
410
403
  committee_members.approved.count >= minimum_committee_members
411
404
  end
412
405
 
406
+ def component
407
+ nil
408
+ end
409
+
413
410
  # PUBLIC
414
411
  #
415
412
  # Checks if the type the initiative belongs to enables SMS code
@@ -428,6 +425,15 @@ module Decidim
428
425
  Decidim::ParticipatorySpaceRoleConfig::Base.new(:empty_role_name)
429
426
  end
430
427
 
428
+ # Public: Overrides the `allow_resource_permissions?` Resourceable concern method.
429
+ def allow_resource_permissions?
430
+ true
431
+ end
432
+
433
+ def user_allowed_to_comment?(user)
434
+ ActionAuthorizer.new(user, "comment", self, nil).authorize.ok?
435
+ end
436
+
431
437
  private
432
438
 
433
439
  # Private: This is just an alias because the naming on InitiativeTypeScope
@@ -5,6 +5,7 @@ module Decidim
5
5
  class InitiativesType < ApplicationRecord
6
6
  include Decidim::HasResourcePermission
7
7
  include Decidim::TranslatableResource
8
+ include Decidim::HasUploadValidations
8
9
 
9
10
  translatable_fields :title, :description, :extra_fields_legal_information
10
11
 
@@ -27,7 +28,8 @@ module Decidim
27
28
  validates :title, :description, :signature_type, presence: true
28
29
  validates :document_number_authorization_handler, presence: true, if: ->(form) { form.collect_user_extra_fields? }
29
30
 
30
- mount_uploader :banner_image, Decidim::BannerImageUploader
31
+ has_one_attached :banner_image
32
+ validates_upload :banner_image, uploader: Decidim::BannerImageUploader
31
33
 
32
34
  def allowed_signature_types_for_initiatives
33
35
  return %w(online offline any) if any_signature_type?
@@ -0,0 +1,6 @@
1
+ import "src/decidim/initiatives/application"
2
+ import "src/decidim/initiatives/identity_selector_dialog"
3
+ import "src/decidim/initiatives/scoped_type"
4
+
5
+ // Images
6
+ require.context("../images", true)
@@ -0,0 +1,3 @@
1
+ import "src/decidim/initiatives/admin/initiatives_types"
2
+ import "src/decidim/initiatives/admin/invite_users"
3
+ import "src/decidim/initiatives/scoped_type"
@@ -0,0 +1 @@
1
+ import "entrypoints/decidim_initiatives_initiatives_votes.scss"
@@ -0,0 +1 @@
1
+ @import "stylesheets/decidim/initiatives/initiatives-votes.scss";
@@ -0,0 +1 @@
1
+ import "entrypoints/decidim_initiatives_print.scss"
@@ -0,0 +1 @@
1
+ @import "stylesheets/decidim/initiatives/print-initiative";
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-empty */
2
2
 
3
- (function () {
3
+ $(() => {
4
4
  let inviteUsersButton = document.querySelector(".invite-users-link");
5
5
 
6
6
  if (inviteUsersButton !== null) {
@@ -20,4 +20,4 @@
20
20
  window.getSelection().removeAllRanges();
21
21
  });
22
22
  }
23
- }());
23
+ });
@@ -0,0 +1,3 @@
1
+ import "src/decidim/editor"
2
+ import "src/decidim/initiatives/scoped_type"
3
+ import "src/decidim/initiatives/identity_selector_dialog"
@@ -1,4 +1,4 @@
1
- $(document).ready(function () {
1
+ $(() => {
2
2
  let button = $("#select-identity-button"),
3
3
  userIdentitiesDialog = $("#user-identities");
4
4
 
@@ -11,4 +11,4 @@ $(document).ready(function () {
11
11
  });
12
12
  });
13
13
  }
14
- });
14
+ })
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable camelcase */
2
- let controlSelector = function(source, prefix, currentValueKey) {
2
+ const controlSelector = function(source, prefix, currentValueKey) {
3
3
  if (source.length) {
4
4
  let currentValue = source.data(currentValueKey),
5
5
  searchUrl = source.data(`${prefix}-search-url`),
@@ -27,7 +27,7 @@ let controlSelector = function(source, prefix, currentValueKey) {
27
27
  }
28
28
  };
29
29
 
30
- $(document).ready(function () {
30
+ $(() => {
31
31
  let typeSelector = $("[data-scope-selector]");
32
32
  controlSelector(typeSelector, "scope", "scope-id");
33
33
  controlSelector(typeSelector, "signature-types", "signature-type");
@@ -1,6 +1,6 @@
1
- @import "popularity_item";
2
- @import "statistics";
3
- @import "admin";
1
+ @import "stylesheets/decidim/initiatives/popularity_item";
2
+ @import "stylesheets/decidim/initiatives/statistics";
3
+ @import "stylesheets/decidim/initiatives/admin";
4
4
 
5
5
  .ql-formats{
6
6
  .ql-video{
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  module Admin
6
- # A class used to find the admins for an initiative.
6
+ # A class used to find the admins for an initiative or an organization initiatives.
7
7
  class AdminUsers < Rectify::Query
8
8
  # Syntactic sugar to initialize the class and return the queried objects.
9
9
  #
@@ -12,27 +12,32 @@ module Decidim
12
12
  new(initiative).query
13
13
  end
14
14
 
15
+ # Syntactic sugar to initialize the class and return the queried objects.
16
+ #
17
+ # organization - an organization that needs to find its initiative admins
18
+ def self.for_organization(organization)
19
+ new(nil, organization).query
20
+ end
21
+
15
22
  # Initializes the class.
16
23
  #
17
24
  # initiative - Decidim::Initiative
18
- def initialize(initiative)
25
+ # organization - an organization that needs to find its initiative admins
26
+ def initialize(initiative, organization = nil)
19
27
  @initiative = initiative
28
+ @organization = initiative&.organization || organization
20
29
  end
21
30
 
22
31
  # Finds organization admins and the users with role admin for the given initiative.
23
32
  #
24
33
  # Returns an ActiveRecord::Relation.
25
34
  def query
26
- Decidim::User.where(id: organization_admins)
35
+ organization.admins
27
36
  end
28
37
 
29
38
  private
30
39
 
31
- attr_reader :initiative
32
-
33
- def organization_admins
34
- initiative.organization.admins
35
- end
40
+ attr_reader :initiative, :organization
36
41
  end
37
42
  end
38
43
  end