decidim-admin 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-admin might be problematic. Click here for more details.

Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +619 -0
  3. data/README.md +1 -1
  4. data/app/assets/javascripts/decidim/admin/application.js.es6 +12 -0
  5. data/app/assets/javascripts/decidim/admin/sort_steps.js.es6 +21 -0
  6. data/app/assets/stylesheets/decidim/admin/_tables.scss +9 -0
  7. data/app/commands/decidim/admin/activate_participatory_process_step.rb +43 -0
  8. data/app/commands/decidim/admin/create_participatory_process.rb +1 -0
  9. data/app/commands/decidim/admin/create_participatory_process_step.rb +46 -0
  10. data/app/commands/decidim/admin/deactivate_participatory_process_step.rb +35 -0
  11. data/app/commands/decidim/admin/publish_participatory_process.rb +35 -0
  12. data/app/commands/decidim/admin/reorder_participatory_process_steps.rb +47 -0
  13. data/app/commands/decidim/admin/unpublish_participatory_process.rb +35 -0
  14. data/app/commands/decidim/admin/update_participatory_process.rb +1 -0
  15. data/app/commands/decidim/admin/update_participatory_process_step.rb +49 -0
  16. data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  17. data/app/controllers/decidim/admin/application_controller.rb +4 -0
  18. data/app/controllers/decidim/admin/dashboard_controller.rb +1 -9
  19. data/app/controllers/decidim/admin/participatory_process_publications_controller.rb +49 -0
  20. data/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +56 -0
  21. data/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +30 -0
  22. data/app/controllers/decidim/admin/participatory_process_steps_controller.rb +81 -0
  23. data/app/controllers/decidim/admin/participatory_processes_controller.rb +7 -12
  24. data/app/forms/decidim/admin/participatory_process_form.rb +1 -0
  25. data/app/forms/decidim/admin/participatory_process_step_form.rb +25 -0
  26. data/app/helpers/decidim/admin/application_helper.rb +1 -0
  27. data/app/mailers/decidim/admin/application_mailer.rb +1 -1
  28. data/app/models/decidim/admin/abilities/admin.rb +21 -0
  29. data/app/views/decidim/admin/participatory_process_steps/_form.html.erb +19 -0
  30. data/app/views/decidim/admin/participatory_process_steps/_table.html.erb +53 -0
  31. data/app/views/decidim/admin/participatory_process_steps/edit.html.erb +11 -0
  32. data/app/views/decidim/admin/participatory_process_steps/new.html.erb +11 -0
  33. data/app/views/decidim/admin/participatory_process_steps/show.html.erb +22 -0
  34. data/app/views/decidim/admin/participatory_processes/_form.html.erb +4 -0
  35. data/app/views/decidim/admin/participatory_processes/index.html.erb +22 -2
  36. data/app/views/decidim/admin/participatory_processes/show.html.erb +21 -2
  37. data/config/i18n-tasks.yml +2 -2
  38. data/config/locales/ca.yml +55 -2
  39. data/config/locales/en.yml +55 -2
  40. data/config/locales/es.yml +56 -3
  41. data/config/routes.rb +10 -1
  42. data/lib/decidim/admin/engine.rb +6 -1
  43. data/vendor/assets/javascripts/html.sortable.min.js +2 -0
  44. metadata +39 -37
  45. data/app/assets/javascripts/decidim/admin/application.js +0 -22
  46. data/app/controllers/concerns/decidim/needs_authorization.rb +0 -50
  47. data/app/policies/decidim/admin/application_policy.rb +0 -20
  48. data/app/policies/decidim/admin/dashboard_policy.rb +0 -15
  49. data/app/policies/decidim/admin/organization_policy.rb +0 -15
  50. data/app/policies/decidim/admin/participatory_process_policy.rb +0 -57
@@ -1,22 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require foundation
16
- //= require turbolinks
17
- //= require_self
18
-
19
- $(document).on("turbolinks:load", function() {
20
- $(function(){ $(document).foundation(); });
21
- });
22
-
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/concern"
4
-
5
- module Decidim
6
- # Shared behaviour for controllers that need authorization to work.
7
- module NeedsAuthorization
8
- extend ActiveSupport::Concern
9
-
10
- included do
11
- include Pundit
12
- after_action :verify_authorized
13
-
14
- rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
15
-
16
- private
17
-
18
- # Overwrites the `policy` method from the `pundit` gem in order to be
19
- # able to specify which policy class should be used in each case. This is
20
- # due to `pundit` failing to correctly identify the policy class when the
21
- # model class name is scoped and the policy class is in a different scope
22
- # (eg. `Decidim::ParticipatoryProcess` and
23
- # `Decidim::Admin::ParticipatoryProcessPolicy`). The original method does
24
- # not let us specify the correct class.
25
- #
26
- # Remember that, in order to make this work, you'll need to define the
27
- # `policy_class` method in the controller, which should only return a
28
- # policy class name.
29
- #
30
- # record - the record that will be evaluated against the policy class.
31
- def policy(record)
32
- policies[record] ||= policy_class.new(current_user, record)
33
- end
34
-
35
- # Needed in order to make the `policy` method work. Overwirite it in the
36
- # given controller and make it return a Policy class.
37
- def policy_class
38
- raise NotImplementedError, "Define this method and make it return a policy class name in order to make it work"
39
- end
40
-
41
- # Handles the case when a user visits a path that is not allowed to them.
42
- # Redirects the user to the root path and shows a flash message telling
43
- # them they are not authorized.
44
- def user_not_authorized
45
- flash[:alert] = t("actions.unauthorized", scope: "decidim.admin")
46
- redirect_to(request.referrer || decidim_admin.root_path)
47
- end
48
- end
49
- end
50
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- module Decidim
3
- module Admin
4
- # Main application policy so we don't ahve to repeat the initialization
5
- # code in each Policy. To be used with Pundit.
6
- class ApplicationPolicy
7
- attr_reader :user, :record
8
-
9
- # Initializes a Policy.
10
- #
11
- # user - The User that we want to authorize.
12
- # record - The record on which to perform the authorizations.
13
- #
14
- def initialize(user, record)
15
- @user = user
16
- @record = record
17
- end
18
- end
19
- end
20
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
- module Decidim
3
- module Admin
4
- # A policy to define all the authorizations regarding a
5
- # ParticipatoryProcess, to be used with Pundit.
6
- class DashboardPolicy < ApplicationPolicy
7
- # Checks if the user can see the admin dashboard.
8
- #
9
- # Returns a Boolean.
10
- def show?
11
- user.roles.include?("admin")
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
- module Decidim
3
- module Admin
4
- # A policy to define all the authorizations regarding an Organization, to
5
- # be used with Pundit.
6
- class OrganizationPolicy < ApplicationPolicy
7
- # Checks if the user can update an organization.
8
- #
9
- # Returns a Boolean.
10
- def update?
11
- user.roles.include?("admin") && user.organization == record
12
- end
13
- end
14
- end
15
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
- module Decidim
3
- module Admin
4
- # A policy to define all the authorizations regarding a
5
- # ParticipatoryProcess, to be used with Pundit.
6
- class ParticipatoryProcessPolicy < ApplicationPolicy
7
- # Checks if the user can see the form for participatory process creation.
8
- #
9
- # Returns a Boolean.
10
- def new?
11
- user.roles.include?("admin")
12
- end
13
-
14
- # Checks if the user can create a participatory process.
15
- #
16
- # Returns a Boolean.
17
- def create?
18
- user.roles.include?("admin")
19
- end
20
-
21
- # Checks if the user can list a participatory process.
22
- #
23
- # Returns a Boolean.
24
- def index?
25
- user.roles.include?("admin") && user.organization == record.first.organization
26
- end
27
-
28
- # Checks if the user can see a participatory process.
29
- #
30
- # Returns a Boolean.
31
- def show?
32
- user.roles.include?("admin") && user.organization == record.organization
33
- end
34
-
35
- # Checks if the user can edit a participatory process.
36
- #
37
- # Returns a Boolean.
38
- def edit?
39
- user.roles.include?("admin") && user.organization == record.organization
40
- end
41
-
42
- # Checks if the user can update a participatory process.
43
- #
44
- # Returns a Boolean.
45
- def update?
46
- user.roles.include?("admin") && user.organization == record.organization
47
- end
48
-
49
- # Checks if the user can destroy a participatory process.
50
- #
51
- # Returns a Boolean.
52
- def destroy?
53
- user.roles.include?("admin") && user.organization == record.organization
54
- end
55
- end
56
- end
57
- end