decidim 0.4.2 → 0.4.3

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +13 -13
  3. data/.rubocop.yml +1 -0
  4. data/CHANGELOG.md +16 -2
  5. data/Dockerfile +4 -7
  6. data/Gemfile.lock +42 -42
  7. data/README.md +2 -2
  8. data/Rakefile +6 -7
  9. data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +2 -1
  10. data/decidim-admin/app/controllers/decidim/admin/categories_controller.rb +1 -3
  11. data/decidim-admin/app/controllers/decidim/admin/dashboard_controller.rb +1 -3
  12. data/decidim-admin/app/controllers/decidim/admin/feature_permissions_controller.rb +1 -3
  13. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +1 -3
  14. data/decidim-admin/app/controllers/decidim/admin/moderations_controller.rb +1 -1
  15. data/decidim-admin/app/controllers/decidim/admin/organization_controller.rb +1 -3
  16. data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +1 -3
  17. data/decidim-admin/app/controllers/decidim/admin/participatory_process_copies_controller.rb +1 -9
  18. data/decidim-admin/app/controllers/decidim/admin/participatory_process_groups_controller.rb +1 -3
  19. data/decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb +1 -3
  20. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +1 -3
  21. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +1 -3
  22. data/decidim-admin/app/controllers/decidim/admin/participatory_process_steps_controller.rb +1 -3
  23. data/decidim-admin/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +2 -4
  24. data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +1 -3
  25. data/decidim-admin/app/controllers/decidim/admin/scopes_controller.rb +1 -3
  26. data/decidim-admin/app/controllers/decidim/admin/static_pages_controller.rb +1 -3
  27. data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +1 -3
  28. data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +1 -0
  29. data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +4 -0
  30. data/decidim-admin/spec/commands/update_participatory_process_spec.rb +2 -1
  31. data/decidim-admin/spec/factories.rb +0 -1
  32. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +1 -1
  33. data/decidim-admin/spec/forms/participatory_process_form_spec.rb +5 -3
  34. data/decidim-admin/spec/forms/participatory_process_group_form_spec.rb +2 -2
  35. data/decidim-admin/spec/shared/participatory_admin_shared_context.rb +6 -11
  36. data/decidim-admin/spec/spec_helper.rb +0 -6
  37. data/decidim-budgets/lib/decidim/budgets/feature.rb +9 -2
  38. data/decidim-budgets/spec/factories.rb +3 -2
  39. data/decidim-comments/README.md +3 -3
  40. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  41. data/decidim-comments/app/frontend/comments/down_vote_button.component.tsx +3 -3
  42. data/decidim-comments/app/frontend/comments/up_vote_button.component.tsx +3 -3
  43. data/decidim-comments/lib/decidim/comments/test/factories.rb +0 -3
  44. data/decidim-comments/spec/factories.rb +1 -0
  45. data/decidim-dev/lib/decidim/dev.rb +5 -0
  46. data/decidim-dev/lib/decidim/dev/test/rspec_support/helpers.rb +6 -0
  47. data/decidim-dev/lib/decidim/dev/test/rspec_support/wisper.rb +1 -1
  48. data/decidim-dev/lib/generators/decidim/dummy_generator.rb +1 -1
  49. data/decidim-dev/lib/tasks/test_app.rake +0 -1
  50. data/decidim-meetings/lib/decidim/meetings/feature.rb +1 -1
  51. data/decidim-meetings/spec/factories.rb +0 -1
  52. data/decidim-pages/lib/decidim/pages/feature.rb +8 -1
  53. data/decidim-proposals/lib/decidim/proposals/feature.rb +1 -1
  54. data/decidim-proposals/lib/decidim/proposals/test/factories.rb +0 -7
  55. data/decidim-proposals/spec/factories.rb +6 -0
  56. data/decidim-results/lib/decidim/results/feature.rb +1 -1
  57. data/decidim-results/spec/factories.rb +2 -2
  58. data/decidim-surveys/bin/rails +0 -0
  59. data/decidim-surveys/lib/decidim/surveys/feature.rb +16 -1
  60. data/decidim-surveys/lib/decidim/surveys/test/factories.rb +0 -3
  61. data/decidim-surveys/spec/factories.rb +2 -0
  62. data/decidim-system/app/controllers/decidim/system/admins_controller.rb +1 -3
  63. data/decidim-system/app/controllers/decidim/system/dashboard_controller.rb +1 -3
  64. data/decidim-system/app/controllers/decidim/system/organizations_controller.rb +1 -3
  65. data/docs/how_to_create_a_plugin.md +20 -10
  66. data/lib/generators/decidim/app_generator.rb +0 -4
  67. data/lib/generators/decidim/install_generator.rb +0 -3
  68. data/package-lock.json +6965 -0
  69. data/package.json +7 -7
  70. metadata +25 -33
  71. data/.travis.yml +0 -70
  72. data/decidim-admin/lib/decidim/admin/test/factories.rb +0 -9
  73. data/decidim-admin/lib/tasks/decidim/admin_tasks.rake +0 -5
  74. data/decidim-admin/spec/support/processes_menu_links_helpers.rb +0 -13
  75. data/decidim-api/lib/tasks/decidim/api_tasks.rake +0 -5
  76. data/decidim-pages/lib/tasks/decidim/pages_tasks.rake +0 -1
  77. data/decidim-system/lib/tasks/decidim/system_tasks.rake +0 -5
  78. data/run_ci.sh +0 -10
  79. data/yarn.lock +0 -5860
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing all the attachments for a participatory
8
6
  # process.
9
7
  #
10
- class ParticipatoryProcessAttachmentsController < ApplicationController
8
+ class ParticipatoryProcessAttachmentsController < Decidim::Admin::ApplicationController
11
9
  include Concerns::ParticipatoryProcessAdmin
12
10
  include Concerns::HasAttachments
13
11
 
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory processes.
8
6
  #
9
- class ParticipatoryProcessCopiesController < ApplicationController
7
+ class ParticipatoryProcessCopiesController < Decidim::Admin::ApplicationController
10
8
  include Concerns::ParticipatoryProcessAdmin
11
9
 
12
10
  def new
@@ -30,12 +28,6 @@ module Decidim
30
28
  end
31
29
  end
32
30
  end
33
-
34
- private
35
-
36
- def collection
37
- @collection ||= Decidim::ParticipatoryProcessesWithUserRole.for(current_user, :admin)
38
- end
39
31
  end
40
32
  end
41
33
  end
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory process groups.
8
6
  #
9
- class ParticipatoryProcessGroupsController < ApplicationController
7
+ class ParticipatoryProcessGroupsController < Decidim::Admin::ApplicationController
10
8
  helper_method :collection, :participatory_process_group
11
9
 
12
10
  def index
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory process publications.
8
6
  #
9
- class ParticipatoryProcessPublicationsController < ApplicationController
7
+ class ParticipatoryProcessPublicationsController < Decidim::Admin::ApplicationController
10
8
  include Concerns::ParticipatoryProcessAdmin
11
9
 
12
10
  def create
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory process step activations.
8
6
  #
9
- class ParticipatoryProcessStepActivationsController < ApplicationController
7
+ class ParticipatoryProcessStepActivationsController < Decidim::Admin::ApplicationController
10
8
  include Concerns::ParticipatoryProcessAdmin
11
9
 
12
10
  def create
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory process step ordering.
8
6
  #
9
- class ParticipatoryProcessStepOrderingController < ApplicationController
7
+ class ParticipatoryProcessStepOrderingController < Decidim::Admin::ApplicationController
10
8
  include Concerns::ParticipatoryProcessAdmin
11
9
 
12
10
  def create
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory process steps.
8
6
  #
9
- class ParticipatoryProcessStepsController < ApplicationController
7
+ class ParticipatoryProcessStepsController < Decidim::Admin::ApplicationController
10
8
  include Concerns::ParticipatoryProcessAdmin
11
9
 
12
10
  def index
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory process user roles.
8
6
  #
9
- class ParticipatoryProcessUserRolesController < ApplicationController
7
+ class ParticipatoryProcessUserRolesController < Decidim::Admin::ApplicationController
10
8
  include Concerns::ParticipatoryProcessAdmin
11
9
 
12
10
  def index
@@ -38,7 +36,7 @@ module Decidim
38
36
  def edit
39
37
  @user_role = collection.find(params[:id])
40
38
  authorize! :update, @user_role
41
- @form = form(ParticipatoryProcessUserRoleForm).from_model(@user_role.user, current_process: current_participatory_process)
39
+ @form = form(ParticipatoryProcessUserRoleForm).from_model(@user_role.user)
42
40
  end
43
41
 
44
42
  def update
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing participatory processes.
8
6
  #
9
- class ParticipatoryProcessesController < ApplicationController
7
+ class ParticipatoryProcessesController < Decidim::Admin::ApplicationController
10
8
  helper Decidim::OrganizationScopesHelper
11
9
  helper_method :current_participatory_process
12
10
 
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing all scopes at the admin panel.
8
6
  #
9
- class ScopesController < ApplicationController
7
+ class ScopesController < Decidim::Admin::ApplicationController
10
8
  layout "decidim/admin/settings"
11
9
 
12
10
  def index
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing all pages at the admin panel.
8
6
  #
9
- class StaticPagesController < ApplicationController
7
+ class StaticPagesController < Decidim::Admin::ApplicationController
10
8
  layout "decidim/admin/pages"
11
9
 
12
10
  def index
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/admin/application_controller"
4
-
5
3
  module Decidim
6
4
  module Admin
7
5
  # Controller that allows managing all admins at the admin panel.
8
6
  #
9
- class UsersController < Admin::ApplicationController
7
+ class UsersController < Decidim::Admin::ApplicationController
10
8
  def index
11
9
  authorize! :index, :admin_users
12
10
  @users = collection.page(params[:page]).per(15)
@@ -31,6 +31,7 @@ module Decidim
31
31
  attribute :banner_image
32
32
  attribute :remove_banner_image
33
33
  attribute :participatory_process_group_id, Integer
34
+ attribute :show_statistics, Boolean
34
35
 
35
36
  validates :slug, presence: true
36
37
  validates :title, :subtitle, :description, :short_description, translatable_presence: true
@@ -88,5 +88,9 @@
88
88
  <%= form.select :participatory_process_group_id, process_groups_for_select, prompt: I18n.t("decidim.participatory_processes.participatory_process_groups.none") %>
89
89
  <% end %>
90
90
  </div>
91
+
92
+ <div class="row column">
93
+ <%= form.check_box :show_statistics %>
94
+ </div>
91
95
  </div>
92
96
  </div>
@@ -33,7 +33,8 @@ module Decidim
33
33
  current_organization: my_process.organization,
34
34
  scope: my_process.scope,
35
35
  errors: my_process.errors,
36
- participatory_process_group: my_process.participatory_process_group
36
+ participatory_process_group: my_process.participatory_process_group,
37
+ show_statistics: my_process.show_statistics
37
38
  }
38
39
  }
39
40
  end
@@ -1,4 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "decidim/core/test/factories"
4
- require "decidim/admin/test/factories"
@@ -80,7 +80,7 @@ describe "Admin manage participatory processes", type: :feature do
80
80
 
81
81
  it "update a participatory process without images does not delete them" do
82
82
  click_link translated(participatory_process3.title)
83
- click_processes_menu_link "Info"
83
+ click_submenu_link "Info"
84
84
  click_button "Update"
85
85
 
86
86
  within ".callout-wrapper" do
@@ -35,7 +35,8 @@ module Decidim
35
35
  }
36
36
  end
37
37
  let(:slug) { "slug" }
38
- let(:attachment) { test_file("city.jpeg", "image/jpeg") }
38
+ let(:attachment) { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
39
+ let(:show_statistics) { true }
39
40
  let(:attributes) do
40
41
  {
41
42
  "participatory_process" => {
@@ -53,7 +54,8 @@ module Decidim
53
54
  "short_description_ca" => short_description[:ca],
54
55
  "hero_image" => attachment,
55
56
  "banner_image" => attachment,
56
- "slug" => slug
57
+ "slug" => slug,
58
+ "show_statistics" => show_statistics
57
59
  }
58
60
  }
59
61
  end
@@ -86,7 +88,7 @@ module Decidim
86
88
  end
87
89
 
88
90
  context "when images are not the expected type" do
89
- let(:attachment) { test_file("Exampledocument.pdf", "application/pdf") }
91
+ let(:attachment) { Decidim::Dev.test_file("Exampledocument.pdf", "application/pdf") }
90
92
 
91
93
  it { is_expected.not_to be_valid }
92
94
  end
@@ -21,7 +21,7 @@ module Decidim
21
21
  ca: "Descripció"
22
22
  }
23
23
  end
24
- let(:attachment) { test_file("city.jpeg", "image/jpeg") }
24
+ let(:attachment) { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
25
25
 
26
26
  let(:attributes) do
27
27
  {
@@ -56,7 +56,7 @@ module Decidim
56
56
  end
57
57
 
58
58
  context "when images are not the expected type" do
59
- let(:attachment) { test_file("Exampledocument.pdf", "application/pdf") }
59
+ let(:attachment) { Decidim::Dev.test_file("Exampledocument.pdf", "application/pdf") }
60
60
 
61
61
  it { is_expected.not_to be_valid }
62
62
  end
@@ -3,19 +3,14 @@
3
3
  RSpec.shared_context "participatory process admin" do
4
4
  let(:organization) { create(:organization) }
5
5
  let!(:user) { create(:user, :admin, :confirmed, organization: organization) }
6
+
6
7
  let(:participatory_process) { create(:participatory_process, organization: organization) }
7
- let(:process_admin) { create :user, :confirmed, organization: organization }
8
- let!(:user_role) { create :participatory_process_user_role, user: process_admin, participatory_process: participatory_process }
8
+ let!(:process_admin) { create :user, :process_admin, :confirmed, organization: organization, participatory_process: participatory_process }
9
+
9
10
  let(:image1_filename) { "city.jpeg" }
10
- let(:image1_path) do
11
- File.expand_path(File.join(__dir__, "..", "..", "..", "decidim-dev", "spec", "support", image1_filename))
12
- end
11
+ let(:image1_path) { Decidim::Dev.asset(image1_filename) }
13
12
  let(:image2_filename) { "city2.jpeg" }
14
- let(:image2_path) do
15
- File.expand_path(File.join(__dir__, "..", "..", "..", "decidim-dev", "spec", "support", image2_filename))
16
- end
13
+ let(:image2_path) { Decidim::Dev.asset(image2_filename) }
17
14
  let(:image3_filename) { "city3.jpeg" }
18
- let(:image3_path) do
19
- File.expand_path(File.join(__dir__, "..", "..", "..", "decidim-dev", "spec", "support", image3_filename))
20
- end
15
+ let(:image3_path) { Decidim::Dev.asset(image3_filename) }
21
16
  end
@@ -7,9 +7,3 @@ ENV["ENGINE_NAME"] = File.dirname(__dir__).split("/").last
7
7
  Decidim::Dev.dummy_app_path = File.expand_path(File.join("..", "spec", "decidim_dummy_app"))
8
8
 
9
9
  require "decidim/dev/test/base_spec_helper"
10
-
11
- Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
12
-
13
- RSpec.configure do |config|
14
- config.include ProcessesMenuLinksHelpers
15
- end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "decidim/features/namer"
3
+ require "decidim/features/namer"
4
4
 
5
5
  Decidim.register_feature(:budgets) do |feature|
6
6
  feature.engine = Decidim::Budgets::Engine
@@ -19,10 +19,17 @@ Decidim.register_feature(:budgets) do |feature|
19
19
  resource.template = "decidim/budgets/projects/linked_projects"
20
20
  end
21
21
 
22
- feature.register_stat :projects_count, primary: true do |features, start_at, end_at|
22
+ feature.register_stat :projects_count, primary: true, priority: Decidim::StatsRegistry::HIGH_PRIORITY do |features, start_at, end_at|
23
23
  Decidim::Budgets::FilteredProjects.for(features, start_at, end_at).count
24
24
  end
25
25
 
26
+ feature.register_stat :orders_count do |features, start_at, end_at|
27
+ orders = Decidim::Budgets::Order.where(feature: features)
28
+ orders = orders.where("created_at >= ?", start_at) if start_at.present?
29
+ orders = orders.where("created_at <= ?", end_at) if end_at.present?
30
+ orders.count
31
+ end
32
+
26
33
  feature.register_stat :comments_count, tag: :comments do |features, start_at, end_at|
27
34
  projects = Decidim::Budgets::FilteredProjects.for(features, start_at, end_at)
28
35
  Decidim::Comments::Comment.where(root_commentable: projects).count
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "decidim/core/test/factories"
4
- require "decidim/admin/test/factories"
5
- require "decidim/budgets/test/factories"
6
4
  require "decidim/proposals/test/factories"
5
+ require "decidim/comments/test/factories"
6
+
7
+ require "decidim/budgets/test/factories"
@@ -52,18 +52,18 @@ The frontend code can be found in the folder `app/frontend` instead of `app/asse
52
52
 
53
53
  #### Developing React components
54
54
 
55
- You need to execute `yarn start` in a separate terminal, in the `decidim` root folder while you are developing this module. When you are finished you can build the project for production like this: `yarn build:prod`. We are checking in the bundle into the repository.
55
+ You need to execute `npm start` in a separate terminal, in the `decidim` root folder while you are developing this module. When you are finished you can build the project for production like this: `npm run build:prod`. We are checking in the bundle into the repository.
56
56
 
57
57
  #### Run tests
58
58
 
59
- You can execute `yarn test` to run the javascript test suite or you can run `yarn test:watch` to listen for file changes.
59
+ You can execute `npm test` to run the javascript test suite or you can run `npm test:watch` to listen for file changes.
60
60
 
61
61
  #### GraphQL schema and Typescript
62
62
 
63
63
  Since we are using Typescript we can generate interfaces and types from our schema using the following command:
64
64
 
65
65
  ```bash
66
- yarn run graphql:generate_schema_types
66
+ npm run graphql:generate_schema_types
67
67
  ```
68
68
 
69
69
  This command will create a file called `app/frontend/support/schema.ts` that can be used to strict type checking in our components.
@@ -74,7 +74,7 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
74
74
  },
75
75
  },
76
76
  },
77
- update: (store, result: DownVoteMutation) => {
77
+ update: (store, { data }: { data: DownVoteMutation }) => {
78
78
  const variables = {
79
79
  commentableId: ownProps.rootCommentable.id,
80
80
  commentableType: ownProps.rootCommentable.type,
@@ -84,8 +84,8 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
84
84
  const commentReducer = (comment: CommentFragment): CommentFragment => {
85
85
  const replies = comment.comments || [];
86
86
 
87
- if (comment.id === ownProps.comment.id && result.comment) {
88
- return result.comment.downVote;
87
+ if (comment.id === ownProps.comment.id && data.comment) {
88
+ return data.comment.downVote;
89
89
  }
90
90
 
91
91
  return {
@@ -72,7 +72,7 @@ const UpVoteButtonWithMutation = graphql(upVoteMutation, {
72
72
  },
73
73
  },
74
74
  },
75
- update: (store, result: UpVoteMutation) => {
75
+ update: (store, { data }: { data: UpVoteMutation }) => {
76
76
  const variables = {
77
77
  commentableId: ownProps.rootCommentable.id,
78
78
  commentableType: ownProps.rootCommentable.type,
@@ -82,8 +82,8 @@ const UpVoteButtonWithMutation = graphql(upVoteMutation, {
82
82
  const commentReducer = (comment: CommentFragment): CommentFragment => {
83
83
  const replies = comment.comments || [];
84
84
 
85
- if (comment.id === ownProps.comment.id && result.comment) {
86
- return result.comment.upVote;
85
+ if (comment.id === ownProps.comment.id && data.comment) {
86
+ return data.comment.upVote;
87
87
  }
88
88
 
89
89
  return {
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "decidim/core/test/factories"
4
- require "decidim/admin/test/factories"
5
-
6
3
  FactoryGirl.define do
7
4
  factory :comment, class: "Decidim::Comments::Comment" do
8
5
  author { build(:user, organization: commentable.organization) }