decidim 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1626 -0
  3. data/Gemfile.lock +82 -82
  4. data/decidim-admin/app/assets/stylesheets/decidim/admin/_variables.scss +2 -0
  5. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_cards.scss +6 -0
  6. data/decidim-admin/app/assets/stylesheets/decidim/admin/modules/_typography.scss +4 -0
  7. data/decidim-admin/app/commands/decidim/admin/create_participatory_process_admin.rb +3 -5
  8. data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  9. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +1 -1
  10. data/decidim-admin/app/controllers/decidim/admin/categories_controller.rb +9 -9
  11. data/decidim-admin/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +1 -8
  12. data/decidim-admin/app/controllers/decidim/admin/exports_controller.rb +2 -2
  13. data/decidim-admin/app/controllers/decidim/admin/feature_permissions_controller.rb +2 -2
  14. data/decidim-admin/app/controllers/decidim/admin/features/base_controller.rb +0 -5
  15. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +4 -4
  16. data/decidim-admin/app/controllers/decidim/admin/moderations_controller.rb +1 -1
  17. data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +2 -2
  18. data/decidim-admin/app/controllers/decidim/admin/participatory_process_copies_controller.rb +3 -9
  19. data/decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb +4 -4
  20. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +2 -2
  21. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +2 -2
  22. data/decidim-admin/app/controllers/decidim/admin/participatory_process_steps_controller.rb +6 -6
  23. data/decidim-admin/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +13 -15
  24. data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +16 -18
  25. data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +4 -4
  26. data/decidim-admin/app/forms/decidim/admin/participatory_process_user_role_form.rb +2 -2
  27. data/decidim-admin/app/models/decidim/admin/abilities/{admin_user.rb → admin_ability.rb} +3 -6
  28. data/decidim-admin/app/models/decidim/admin/abilities/{base.rb → base_ability.rb} +1 -4
  29. data/decidim-admin/app/models/decidim/admin/abilities/{participatory_process_admin.rb → participatory_process_admin_ability.rb} +18 -28
  30. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_collaborator_ability.rb +19 -0
  31. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_moderator_ability.rb +23 -0
  32. data/decidim-admin/app/queries/decidim/admin/process_admins.rb +1 -1
  33. data/decidim-admin/app/views/decidim/admin/categories/index.html.erb +9 -9
  34. data/decidim-admin/app/views/decidim/admin/categories/new.html.erb +1 -1
  35. data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +1 -1
  36. data/decidim-admin/app/views/decidim/admin/features/edit.html.erb +1 -1
  37. data/decidim-admin/app/views/decidim/admin/features/new.html.erb +1 -1
  38. data/decidim-admin/app/views/decidim/admin/participatory_process_copies/new.html.erb +1 -1
  39. data/decidim-admin/app/views/decidim/admin/participatory_process_groups/index.html.erb +5 -1
  40. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/index.html.erb +9 -9
  41. data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +6 -6
  42. data/decidim-admin/app/views/decidim/admin/participatory_processes/edit.html.erb +6 -6
  43. data/decidim-admin/app/views/decidim/admin/participatory_processes/index.html.erb +11 -1
  44. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +18 -18
  45. data/decidim-admin/config/locales/ca.yml +4 -3
  46. data/decidim-admin/config/locales/en.yml +1 -0
  47. data/decidim-admin/config/locales/es.yml +1 -2
  48. data/decidim-admin/db/migrate/20170714083651_rename_participatory_process_user_roles_table.rb +7 -0
  49. data/decidim-admin/lib/decidim/admin/engine.rb +8 -6
  50. data/decidim-admin/lib/decidim/admin/test/factories.rb +1 -1
  51. data/decidim-admin/spec/commands/create_participatory_process_admin_spec.rb +4 -4
  52. data/decidim-admin/spec/models/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  53. data/decidim-admin/spec/models/abilities/{participatory_process_admin_spec.rb → participatory_process_admin_ability_spec.rb} +3 -3
  54. data/decidim-admin/spec/models/abilities/participatory_process_collaborator_ability_spec.rb +18 -0
  55. data/decidim-admin/spec/queries/process_admins_spec.rb +1 -1
  56. data/decidim-admin/spec/views/decidim/static_pages/_form.html.erb_spec.rb +1 -1
  57. data/decidim-budgets/config/locales/ca.yml +2 -2
  58. data/decidim-comments/app/models/decidim/comments/abilities/admin_ability.rb +19 -0
  59. data/decidim-comments/app/models/decidim/comments/abilities/{admin_user.rb → current_user_ability.rb} +4 -6
  60. data/decidim-comments/app/models/decidim/comments/abilities/participatory_process_admin_ability.rb +19 -0
  61. data/decidim-comments/app/models/decidim/comments/abilities/participatory_process_moderator_ability.rb +19 -0
  62. data/decidim-comments/lib/decidim/comments/admin_engine.rb +5 -2
  63. data/decidim-comments/lib/decidim/comments/engine.rb +6 -0
  64. data/decidim-comments/spec/models/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  65. data/decidim-comments/spec/models/abilities/{process_admin_user_spec.rb → participatory_process_admin_ability_spec.rb} +3 -2
  66. data/decidim-meetings/app/controllers/decidim/meetings/meeting_widgets_controller.rb +1 -0
  67. data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +2 -2
  68. data/decidim-meetings/app/views/decidim/meetings/meeting_widgets/show.html.erb +1 -1
  69. data/decidim-meetings/app/views/decidim/meetings/meetings/_meetings.html.erb +2 -0
  70. data/decidim-meetings/config/locales/ca.yml +1 -1
  71. data/decidim-meetings/spec/features/explore_meetings_spec.rb +11 -0
  72. data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +2 -1
  73. data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_answer_form.rb +1 -1
  74. data/decidim-proposals/app/helpers/decidim/proposals/application_helper.rb +23 -11
  75. data/decidim-proposals/app/models/decidim/proposals/abilities/{admin_user.rb → admin_ability.rb} +5 -12
  76. data/decidim-proposals/app/models/decidim/proposals/abilities/{current_user.rb → current_user_ability.rb} +1 -2
  77. data/decidim-proposals/app/models/decidim/proposals/abilities/{process_admin_user.rb → participatory_process_admin_ability.rb} +10 -22
  78. data/decidim-proposals/app/models/decidim/proposals/abilities/participatory_process_moderator_ability.rb +19 -0
  79. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +8 -0
  80. data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +5 -2
  81. data/decidim-proposals/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +1 -1
  82. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +1 -1
  83. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -1
  84. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposals.html.erb +10 -1
  85. data/decidim-proposals/config/locales/ca.yml +3 -0
  86. data/decidim-proposals/config/locales/en.yml +3 -0
  87. data/decidim-proposals/config/locales/es.yml +3 -0
  88. data/decidim-proposals/lib/decidim/proposals/admin_engine.rb +5 -2
  89. data/decidim-proposals/lib/decidim/proposals/engine.rb +1 -1
  90. data/decidim-proposals/lib/decidim/proposals/feature.rb +4 -0
  91. data/decidim-proposals/lib/decidim/proposals/proposal_serializer.rb +4 -0
  92. data/decidim-proposals/spec/features/proposals_spec.rb +12 -5
  93. data/decidim-proposals/spec/models/decidim/proposals/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  94. data/decidim-proposals/spec/models/decidim/proposals/abilities/{process_admin_user_spec.rb → participatory_process_admin_ability.rb} +10 -2
  95. data/decidim-proposals/spec/services/decidim/proposals/proposal_serializer_spec.rb +7 -0
  96. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +21 -0
  97. data/decidim-results/app/controllers/decidim/results/results_controller.rb +2 -1
  98. data/decidim-results/app/views/decidim/results/results/_results.html.erb +2 -0
  99. data/decidim-results/config/locales/ca.yml +1 -1
  100. data/decidim-results/spec/features/comments_spec.rb +1 -1
  101. data/decidim-results/spec/features/explore_results_spec.rb +11 -0
  102. data/decidim-surveys/app/models/decidim/surveys/abilities/admin_ability.rb +17 -0
  103. data/decidim-surveys/app/models/decidim/surveys/abilities/{current_user.rb → current_user_ability.rb} +1 -1
  104. data/decidim-surveys/app/models/decidim/surveys/abilities/participatory_process_admin_ability.rb +19 -0
  105. data/decidim-surveys/config/locales/ca.yml +1 -1
  106. data/decidim-surveys/lib/decidim/surveys/admin_engine.rb +4 -2
  107. data/decidim-surveys/lib/decidim/surveys/engine.rb +1 -1
  108. data/decidim-surveys/spec/models/decidim/surveys/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  109. data/decidim-surveys/spec/models/decidim/surveys/abilities/{current_user_spec.rb → current_user_ability_spec.rb} +1 -1
  110. data/decidim-surveys/spec/models/decidim/surveys/abilities/{process_admin_user_spec.rb → participatory_process_admin_ability_spec.rb} +3 -2
  111. data/decidim-system/app/commands/decidim/system/register_organization.rb +2 -2
  112. data/decidim-system/spec/commands/decidim/system/register_organization_spec.rb +1 -1
  113. data/docs/getting_started.md +1 -1
  114. data/lib/generators/decidim/templates/initializer.rb +2 -2
  115. data/package.json +1 -3
  116. data/yarn.lock +21 -18
  117. metadata +52 -54
  118. data/decidim-admin/app/models/decidim/admin/abilities/collaborator_user.rb +0 -20
  119. data/decidim-admin/app/models/decidim/admin/participatory_process_user_role.rb +0 -15
  120. data/decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb +0 -42
  121. data/decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb +0 -36
  122. data/decidim-admin/db/seeds.rb +0 -24
  123. data/decidim-admin/spec/models/abilities/collaborator_user_spec.rb +0 -67
  124. data/decidim-admin/spec/models/participatory_process_user_role_spec.rb +0 -39
  125. data/decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb +0 -39
  126. data/decidim-admin/spec/queries/process_admin_roles_for_process_spec.rb +0 -19
  127. data/decidim-comments/app/models/decidim/comments/abilities/process_admin_user.rb +0 -34
  128. data/decidim-meetings/app/views/decidim/meetings/meeting_widgets/.erb +0 -16
  129. data/decidim-surveys/app/models/decidim/surveys/abilities/admin_user.rb +0 -34
  130. data/decidim-surveys/app/models/decidim/surveys/abilities/process_admin_user.rb +0 -44
@@ -10,17 +10,10 @@ module Decidim
10
10
  extend ActiveSupport::Concern
11
11
 
12
12
  included do
13
- helper_method :participatory_process
13
+ include Decidim::NeedsParticipatoryProcess
14
14
 
15
15
  layout "decidim/admin/participatory_process"
16
16
  end
17
-
18
- private
19
-
20
- def participatory_process
21
- @participatory_process ||=
22
- current_organization.participatory_processes.find(params[:participatory_process_id])
23
- end
24
17
  end
25
18
  end
26
19
  end
@@ -23,7 +23,7 @@ module Decidim
23
23
  send(
24
24
  "decidim_admin_#{feature.manifest.name}_path",
25
25
  feature_id: feature.id,
26
- participatory_process_id: participatory_process.id
26
+ participatory_process_id: current_participatory_process.id
27
27
  )
28
28
  end
29
29
 
@@ -32,7 +32,7 @@ module Decidim
32
32
  end
33
33
 
34
34
  def feature
35
- @feature ||= participatory_process.features.find(params[:feature_id])
35
+ @feature ||= current_participatory_process.features.find(params[:feature_id])
36
36
  end
37
37
  end
38
38
  end
@@ -24,7 +24,7 @@ module Decidim
24
24
  UpdateFeaturePermissions.call(@permissions_form, feature) do
25
25
  on(:ok) do
26
26
  flash[:notice] = t("feature_permissions.update.success", scope: "decidim.admin")
27
- redirect_to participatory_process_features_path(participatory_process)
27
+ redirect_to participatory_process_features_path(current_participatory_process)
28
28
  end
29
29
 
30
30
  on(:invalid) do
@@ -53,7 +53,7 @@ module Decidim
53
53
  end
54
54
 
55
55
  def feature
56
- @feature ||= participatory_process.features.find(params[:feature_id])
56
+ @feature ||= current_participatory_process.features.find(params[:feature_id])
57
57
  end
58
58
  end
59
59
  end
@@ -13,7 +13,6 @@ module Decidim
13
13
  helper Decidim::Admin::ExportsHelper
14
14
 
15
15
  helper_method :current_feature,
16
- :current_participatory_process,
17
16
  :parent_path
18
17
 
19
18
  delegate :active_step, to: :current_participatory_process, prefix: false
@@ -30,10 +29,6 @@ module Decidim
30
29
  request.env["decidim.current_feature"]
31
30
  end
32
31
 
33
- def current_participatory_process
34
- request.env["decidim.current_participatory_process"]
35
- end
36
-
37
32
  def parent_path
38
33
  decidim_admin.participatory_process_features_path(current_participatory_process)
39
34
  end
@@ -15,7 +15,7 @@ module Decidim
15
15
  def index
16
16
  authorize! :read, Feature
17
17
  @manifests = Decidim.feature_manifests
18
- @features = participatory_process.features
18
+ @features = current_participatory_process.features
19
19
  end
20
20
 
21
21
  def new
@@ -24,7 +24,7 @@ module Decidim
24
24
  @feature = Feature.new(
25
25
  name: default_name(manifest),
26
26
  manifest_name: params[:type],
27
- participatory_process: participatory_process
27
+ participatory_process: current_participatory_process
28
28
  )
29
29
 
30
30
  @form = form(FeatureForm).from_model(@feature)
@@ -34,7 +34,7 @@ module Decidim
34
34
  @form = form(FeatureForm).from_params(params)
35
35
  authorize! :create, Feature
36
36
 
37
- CreateFeature.call(manifest, @form, participatory_process) do
37
+ CreateFeature.call(manifest, @form, current_participatory_process) do
38
38
  on(:ok) do
39
39
  flash[:notice] = I18n.t("features.create.success", scope: "decidim.admin")
40
40
  redirect_to action: :index
@@ -112,7 +112,7 @@ module Decidim
112
112
  private
113
113
 
114
114
  def query_scope
115
- participatory_process.features
115
+ current_participatory_process.features
116
116
  end
117
117
 
118
118
  def manifest
@@ -61,7 +61,7 @@ module Decidim
61
61
  end
62
62
 
63
63
  def participatory_process_moderations
64
- @participatory_process_moderations ||= Decidim::Moderation.where(participatory_process: participatory_process)
64
+ @participatory_process_moderations ||= Decidim::Moderation.where(participatory_process: current_participatory_process)
65
65
  end
66
66
  end
67
67
  end
@@ -12,11 +12,11 @@ module Decidim
12
12
  include Concerns::HasAttachments
13
13
 
14
14
  def after_destroy_path
15
- participatory_process_attachments_path(participatory_process.id)
15
+ participatory_process_attachments_path(current_participatory_process.id)
16
16
  end
17
17
 
18
18
  def attached_to
19
- participatory_process
19
+ current_participatory_process
20
20
  end
21
21
 
22
22
  def authorization_object
@@ -9,18 +9,16 @@ module Decidim
9
9
  class ParticipatoryProcessCopiesController < ApplicationController
10
10
  include Concerns::ParticipatoryProcessAdmin
11
11
 
12
- helper_method :participatory_process
13
-
14
12
  def new
15
13
  authorize! :new, Decidim::ParticipatoryProcess
16
- @form = form(ParticipatoryProcessCopyForm).from_model(participatory_process)
14
+ @form = form(ParticipatoryProcessCopyForm).from_model(current_participatory_process)
17
15
  end
18
16
 
19
17
  def create
20
18
  authorize! :create, Decidim::ParticipatoryProcess
21
19
  @form = form(ParticipatoryProcessCopyForm).from_params(params)
22
20
 
23
- CopyParticipatoryProcess.call(@form, participatory_process) do
21
+ CopyParticipatoryProcess.call(@form, current_participatory_process) do
24
22
  on(:ok) do
25
23
  flash[:notice] = I18n.t("participatory_processes_copies.create.success", scope: "decidim.admin")
26
24
  redirect_to participatory_processes_path
@@ -36,11 +34,7 @@ module Decidim
36
34
  private
37
35
 
38
36
  def collection
39
- @collection ||= ManageableParticipatoryProcessesForUser.for(current_user)
40
- end
41
-
42
- def participatory_process
43
- @participatory_process ||= collection.find(params[:participatory_process_id])
37
+ @collection ||= Decidim::ParticipatoryProcessesWithUserRole.for(current_user, :admin)
44
38
  end
45
39
  end
46
40
  end
@@ -10,9 +10,9 @@ module Decidim
10
10
  include Concerns::ParticipatoryProcessAdmin
11
11
 
12
12
  def create
13
- authorize! :publish, participatory_process
13
+ authorize! :publish, current_participatory_process
14
14
 
15
- PublishParticipatoryProcess.call(participatory_process) do
15
+ PublishParticipatoryProcess.call(current_participatory_process) do
16
16
  on(:ok) do
17
17
  flash[:notice] = I18n.t("participatory_process_publications.create.success", scope: "decidim.admin")
18
18
  end
@@ -26,9 +26,9 @@ module Decidim
26
26
  end
27
27
 
28
28
  def destroy
29
- authorize! :publish, participatory_process
29
+ authorize! :publish, current_participatory_process
30
30
 
31
- UnpublishParticipatoryProcess.call(participatory_process) do
31
+ UnpublishParticipatoryProcess.call(current_participatory_process) do
32
32
  on(:ok) do
33
33
  flash[:notice] = I18n.t("participatory_process_publications.destroy.success", scope: "decidim.admin")
34
34
  end
@@ -21,7 +21,7 @@ module Decidim
21
21
  flash.now[:alert] = I18n.t("participatory_process_step_activations.create.error", scope: "decidim.admin")
22
22
  end
23
23
 
24
- redirect_to participatory_process_steps_path(participatory_process)
24
+ redirect_to participatory_process_steps_path(current_participatory_process)
25
25
  end
26
26
  end
27
27
 
@@ -32,7 +32,7 @@ module Decidim
32
32
  end
33
33
 
34
34
  def collection
35
- participatory_process.steps
35
+ current_participatory_process.steps
36
36
  end
37
37
  end
38
38
  end
@@ -14,7 +14,7 @@ module Decidim
14
14
  ReorderParticipatoryProcessSteps.call(collection, params[:items_ids]) do
15
15
  on(:invalid) do
16
16
  flash.now[:alert] = I18n.t("participatory_process_steps.ordering.error", scope: "decidim.admin")
17
- redirect_to participatory_process_path(participatory_process)
17
+ redirect_to participatory_process_path(current_participatory_process)
18
18
  end
19
19
  end
20
20
  end
@@ -22,7 +22,7 @@ module Decidim
22
22
  private
23
23
 
24
24
  def collection
25
- participatory_process.steps
25
+ current_participatory_process.steps
26
26
  end
27
27
  end
28
28
  end
@@ -22,10 +22,10 @@ module Decidim
22
22
  authorize! :create, Decidim::ParticipatoryProcessStep
23
23
  @form = form(ParticipatoryProcessStepForm).from_params(params)
24
24
 
25
- CreateParticipatoryProcessStep.call(@form, participatory_process) do
25
+ CreateParticipatoryProcessStep.call(@form, current_participatory_process) do
26
26
  on(:ok) do
27
27
  flash[:notice] = I18n.t("participatory_process_steps.create.success", scope: "decidim.admin")
28
- redirect_to participatory_process_steps_path(participatory_process)
28
+ redirect_to participatory_process_steps_path(current_participatory_process)
29
29
  end
30
30
 
31
31
  on(:invalid) do
@@ -49,7 +49,7 @@ module Decidim
49
49
  UpdateParticipatoryProcessStep.call(@participatory_process_step, @form) do
50
50
  on(:ok) do
51
51
  flash[:notice] = I18n.t("participatory_process_steps.update.success", scope: "decidim.admin")
52
- redirect_to participatory_process_steps_path(participatory_process)
52
+ redirect_to participatory_process_steps_path(current_participatory_process)
53
53
  end
54
54
 
55
55
  on(:invalid) do
@@ -71,12 +71,12 @@ module Decidim
71
71
  DestroyParticipatoryProcessStep.call(@participatory_process_step) do
72
72
  on(:ok) do
73
73
  flash[:notice] = I18n.t("participatory_process_steps.destroy.success", scope: "decidim.admin")
74
- redirect_to participatory_process_steps_path(participatory_process)
74
+ redirect_to participatory_process_steps_path(current_participatory_process)
75
75
  end
76
76
 
77
77
  on(:invalid) do |reason|
78
78
  flash[:alert] = I18n.t("participatory_process_steps.destroy.error.#{reason}", scope: "decidim.admin")
79
- redirect_to participatory_process_steps_path(participatory_process)
79
+ redirect_to participatory_process_steps_path(current_participatory_process)
80
80
  end
81
81
  end
82
82
  end
@@ -84,7 +84,7 @@ module Decidim
84
84
  private
85
85
 
86
86
  def collection
87
- @collection ||= participatory_process.steps
87
+ @collection ||= current_participatory_process.steps
88
88
  end
89
89
  end
90
90
  end
@@ -9,22 +9,21 @@ module Decidim
9
9
  class ParticipatoryProcessUserRolesController < ApplicationController
10
10
  include Concerns::ParticipatoryProcessAdmin
11
11
 
12
- helper_method :participatory_process, :process_admin_roles
13
-
14
12
  def index
15
- authorize! :read, Decidim::Admin::ParticipatoryProcessUserRole
13
+ authorize! :read, Decidim::ParticipatoryProcessUserRole
14
+ @participatory_process_user_roles = collection
16
15
  end
17
16
 
18
17
  def new
19
- authorize! :create, Decidim::Admin::ParticipatoryProcessUserRole
18
+ authorize! :create, Decidim::ParticipatoryProcessUserRole
20
19
  @form = form(ParticipatoryProcessUserRoleForm).instance
21
20
  end
22
21
 
23
22
  def create
24
- authorize! :create, Decidim::Admin::ParticipatoryProcessUserRole
23
+ authorize! :create, Decidim::ParticipatoryProcessUserRole
25
24
  @form = form(ParticipatoryProcessUserRoleForm).from_params(params)
26
25
 
27
- CreateParticipatoryProcessAdmin.call(@form, current_user, participatory_process) do
26
+ CreateParticipatoryProcessAdmin.call(@form, current_user, current_participatory_process) do
28
27
  on(:ok) do
29
28
  flash[:notice] = I18n.t("participatory_process_user_roles.create.success", scope: "decidim.admin")
30
29
  end
@@ -32,14 +31,14 @@ module Decidim
32
31
  on(:invalid) do
33
32
  flash[:alert] = I18n.t("participatory_process_user_roles.create.error", scope: "decidim.admin")
34
33
  end
35
- redirect_to participatory_process_user_roles_path(participatory_process)
34
+ redirect_to participatory_process_user_roles_path(current_participatory_process)
36
35
  end
37
36
  end
38
37
 
39
38
  def edit
40
39
  @user_role = collection.find(params[:id])
41
40
  authorize! :update, @user_role
42
- @form = form(ParticipatoryProcessUserRoleForm).from_model(@user_role.user, current_process: participatory_process)
41
+ @form = form(ParticipatoryProcessUserRoleForm).from_model(@user_role.user, current_process: current_participatory_process)
43
42
  end
44
43
 
45
44
  def update
@@ -50,7 +49,7 @@ module Decidim
50
49
  UpdateParticipatoryProcessAdmin.call(@form, @user_role) do
51
50
  on(:ok) do
52
51
  flash[:notice] = I18n.t("participatory_process_user_roles.update.success", scope: "decidim.admin")
53
- redirect_to participatory_process_user_roles_path(participatory_process)
52
+ redirect_to participatory_process_user_roles_path(current_participatory_process)
54
53
  end
55
54
 
56
55
  on(:invalid) do
@@ -84,17 +83,16 @@ module Decidim
84
83
  end
85
84
  end
86
85
 
87
- redirect_to participatory_process_user_roles_path(participatory_process)
86
+ redirect_to participatory_process_user_roles_path(current_participatory_process)
88
87
  end
89
88
 
90
89
  private
91
90
 
92
91
  def collection
93
- @collection ||= ProcessAdminRolesForProcess.for(participatory_process)
94
- end
95
-
96
- def process_admin_roles
97
- @process_admin_roles ||= ProcessAdminRolesForProcess.for(@participatory_process)
92
+ @collection ||= Decidim::ParticipatoryProcessUserRole
93
+ .includes(:user)
94
+ .where(participatory_process: current_participatory_process)
95
+ .order(:role, "decidim_users.name")
98
96
  end
99
97
  end
100
98
  end
@@ -7,8 +7,8 @@ module Decidim
7
7
  # Controller that allows managing participatory processes.
8
8
  #
9
9
  class ParticipatoryProcessesController < ApplicationController
10
- helper_method :participatory_process
11
10
  helper Decidim::OrganizationScopesHelper
11
+ helper_method :current_participatory_process
12
12
 
13
13
  def index
14
14
  authorize! :index, Decidim::ParticipatoryProcess
@@ -38,18 +38,16 @@ module Decidim
38
38
  end
39
39
 
40
40
  def edit
41
- @participatory_process = collection.find(params[:id])
42
- authorize! :update, @participatory_process
43
- @form = form(ParticipatoryProcessForm).from_model(@participatory_process)
41
+ authorize! :update, current_participatory_process
42
+ @form = form(ParticipatoryProcessForm).from_model(current_participatory_process)
44
43
  render layout: "decidim/admin/participatory_process"
45
44
  end
46
45
 
47
46
  def update
48
- @participatory_process = collection.find(params[:id])
49
- authorize! :update, @participatory_process
47
+ authorize! :update, current_participatory_process
50
48
  @form = form(ParticipatoryProcessForm).from_params(participatory_process_params)
51
49
 
52
- UpdateParticipatoryProcess.call(@participatory_process, @form) do
50
+ UpdateParticipatoryProcess.call(current_participatory_process, @form) do
53
51
  on(:ok) do |participatory_process|
54
52
  flash[:notice] = I18n.t("participatory_processes.update.success", scope: "decidim.admin")
55
53
  redirect_to edit_participatory_process_path(participatory_process)
@@ -63,14 +61,12 @@ module Decidim
63
61
  end
64
62
 
65
63
  def show
66
- @participatory_process = collection.find(params[:id])
67
- authorize! :read, @participatory_process
64
+ authorize! :read, current_participatory_process
68
65
  end
69
66
 
70
67
  def destroy
71
- @participatory_process = collection.find(params[:id])
72
- authorize! :destroy, @participatory_process
73
- @participatory_process.destroy!
68
+ authorize! :destroy, current_participatory_process
69
+ current_participatory_process.destroy!
74
70
 
75
71
  flash[:notice] = I18n.t("participatory_processes.destroy.success", scope: "decidim.admin")
76
72
 
@@ -78,22 +74,24 @@ module Decidim
78
74
  end
79
75
 
80
76
  def copy
81
- @participatory_process ||= collection.find(params[:id])
77
+ authorize! :create, Decidim::ParticipatoryProcess
82
78
  end
83
79
 
84
- private
80
+ def current_participatory_process
81
+ @current_participatory_process ||= collection.find(params[:id]) if params[:id]
82
+ end
85
83
 
86
- attr_reader :participatory_process
84
+ private
87
85
 
88
86
  def collection
89
- @collection ||= ManageableParticipatoryProcessesForUser.for(current_user)
87
+ @collection ||= Decidim::ParticipatoryProcessesWithUserRole.for(current_user)
90
88
  end
91
89
 
92
90
  def participatory_process_params
93
91
  {
94
92
  id: params[:id],
95
- hero_image: @participatory_process.hero_image,
96
- banner_image: @participatory_process.banner_image
93
+ hero_image: current_participatory_process.hero_image,
94
+ banner_image: current_participatory_process.banner_image
97
95
  }.merge(params[:participatory_process].to_unsafe_h)
98
96
  end
99
97
  end
@@ -14,7 +14,7 @@ module Decidim
14
14
 
15
15
  def new
16
16
  authorize! :new, :admin_users
17
- @form = form(InviteAdminForm).instance
17
+ @form = form(InviteUserForm).instance
18
18
  end
19
19
 
20
20
  def create
@@ -23,13 +23,13 @@ module Decidim
23
23
  default_params = {
24
24
  organization: current_organization,
25
25
  invitation_instructions: "invite_admin",
26
- roles: %w(admin),
26
+ admin: true,
27
27
  invited_by: current_user,
28
28
  comments_notifications: true,
29
29
  replies_notifications: true
30
30
  }
31
31
 
32
- @form = form(InviteAdminForm).from_params(params.merge(default_params))
32
+ @form = form(InviteUserForm).from_params(params.merge(default_params))
33
33
 
34
34
  InviteUser.call(@form) do
35
35
  on(:ok) do
@@ -63,7 +63,7 @@ module Decidim
63
63
  def destroy
64
64
  authorize! :destroy, :admin_users
65
65
 
66
- RemoveUserRole.call(user, "admin") do
66
+ RemoveAdmin.call(user) do
67
67
  on(:ok) do
68
68
  flash[:notice] = I18n.t("users.destroy.success", scope: "decidim.admin")
69
69
  end