decidim-admin 0.0.5 → 0.0.6

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/stylesheets/decidim/admin/_sidebar.scss +30 -1
  4. data/app/assets/stylesheets/decidim/admin/_tables.scss +3 -0
  5. data/app/assets/stylesheets/decidim/admin/application.scss +3 -0
  6. data/app/commands/decidim/admin/create_participatory_process.rb +4 -1
  7. data/app/commands/decidim/admin/create_participatory_process_admin.rb +26 -7
  8. data/app/commands/decidim/admin/create_participatory_process_group.rb +54 -0
  9. data/app/commands/decidim/admin/create_participatory_process_step.rb +0 -1
  10. data/app/commands/decidim/admin/destroy_participatory_process_step.rb +3 -1
  11. data/app/commands/decidim/admin/hide_resource.rb +37 -0
  12. data/app/commands/decidim/admin/reorder_participatory_process_steps.rb +1 -0
  13. data/app/commands/decidim/admin/unreport_resource.rb +33 -0
  14. data/app/commands/decidim/admin/update_participatory_process.rb +4 -2
  15. data/app/commands/decidim/admin/update_participatory_process_group.rb +57 -0
  16. data/app/commands/decidim/admin/update_participatory_process_step.rb +1 -2
  17. data/app/controllers/decidim/admin/application_controller.rb +4 -0
  18. data/app/controllers/decidim/admin/categories_controller.rb +1 -1
  19. data/app/controllers/decidim/admin/feature_permissions_controller.rb +2 -2
  20. data/{lib → app/controllers}/decidim/admin/features/base_controller.rb +0 -0
  21. data/app/controllers/decidim/admin/moderations_controller.rb +64 -0
  22. data/app/controllers/decidim/admin/newsletters_controller.rb +1 -1
  23. data/app/controllers/decidim/admin/participatory_process_groups_controller.rb +86 -0
  24. data/app/controllers/decidim/admin/participatory_process_publications_controller.rb +1 -1
  25. data/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +1 -1
  26. data/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +1 -1
  27. data/app/controllers/decidim/admin/participatory_process_steps_controller.rb +1 -1
  28. data/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +3 -3
  29. data/app/controllers/decidim/admin/participatory_processes_controller.rb +3 -2
  30. data/app/forms/decidim/admin/organization_form.rb +1 -0
  31. data/app/forms/decidim/admin/participatory_process_form.rb +12 -1
  32. data/app/forms/decidim/admin/participatory_process_group_form.rb +23 -0
  33. data/app/forms/decidim/admin/participatory_process_step_form.rb +0 -1
  34. data/app/forms/decidim/admin/participatory_process_user_role_form.rb +5 -1
  35. data/app/helpers/decidim/admin/application_helper.rb +1 -0
  36. data/app/helpers/decidim/admin/process_groups_for_select_helper.rb +20 -0
  37. data/app/helpers/decidim/admin/processes_for_select_helper.rb +22 -0
  38. data/app/models/decidim/admin/abilities/admin_user.rb +2 -0
  39. data/app/models/decidim/admin/abilities/participatory_process_admin.rb +4 -0
  40. data/app/models/decidim/admin/participatory_process_user_role.rb +1 -1
  41. data/app/queries/decidim/admin/process_admins.rb +43 -0
  42. data/app/views/decidim/admin/moderations/index.html.erb +65 -0
  43. data/app/views/decidim/admin/organization/_form.html.erb +4 -0
  44. data/app/views/decidim/admin/participatory_process_groups/_form.html.erb +17 -0
  45. data/app/views/decidim/admin/participatory_process_groups/edit.html.erb +13 -0
  46. data/app/views/decidim/admin/participatory_process_groups/index.html.erb +38 -0
  47. data/app/views/decidim/admin/participatory_process_groups/new.html.erb +11 -0
  48. data/app/views/decidim/admin/participatory_process_groups/show.html.erb +23 -0
  49. data/app/views/decidim/admin/participatory_process_steps/_form.html.erb +0 -4
  50. data/app/views/decidim/admin/participatory_process_steps/show.html.erb +4 -5
  51. data/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +27 -24
  52. data/app/views/decidim/admin/participatory_processes/_form.html.erb +10 -1
  53. data/app/views/decidim/admin/participatory_processes/show.html.erb +15 -1
  54. data/app/views/layouts/decidim/admin/_header.html.erb +1 -0
  55. data/app/views/layouts/decidim/admin/_language_chooser.html.erb +14 -0
  56. data/app/views/layouts/decidim/admin/_sidebar.html.erb +2 -0
  57. data/app/views/layouts/decidim/admin/participatory_process.html.erb +5 -0
  58. data/config/i18n-tasks.yml +3 -1
  59. data/config/locales/ca.yml +83 -3
  60. data/config/locales/en.yml +81 -1
  61. data/config/locales/es.yml +81 -1
  62. data/config/locales/eu.yml +340 -1
  63. data/config/locales/fi.yml +464 -0
  64. data/config/routes.rb +8 -0
  65. data/db/seeds.rb +1 -1
  66. data/lib/decidim/admin/engine.rb +1 -0
  67. metadata +27 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae578c5b5087d3e005a7216cd75b4231041c2572
4
- data.tar.gz: 43e84e9529896d1a143e33fa1f0d3bb436586cab
3
+ metadata.gz: 453c1956a164da5d0e33cb0bb83bf80b5e98af5b
4
+ data.tar.gz: 392bb84e1a55a2ff9091b7d31787df52c31b867c
5
5
  SHA512:
6
- metadata.gz: 2c505c94e7f607153ce8f8db38e319886393abd5c3460eab9bf111de20f025a78bdd545bbfe8e3d9688c891de4e6f86dd73646379d9b7cee36721a5d8b22ce3b
7
- data.tar.gz: 4404856289d63a285fc84ba7f7c7f964d44df6909f726a2081728e0c345c57218e0ee0fd373fd113febc3d7cd244bbbe5c7b15ddfa59f67c28457641883f3733
6
+ metadata.gz: b4de3b16e2c4cdb283bbd914af8302b1a1802b2a6823a9b3e741ed2feb2dca233d44d6dee6a59c84bb68ffc7f9d35ff316f450e5bc01409826bc27d5f0795ba4
7
+ data.tar.gz: d8c631dc2ae0a6138e5b40e11ce79b32eae1daf4a5ad1d2df456dac2ab7410db255e930e5cb3901e1ed256c442da3c8b9b55953f7f03038f7b2b0b03d5761994
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Decidim::Admin
2
2
 
3
- This library adds and administration dashboard so users can manage their
3
+ This library adds an administration dashboard so users can manage their
4
4
  organization, participatory processes and all other entities.
5
5
 
6
6
  ## Usage
@@ -60,6 +60,7 @@
60
60
 
61
61
  .session-box {
62
62
  padding: $global-padding 0;
63
+ border-bottom: 1px solid black;
63
64
 
64
65
  @include grid-row;
65
66
 
@@ -69,5 +70,33 @@
69
70
  overflow: hidden;
70
71
  }
71
72
  .sign-out{ @include grid-column(4); }
73
+
72
74
  }
73
- }
75
+ }
76
+
77
+ .dropdown > li > a{
78
+ padding-left: 0;
79
+ }
80
+ .dropdown{
81
+ display: inline-block;
82
+ vertical-align: middle;
83
+ }
84
+
85
+ .is-dropdown-submenu{
86
+ z-index: 2;
87
+ text-align: left;
88
+ background: lighten($black, 5) !important;
89
+ border: none !important;
90
+ box-shadow: 0 3px 5px rgba(0, 0, 0, .3) !important;;
91
+ min-width: 250px !important;
92
+ a{
93
+ color: $light-gray;
94
+ padding: .5rem;
95
+ }
96
+ a:hover{
97
+ color: lighten($light-gray, 20);
98
+ }
99
+ li:hover{
100
+ background: lighten($black, 10);
101
+ }
102
+ }
@@ -2,6 +2,9 @@ table{
2
2
  td.actions, th.actions{
3
3
  text-align: right;
4
4
  }
5
+ td.center, th.center{
6
+ text-align: center;
7
+ }
5
8
  }
6
9
 
7
10
  tbody.sortable tr {
@@ -11,6 +11,9 @@
11
11
  @import "decidim/editor";
12
12
  @import "decidim/utils/fontface";
13
13
 
14
+ @import "foundation";
15
+ @include foundation-everything;
16
+
14
17
  body {
15
18
  font-family: 'Source Sans Pro', sans-serif;
16
19
  }
@@ -46,7 +46,10 @@ module Decidim
46
46
  hero_image: form.hero_image,
47
47
  banner_image: form.banner_image,
48
48
  promoted: form.promoted,
49
- organization: form.current_organization
49
+ meta_scope: form.meta_scope,
50
+ scope: form.scope,
51
+ organization: form.current_organization,
52
+ participatory_process_group: form.participatory_process_group
50
53
  )
51
54
 
52
55
  return process unless process.valid?
@@ -9,8 +9,9 @@ module Decidim
9
9
  # form - A form object with the params.
10
10
  # participatory_process - The ParticipatoryProcess that will hold the
11
11
  # user role
12
- def initialize(form, participatory_process)
12
+ def initialize(form, current_user, participatory_process)
13
13
  @form = form
14
+ @current_user = current_user
14
15
  @participatory_process = participatory_process
15
16
  end
16
17
 
@@ -24,7 +25,7 @@ module Decidim
24
25
  return broadcast(:invalid) if form.invalid?
25
26
  return broadcast(:invalid) unless user
26
27
 
27
- create_participatory_process_admin
28
+ create_role
28
29
  broadcast(:ok)
29
30
  rescue ActiveRecord::RecordInvalid
30
31
  form.errors.add(:email, :taken)
@@ -33,21 +34,39 @@ module Decidim
33
34
 
34
35
  private
35
36
 
36
- attr_reader :form, :participatory_process
37
+ attr_reader :form, :participatory_process, :current_user
37
38
 
38
- def create_participatory_process_admin
39
+ def create_role
39
40
  ParticipatoryProcessUserRole.create!(
40
- role: :admin,
41
+ role: form.role.to_sym,
41
42
  user: user,
42
43
  participatory_process: @participatory_process
43
44
  )
44
45
  end
45
46
 
46
47
  def user
47
- User.where(
48
+ @user ||= User.where(
48
49
  email: form.email,
49
50
  organization: participatory_process.organization
50
- ).first
51
+ ).first || InviteUser.call(user_form) do
52
+ on(:ok) do |user|
53
+ return user
54
+ end
55
+ end
56
+ end
57
+
58
+ def user_form
59
+ OpenStruct.new(name: form.name,
60
+ email: form.email.downcase,
61
+ organization: participatory_process.organization,
62
+ roles: [form.role.to_sym],
63
+ invited_by: current_user,
64
+ invitation_instructions: invitation_instructions)
65
+ end
66
+
67
+ def invitation_instructions
68
+ return "invite_admin" if form.role == "admin"
69
+ "invite_collaborator"
51
70
  end
52
71
  end
53
72
  end
@@ -0,0 +1,54 @@
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 group in the system.
6
+ class CreateParticipatoryProcessGroup < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form)
11
+ @form = form
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid.
17
+ # - :invalid if the form wasn't valid and we couldn't proceed.
18
+ #
19
+ # Returns nothing.
20
+ def call
21
+ return broadcast(:invalid) if form.invalid?
22
+ group = create_participatory_process_group
23
+
24
+ if group.persisted?
25
+ broadcast(:ok, group)
26
+ else
27
+ form.errors.add(:hero_image, group.errors[:hero_image]) if group.errors.include? :hero_image
28
+ form.errors.add(:banner_image, group.errors[:banner_image]) if group.errors.include? :banner_image
29
+ broadcast(:invalid)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :form
36
+
37
+ def create_participatory_process_group
38
+ transaction do
39
+ group = ParticipatoryProcessGroup.create(
40
+ name: form.name,
41
+ description: form.description,
42
+ hero_image: form.hero_image,
43
+ participatory_processes: participatory_processes,
44
+ organization: form.current_organization
45
+ )
46
+ end
47
+ end
48
+
49
+ def participatory_processes
50
+ Decidim::ParticipatoryProcess.where(id: form.participatory_process_ids)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -35,7 +35,6 @@ module Decidim
35
35
  ParticipatoryProcessStep.create!(
36
36
  title: form.title,
37
37
  description: form.description,
38
- short_description: form.short_description,
39
38
  start_date: form.start_date,
40
39
  end_date: form.end_date,
41
40
  participatory_process: @participatory_process
@@ -29,8 +29,10 @@ module Decidim
29
29
  private
30
30
 
31
31
  def reorder_steps
32
+ steps = @participatory_process.steps.reload
33
+
32
34
  ReorderParticipatoryProcessSteps
33
- .new(@participatory_process.steps, @participatory_process.steps.map(&:id))
35
+ .new(steps, steps.map(&:id))
34
36
  .call
35
37
  end
36
38
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # A command with all the business logic when a user hides a resource.
5
+ class HideResource < Rectify::Command
6
+ # Public: Initializes the command.
7
+ #
8
+ # reportable - A Decidim::Reportable
9
+ def initialize(reportable)
10
+ @reportable = reportable
11
+ end
12
+
13
+ # Executes the command. Broadcasts these events:
14
+ #
15
+ # - :ok when everything is valid, together with the resource.
16
+ # - :invalid if the resource is already hidden
17
+ #
18
+ # Returns nothing.
19
+ def call
20
+ return broadcast(:invalid) unless hideable?
21
+
22
+ hide!
23
+ broadcast(:ok, @reportable)
24
+ end
25
+
26
+ private
27
+
28
+ def hideable?
29
+ !@reportable.hidden? && @reportable.reported?
30
+ end
31
+
32
+ def hide!
33
+ @reportable.moderation.update_attributes!(hidden_at: Time.current)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -36,6 +36,7 @@ module Decidim
36
36
 
37
37
  ParticipatoryProcessStep.transaction do
38
38
  collection.update_all(position: nil)
39
+ collection.reload
39
40
  collection.update(data.keys, data.values)
40
41
  end
41
42
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # A command with all the business logic when a user unreports a resource.
5
+ class UnreportResource < Rectify::Command
6
+ # Public: Initializes the command.
7
+ #
8
+ # reportable - A Decidim::Reportable
9
+ def initialize(reportable)
10
+ @reportable = reportable
11
+ end
12
+
13
+ # Executes the command. Broadcasts these events:
14
+ #
15
+ # - :ok when everything is valid, together with the resource.
16
+ # - :invalid if the resource is not reported
17
+ #
18
+ # Returns nothing.
19
+ def call
20
+ return broadcast(:invalid) unless @reportable.reported?
21
+
22
+ unreport!
23
+ broadcast(:ok, @reportable)
24
+ end
25
+
26
+ private
27
+
28
+ def unreport!
29
+ @reportable.moderation.update_attributes!(report_count: 0, hidden_at: nil)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -58,8 +58,10 @@ module Decidim
58
58
  target: form.target,
59
59
  participatory_scope: form.participatory_scope,
60
60
  participatory_structure: form.participatory_structure,
61
- end_date: form.end_date
62
- }.compact
61
+ meta_scope: form.meta_scope,
62
+ end_date: form.end_date,
63
+ participatory_process_group: form.participatory_process_group
64
+ }
63
65
  end
64
66
  end
65
67
  end
@@ -0,0 +1,57 @@
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 group in the system.
6
+ class UpdateParticipatoryProcessGroup < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # participatory_process_group - the ParticipatoryProcessGroup to update
10
+ # form - A form object with the params.
11
+ def initialize(participatory_process_group, form)
12
+ @participatory_process_group = participatory_process_group
13
+ @form = form
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if the form wasn't valid and we couldn't proceed.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ return broadcast(:invalid) if form.invalid?
24
+ update_participatory_process_group
25
+
26
+ if @participatory_process_group.valid?
27
+ broadcast(:ok, @participatory_process_group)
28
+ else
29
+ form.errors.add(:hero_image, @participatory_process_group.errors[:hero_image]) if @participatory_process_group.errors.include? :hero_image
30
+ broadcast(:invalid)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form
37
+
38
+ def update_participatory_process_group
39
+ @participatory_process_group.assign_attributes(attributes)
40
+ @participatory_process_group.save! if @participatory_process_group.valid?
41
+ end
42
+
43
+ def attributes
44
+ {
45
+ name: form.name,
46
+ hero_image: form.hero_image,
47
+ description: form.description,
48
+ participatory_processes: participatory_processes
49
+ }
50
+ end
51
+
52
+ def participatory_processes
53
+ Decidim::ParticipatoryProcess.where(id: form.participatory_process_ids)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -40,8 +40,7 @@ module Decidim
40
40
  title: form.title,
41
41
  start_date: form.start_date,
42
42
  end_date: form.end_date,
43
- description: form.description,
44
- short_description: form.short_description
43
+ description: form.description
45
44
  }
46
45
  end
47
46
  end
@@ -7,7 +7,11 @@ module Decidim
7
7
  include NeedsAuthorization
8
8
  include FormFactory
9
9
  include LocaleSwitcher
10
+ include PayloadInfo
10
11
  helper Decidim::DecidimFormHelper
12
+ helper Decidim::ReplaceButtonsHelper
13
+ helper Decidim::OrganizationScopesHelper
14
+ helper Decidim::TranslationsHelper
11
15
 
12
16
  helper Decidim::LanguageChooserHelper
13
17
 
@@ -3,7 +3,7 @@ require_dependency "decidim/admin/application_controller"
3
3
 
4
4
  module Decidim
5
5
  module Admin
6
- # Controller that allows managing all the Admins.
6
+ # Controller that allows managing categories.
7
7
  #
8
8
  class CategoriesController < ApplicationController
9
9
  include Concerns::ParticipatoryProcessAdmin
@@ -3,7 +3,7 @@ require_dependency "decidim/admin/application_controller"
3
3
 
4
4
  module Decidim
5
5
  module Admin
6
- # Controller that allows managing all the Admins.
6
+ # Controller that allows managing feature permissions.
7
7
  #
8
8
  class FeaturePermissionsController < ApplicationController
9
9
  include Concerns::ParticipatoryProcessAdmin
@@ -48,7 +48,7 @@ module Decidim
48
48
  end
49
49
 
50
50
  def authorizations
51
- Decidim.authorization_handlers.map(&:handler_name)
51
+ current_organization.available_authorizations.map(&:constantize).map(&:handler_name)
52
52
  end
53
53
 
54
54
  def feature