decidim-proposals 0.10.1 → 0.11.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +3 -3
  4. data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +6 -7
  5. data/app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6 +17 -17
  6. data/app/assets/javascripts/decidim/proposals/utils.js.es6 +2 -2
  7. data/app/commands/decidim/proposals/admin/create_proposal.rb +2 -2
  8. data/app/commands/decidim/proposals/admin/import_proposals.rb +16 -8
  9. data/app/commands/decidim/proposals/create_proposal.rb +6 -6
  10. data/app/commands/decidim/proposals/destroy_proposal.rb +33 -0
  11. data/app/commands/decidim/proposals/update_proposal.rb +4 -4
  12. data/app/controllers/decidim/proposals/admin/application_controller.rb +2 -2
  13. data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +1 -1
  14. data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +1 -1
  15. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
  16. data/app/controllers/decidim/proposals/admin/proposals_imports_controller.rb +4 -4
  17. data/app/controllers/decidim/proposals/application_controller.rb +5 -5
  18. data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +1 -1
  19. data/app/controllers/decidim/proposals/proposal_votes_controller.rb +1 -1
  20. data/app/controllers/decidim/proposals/proposal_widgets_controller.rb +1 -1
  21. data/app/controllers/decidim/proposals/proposals_controller.rb +52 -24
  22. data/app/events/decidim/proposals/proposal_mentioned_event.rb +19 -0
  23. data/app/forms/decidim/proposals/admin/proposal_form.rb +3 -3
  24. data/app/forms/decidim/proposals/admin/proposals_import_form.rb +9 -9
  25. data/app/forms/decidim/proposals/proposal_form.rb +5 -4
  26. data/app/helpers/decidim/proposals/application_helper.rb +38 -3
  27. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +7 -3
  28. data/app/helpers/decidim/proposals/proposal_votes_helper.rb +9 -9
  29. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +2 -1
  30. data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +28 -0
  31. data/app/jobs/decidim/proposals/settings_change_job.rb +4 -4
  32. data/app/models/decidim/proposals/abilities/admin_ability.rb +4 -4
  33. data/app/models/decidim/proposals/abilities/current_user_ability.rb +12 -12
  34. data/app/models/decidim/proposals/abilities/participatory_process_admin_ability.rb +8 -8
  35. data/app/models/decidim/proposals/abilities/participatory_process_moderator_ability.rb +1 -1
  36. data/app/models/decidim/proposals/proposal.rb +7 -7
  37. data/app/models/decidim/proposals/proposal_endorsement.rb +6 -2
  38. data/app/presenters/decidim/proposals/proposal_presenter.rb +12 -0
  39. data/app/queries/decidim/proposals/filtered_proposals.rb +9 -9
  40. data/app/queries/decidim/proposals/similar_proposals.rb +9 -9
  41. data/app/services/decidim/proposals/proposal_search.rb +1 -1
  42. data/app/types/decidim/proposals/proposal_type.rb +17 -2
  43. data/app/types/decidim/proposals/proposals_type.rb +6 -6
  44. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +1 -1
  45. data/app/views/decidim/participatory_processes/participatory_process_groups/_proposal.html.erb +1 -1
  46. data/app/views/decidim/participatory_spaces/_highlighted_proposals.html.erb +2 -2
  47. data/app/views/decidim/participatory_spaces/_proposal.html.erb +1 -1
  48. data/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +3 -3
  49. data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +2 -2
  50. data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +3 -3
  51. data/app/views/decidim/proposals/admin/proposal_notes/index.html.erb +1 -1
  52. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +2 -2
  53. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +3 -3
  54. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +1 -1
  55. data/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
  56. data/app/views/decidim/proposals/admin/proposals/new.html.erb +2 -2
  57. data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +3 -3
  58. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +3 -3
  59. data/app/views/decidim/proposals/admin/shared/_info_proposal.html.erb +1 -1
  60. data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +2 -2
  61. data/app/views/decidim/proposals/proposal_endorsements/identities.html.erb +2 -2
  62. data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +19 -8
  63. data/app/views/decidim/proposals/proposals/_endorsement_button.html.erb +2 -2
  64. data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +3 -3
  65. data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +4 -4
  66. data/app/views/decidim/proposals/proposals/_endorsements_count.html.erb +2 -2
  67. data/app/views/decidim/proposals/proposals/_filters.html.erb +10 -10
  68. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
  69. data/app/views/decidim/proposals/proposals/_identities_listing.html.erb +30 -0
  70. data/app/views/decidim/proposals/proposals/{_endorsement_xxs.html.erb → _identity_xxs.html.erb} +1 -2
  71. data/app/views/decidim/proposals/proposals/_proposal.html.erb +2 -2
  72. data/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -1
  73. data/app/views/decidim/proposals/proposals/_tags.html.erb +25 -0
  74. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +7 -7
  75. data/app/views/decidim/proposals/proposals/_votes_count.html.erb +6 -5
  76. data/app/views/decidim/proposals/proposals/_voting_rules.html.erb +7 -7
  77. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +5 -5
  78. data/app/views/decidim/proposals/proposals/compare.html.erb +1 -1
  79. data/app/views/decidim/proposals/proposals/complete.html.erb +70 -0
  80. data/app/views/decidim/proposals/proposals/edit.html.erb +3 -3
  81. data/app/views/decidim/proposals/proposals/edit_draft.html.erb +5 -3
  82. data/app/views/decidim/proposals/proposals/index.html.erb +5 -5
  83. data/app/views/decidim/proposals/proposals/new.html.erb +1 -43
  84. data/app/views/decidim/proposals/proposals/preview.html.erb +1 -1
  85. data/app/views/decidim/proposals/proposals/show.html.erb +16 -23
  86. data/config/locales/ca.yml +69 -55
  87. data/config/locales/en.yml +64 -50
  88. data/config/locales/es.yml +73 -59
  89. data/config/locales/eu.yml +64 -50
  90. data/config/locales/fi.yml +64 -50
  91. data/config/locales/fr.yml +75 -61
  92. data/config/locales/gl.yml +64 -50
  93. data/config/locales/it.yml +64 -50
  94. data/config/locales/nl.yml +153 -139
  95. data/config/locales/pl.yml +64 -50
  96. data/config/locales/pt-BR.yml +64 -50
  97. data/config/locales/pt.yml +64 -50
  98. data/config/locales/ru.yml +0 -9
  99. data/config/locales/sv.yml +64 -50
  100. data/config/locales/uk.yml +2 -16
  101. data/db/migrate/20171212102250_enable_pg_extensions.rb +12 -1
  102. data/db/migrate/20180305133811_rename_features_to_components_at_proposals.rb +11 -0
  103. data/db/migrate/20180413135249_fix_nil_threshold_per_proposal.rb +18 -0
  104. data/lib/decidim/content_parsers/proposal_parser.rb +95 -0
  105. data/lib/decidim/content_renderers/proposal_renderer.rb +33 -0
  106. data/lib/decidim/proposals.rb +9 -1
  107. data/lib/decidim/proposals/commentable_proposal.rb +3 -3
  108. data/lib/decidim/proposals/{feature.rb → component.rb} +39 -38
  109. data/lib/decidim/proposals/engine.rb +21 -6
  110. data/lib/decidim/proposals/proposal_serializer.rb +3 -3
  111. data/lib/decidim/proposals/test/factories.rb +5 -8
  112. data/lib/decidim/proposals/version.rb +1 -1
  113. metadata +32 -23
  114. data/app/views/decidim/proposals/proposals/_endorsements_listing.html.erb +0 -34
@@ -68,6 +68,7 @@ module Decidim
68
68
  #{proposal_wizard_stepper_step(:step_1, current_step)}
69
69
  #{proposal_wizard_stepper_step(:step_2, current_step)}
70
70
  #{proposal_wizard_stepper_step(:step_3, current_step)}
71
+ #{proposal_wizard_stepper_step(:step_4, current_step)}
71
72
  ).html_safe
72
73
  end
73
74
  end
@@ -89,7 +90,7 @@ module Decidim
89
90
  #
90
91
  # step - A symbol of the target step
91
92
  def proposal_wizard_step_help_text?(step)
92
- translated_attribute(feature_settings.try("proposal_wizard_#{step}_help_text")).present?
93
+ translated_attribute(component_settings.try("proposal_wizard_#{step}_help_text")).present?
93
94
  end
94
95
 
95
96
  # Renders a user_group select field in a form.
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ class NotifyProposalsMentionedJob < ApplicationJob
6
+ def perform(comment_id, proposal_metadata)
7
+ comment = Decidim::Comments::Comment.find(comment_id)
8
+ linked_proposals = proposal_metadata.linked_proposals
9
+ linked_proposals.each do |proposal_id|
10
+ proposal = Proposal.find(proposal_id)
11
+ next if proposal.decidim_author_id.blank?
12
+
13
+ recipient_ids = [proposal.decidim_author_id]
14
+ Decidim::EventsManager.publish(
15
+ event: "decidim.events.proposals.proposal_mentioned",
16
+ event_class: Decidim::Proposals::ProposalMentionedEvent,
17
+ resource: comment.root_commentable,
18
+ recipient_ids: recipient_ids,
19
+ extra: {
20
+ comment_id: comment.id,
21
+ mentioned_proposal_id: proposal_id
22
+ }
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -3,8 +3,8 @@
3
3
  module Decidim
4
4
  module Proposals
5
5
  class SettingsChangeJob < ApplicationJob
6
- def perform(feature_id, previous_settings, current_settings)
7
- feature = Decidim::Feature.find(feature_id)
6
+ def perform(component_id, previous_settings, current_settings)
7
+ component = Decidim::Component.find(component_id)
8
8
 
9
9
  if creation_enabled?(previous_settings, current_settings)
10
10
  event = "decidim.events.proposals.creation_enabled"
@@ -22,8 +22,8 @@ module Decidim
22
22
  Decidim::EventsManager.publish(
23
23
  event: event,
24
24
  event_class: event_class,
25
- resource: feature,
26
- recipient_ids: feature.participatory_space.followers.pluck(:id)
25
+ resource: component,
26
+ recipient_ids: component.participatory_space.followers.pluck(:id)
27
27
  )
28
28
  end
29
29
 
@@ -23,18 +23,18 @@ module Decidim
23
23
  @context.fetch(:current_settings, nil)
24
24
  end
25
25
 
26
- def feature_settings
27
- @context.fetch(:feature_settings, nil)
26
+ def component_settings
27
+ @context.fetch(:component_settings, nil)
28
28
  end
29
29
 
30
30
  def can_create_proposal?
31
31
  current_settings.try(:creation_enabled?) &&
32
- feature_settings.try(:official_proposals_enabled)
32
+ component_settings.try(:official_proposals_enabled)
33
33
  end
34
34
 
35
35
  def can_update_proposal?
36
36
  current_settings.try(:proposal_answering_enabled) &&
37
- feature_settings.try(:proposal_answering_enabled)
37
+ component_settings.try(:proposal_answering_enabled)
38
38
  end
39
39
  end
40
40
  end
@@ -51,14 +51,14 @@ module Decidim
51
51
  end
52
52
 
53
53
  def authorized?(action)
54
- return unless feature
54
+ return unless component
55
55
 
56
- ActionAuthorizer.new(user, feature, action).authorize.ok?
56
+ ActionAuthorizer.new(user, component, action).authorize.ok?
57
57
  end
58
58
 
59
59
  def vote_limit_enabled?
60
- return unless feature_settings
61
- feature_settings.vote_limit.present? && feature_settings.vote_limit.positive?
60
+ return unless component_settings
61
+ component_settings.vote_limit.present? && component_settings.vote_limit.positive?
62
62
  end
63
63
 
64
64
  def creation_enabled?
@@ -69,9 +69,9 @@ module Decidim
69
69
  def remaining_votes
70
70
  return 1 unless vote_limit_enabled?
71
71
 
72
- proposals = Proposal.where(feature: feature)
72
+ proposals = Proposal.where(component: component)
73
73
  votes_count = ProposalVote.where(author: user, proposal: proposals).size
74
- feature_settings.vote_limit - votes_count
74
+ component_settings.vote_limit - votes_count
75
75
  end
76
76
 
77
77
  def endorsements_enabled?
@@ -93,15 +93,15 @@ module Decidim
93
93
  context.fetch(:current_settings, nil)
94
94
  end
95
95
 
96
- def feature_settings
97
- context.fetch(:feature_settings, nil)
96
+ def component_settings
97
+ context.fetch(:component_settings, nil)
98
98
  end
99
99
 
100
- def feature
101
- feature = context.fetch(:current_feature, nil)
102
- return nil unless feature && feature.manifest.name == :proposals
100
+ def component
101
+ component = context.fetch(:current_component, nil)
102
+ return nil unless component && component.manifest.name == :proposals
103
103
 
104
- feature
104
+ component
105
105
  end
106
106
 
107
107
  def can_withdraw?(proposal)
@@ -10,7 +10,7 @@ module Decidim
10
10
  super
11
11
 
12
12
  can [:manage, :unreport, :hide], Proposal do |proposal|
13
- can_manage_process?(proposal.feature.participatory_space)
13
+ can_manage_process?(proposal.component.participatory_space)
14
14
  end
15
15
 
16
16
  cannot :create, Proposal unless can_create_proposal?
@@ -24,23 +24,23 @@ module Decidim
24
24
  @context.fetch(:current_settings, nil)
25
25
  end
26
26
 
27
- def feature_settings
28
- @context.fetch(:feature_settings, nil)
27
+ def component_settings
28
+ @context.fetch(:component_settings, nil)
29
29
  end
30
30
 
31
- def current_feature
32
- @context.fetch(:current_feature, nil)
31
+ def current_component
32
+ @context.fetch(:current_component, nil)
33
33
  end
34
34
 
35
35
  def can_create_proposal?
36
36
  current_settings.try(:creation_enabled?) &&
37
- feature_settings.try(:official_proposals_enabled) &&
38
- can_manage_process?(current_feature.try(:participatory_space))
37
+ component_settings.try(:official_proposals_enabled) &&
38
+ can_manage_process?(current_component.try(:participatory_space))
39
39
  end
40
40
 
41
41
  def can_update_proposal?
42
42
  current_settings.try(:proposal_answering_enabled) &&
43
- feature_settings.try(:proposal_answering_enabled)
43
+ component_settings.try(:proposal_answering_enabled)
44
44
  end
45
45
  end
46
46
  end
@@ -10,7 +10,7 @@ module Decidim
10
10
  super
11
11
 
12
12
  can [:unreport, :hide], Proposal do |proposal|
13
- can_manage_process?(proposal.feature.participatory_space)
13
+ can_manage_process?(proposal.component.participatory_space)
14
14
  end
15
15
  end
16
16
  end
@@ -6,8 +6,8 @@ module Decidim
6
6
  class Proposal < Proposals::ApplicationRecord
7
7
  include Decidim::Resourceable
8
8
  include Decidim::Authorable
9
- include Decidim::HasFeature
10
- include Decidim::ScopableFeature
9
+ include Decidim::HasComponent
10
+ include Decidim::ScopableComponent
11
11
  include Decidim::HasReference
12
12
  include Decidim::HasCategory
13
13
  include Decidim::Reportable
@@ -17,7 +17,7 @@ module Decidim
17
17
  include Decidim::Traceable
18
18
  include Decidim::Loggable
19
19
 
20
- feature_manifest_name "proposals"
20
+ component_manifest_name "proposals"
21
21
 
22
22
  has_many :endorsements, foreign_key: "decidim_proposal_id", class_name: "ProposalEndorsement", dependent: :destroy, counter_cache: "proposal_endorsements_count"
23
23
  has_many :votes, foreign_key: "decidim_proposal_id", class_name: "ProposalVote", dependent: :destroy, counter_cache: "proposal_votes_count"
@@ -25,7 +25,7 @@ module Decidim
25
25
 
26
26
  validates :title, :body, presence: true
27
27
 
28
- geocoded_by :address, http_headers: ->(proposal) { { "Referer" => proposal.feature.organization.host } }
28
+ geocoded_by :address, http_headers: ->(proposal) { { "Referer" => proposal.component.organization.host } }
29
29
 
30
30
  scope :accepted, -> { where(state: "accepted") }
31
31
  scope :rejected, -> { where(state: "rejected") }
@@ -109,7 +109,7 @@ module Decidim
109
109
  #
110
110
  # Returns an Integer with the maximum amount of votes, nil otherwise.
111
111
  def maximum_votes
112
- maximum_votes = feature.settings.threshold_per_proposal || 0
112
+ maximum_votes = component.settings.threshold_per_proposal
113
113
  return nil if maximum_votes.zero?
114
114
 
115
115
  maximum_votes
@@ -128,7 +128,7 @@ module Decidim
128
128
  #
129
129
  # Returns true if can accumulate, false otherwise
130
130
  def can_accumulate_supports_beyond_threshold
131
- feature.settings.can_accumulate_supports_beyond_threshold
131
+ component.settings.can_accumulate_supports_beyond_threshold
132
132
  end
133
133
 
134
134
  # Checks whether the user can edit the given proposal.
@@ -169,7 +169,7 @@ module Decidim
169
169
  # Checks whether the proposal is inside the time window to be editable or not once published.
170
170
  def within_edit_time_limit?
171
171
  return true if draft?
172
- limit = updated_at + feature.settings.proposal_edit_before_minutes.minutes
172
+ limit = updated_at + component.settings.proposal_edit_before_minutes.minutes
173
173
  Time.current < limit
174
174
  end
175
175
 
@@ -4,9 +4,9 @@ module Decidim
4
4
  module Proposals
5
5
  # A proposal can include an endorsement per user or group.
6
6
  class ProposalEndorsement < ApplicationRecord
7
+ include Decidim::Authorable
8
+
7
9
  belongs_to :proposal, foreign_key: "decidim_proposal_id", class_name: "Decidim::Proposals::Proposal", counter_cache: true
8
- belongs_to :author, foreign_key: "decidim_author_id", class_name: "Decidim::User"
9
- belongs_to :user_group, foreign_key: "decidim_user_group_id", class_name: "Decidim::UserGroup", optional: true
10
10
 
11
11
  validates :proposal, uniqueness: { scope: [:author, :user_group] }
12
12
  validate :author_and_proposal_same_organization
@@ -16,6 +16,10 @@ module Decidim
16
16
 
17
17
  private
18
18
 
19
+ def organization
20
+ proposal&.component&.organization
21
+ end
22
+
19
23
  # Private: check if the proposal and the author have the same organization
20
24
  def author_and_proposal_same_organization
21
25
  return if !proposal || !author
@@ -6,6 +6,9 @@ module Decidim
6
6
  # Decorator for proposals
7
7
  #
8
8
  class ProposalPresenter < SimpleDelegator
9
+ include Rails.application.routes.mounted_helpers
10
+ include ActionView::Helpers::UrlHelper
11
+
9
12
  def author
10
13
  @author ||= if official?
11
14
  Decidim::Proposals::OfficialAuthorPresenter.new
@@ -15,6 +18,15 @@ module Decidim
15
18
  Decidim::UserPresenter.new(super)
16
19
  end
17
20
  end
21
+
22
+ def proposal_path
23
+ proposal = __getobj__
24
+ Decidim::ResourceLocatorPresenter.new(proposal).path
25
+ end
26
+
27
+ def display_mention
28
+ link_to title, proposal_path
29
+ end
18
30
  end
19
31
  end
20
32
  end
@@ -2,32 +2,32 @@
2
2
 
3
3
  module Decidim
4
4
  module Proposals
5
- # A class used to find proposals filtered by features and a date range
5
+ # A class used to find proposals filtered by components and a date range
6
6
  class FilteredProposals < Rectify::Query
7
7
  # Syntactic sugar to initialize the class and return the queried objects.
8
8
  #
9
- # features - An array of Decidim::Feature
9
+ # components - An array of Decidim::Component
10
10
  # start_at - A date to filter resources created after it
11
11
  # end_at - A date to filter resources created before it.
12
- def self.for(features, start_at = nil, end_at = nil)
13
- new(features, start_at, end_at).query
12
+ def self.for(components, start_at = nil, end_at = nil)
13
+ new(components, start_at, end_at).query
14
14
  end
15
15
 
16
16
  # Initializes the class.
17
17
  #
18
- # features - An array of Decidim::Feature
18
+ # components - An array of Decidim::Component
19
19
  # start_at - A date to filter resources created after it
20
20
  # end_at - A date to filter resources created before it.
21
- def initialize(features, start_at = nil, end_at = nil)
22
- @features = features
21
+ def initialize(components, start_at = nil, end_at = nil)
22
+ @components = components
23
23
  @start_at = start_at
24
24
  @end_at = end_at
25
25
  end
26
26
 
27
- # Finds the Proposals scoped to an array of features and filtered
27
+ # Finds the Proposals scoped to an array of components and filtered
28
28
  # by a range of dates.
29
29
  def query
30
- proposals = Decidim::Proposals::Proposal.where(feature: @features)
30
+ proposals = Decidim::Proposals::Proposal.where(component: @components)
31
31
  proposals = proposals.where("created_at >= ?", @start_at) if @start_at.present?
32
32
  proposals = proposals.where("created_at <= ?", @end_at) if @end_at.present?
33
33
  proposals
@@ -8,30 +8,30 @@ module Decidim
8
8
 
9
9
  # Syntactic sugar to initialize the class and return the queried objects.
10
10
  #
11
- # features - Decidim::CurrentFeature
11
+ # components - Decidim::CurrentComponent
12
12
  # proposal - Decidim::Proposals::Proposal
13
- def self.for(features, proposal)
14
- new(features, proposal).query
13
+ def self.for(components, proposal)
14
+ new(components, proposal).query
15
15
  end
16
16
 
17
17
  # Initializes the class.
18
18
  #
19
- # features - Decidim::CurrentFeature
19
+ # components - Decidim::CurrentComponent
20
20
  # proposal - Decidim::Proposals::Proposal
21
- def initialize(features, proposal)
22
- @features = features
21
+ def initialize(components, proposal)
22
+ @components = components
23
23
  @proposal = proposal
24
24
  end
25
25
 
26
26
  # Retrieves similar proposals
27
27
  def query
28
28
  Decidim::Proposals::Proposal
29
- .where(feature: @features)
29
+ .where(component: @components)
30
30
  .published
31
31
  .where(
32
32
  "GREATEST(#{title_similarity}, #{body_similarity}) >= ?",
33
- proposal.title,
34
- proposal.body,
33
+ @proposal[:title],
34
+ @proposal[:body],
35
35
  Decidim::Proposals.similarity_threshold
36
36
  )
37
37
  .limit(Decidim::Proposals.similarity_limit)
@@ -6,7 +6,7 @@ module Decidim
6
6
  # proposals in a participatory process.
7
7
  class ProposalSearch < ResourceSearch
8
8
  # Public: Initializes the service.
9
- # feature - A Decidim::Feature to get the proposals from.
9
+ # component - A Decidim::Component to get the proposals from.
10
10
  # page - The page number to paginate the results.
11
11
  # per_page - The number of proposals to return per page.
12
12
  def initialize(options = {})
@@ -6,17 +6,32 @@ module Decidim
6
6
  name "Proposal"
7
7
  description "A proposal"
8
8
 
9
+ interfaces [
10
+ Decidim::Comments::CommentableInterface,
11
+ Decidim::Core::AuthorableInterface,
12
+ Decidim::Core::CategorizableInterface,
13
+ Decidim::Core::ScopableInterface,
14
+ Decidim::Core::AttachableInterface
15
+ ]
16
+
9
17
  field :id, !types.ID
10
18
  field :title, !types.String, "This proposal's title"
11
19
  field :body, types.String, "This proposal's body"
12
20
  field :state, types.String, "The state in which proposal is in"
13
21
  field :address, types.String, "The physical address (location) of this proposal"
22
+ field :reference, types.String, "This proposa'ls unique reference"
14
23
 
15
24
  field :publishedAt, Decidim::Core::DateTimeType do
16
25
  description "The date and time this proposal was published"
17
26
  property :published_at
18
27
  end
19
28
 
29
+ field :endorsements, !types[Decidim::Core::AuthorInterface], "The endorsements of this proposal." do
30
+ resolve ->(proposal, _, _) {
31
+ proposal.endorsements.map(&:normalized_author)
32
+ }
33
+ end
34
+
20
35
  field :endorsementsCount, types.Int do
21
36
  description "The total amount of endorsements the proposal has received"
22
37
  property :proposal_endorsements_count
@@ -25,8 +40,8 @@ module Decidim
25
40
  field :voteCount, types.Int do
26
41
  description "The total amount of votes the proposal has received"
27
42
  resolve ->(proposal, _args, _ctx) {
28
- current_feature = proposal.feature
29
- proposal.proposal_votes_count unless current_feature.current_settings.votes_hidden?
43
+ current_component = proposal.component
44
+ proposal.proposal_votes_count unless current_component.current_settings.votes_hidden?
30
45
  }
31
46
  end
32
47
  end
@@ -9,24 +9,24 @@ module Decidim
9
9
  description "A proposals component of a participatory space."
10
10
 
11
11
  connection :proposals, ProposalType.connection_type do
12
- resolve ->(feature, _args, _ctx) {
13
- ProposalsTypeHelper.base_scope(feature).includes(:feature)
12
+ resolve ->(component, _args, _ctx) {
13
+ ProposalsTypeHelper.base_scope(component).includes(:component)
14
14
  }
15
15
  end
16
16
 
17
17
  field(:proposal, ProposalType) do
18
18
  argument :id, !types.ID
19
19
 
20
- resolve ->(feature, args, _ctx) {
21
- ProposalsTypeHelper.base_scope(feature).find_by(id: args[:id])
20
+ resolve ->(component, args, _ctx) {
21
+ ProposalsTypeHelper.base_scope(component).find_by(id: args[:id])
22
22
  }
23
23
  end
24
24
  end
25
25
 
26
26
  module ProposalsTypeHelper
27
- def self.base_scope(feature)
27
+ def self.base_scope(component)
28
28
  Proposal
29
- .where(feature: feature)
29
+ .where(component: component)
30
30
  .published
31
31
  end
32
32
  end