decidim 0.0.1.alpha7 → 0.0.1.alpha8
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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -1
- data/.eslintignore +1 -0
- data/.eslintrc.json +12 -0
- data/.github/ISSUE_TEMPLATE.md +12 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +8 -11
- data/.gitignore +1 -0
- data/.hound.yml +4 -0
- data/.rubocop.yml +14 -1
- data/.travis.yml +20 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/Dockerfile +1 -0
- data/Gemfile +3 -2
- data/Gemfile.common +1 -1
- data/Gemfile.lock +68 -39
- data/LICENSE.txt +619 -21
- data/README.md +17 -13
- data/Rakefile +1 -1
- data/codecov.yml +6 -1
- data/crowdin.yaml +4 -0
- data/decidim-admin/LICENSE.txt +619 -0
- data/decidim-admin/README.md +1 -1
- data/decidim-admin/app/assets/javascripts/decidim/admin/application.js.es6 +12 -0
- data/decidim-admin/app/assets/javascripts/decidim/admin/sort_steps.js.es6 +21 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_tables.scss +9 -0
- data/decidim-admin/app/commands/decidim/admin/activate_participatory_process_step.rb +43 -0
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process.rb +1 -0
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process_step.rb +46 -0
- data/decidim-admin/app/commands/decidim/admin/deactivate_participatory_process_step.rb +35 -0
- data/decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb +35 -0
- data/decidim-admin/app/commands/decidim/admin/reorder_participatory_process_steps.rb +47 -0
- data/decidim-admin/app/commands/decidim/admin/unpublish_participatory_process.rb +35 -0
- data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +1 -0
- data/decidim-admin/app/commands/decidim/admin/update_participatory_process_step.rb +49 -0
- data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
- data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +4 -0
- data/decidim-admin/app/controllers/decidim/admin/dashboard_controller.rb +1 -9
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb +49 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +56 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +30 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_steps_controller.rb +81 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +7 -12
- data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +1 -0
- data/decidim-admin/app/forms/decidim/admin/participatory_process_step_form.rb +25 -0
- data/decidim-admin/app/helpers/decidim/admin/application_helper.rb +1 -0
- data/decidim-admin/app/mailers/decidim/admin/application_mailer.rb +1 -1
- data/decidim-admin/app/models/decidim/admin/abilities/admin.rb +21 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/_form.html.erb +19 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/_table.html.erb +53 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/edit.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/new.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/show.html.erb +22 -0
- data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +4 -0
- data/decidim-admin/app/views/decidim/admin/participatory_processes/index.html.erb +22 -2
- data/decidim-admin/app/views/decidim/admin/participatory_processes/show.html.erb +21 -2
- data/decidim-admin/config/i18n-tasks.yml +2 -2
- data/decidim-admin/config/locales/ca.yml +55 -2
- data/decidim-admin/config/locales/en.yml +55 -2
- data/decidim-admin/config/locales/es.yml +56 -3
- data/decidim-admin/config/routes.rb +10 -1
- data/decidim-admin/decidim-admin.gemspec +6 -7
- data/decidim-admin/lib/decidim/admin/engine.rb +6 -1
- data/decidim-admin/spec/commands/activate_participatory_process_step_spec.rb +44 -0
- data/decidim-admin/spec/commands/deactivate_participatory_process_step_spec.rb +35 -0
- data/decidim-admin/spec/commands/publish_participatory_process_spec.rb +35 -0
- data/decidim-admin/spec/commands/reorder_participatory_process_steps_spec.rb +53 -0
- data/decidim-admin/spec/commands/unpublish_participatory_process_spec.rb +35 -0
- data/decidim-admin/spec/controllers/participatory_processes_controller_spec.rb +32 -0
- data/decidim-admin/spec/features/manage_participatory_process_steps_spec.rb +151 -0
- data/decidim-admin/spec/features/manage_participatory_processes_spec.rb +87 -39
- data/decidim-admin/spec/forms/participatory_process_form_spec.rb +122 -0
- data/decidim-admin/spec/forms/participatory_process_step_form_spec.rb +113 -0
- data/decidim-admin/spec/models/abilities/admin_spec.rb +25 -0
- data/decidim-admin/spec/spec_helper.rb +0 -1
- data/decidim-admin/vendor/assets/javascripts/html.sortable.min.js +2 -0
- data/decidim-api/.gitignore +7 -0
- data/decidim-api/LICENSE.txt +619 -0
- data/decidim-api/README.md +28 -0
- data/decidim-api/Rakefile +27 -0
- data/decidim-api/app/controllers/decidim/api/application_controller.rb +9 -0
- data/decidim-api/app/controllers/decidim/api/queries_controller.rb +33 -0
- data/decidim-api/app/schemas/decidim/api/schema.rb +9 -0
- data/decidim-api/app/types/decidim/api/localized_string_type.rb +13 -0
- data/decidim-api/app/types/decidim/api/process_step_type.rb +26 -0
- data/decidim-api/app/types/decidim/api/process_type.rb +18 -0
- data/decidim-api/app/types/decidim/api/query_type.rb +19 -0
- data/decidim-api/app/types/decidim/api/translated_field_type.rb +44 -0
- data/decidim-api/bin/rails +14 -0
- data/decidim-api/config/routes.rb +6 -0
- data/decidim-api/decidim-api.gemspec +27 -0
- data/decidim-api/lib/decidim/api.rb +9 -0
- data/decidim-api/lib/decidim/api/engine.rb +22 -0
- data/decidim-api/lib/tasks/decidim/api_tasks.rake +5 -0
- data/decidim-api/spec/controllers/queries_controller_spec.rb +22 -0
- data/decidim-api/spec/factories.rb +1 -0
- data/decidim-api/spec/schemas/schema_spec.rb +38 -0
- data/decidim-api/spec/spec_helper.rb +2 -0
- data/decidim-api/spec/support/type_helpers.rb +46 -0
- data/decidim-api/spec/types/localized_string_type_spec.rb +30 -0
- data/decidim-api/spec/types/process_step_type_spec.rb +50 -0
- data/decidim-api/spec/types/process_type_spec.rb +39 -0
- data/decidim-api/spec/types/query_type_spec.rb +24 -0
- data/decidim-api/spec/types/translated_field_type_spec.rb +68 -0
- data/decidim-dev/README.md +1 -1
- data/decidim-dev/decidim-dev.gemspec +5 -3
- data/decidim-dev/lib/decidim/dummy_authorization_handler.rb +18 -0
- data/decidim-dev/lib/decidim/test/authorization_shared_examples.rb +31 -0
- data/decidim-dev/lib/decidim/test/base_spec_helper.rb +6 -1
- data/decidim-dev/lib/decidim/test/rspec_support/authenticated_controller_context.rb +9 -0
- data/decidim-dev/lib/decidim/test/rspec_support/authorization_handlers.rb +7 -0
- data/decidim-dev/lib/decidim/test/rspec_support/bullet.rb +15 -0
- data/decidim-dev/lib/decidim/test/rspec_support/engine_routes.rb +30 -0
- data/decidim-dev/lib/decidim/test/rspec_support/translation_helpers.rb +12 -0
- data/decidim-dev/lib/generators/decidim/dummy_generator.rb +10 -0
- data/decidim-dev/lib/generators/decidim/templates/bullet.rb +6 -0
- data/decidim-system/LICENSE.txt +619 -0
- data/decidim-system/README.md +1 -1
- data/decidim-system/app/assets/javascripts/decidim/system/application.js.es6 +10 -0
- data/decidim-system/app/mailers/decidim/system/application_mailer.rb +1 -1
- data/decidim-system/decidim-system.gemspec +4 -4
- data/decidim.gemspec +3 -2
- data/lib/decidim.rb +1 -6
- data/lib/generators/decidim/app_generator.rb +13 -1
- data/lib/generators/decidim/install_generator.rb +11 -2
- data/lib/generators/decidim/templates/Gemfile.erb +5 -2
- data/lib/generators/decidim/templates/authorization_handler.rb +50 -0
- data/lib/generators/decidim/templates/carrierwave.rb +27 -0
- data/lib/generators/decidim/templates/decidim.scss.erb +3 -0
- data/lib/generators/decidim/templates/initializer.rb +3 -1
- data/package.json +21 -0
- data/yarn.lock +890 -0
- metadata +102 -21
- data/.eslintrc +0 -213
- data/decidim-admin/app/assets/javascripts/decidim/admin/application.js +0 -22
- data/decidim-admin/app/controllers/concerns/decidim/needs_authorization.rb +0 -50
- data/decidim-admin/app/policies/decidim/admin/application_policy.rb +0 -20
- data/decidim-admin/app/policies/decidim/admin/dashboard_policy.rb +0 -15
- data/decidim-admin/app/policies/decidim/admin/organization_policy.rb +0 -15
- data/decidim-admin/app/policies/decidim/admin/participatory_process_policy.rb +0 -57
- data/decidim-admin/spec/policies/dashboard_policy_spec.rb +0 -23
- data/decidim-admin/spec/policies/organization_policy_spec.rb +0 -41
- data/decidim-admin/spec/policies/participatory_process_policy_spec.rb +0 -153
- data/decidim-system/app/assets/javascripts/decidim/system/application.js +0 -22
data/decidim-admin/README.md
CHANGED
@@ -25,4 +25,4 @@ $ gem install decidim-admin
|
|
25
25
|
Contribution directions go here.
|
26
26
|
|
27
27
|
## License
|
28
|
-
The gem is available as open source under the terms of the [
|
28
|
+
The gem is available as open source under the terms of the [AGPLv3 License](https://opensource.org/licenses/AGPL-3.0).
|
@@ -0,0 +1,12 @@
|
|
1
|
+
//= require jquery
|
2
|
+
//= require jquery_ujs
|
3
|
+
//= require foundation
|
4
|
+
//= require turbolinks
|
5
|
+
//= require html.sortable.min
|
6
|
+
//= require ./sort_steps
|
7
|
+
//= require_self
|
8
|
+
|
9
|
+
$(document).on('turbolinks:load', () => {
|
10
|
+
$(() => { $(document).foundation(); });
|
11
|
+
});
|
12
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* global sortable */
|
2
|
+
|
3
|
+
// consider removing from application.js file
|
4
|
+
//
|
5
|
+
// Needs a `tbody` element inside a `#steps` section. The `tbody` element
|
6
|
+
// should have a `data-sort-url` attribute with the URL where the data should
|
7
|
+
// be posted to.
|
8
|
+
$(() => {
|
9
|
+
const sortableElement = $('#steps tbody');
|
10
|
+
|
11
|
+
if (sortableElement) {
|
12
|
+
const sortUrl = sortableElement.data('sort-url');
|
13
|
+
|
14
|
+
sortable('#steps tbody', {
|
15
|
+
placeholder: $('<tr style="border-style: dashed; border-color: #000"><td colspan="4"> </td></tr>')[0],
|
16
|
+
})[0].addEventListener('sortupdate', (e) => {
|
17
|
+
const order = $(e.target).children().map(() => $(this).data('id')).toArray();
|
18
|
+
$.ajax({ method: 'POST', url: sortUrl, data: { items_ids: order } });
|
19
|
+
});
|
20
|
+
}
|
21
|
+
});
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command that sets a step in a participatory process as active (and
|
5
|
+
# unsets a previous active step)
|
6
|
+
class ActivateParticipatoryProcessStep < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# step - A ParticipatoryProcessStep that will be activated
|
10
|
+
def initialize(step)
|
11
|
+
@step = step
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Braodcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the data wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if step.nil? || step.active?
|
22
|
+
|
23
|
+
Decidim::ParticipatoryProcessStep.transaction do
|
24
|
+
deactivate_active_steps
|
25
|
+
activate_step
|
26
|
+
end
|
27
|
+
broadcast(:ok)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :step
|
33
|
+
|
34
|
+
def deactivate_active_steps
|
35
|
+
step.participatory_process.steps.where(active: true).update_all(active: false)
|
36
|
+
end
|
37
|
+
|
38
|
+
def activate_step
|
39
|
+
step.update_attribute(:active, true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command with all the business logic when creating a new participatory
|
5
|
+
# process in the system.
|
6
|
+
class CreateParticipatoryProcessStep < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
# participatory_process - The ParticipatoryProcess that will hold the
|
11
|
+
# step
|
12
|
+
def initialize(form, participatory_process)
|
13
|
+
@form = form
|
14
|
+
@participatory_process = participatory_process
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Braodcasts 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
|
+
create_participatory_process_step
|
27
|
+
broadcast(:ok)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :form
|
33
|
+
|
34
|
+
def create_participatory_process_step
|
35
|
+
ParticipatoryProcessStep.create!(
|
36
|
+
title: form.title,
|
37
|
+
description: form.description,
|
38
|
+
short_description: form.short_description,
|
39
|
+
start_date: form.start_date.at_midnight,
|
40
|
+
end_date: form.end_date.at_midnight,
|
41
|
+
participatory_process: @participatory_process
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command that sets all steps in a participatory process as inactive
|
5
|
+
class DeactivateParticipatoryProcessStep < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# step - A ParticipatoryProcessStep that will be deactivated
|
9
|
+
def initialize(step)
|
10
|
+
@step = step
|
11
|
+
end
|
12
|
+
|
13
|
+
# Executes the command. Broadcasts these events:
|
14
|
+
#
|
15
|
+
# - :ok when everything is valid.
|
16
|
+
# - :invalid if the data wasn't valid and we couldn't proceed.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def call
|
20
|
+
return broadcast(:invalid) if step.nil? || !step.active?
|
21
|
+
|
22
|
+
deactivate_active_steps
|
23
|
+
broadcast(:ok)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :step
|
29
|
+
|
30
|
+
def deactivate_active_steps
|
31
|
+
step.participatory_process.steps.where(active: true).update_all(active: false)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command that sets a participatory process as published.
|
5
|
+
class PublishParticipatoryProcess < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# process - A ParticipatoryProcess that will be published
|
9
|
+
def initialize(process)
|
10
|
+
@process = process
|
11
|
+
end
|
12
|
+
|
13
|
+
# Executes the command. Braodcasts these events:
|
14
|
+
#
|
15
|
+
# - :ok when everything is valid.
|
16
|
+
# - :invalid if the data wasn't valid and we couldn't proceed.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def call
|
20
|
+
return broadcast(:invalid) if process.nil? || process.published?
|
21
|
+
|
22
|
+
publish_process
|
23
|
+
broadcast(:ok)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :process
|
29
|
+
|
30
|
+
def publish_process
|
31
|
+
process.update_attribute(:published_at, Time.current)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command that reorders the steps in a participatory process.
|
5
|
+
class ReorderParticipatoryProcessSteps < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# collection - an ActiveRecord::Relation of steps
|
9
|
+
# order - an Array holding the order of IDs of steps
|
10
|
+
def initialize(collection, order)
|
11
|
+
@collection = collection
|
12
|
+
@order = order
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Braodcasts 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) unless order.present?
|
23
|
+
|
24
|
+
reorder_steps
|
25
|
+
broadcast(:ok)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :collection
|
31
|
+
|
32
|
+
def reorder_steps
|
33
|
+
data = order.each_with_index.inject({}) do |hash, (id, index)|
|
34
|
+
hash.update(id => { position: index })
|
35
|
+
end
|
36
|
+
|
37
|
+
collection.update(data.keys, data.values)
|
38
|
+
end
|
39
|
+
|
40
|
+
def order
|
41
|
+
return nil unless @order.is_a?(Array) && @order.present?
|
42
|
+
|
43
|
+
@order
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command that sets a participatory process as unpublished.
|
5
|
+
class UnpublishParticipatoryProcess < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# process - A ParticipatoryProcess that will be unpublished
|
9
|
+
def initialize(process)
|
10
|
+
@process = process
|
11
|
+
end
|
12
|
+
|
13
|
+
# Executes the command. Braodcasts these events:
|
14
|
+
#
|
15
|
+
# - :ok when everything is valid.
|
16
|
+
# - :invalid if the data wasn't valid and we couldn't proceed.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def call
|
20
|
+
return broadcast(:invalid) if process.nil? || !process.published?
|
21
|
+
|
22
|
+
unpublish_process
|
23
|
+
broadcast(:ok)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :process
|
29
|
+
|
30
|
+
def unpublish_process
|
31
|
+
process.update_attribute(:published_at, nil)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command with all the business logic when creating a new participatory
|
5
|
+
# process in the system.
|
6
|
+
class UpdateParticipatoryProcessStep < Rectify::Command
|
7
|
+
attr_reader :participatory_process_step
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# participatory_process_step - the ParticipatoryProcessStep to update
|
11
|
+
# form - A form object with the params.
|
12
|
+
def initialize(participatory_process_step, form)
|
13
|
+
@participatory_process_step = participatory_process_step
|
14
|
+
@form = form
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Braodcasts 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
|
+
update_participatory_process_step
|
27
|
+
broadcast(:ok)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :form
|
33
|
+
|
34
|
+
def update_participatory_process_step
|
35
|
+
participatory_process_step.update_attributes!(attributes)
|
36
|
+
end
|
37
|
+
|
38
|
+
def attributes
|
39
|
+
{
|
40
|
+
title: form.title,
|
41
|
+
start_date: form.start_date,
|
42
|
+
end_date: form.end_date,
|
43
|
+
description: form.description,
|
44
|
+
short_description: form.short_description
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -6,15 +6,7 @@ module Decidim
|
|
6
6
|
# Controller that shows a simple dashboard.
|
7
7
|
#
|
8
8
|
class DashboardController < ApplicationController
|
9
|
-
|
10
|
-
authorize :dashboard
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def policy_class
|
16
|
-
Decidim::Admin::DashboardPolicy
|
17
|
-
end
|
9
|
+
authorize_resource :admin_dashboard, class: false
|
18
10
|
end
|
19
11
|
end
|
20
12
|
end
|
data/decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency "decidim/admin/application_controller"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module Admin
|
6
|
+
# Controller that allows managing all the Admins.
|
7
|
+
#
|
8
|
+
class ParticipatoryProcessPublicationsController < ApplicationController
|
9
|
+
def create
|
10
|
+
authorize! :publish, participatory_process
|
11
|
+
|
12
|
+
PublishParticipatoryProcess.call(participatory_process) do
|
13
|
+
on(:ok) do
|
14
|
+
flash[:notice] = I18n.t("participatory_process_publications.create.success", scope: "decidim.admin")
|
15
|
+
end
|
16
|
+
|
17
|
+
on(:invalid) do
|
18
|
+
flash.now[:alert] = I18n.t("participatory_process_publications.create.error", scope: "decidim.admin")
|
19
|
+
end
|
20
|
+
|
21
|
+
redirect_back(fallback_location: participatory_processes_path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy
|
26
|
+
authorize! :publish, participatory_process
|
27
|
+
|
28
|
+
UnpublishParticipatoryProcess.call(participatory_process) do
|
29
|
+
on(:ok) do
|
30
|
+
flash[:notice] = I18n.t("participatory_process_publications.destroy.success", scope: "decidim.admin")
|
31
|
+
end
|
32
|
+
|
33
|
+
on(:invalid) do
|
34
|
+
flash.now[:alert] = I18n.t("participatory_process_publications.destroy.error", scope: "decidim.admin")
|
35
|
+
end
|
36
|
+
|
37
|
+
redirect_back(fallback_location: participatory_processes_path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def participatory_process
|
44
|
+
@participatory_process ||=
|
45
|
+
current_organization.participatory_processes.find(params[:participatory_process_id])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|