decidim-initiatives 0.28.3 → 0.29.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/cells/decidim/initiatives/initiative_g_cell.rb +6 -4
  4. data/app/cells/decidim/initiatives_votes/vote_cell.rb +1 -3
  5. data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +9 -58
  6. data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +5 -43
  7. data/app/commands/decidim/initiatives/admin/update_initiative.rb +25 -42
  8. data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +3 -4
  9. data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +11 -61
  10. data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +2 -33
  11. data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +2 -35
  12. data/app/commands/decidim/initiatives/create_initiative.rb +5 -6
  13. data/app/commands/decidim/initiatives/spawn_committee_request.rb +3 -4
  14. data/app/commands/decidim/initiatives/update_initiative.rb +3 -3
  15. data/app/commands/decidim/initiatives/validate_sms_code.rb +3 -3
  16. data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
  17. data/app/controllers/decidim/initiatives/admin/answers_controller.rb +1 -1
  18. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +7 -1
  19. data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +1 -1
  20. data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +2 -2
  21. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +2 -2
  22. data/app/controllers/decidim/initiatives/application_controller.rb +5 -2
  23. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +1 -1
  24. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +1 -1
  25. data/app/controllers/decidim/initiatives/initiatives_controller.rb +1 -1
  26. data/app/events/decidim/initiatives/approve_membership_request_event.rb +9 -29
  27. data/app/events/decidim/initiatives/create_initiative_event.rb +17 -36
  28. data/app/events/decidim/initiatives/revoke_membership_request_event.rb +10 -33
  29. data/app/events/decidim/initiatives/spawn_committee_request_event.rb +10 -33
  30. data/app/forms/decidim/initiatives/admin/initiative_form.rb +2 -2
  31. data/app/forms/decidim/initiatives/initiative_form.rb +11 -1
  32. data/app/forms/decidim/initiatives/vote_form.rb +2 -2
  33. data/app/helpers/decidim/initiatives/initiative_helper.rb +0 -74
  34. data/app/helpers/decidim/initiatives/initiatives_helper.rb +0 -7
  35. data/app/models/decidim/initiative.rb +1 -1
  36. data/app/packs/src/decidim/initiatives/admin/invite_users.js +1 -1
  37. data/app/serializers/decidim/initiatives/initiative_serializer.rb +1 -1
  38. data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +1 -1
  39. data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +1 -1
  40. data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +6 -6
  41. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +74 -68
  42. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/_form.html.erb +1 -1
  43. data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +1 -1
  44. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +1 -1
  45. data/app/views/decidim/initiatives/committee_requests/new.html.erb +3 -4
  46. data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +1 -1
  47. data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +1 -1
  48. data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +1 -1
  49. data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +1 -1
  50. data/app/views/decidim/initiatives/initiatives/print.html.erb +2 -2
  51. data/app/views/decidim/initiatives/initiatives/show.html.erb +2 -3
  52. data/app/views/layouts/decidim/_initiative_header.html.erb +6 -6
  53. data/app/views/layouts/decidim/initiative.html.erb +2 -2
  54. data/app/views/layouts/decidim/initiative_head.html.erb +1 -1
  55. data/config/initializers/wicked_pdf.rb +5 -5
  56. data/config/locales/ar.yml +0 -1
  57. data/config/locales/bg.yml +1 -3
  58. data/config/locales/ca.yml +5 -2
  59. data/config/locales/cs.yml +4 -2
  60. data/config/locales/de.yml +6 -3
  61. data/config/locales/el.yml +0 -1
  62. data/config/locales/en.yml +6 -3
  63. data/config/locales/es-MX.yml +5 -2
  64. data/config/locales/es-PY.yml +5 -2
  65. data/config/locales/es.yml +5 -2
  66. data/config/locales/eu.yml +6 -3
  67. data/config/locales/fi-plain.yml +5 -2
  68. data/config/locales/fi.yml +6 -3
  69. data/config/locales/fr-CA.yml +1 -3
  70. data/config/locales/fr.yml +1 -3
  71. data/config/locales/gl.yml +0 -1
  72. data/config/locales/he-IL.yml +0 -6
  73. data/config/locales/hu.yml +0 -3
  74. data/config/locales/id-ID.yml +0 -1
  75. data/config/locales/it.yml +0 -1
  76. data/config/locales/ja.yml +6 -3
  77. data/config/locales/lt.yml +0 -3
  78. data/config/locales/lv.yml +0 -1
  79. data/config/locales/nl.yml +0 -1
  80. data/config/locales/no.yml +0 -1
  81. data/config/locales/pl.yml +5 -2
  82. data/config/locales/pt-BR.yml +0 -2
  83. data/config/locales/pt.yml +0 -1
  84. data/config/locales/ro-RO.yml +0 -1
  85. data/config/locales/ru.yml +0 -1
  86. data/config/locales/sk.yml +0 -1
  87. data/config/locales/sv.yml +14 -41
  88. data/config/locales/tr-TR.yml +0 -1
  89. data/config/locales/uk.yml +0 -1
  90. data/config/locales/zh-CN.yml +0 -1
  91. data/config/locales/zh-TW.yml +0 -3
  92. data/decidim-initiatives.gemspec +1 -1
  93. data/lib/decidim/api/initiative_api_type.rb +2 -2
  94. data/lib/decidim/initiatives/engine.rb +1 -0
  95. data/lib/decidim/initiatives/menu.rb +12 -1
  96. data/lib/decidim/initiatives/seeds.rb +89 -64
  97. data/lib/decidim/initiatives/version.rb +1 -1
  98. data/lib/decidim/initiatives.rb +0 -12
  99. data/lib/tasks/decidim_initiatives.rake +3 -3
  100. data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +9 -11
  101. metadata +18 -20
  102. data/app/forms/decidim/initiatives/previous_form.rb +0 -24
  103. data/app/queries/decidim/initiatives/similar_initiatives.rb +0 -54
@@ -17,6 +17,8 @@ module Decidim
17
17
  helper Decidim::Initiatives::InitiativeHelper
18
18
  helper Decidim::Initiatives::SignatureTypeOptionsHelper
19
19
 
20
+ helper_method :show_initiative_type_callout?
21
+
20
22
  # GET /admin/initiatives
21
23
  def index
22
24
  enforce_permission_to :list, :initiative
@@ -46,7 +48,7 @@ module Decidim
46
48
  @form = form(Decidim::Initiatives::Admin::InitiativeForm)
47
49
  .from_params(params, initiative: current_initiative)
48
50
 
49
- Decidim::Initiatives::Admin::UpdateInitiative.call(current_initiative, @form, current_user) do
51
+ Decidim::Initiatives::Admin::UpdateInitiative.call(@form, current_initiative) do
50
52
  on(:ok) do |initiative|
51
53
  flash[:notice] = I18n.t("initiatives.update.success", scope: "decidim.initiatives.admin")
52
54
  redirect_to edit_initiative_path(initiative)
@@ -183,6 +185,10 @@ module Decidim
183
185
 
184
186
  private
185
187
 
188
+ def show_initiative_type_callout?
189
+ Decidim::InitiativesType.where(organization: current_organization).none?
190
+ end
191
+
186
192
  def collection
187
193
  @collection ||= ManageableInitiatives.for(current_user)
188
194
  end
@@ -23,7 +23,7 @@ module Decidim
23
23
  @form = initiatives_settings_form
24
24
  .from_params(params, initiatives_settings: current_initiatives_settings)
25
25
 
26
- UpdateInitiativesSettings.call(current_initiatives_settings, @form) do
26
+ UpdateInitiativesSettings.call(@form, current_initiatives_settings) do
27
27
  on(:ok) do
28
28
  flash[:notice] = I18n.t("initiatives_settings.update.success", scope: "decidim.admin")
29
29
  redirect_to edit_initiatives_setting_path
@@ -48,10 +48,10 @@ module Decidim
48
48
  enforce_permission_to :update, :initiative_type_scope, initiative_type_scope: current_initiative_type_scope
49
49
  @form = initiative_type_scope_form.from_params(params)
50
50
 
51
- UpdateInitiativeTypeScope.call(current_initiative_type_scope, @form) do
51
+ UpdateInitiativeTypeScope.call(@form, current_initiative_type_scope) do
52
52
  on(:ok) do
53
53
  flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_type_scopes.update.success")
54
- redirect_to edit_initiatives_type_path(initiative_type_scope.type)
54
+ redirect_to edit_initiatives_type_path(resource.type)
55
55
  end
56
56
 
57
57
  on(:invalid) do
@@ -32,7 +32,7 @@ module Decidim
32
32
  enforce_permission_to :create, :initiative_type
33
33
  @form = initiative_type_form.from_params(params)
34
34
 
35
- CreateInitiativeType.call(@form, current_user) do
35
+ CreateInitiativeType.call(@form) do
36
36
  on(:ok) do |initiative_type|
37
37
  flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_types.create.success")
38
38
  redirect_to edit_initiatives_type_path(initiative_type)
@@ -60,7 +60,7 @@ module Decidim
60
60
  @form = initiative_type_form
61
61
  .from_params(params, initiative_type: current_initiative_type)
62
62
 
63
- UpdateInitiativeType.call(current_initiative_type, @form, current_user) do
63
+ UpdateInitiativeType.call(@form, current_initiative_type) do
64
64
  on(:ok) do
65
65
  flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_types.update.success")
66
66
  redirect_to edit_initiatives_type_path(current_initiative_type)
@@ -2,7 +2,10 @@
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- # The main admin application controller for initiatives
5
+ # The main application controller for initiatives
6
+ #
7
+ # This controller is the abstract class from which all other controllers of
8
+ # this engine inherit.
6
9
  class ApplicationController < Decidim::ApplicationController
7
10
  include NeedsPermission
8
11
  register_permissions(::Decidim::Initiatives::ApplicationController,
@@ -11,7 +14,7 @@ module Decidim
11
14
  ::Decidim::Permissions)
12
15
 
13
16
  before_action do
14
- if Decidim::InitiativesType.joins(:scopes).where(organization: current_organization).all.empty?
17
+ if Decidim::InitiativesType.joins(:scopes).where(organization: current_organization).none?
15
18
  flash[:alert] = t("index.uninitialized", scope: "decidim.initiatives")
16
19
  redirect_to(decidim.root_path)
17
20
  end
@@ -21,7 +21,7 @@ module Decidim
21
21
  form = Decidim::Initiatives::CommitteeMemberForm
22
22
  .from_params(initiative_id: current_initiative.id, user_id: current_user.id, state: "requested")
23
23
 
24
- SpawnCommitteeRequest.call(form, current_user) do
24
+ SpawnCommitteeRequest.call(form) do
25
25
  on(:ok) do
26
26
  redirect_to initiatives_path, flash: {
27
27
  notice: I18n.t(
@@ -57,7 +57,7 @@ module Decidim
57
57
  def store_data
58
58
  @form = form(Decidim::Initiatives::InitiativeForm).from_params(params, { initiative_type: })
59
59
 
60
- CreateInitiative.call(@form, current_user) do
60
+ CreateInitiative.call(@form) do
61
61
  on(:ok) do |initiative|
62
62
  session[:initiative_id] = initiative.id
63
63
 
@@ -93,7 +93,7 @@ module Decidim
93
93
  @form = form(Decidim::Initiatives::InitiativeForm)
94
94
  .from_params(params, initiative_type: current_initiative.type, initiative: current_initiative)
95
95
 
96
- UpdateInitiative.call(current_initiative, @form, current_user) do
96
+ UpdateInitiative.call(current_initiative, @form) do
97
97
  on(:ok) do |initiative|
98
98
  flash[:notice] = I18n.t("success", scope: "decidim.initiatives.update")
99
99
  redirect_to initiative_path(initiative)
@@ -3,39 +3,19 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  class ApproveMembershipRequestEvent < Decidim::Events::SimpleEvent
6
- def email_subject
7
- I18n.t(
8
- "decidim.initiatives.events.approve_membership_request.email_subject",
9
- author_nickname:
10
- )
11
- end
6
+ def i18n_scope = "decidim.initiatives.events.approve_membership_request"
12
7
 
13
- def email_intro
14
- I18n.t(
15
- "decidim.initiatives.events.approve_membership_request.email_intro",
16
- resource_title:,
17
- resource_url:,
8
+ def i18n_options
9
+ {
10
+ author_nickname:,
18
11
  author_profile_url:,
19
- author_nickname:
20
- )
21
- end
22
-
23
- def email_outro
24
- I18n.t(
25
- "decidim.initiatives.events.approve_membership_request.email_outro",
26
- resource_title:,
27
- resource_url:
28
- )
29
- end
30
-
31
- def notification_title
32
- I18n.t(
33
- "decidim.initiatives.events.approve_membership_request.notification_title",
12
+ participatory_space_title:,
13
+ participatory_space_url:,
14
+ resource_path:,
34
15
  resource_title:,
35
16
  resource_url:,
36
- author_profile_url:,
37
- author_nickname:
38
- ).html_safe
17
+ scope: i18n_scope
18
+ }
39
19
  end
40
20
 
41
21
  private
@@ -2,49 +2,30 @@
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class CreateInitiativeEvent < Decidim::Events::BaseEvent
6
- include Decidim::Events::EmailEvent
7
- include Decidim::Events::NotificationEvent
5
+ class CreateInitiativeEvent < Decidim::Events::SimpleEvent
6
+ def i18n_scope = "decidim.initiatives.events.create_initiative_event"
8
7
 
9
- def email_subject
10
- I18n.t(
11
- "decidim.initiatives.events.create_initiative_event.email_subject",
8
+ def i18n_options
9
+ {
10
+ author_name:,
11
+ author_nickname:,
12
+ author_path:,
13
+ participatory_space_title:,
14
+ participatory_space_url:,
15
+ resource_path:,
12
16
  resource_title:,
13
- author_nickname: author.nickname,
14
- author_name: author.name
15
- )
17
+ resource_url:,
18
+ scope: i18n_scope
19
+ }
16
20
  end
17
21
 
18
- def email_intro
19
- I18n.t(
20
- "decidim.initiatives.events.create_initiative_event.email_intro",
21
- resource_title:,
22
- author_nickname: author.nickname,
23
- author_name: author.name
24
- )
25
- end
22
+ private
26
23
 
27
- def email_outro
28
- I18n.t(
29
- "decidim.initiatives.events.create_initiative_event.email_outro",
30
- resource_title:,
31
- author_nickname: author.nickname,
32
- author_name: author.name
33
- )
34
- end
24
+ def author_nickname = author.nickname
35
25
 
36
- def notification_title
37
- I18n.t(
38
- "decidim.initiatives.events.create_initiative_event.notification_title",
39
- resource_title:,
40
- resource_path:,
41
- author_nickname: author.nickname,
42
- author_name: author.name,
43
- author_path: author.profile_path
44
- ).html_safe
45
- end
26
+ def author_name = author.name
46
27
 
47
- private
28
+ def author_path = author.profile_path
48
29
 
49
30
  def author
50
31
  @author ||= Decidim::UserPresenter.new(resource.author)
@@ -2,43 +2,20 @@
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class RevokeMembershipRequestEvent < Decidim::Events::BaseEvent
6
- include Decidim::Events::EmailEvent
7
- include Decidim::Events::NotificationEvent
5
+ class RevokeMembershipRequestEvent < Decidim::Events::SimpleEvent
6
+ def i18n_scope = "decidim.initiatives.events.revoke_membership_request"
8
7
 
9
- def email_subject
10
- I18n.t(
11
- "decidim.initiatives.events.revoke_membership_request.email_subject",
12
- author_nickname:
13
- )
14
- end
15
-
16
- def email_intro
17
- I18n.t(
18
- "decidim.initiatives.events.revoke_membership_request.email_intro",
19
- resource_title:,
20
- resource_url:,
8
+ def i18n_options
9
+ {
10
+ author_nickname:,
21
11
  author_profile_url:,
22
- author_nickname:
23
- )
24
- end
25
-
26
- def email_outro
27
- I18n.t(
28
- "decidim.initiatives.events.revoke_membership_request.email_outro",
29
- resource_title:,
30
- resource_url:
31
- )
32
- end
33
-
34
- def notification_title
35
- I18n.t(
36
- "decidim.initiatives.events.revoke_membership_request.notification_title",
12
+ participatory_space_title:,
13
+ participatory_space_url:,
14
+ resource_path:,
37
15
  resource_title:,
38
16
  resource_url:,
39
- author_profile_url:,
40
- author_nickname:
41
- ).html_safe
17
+ scope: i18n_scope
18
+ }
42
19
  end
43
20
 
44
21
  private
@@ -2,43 +2,20 @@
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class SpawnCommitteeRequestEvent < Decidim::Events::BaseEvent
6
- include Decidim::Events::EmailEvent
7
- include Decidim::Events::NotificationEvent
5
+ class SpawnCommitteeRequestEvent < Decidim::Events::SimpleEvent
6
+ def i18n_scope = "decidim.initiatives.events.spawn_committee_request_event"
8
7
 
9
- def email_subject
10
- I18n.t(
11
- "decidim.initiatives.events.spawn_committee_request_event.email_subject",
12
- applicant_nickname:
13
- )
14
- end
15
-
16
- def email_intro
17
- I18n.t(
18
- "decidim.initiatives.events.spawn_committee_request_event.email_intro",
19
- resource_title:,
20
- resource_url:,
8
+ def i18n_options
9
+ {
10
+ applicant_nickname:,
21
11
  applicant_profile_url:,
22
- applicant_nickname:
23
- )
24
- end
25
-
26
- def email_outro
27
- I18n.t(
28
- "decidim.initiatives.events.spawn_committee_request_event.email_outro",
29
- resource_title:,
30
- resource_url:
31
- )
32
- end
33
-
34
- def notification_title
35
- I18n.t(
36
- "decidim.initiatives.events.spawn_committee_request_event.notification_title",
12
+ participatory_space_title:,
13
+ participatory_space_url:,
14
+ resource_path:,
37
15
  resource_title:,
38
16
  resource_url:,
39
- applicant_profile_url:,
40
- applicant_nickname:
41
- ).html_safe
17
+ scope: i18n_scope
18
+ }
42
19
  end
43
20
 
44
21
  private
@@ -41,7 +41,7 @@ module Decidim
41
41
  def map_model(model)
42
42
  self.type_id = model.type.id
43
43
  self.decidim_scope_id = model.scope&.id
44
- self.offline_votes = offline_votes.empty? ? zero_offine_votes_with_scopes_names(model) : offline_votes_with_scopes_names(model)
44
+ self.offline_votes = offline_votes.empty? ? zero_offline_votes_with_scopes_names(model) : offline_votes_with_scopes_names(model)
45
45
  end
46
46
 
47
47
  def signature_type_updatable?
@@ -72,7 +72,7 @@ module Decidim
72
72
  private
73
73
 
74
74
  # Private: set the in-person signatures to zero for every scope
75
- def zero_offine_votes_with_scopes_names(model)
75
+ def zero_offline_votes_with_scopes_names(model)
76
76
  model.votable_initiative_type_scopes.each_with_object({}) do |initiative_scope_type, all_votes|
77
77
  all_votes[initiative_scope_type.decidim_scopes_id || "global"] = [0, initiative_scope_type.scope_name]
78
78
  end
@@ -3,12 +3,15 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A form object used to collect the data for a new initiative.
6
- class InitiativeForm < PreviousForm
6
+ class InitiativeForm < Form
7
7
  include TranslatableAttributes
8
8
  include AttachmentAttributes
9
9
 
10
10
  mimic :initiative
11
11
 
12
+ attribute :title, String
13
+ attribute :description, String
14
+ attribute :type_id, Integer
12
15
  attribute :area_id, Integer
13
16
  attribute :decidim_user_group_id, Integer
14
17
  attribute :signature_type, String
@@ -21,6 +24,9 @@ module Decidim
21
24
  attachments_attribute :photos
22
25
  attachments_attribute :documents
23
26
 
27
+ validates :title, :description, presence: true
28
+ validates :title, length: { maximum: 150 }
29
+ validates :type_id, presence: true
24
30
  validates :signature_type, presence: true
25
31
  validates :area, presence: true, if: ->(form) { form.area_id.present? }
26
32
  validate :notify_missing_attachment_if_errored
@@ -39,6 +45,10 @@ module Decidim
39
45
  self.description = translated_attribute(model.description)
40
46
  end
41
47
 
48
+ def type
49
+ @type ||= type_id ? Decidim::InitiativesType.find(type_id) : context.initiative.type
50
+ end
51
+
42
52
  def signature_type_updatable?
43
53
  state == "created" || state.nil?
44
54
  end
@@ -93,8 +93,8 @@ module Decidim
93
93
  # Public: Builds a list of Decidim::Scopes where the user could have a
94
94
  # valid authorization.
95
95
  #
96
- # If the intiative is set with a global scope (meaning the scope is nil),
97
- # all the scopes in the organizaton are valid.
96
+ # If the initiative is set with a global scope (meaning the scope is nil),
97
+ # all the scopes in the organization are valid.
98
98
  #
99
99
  # Returns an array of Decidim::Scopes.
100
100
  def authorized_scope_candidates
@@ -7,18 +7,6 @@ module Decidim
7
7
  include Decidim::SanitizeHelper
8
8
  include Decidim::ResourceVersionsHelper
9
9
 
10
- # Public: The css class applied based on the initiative state to
11
- # the initiative badge.
12
- #
13
- # initiative - Decidim::Initiative
14
- #
15
- # Returns a String.
16
- def state_badge_css_class(initiative)
17
- return "success" if initiative.accepted?
18
-
19
- "warning"
20
- end
21
-
22
10
  def metadata_badge_css_class(initiative)
23
11
  case initiative
24
12
  when "accepted", "published"
@@ -32,17 +20,6 @@ module Decidim
32
20
  end
33
21
  end
34
22
 
35
- # Public: The state of an initiative in a way a human can understand.
36
- #
37
- # initiative - Decidim::Initiative.
38
- #
39
- # Returns a String.
40
- def humanize_state(initiative)
41
- I18n.t(initiative.accepted? ? "accepted" : "expired",
42
- scope: "decidim.initiatives.states",
43
- default: :expired)
44
- end
45
-
46
23
  # Public: The state of an initiative from an administration perspective in
47
24
  # a way that a human can understand.
48
25
  #
@@ -53,51 +30,6 @@ module Decidim
53
30
  I18n.t(state, scope: "decidim.initiatives.admin_states", default: :created)
54
31
  end
55
32
 
56
- def popularity_tag(initiative)
57
- content_tag(:div, class: "extra__popularity popularity #{popularity_class(initiative)}".strip) do
58
- 5.times do
59
- concat(content_tag(:span, class: "popularity__item") do
60
- # empty block
61
- end)
62
- end
63
-
64
- concat(content_tag(:span, class: "popularity__desc") do
65
- I18n.t("decidim.initiatives.initiatives.vote_cabin.supports_required",
66
- total_supports: initiative.scoped_type.supports_required)
67
- end)
68
- end
69
- end
70
-
71
- def popularity_class(initiative)
72
- return "popularity--level1" if popularity_level1?(initiative)
73
- return "popularity--level2" if popularity_level2?(initiative)
74
- return "popularity--level3" if popularity_level3?(initiative)
75
- return "popularity--level4" if popularity_level4?(initiative)
76
- return "popularity--level5" if popularity_level5?(initiative)
77
-
78
- ""
79
- end
80
-
81
- def popularity_level1?(initiative)
82
- initiative.percentage.positive? && initiative.percentage < 40
83
- end
84
-
85
- def popularity_level2?(initiative)
86
- initiative.percentage >= 40 && initiative.percentage < 60
87
- end
88
-
89
- def popularity_level3?(initiative)
90
- initiative.percentage >= 60 && initiative.percentage < 80
91
- end
92
-
93
- def popularity_level4?(initiative)
94
- initiative.percentage >= 80 && initiative.percentage < 100
95
- end
96
-
97
- def popularity_level5?(initiative)
98
- initiative.percentage >= 100
99
- end
100
-
101
33
  def authorized_create_modal_button(type, html_options, &)
102
34
  tag = "button"
103
35
  html_options ||= {}
@@ -142,12 +74,6 @@ module Decidim
142
74
  initiative.created? || initiative.validating?
143
75
  end
144
76
 
145
- def can_edit_area?(initiative)
146
- return false unless initiative.area_enabled?
147
-
148
- initiative.created? || initiative.validating?
149
- end
150
-
151
77
  def render_committee_tooltip
152
78
  with_tooltip t("decidim.initiatives.create_initiative.share_committee_link.invite_to_committee_help"), class: "left" do
153
79
  icon "file-copy-line"
@@ -19,13 +19,6 @@ module Decidim
19
19
 
20
20
  private
21
21
 
22
- # Creates a unique namespace for a filter form to prevent dupliacte IDs in
23
- # the DOM when multiple filter forms are rendered with the same fields (e.g.
24
- # for desktop and mobile).
25
- def filter_form_namespace
26
- "filters_#{SecureRandom.uuid}"
27
- end
28
-
29
22
  # i18n-tasks-use t('decidim.initiatives.initiatives.filters.state')
30
23
  # i18n-tasks-use t('decidim.initiatives.initiatives.filters.scope')
31
24
  # i18n-tasks-use t('decidim.initiatives.initiatives.filters.type')
@@ -269,7 +269,7 @@ module Decidim
269
269
  update(published_at: nil, state: "discarded")
270
270
  end
271
271
 
272
- # Public: Returns wether the signature interval is already defined or not.
272
+ # Public: Returns whether the signature interval is already defined or not.
273
273
  def has_signature_interval_defined?
274
274
  signature_end_date.present? && signature_start_date.present?
275
275
  end
@@ -5,7 +5,7 @@ $(() => {
5
5
 
6
6
  if (inviteUsersButton !== null) {
7
7
  inviteUsersButton.addEventListener("click", function (event) {
8
- let link = document.querySelector("#committee_link"),
8
+ let link = document.querySelector("div[data-committee_link]"),
9
9
  range = document.createRange();
10
10
 
11
11
  event.preventDefault();
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  class InitiativeSerializer < Decidim::Exporters::Serializer
6
- # Serializes an inititative
6
+ # Serializes an initiative
7
7
  def serialize
8
8
  {
9
9
  id: resource.id,
@@ -3,7 +3,7 @@
3
3
  <div class="card-divider">
4
4
  <h2 class="card-title">
5
5
  <%= link_to "#{t ".initiatives"} > ", initiatives_path %>
6
- <%= decidim_sanitize translated_attribute(initiative.title) %>
6
+ <%= decidim_sanitize_translated(initiative.title) %>
7
7
  </h2>
8
8
  </div>
9
9
 
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
 
14
14
  <div class="row column">
15
- <div class="committee_link" id="committee_link">
15
+ <div data-committee_link>
16
16
  <%= decidim_initiatives.new_initiative_committee_request_url(current_initiative) %>
17
17
  <%= icon_link_to "clipboard-line", "#", t(".invite_to_committee_help"), class: "card--list__data__icon invite-users-link" %>
18
18
  </div>
@@ -1,4 +1,4 @@
1
- <span class="exports button button__sm button__secondary button--simple" data-toggle="<%= dropdown_id(collection_ids) %>">
1
+ <span class="exports button button__sm button__secondary" data-toggle="<%= dropdown_id(collection_ids) %>">
2
2
  <% if collection_ids.present? %>
3
3
  <%= t("actions.export-selection", scope: "decidim.admin") %>
4
4
  <% else %>
@@ -15,11 +15,11 @@
15
15
  data-close-on-click="true">
16
16
  <ul class="vertical menu add-components">
17
17
  <% %w(CSV JSON).each do |format| %>
18
- <%= link_to export_initiatives_path(format:, collection_ids:) do %>
19
- <li class="exports--format--<%= format.downcase %> exports--initiatives">
20
- <%= t("decidim.admin.exports.export_as", name: t("decidim.initiatives.admin.exports.initiatives"), export_format: format.upcase) %>
21
- </li>
22
- <% end %>
18
+ <li class="exports--format--<%= format.downcase %> exports--initiatives">
19
+ <%= link_to t("decidim.admin.exports.export_as", name: t("decidim.initiatives.admin.exports.initiatives"),
20
+ export_format: format.upcase),
21
+ export_initiatives_path(format:, collection_ids:) %>
22
+ </li>
23
23
  <% end %>
24
24
  </ul>
25
25
  </div>