decidim-initiatives 0.28.5 → 0.29.0.rc1

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 (117) 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/approve_membership_request.rb +1 -1
  13. data/app/commands/decidim/initiatives/create_initiative.rb +6 -7
  14. data/app/commands/decidim/initiatives/revoke_membership_request.rb +1 -1
  15. data/app/commands/decidim/initiatives/spawn_committee_request.rb +4 -5
  16. data/app/commands/decidim/initiatives/update_initiative.rb +3 -3
  17. data/app/commands/decidim/initiatives/validate_sms_code.rb +3 -3
  18. data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
  19. data/app/controllers/decidim/initiatives/admin/answers_controller.rb +1 -1
  20. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +7 -6
  21. data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +1 -1
  22. data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +2 -2
  23. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +2 -2
  24. data/app/controllers/decidim/initiatives/application_controller.rb +5 -2
  25. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +1 -2
  26. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +1 -1
  27. data/app/controllers/decidim/initiatives/initiatives_controller.rb +2 -2
  28. data/app/events/decidim/initiatives/approve_membership_request_event.rb +9 -29
  29. data/app/events/decidim/initiatives/create_initiative_event.rb +17 -36
  30. data/app/events/decidim/initiatives/revoke_membership_request_event.rb +10 -33
  31. data/app/events/decidim/initiatives/spawn_committee_request_event.rb +10 -33
  32. data/app/forms/decidim/initiatives/admin/initiative_answer_form.rb +1 -1
  33. data/app/forms/decidim/initiatives/admin/initiative_form.rb +3 -3
  34. data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +2 -2
  35. data/app/forms/decidim/initiatives/initiative_form.rb +11 -1
  36. data/app/forms/decidim/initiatives/vote_form.rb +2 -2
  37. data/app/helpers/decidim/initiatives/initiative_helper.rb +0 -74
  38. data/app/helpers/decidim/initiatives/initiatives_helper.rb +0 -7
  39. data/app/models/decidim/initiative.rb +1 -1
  40. data/app/packs/entrypoints/decidim_initiatives_admin.js +0 -2
  41. data/app/packs/src/decidim/initiatives/admin/invite_users.js +1 -1
  42. data/app/permissions/decidim/initiatives/admin/permissions.rb +2 -2
  43. data/app/permissions/decidim/initiatives/permissions.rb +0 -14
  44. data/app/serializers/decidim/initiatives/initiative_serializer.rb +1 -1
  45. data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +1 -1
  46. data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +1 -2
  47. data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +6 -6
  48. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +65 -59
  49. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/_form.html.erb +1 -1
  50. data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +1 -1
  51. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +1 -1
  52. data/app/views/decidim/initiatives/committee_requests/new.html.erb +3 -4
  53. data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +1 -1
  54. data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +1 -1
  55. data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +1 -1
  56. data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +1 -1
  57. data/app/views/decidim/initiatives/initiatives/print.html.erb +2 -2
  58. data/app/views/decidim/initiatives/initiatives/show.html.erb +2 -3
  59. data/app/views/layouts/decidim/_initiative_header.html.erb +6 -6
  60. data/app/views/layouts/decidim/initiative.html.erb +2 -2
  61. data/app/views/layouts/decidim/initiative_head.html.erb +1 -1
  62. data/config/initializers/wicked_pdf.rb +6 -4
  63. data/config/locales/ar.yml +0 -7
  64. data/config/locales/bg.yml +1 -3
  65. data/config/locales/ca.yml +7 -14
  66. data/config/locales/cs.yml +5 -13
  67. data/config/locales/de.yml +7 -14
  68. data/config/locales/el.yml +0 -4
  69. data/config/locales/en.yml +6 -13
  70. data/config/locales/es-MX.yml +7 -14
  71. data/config/locales/es-PY.yml +7 -14
  72. data/config/locales/es.yml +6 -13
  73. data/config/locales/eu.yml +51 -58
  74. data/config/locales/fi-plain.yml +6 -13
  75. data/config/locales/fi.yml +21 -28
  76. data/config/locales/fr-CA.yml +3 -5
  77. data/config/locales/fr.yml +2 -4
  78. data/config/locales/ga-IE.yml +0 -1
  79. data/config/locales/gl.yml +0 -4
  80. data/config/locales/he-IL.yml +0 -6
  81. data/config/locales/hu.yml +1 -4
  82. data/config/locales/id-ID.yml +0 -4
  83. data/config/locales/is-IS.yml +0 -8
  84. data/config/locales/it.yml +1 -3
  85. data/config/locales/ja.yml +8 -15
  86. data/config/locales/lb.yml +1 -1
  87. data/config/locales/lt.yml +0 -3
  88. data/config/locales/lv.yml +0 -4
  89. data/config/locales/nl.yml +0 -4
  90. data/config/locales/no.yml +0 -2
  91. data/config/locales/pl.yml +5 -2
  92. data/config/locales/pt-BR.yml +1 -17
  93. data/config/locales/pt.yml +0 -2
  94. data/config/locales/ro-RO.yml +0 -12
  95. data/config/locales/ru.yml +0 -9
  96. data/config/locales/sk.yml +0 -4
  97. data/config/locales/sv.yml +69 -194
  98. data/config/locales/tr-TR.yml +1 -3
  99. data/config/locales/uk.yml +0 -9
  100. data/config/locales/zh-CN.yml +0 -3
  101. data/config/locales/zh-TW.yml +0 -3
  102. data/decidim-initiatives.gemspec +3 -2
  103. data/lib/decidim/api/initiative_api_type.rb +2 -2
  104. data/lib/decidim/initiatives/engine.rb +1 -0
  105. data/lib/decidim/initiatives/menu.rb +12 -1
  106. data/lib/decidim/initiatives/seeds.rb +89 -64
  107. data/lib/decidim/initiatives/version.rb +1 -1
  108. data/lib/decidim/initiatives.rb +0 -12
  109. data/lib/tasks/decidim_initiatives.rake +3 -3
  110. data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +9 -11
  111. metadata +33 -25
  112. data/app/forms/decidim/initiatives/previous_form.rb +0 -24
  113. data/app/packs/entrypoints/decidim_initiatives_admin.scss +0 -1
  114. data/app/packs/stylesheets/decidim/initiatives/admin/initiatives.scss +0 -13
  115. data/app/queries/decidim/initiatives/similar_initiatives.rb +0 -54
  116. data/config/locales/bn-BD.yml +0 -1
  117. data/config/locales/bs-BA.yml +0 -1
@@ -30,7 +30,7 @@ module Decidim
30
30
  @form = form(Decidim::Initiatives::Admin::InitiativeAnswerForm)
31
31
  .from_params(params, initiative: current_initiative)
32
32
 
33
- UpdateInitiativeAnswer.call(current_initiative, @form, current_user) do
33
+ UpdateInitiativeAnswer.call(current_initiative, @form) do
34
34
  on(:ok) do
35
35
  flash[:notice] = I18n.t("initiatives.update.success", scope: "decidim.initiatives.admin")
36
36
  redirect_to initiatives_path
@@ -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)
@@ -65,7 +67,6 @@ module Decidim
65
67
 
66
68
  PublishInitiative.call(current_initiative, current_user) do
67
69
  on(:ok) do
68
- flash[:notice] = I18n.t("initiatives.publish.success", scope: "decidim.initiatives.admin")
69
70
  redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
70
71
  end
71
72
  end
@@ -77,7 +78,6 @@ module Decidim
77
78
 
78
79
  UnpublishInitiative.call(current_initiative, current_user) do
79
80
  on(:ok) do
80
- flash[:notice] = I18n.t("initiatives.unpublish.success", scope: "decidim.initiatives.admin")
81
81
  redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
82
82
  end
83
83
  end
@@ -88,7 +88,6 @@ module Decidim
88
88
  enforce_permission_to :discard, :initiative, initiative: current_initiative
89
89
  DiscardInitiative.call(current_initiative, current_user) do
90
90
  on(:ok) do
91
- flash[:notice] = I18n.t("initiatives.discard.success", scope: "decidim.initiatives.admin")
92
91
  redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
93
92
  end
94
93
  end
@@ -99,7 +98,6 @@ module Decidim
99
98
  enforce_permission_to :accept, :initiative, initiative: current_initiative
100
99
  AcceptInitiative.call(current_initiative, current_user) do
101
100
  on(:ok) do
102
- flash[:notice] = I18n.t("initiatives.accept.success", scope: "decidim.initiatives.admin")
103
101
  redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
104
102
  end
105
103
  end
@@ -110,7 +108,6 @@ module Decidim
110
108
  enforce_permission_to :reject, :initiative, initiative: current_initiative
111
109
  RejectInitiative.call(current_initiative, current_user) do
112
110
  on(:ok) do
113
- flash[:notice] = I18n.t("initiatives.reject.success", scope: "decidim.initiatives.admin")
114
111
  redirect_to decidim_admin_initiatives.edit_initiative_path(current_initiative)
115
112
  end
116
113
  end
@@ -188,6 +185,10 @@ module Decidim
188
185
 
189
186
  private
190
187
 
188
+ def show_initiative_type_callout?
189
+ Decidim::InitiativesType.where(organization: current_organization).none?
190
+ end
191
+
191
192
  def collection
192
193
  @collection ||= ManageableInitiatives.for(current_user)
193
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
@@ -20,9 +20,8 @@ module Decidim
20
20
 
21
21
  form = Decidim::Initiatives::CommitteeMemberForm
22
22
  .from_params(initiative_id: current_initiative.id, user_id: current_user.id, state: "requested")
23
- .with_context(current_organization: current_initiative.organization, current_user:)
24
23
 
25
- SpawnCommitteeRequest.call(form, current_user) do
24
+ SpawnCommitteeRequest.call(form) do
26
25
  on(:ok) do
27
26
  redirect_to initiatives_path, flash: {
28
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)
@@ -107,7 +107,7 @@ module Decidim
107
107
  end
108
108
 
109
109
  def print
110
- enforce_permission_to :print, :initiative, initiative: current_initiative
110
+ enforce_permission_to :read, :initiative, initiative: current_initiative
111
111
  end
112
112
 
113
113
  private
@@ -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
@@ -10,7 +10,7 @@ module Decidim
10
10
 
11
11
  mimic :initiative
12
12
 
13
- translatable_attribute :answer, Decidim::Attributes::RichText
13
+ translatable_attribute :answer, String
14
14
  attribute :answer_url, String
15
15
  attribute :signature_start_date, Decidim::Attributes::LocalizedDate
16
16
  attribute :signature_end_date, Decidim::Attributes::LocalizedDate
@@ -11,7 +11,7 @@ module Decidim
11
11
  mimic :initiative
12
12
 
13
13
  translatable_attribute :title, String
14
- translatable_attribute :description, Decidim::Attributes::RichText
14
+ translatable_attribute :description, String
15
15
  attribute :type_id, Integer
16
16
  attribute :decidim_scope_id, Integer
17
17
  attribute :area_id, Integer
@@ -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
@@ -12,7 +12,7 @@ module Decidim
12
12
  mimic :initiatives_type
13
13
 
14
14
  translatable_attribute :title, String
15
- translatable_attribute :description, Decidim::Attributes::RichText
15
+ translatable_attribute :description, String
16
16
  attribute :banner_image
17
17
  attribute :signature_type, String
18
18
  attribute :undo_online_signatures_enabled, Boolean
@@ -25,7 +25,7 @@ module Decidim
25
25
  attribute :promoting_committee_enabled, Boolean
26
26
  attribute :minimum_committee_members, Integer
27
27
  attribute :collect_user_extra_fields, Boolean
28
- translatable_attribute :extra_fields_legal_information, Decidim::Attributes::RichText
28
+ translatable_attribute :extra_fields_legal_information, String
29
29
  attribute :validate_sms_code_on_votes, Boolean
30
30
  attribute :document_number_authorization_handler, String
31
31
 
@@ -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
@@ -1,5 +1,3 @@
1
1
  import "src/decidim/initiatives/admin/initiatives_types"
2
2
  import "src/decidim/initiatives/admin/invite_users"
3
3
  import "src/decidim/initiatives/scoped_type"
4
-
5
- import "entrypoints/decidim_initiatives_admin.scss"
@@ -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();