decidim-admin 0.5.1 → 0.6.0

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

Potentially problematic release.


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

Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -7
  3. data/app/assets/javascripts/decidim/admin/application.js.es6 +0 -1
  4. data/app/assets/stylesheets/decidim/admin/extra/_quill.scss +5 -0
  5. data/app/commands/decidim/admin/create_category.rb +4 -4
  6. data/app/commands/decidim/admin/create_feature.rb +7 -7
  7. data/app/commands/decidim/admin/create_managed_user.rb +0 -2
  8. data/app/commands/decidim/admin/update_organization.rb +1 -0
  9. data/app/controllers/decidim/admin/application_controller.rb +0 -2
  10. data/app/controllers/decidim/admin/categories_controller.rb +10 -10
  11. data/app/controllers/decidim/admin/exports_controller.rb +1 -2
  12. data/app/controllers/decidim/admin/feature_permissions_controller.rb +2 -3
  13. data/app/controllers/decidim/admin/features/base_controller.rb +9 -3
  14. data/app/controllers/decidim/admin/features_controller.rb +5 -7
  15. data/app/controllers/decidim/admin/moderations_controller.rb +5 -7
  16. data/app/controllers/decidim/admin/scopes_controller.rb +12 -10
  17. data/app/controllers/decidim/admin/users_controller.rb +1 -3
  18. data/app/forms/decidim/admin/category_form.rb +2 -2
  19. data/app/forms/decidim/admin/feature_form.rb +1 -18
  20. data/app/forms/decidim/admin/organization_form.rb +1 -0
  21. data/app/helpers/decidim/admin/exports_helper.rb +10 -0
  22. data/app/models/decidim/admin/abilities/admin_ability.rb +0 -3
  23. data/app/models/decidim/admin/abilities/participatory_process_admin_ability.rb +3 -3
  24. data/app/views/decidim/admin/attachments/edit.html.erb +1 -1
  25. data/app/views/decidim/admin/attachments/new.html.erb +1 -1
  26. data/app/views/decidim/admin/categories/edit.html.erb +2 -2
  27. data/app/views/decidim/admin/categories/index.html.erb +11 -11
  28. data/app/views/decidim/admin/categories/new.html.erb +3 -3
  29. data/app/views/decidim/admin/categories/show.html.erb +2 -2
  30. data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  31. data/app/views/decidim/admin/features/_form.html.erb +15 -15
  32. data/app/views/decidim/admin/features/edit.html.erb +1 -1
  33. data/app/views/decidim/admin/features/new.html.erb +1 -1
  34. data/app/views/decidim/admin/moderations/index.html.erb +2 -2
  35. data/app/views/decidim/admin/organization/_form.html.erb +5 -0
  36. data/app/views/decidim/admin/users/index.html.erb +1 -1
  37. data/config/locales/ca.yml +8 -195
  38. data/config/locales/en.yml +6 -197
  39. data/config/locales/es.yml +11 -198
  40. data/config/locales/eu.yml +95 -208
  41. data/config/locales/fi.yml +168 -123
  42. data/config/locales/fr.yml +114 -191
  43. data/config/locales/it.yml +150 -168
  44. data/config/locales/nl.yml +443 -0
  45. data/config/locales/pl.yml +444 -0
  46. data/config/locales/uk.yml +451 -0
  47. data/config/routes.rb +2 -46
  48. data/lib/decidim/admin/engine.rb +0 -14
  49. data/lib/decidim/admin/test/commands/create_category_examples.rb +62 -0
  50. data/lib/decidim/admin/test/commands/destroy_category_examples.rb +46 -0
  51. data/lib/decidim/admin/test/commands/update_category_examples.rb +65 -0
  52. data/lib/decidim/admin/test/forms/category_form_examples.rb +90 -0
  53. data/lib/decidim/admin/test/manage_attachments_examples.rb +2 -2
  54. data/lib/decidim/admin/test/manage_feature_permissions_examples.rb +41 -0
  55. metadata +27 -64
  56. data/app/assets/javascripts/decidim/admin/participatory_processes.js.es6 +0 -12
  57. data/app/commands/decidim/admin/activate_participatory_process_step.rb +0 -44
  58. data/app/commands/decidim/admin/copy_participatory_process.rb +0 -113
  59. data/app/commands/decidim/admin/create_participatory_process.rb +0 -78
  60. data/app/commands/decidim/admin/create_participatory_process_admin.rb +0 -93
  61. data/app/commands/decidim/admin/create_participatory_process_group.rb +0 -55
  62. data/app/commands/decidim/admin/create_participatory_process_step.rb +0 -47
  63. data/app/commands/decidim/admin/deactivate_participatory_process_step.rb +0 -36
  64. data/app/commands/decidim/admin/destroy_participatory_process_step.rb +0 -44
  65. data/app/commands/decidim/admin/publish_participatory_process.rb +0 -32
  66. data/app/commands/decidim/admin/reorder_participatory_process_steps.rb +0 -52
  67. data/app/commands/decidim/admin/unpublish_participatory_process.rb +0 -32
  68. data/app/commands/decidim/admin/update_participatory_process.rb +0 -74
  69. data/app/commands/decidim/admin/update_participatory_process_admin.rb +0 -41
  70. data/app/commands/decidim/admin/update_participatory_process_group.rb +0 -58
  71. data/app/commands/decidim/admin/update_participatory_process_step.rb +0 -49
  72. data/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +0 -20
  73. data/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +0 -25
  74. data/app/controllers/decidim/admin/participatory_process_copies_controller.rb +0 -33
  75. data/app/controllers/decidim/admin/participatory_process_groups_controller.rb +0 -86
  76. data/app/controllers/decidim/admin/participatory_process_publications_controller.rb +0 -43
  77. data/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +0 -37
  78. data/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +0 -27
  79. data/app/controllers/decidim/admin/participatory_process_steps_controller.rb +0 -89
  80. data/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +0 -97
  81. data/app/controllers/decidim/admin/participatory_processes_controller.rb +0 -96
  82. data/app/forms/decidim/admin/participatory_process_copy_form.rb +0 -33
  83. data/app/forms/decidim/admin/participatory_process_form.rb +0 -69
  84. data/app/forms/decidim/admin/participatory_process_group_form.rb +0 -24
  85. data/app/forms/decidim/admin/participatory_process_step_form.rb +0 -35
  86. data/app/forms/decidim/admin/participatory_process_user_role_form.rb +0 -29
  87. data/app/helpers/decidim/admin/process_groups_for_select_helper.rb +0 -21
  88. data/app/helpers/decidim/admin/processes_for_select_helper.rb +0 -23
  89. data/app/queries/decidim/admin/process_admins.rb +0 -44
  90. data/app/views/decidim/admin/participatory_process_copies/_form.html.erb +0 -38
  91. data/app/views/decidim/admin/participatory_process_copies/new.html.erb +0 -7
  92. data/app/views/decidim/admin/participatory_process_groups/_form.html.erb +0 -17
  93. data/app/views/decidim/admin/participatory_process_groups/edit.html.erb +0 -19
  94. data/app/views/decidim/admin/participatory_process_groups/index.html.erb +0 -44
  95. data/app/views/decidim/admin/participatory_process_groups/new.html.erb +0 -13
  96. data/app/views/decidim/admin/participatory_process_groups/show.html.erb +0 -23
  97. data/app/views/decidim/admin/participatory_process_steps/_form.html.erb +0 -25
  98. data/app/views/decidim/admin/participatory_process_steps/edit.html.erb +0 -8
  99. data/app/views/decidim/admin/participatory_process_steps/index.html.erb +0 -63
  100. data/app/views/decidim/admin/participatory_process_steps/new.html.erb +0 -7
  101. data/app/views/decidim/admin/participatory_process_steps/show.html.erb +0 -18
  102. data/app/views/decidim/admin/participatory_process_user_roles/_form.html.erb +0 -22
  103. data/app/views/decidim/admin/participatory_process_user_roles/edit.html.erb +0 -7
  104. data/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +0 -65
  105. data/app/views/decidim/admin/participatory_process_user_roles/new.html.erb +0 -7
  106. data/app/views/decidim/admin/participatory_processes/_form.html.erb +0 -101
  107. data/app/views/decidim/admin/participatory_processes/edit.html.erb +0 -19
  108. data/app/views/decidim/admin/participatory_processes/index.html.erb +0 -66
  109. data/app/views/decidim/admin/participatory_processes/new.html.erb +0 -11
  110. data/app/views/layouts/decidim/admin/participatory_process.html.erb +0 -64
  111. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +0 -14
  112. data/app/views/layouts/decidim/admin/participatory_processes.html.erb +0 -14
  113. data/config/i18n-tasks.yml +0 -132
@@ -1,12 +0,0 @@
1
- $(() => {
2
- const $participatoryProcessScopeEnabled = $('#participatory_process_scopes_enabled');
3
- const $participatoryProcessScopeId = $("#participatory_process_scope_id");
4
-
5
- if ($('.edit_participatory_process').length > 0) {
6
- $participatoryProcessScopeEnabled.on('change', (event) => {
7
- const checked = event.target.checked;
8
- $participatoryProcessScopeId.attr("disabled", !checked);
9
- })
10
- $participatoryProcessScopeId.attr("disabled", !$participatoryProcessScopeEnabled.prop('checked'));
11
- }
12
- });
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A command that sets a step in a participatory process as active (and
6
- # unsets a previous active step)
7
- class ActivateParticipatoryProcessStep < Rectify::Command
8
- # Public: Initializes the command.
9
- #
10
- # step - A ParticipatoryProcessStep that will be activated
11
- def initialize(step)
12
- @step = step
13
- end
14
-
15
- # Executes the command. Broadcasts these events:
16
- #
17
- # - :ok when everything is valid.
18
- # - :invalid if the data wasn't valid and we couldn't proceed.
19
- #
20
- # Returns nothing.
21
- def call
22
- return broadcast(:invalid) if step.nil? || step.active?
23
-
24
- Decidim::ParticipatoryProcessStep.transaction do
25
- deactivate_active_steps
26
- activate_step
27
- end
28
- broadcast(:ok)
29
- end
30
-
31
- private
32
-
33
- attr_reader :step
34
-
35
- def deactivate_active_steps
36
- step.participatory_process.steps.where(active: true).update_all(active: false)
37
- end
38
-
39
- def activate_step
40
- step.update_attribute(:active, true)
41
- end
42
- end
43
- end
44
- end
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A command with all the business logic when copying a new participatory
6
- # process in the system.
7
- class CopyParticipatoryProcess < Rectify::Command
8
- # Public: Initializes the command.
9
- #
10
- # form - A form object with the params.
11
- # participatory_process - A participatory_process we want to duplicate
12
- def initialize(form, participatory_process)
13
- @form = form
14
- @participatory_process = participatory_process
15
- end
16
-
17
- # Executes the command. Broadcasts these events:
18
- #
19
- # - :ok when everything is valid.
20
- # - :invalid if the form wasn't valid and we couldn't proceed.
21
- #
22
- # Returns nothing.
23
- def call
24
- return broadcast(:invalid) if form.invalid?
25
-
26
- ParticipatoryProcess.transaction do
27
- copy_participatory_process
28
- copy_participatory_process_steps if @form.copy_steps?
29
- copy_participatory_process_categories if @form.copy_categories?
30
- copy_participatory_process_features if @form.copy_features?
31
- end
32
-
33
- broadcast(:ok, @copied_process)
34
- end
35
-
36
- private
37
-
38
- attr_reader :form
39
-
40
- def copy_participatory_process
41
- @copied_process = ParticipatoryProcess.create!(
42
- organization: @participatory_process.organization,
43
- title: form.title,
44
- subtitle: @participatory_process.subtitle,
45
- slug: form.slug,
46
- hashtag: @participatory_process.hashtag,
47
- description: @participatory_process.description,
48
- short_description: @participatory_process.short_description,
49
- hero_image: @participatory_process.hero_image,
50
- banner_image: @participatory_process.banner_image,
51
- promoted: @participatory_process.promoted,
52
- scope: @participatory_process.scope,
53
- developer_group: @participatory_process.developer_group,
54
- local_area: @participatory_process.local_area,
55
- target: @participatory_process.target,
56
- participatory_scope: @participatory_process.participatory_scope,
57
- participatory_structure: @participatory_process.participatory_structure,
58
- meta_scope: @participatory_process.meta_scope,
59
- end_date: @participatory_process.end_date,
60
- participatory_process_group: @participatory_process.participatory_process_group
61
- )
62
- end
63
-
64
- def copy_participatory_process_steps
65
- @steps_relationship = {}
66
-
67
- @participatory_process.steps.each do |step|
68
- new_step = ParticipatoryProcessStep.create!(
69
- title: step.title,
70
- description: step.description,
71
- start_date: step.start_date,
72
- end_date: step.end_date,
73
- participatory_process: @copied_process,
74
- position: step.position,
75
- active: step.active
76
- )
77
- @steps_relationship[step.id.to_s] = new_step.id.to_s
78
- end
79
- end
80
-
81
- def copy_participatory_process_categories
82
- @participatory_process.categories.each do |category|
83
- Category.create!(
84
- name: category.name,
85
- description: category.description,
86
- parent_id: category.parent_id,
87
- participatory_process: @copied_process
88
- )
89
- end
90
- end
91
-
92
- def copy_participatory_process_features
93
- @participatory_process.features.each do |feature|
94
- copied_step_settings = @form.copy_steps? ? map_step_settings(feature.step_settings) : {}
95
- new_feature = Feature.create!(
96
- manifest_name: feature.manifest_name,
97
- name: feature.name,
98
- participatory_process: @copied_process,
99
- settings: feature.settings,
100
- step_settings: copied_step_settings
101
- )
102
- feature.manifest.run_hooks(:copy, new_feature: new_feature, old_feature: feature)
103
- end
104
- end
105
-
106
- def map_step_settings(step_settings)
107
- step_settings.each_with_object({}) do |(step_id, settings), acc|
108
- acc.update(@steps_relationship[step_id.to_s] => settings)
109
- end
110
- end
111
- end
112
- end
113
- end
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A command with all the business logic when creating a new participatory
6
- # process in the system.
7
- class CreateParticipatoryProcess < Rectify::Command
8
- # Public: Initializes the command.
9
- #
10
- # form - A form object with the params.
11
- def initialize(form)
12
- @form = form
13
- end
14
-
15
- # Executes the command. Broadcasts these events:
16
- #
17
- # - :ok when everything is valid.
18
- # - :invalid if the form wasn't valid and we couldn't proceed.
19
- #
20
- # Returns nothing.
21
- def call
22
- return broadcast(:invalid) if form.invalid?
23
- process = create_participatory_process
24
-
25
- if process.persisted?
26
- broadcast(:ok, process)
27
- else
28
- form.errors.add(:hero_image, process.errors[:hero_image]) if process.errors.include? :hero_image
29
- form.errors.add(:banner_image, process.errors[:banner_image]) if process.errors.include? :banner_image
30
- broadcast(:invalid)
31
- end
32
- end
33
-
34
- private
35
-
36
- attr_reader :form
37
-
38
- def create_participatory_process
39
- process = ParticipatoryProcess.new(
40
- organization: form.current_organization,
41
- title: form.title,
42
- subtitle: form.subtitle,
43
- slug: form.slug,
44
- hashtag: form.hashtag,
45
- description: form.description,
46
- short_description: form.short_description,
47
- hero_image: form.hero_image,
48
- banner_image: form.banner_image,
49
- promoted: form.promoted,
50
- scope: form.scope,
51
- developer_group: form.developer_group,
52
- local_area: form.local_area,
53
- target: form.target,
54
- participatory_scope: form.participatory_scope,
55
- participatory_structure: form.participatory_structure,
56
- meta_scope: form.meta_scope,
57
- end_date: form.end_date,
58
- participatory_process_group: form.participatory_process_group
59
- )
60
-
61
- return process unless process.valid?
62
- transaction do
63
- process.save!
64
-
65
- process.steps.create!(
66
- title: TranslationsHelper.multi_translation(
67
- "decidim.admin.participatory_process_steps.default_title",
68
- form.current_organization.available_locales
69
- ),
70
- active: true
71
- )
72
-
73
- process
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A command with all the business logic when creating a new participatory
6
- # process admin in the system.
7
- class CreateParticipatoryProcessAdmin < Rectify::Command
8
- # Public: Initializes the command.
9
- #
10
- # form - A form object with the params.
11
- # participatory_process - The ParticipatoryProcess that will hold the
12
- # user role
13
- def initialize(form, current_user, participatory_process)
14
- @form = form
15
- @current_user = current_user
16
- @participatory_process = participatory_process
17
- end
18
-
19
- # Executes the command. Broadcasts these events:
20
- #
21
- # - :ok when everything is valid.
22
- # - :invalid if the form wasn't valid and we couldn't proceed.
23
- #
24
- # Returns nothing.
25
- def call
26
- return broadcast(:invalid) if form.invalid?
27
-
28
- ActiveRecord::Base.transaction do
29
- create_or_invite_user
30
- create_role
31
- end
32
-
33
- broadcast(:ok)
34
- rescue ActiveRecord::RecordInvalid
35
- form.errors.add(:email, :taken)
36
- broadcast(:invalid)
37
- end
38
-
39
- private
40
-
41
- attr_reader :form, :participatory_process, :current_user, :user
42
-
43
- def create_role
44
- Decidim::ParticipatoryProcessUserRole.find_or_create_by!(
45
- role: form.role.to_sym,
46
- user: user,
47
- participatory_process: @participatory_process
48
- )
49
- end
50
-
51
- def create_or_invite_user
52
- @user ||= existing_user || new_user
53
- end
54
-
55
- def existing_user
56
- return @existing_user if defined?(@existing_user)
57
-
58
- @existing_user = User.where(
59
- email: form.email,
60
- organization: participatory_process.organization
61
- ).first
62
-
63
- if @existing_user && !@existing_user.invitation_accepted?
64
- InviteUserAgain.call(@existing_user, invitation_instructions)
65
- end
66
-
67
- @existing_user
68
- end
69
-
70
- def new_user
71
- @new_user ||= InviteUser.call(user_form) do
72
- on(:ok) do |user|
73
- return user
74
- end
75
- end
76
- end
77
-
78
- def user_form
79
- OpenStruct.new(name: form.name,
80
- email: form.email.downcase,
81
- organization: participatory_process.organization,
82
- admin: false,
83
- invited_by: current_user,
84
- invitation_instructions: invitation_instructions)
85
- end
86
-
87
- def invitation_instructions
88
- return "invite_admin" if form.role == "admin"
89
- "invite_collaborator"
90
- end
91
- end
92
- end
93
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A command with all the business logic when creating a new participatory
6
- # process group in the system.
7
- class CreateParticipatoryProcessGroup < Rectify::Command
8
- # Public: Initializes the command.
9
- #
10
- # form - A form object with the params.
11
- def initialize(form)
12
- @form = form
13
- end
14
-
15
- # Executes the command. Broadcasts these events:
16
- #
17
- # - :ok when everything is valid.
18
- # - :invalid if the form wasn't valid and we couldn't proceed.
19
- #
20
- # Returns nothing.
21
- def call
22
- return broadcast(:invalid) if form.invalid?
23
- group = create_participatory_process_group
24
-
25
- if group.persisted?
26
- broadcast(:ok, group)
27
- else
28
- form.errors.add(:hero_image, group.errors[:hero_image]) if group.errors.include? :hero_image
29
- form.errors.add(:banner_image, group.errors[:banner_image]) if group.errors.include? :banner_image
30
- broadcast(:invalid)
31
- end
32
- end
33
-
34
- private
35
-
36
- attr_reader :form
37
-
38
- def create_participatory_process_group
39
- transaction do
40
- ParticipatoryProcessGroup.create(
41
- name: form.name,
42
- description: form.description,
43
- hero_image: form.hero_image,
44
- participatory_processes: participatory_processes,
45
- organization: form.current_organization
46
- )
47
- end
48
- end
49
-
50
- def participatory_processes
51
- Decidim::ParticipatoryProcess.where(id: form.participatory_process_ids)
52
- end
53
- end
54
- end
55
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A command with all the business logic when creating a new participatory
6
- # process in the system.
7
- class CreateParticipatoryProcessStep < Rectify::Command
8
- # Public: Initializes the command.
9
- #
10
- # form - A form object with the params.
11
- # participatory_process - The ParticipatoryProcess that will hold the
12
- # step
13
- def initialize(form, participatory_process)
14
- @form = form
15
- @participatory_process = participatory_process
16
- end
17
-
18
- # Executes the command. Broadcasts these events:
19
- #
20
- # - :ok when everything is valid.
21
- # - :invalid if the form wasn't valid and we couldn't proceed.
22
- #
23
- # Returns nothing.
24
- def call
25
- return broadcast(:invalid) if form.invalid?
26
-
27
- create_participatory_process_step
28
- broadcast(:ok)
29
- end
30
-
31
- private
32
-
33
- attr_reader :form
34
-
35
- def create_participatory_process_step
36
- ParticipatoryProcessStep.create!(
37
- title: form.title,
38
- description: form.description,
39
- start_date: form.start_date,
40
- end_date: form.end_date,
41
- participatory_process: @participatory_process,
42
- active: @participatory_process.steps.empty?
43
- )
44
- end
45
- end
46
- end
47
- end