decidim-assemblies 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/commands/decidim/assemblies/admin/create_assembly.rb +18 -6
- data/app/commands/decidim/assemblies/admin/create_assembly_admin.rb +29 -10
- data/app/commands/decidim/assemblies/admin/destroy_assembly_admin.rb +53 -0
- data/app/commands/decidim/assemblies/admin/publish_assembly.rb +8 -3
- data/app/commands/decidim/assemblies/admin/unpublish_assembly.rb +9 -4
- data/app/commands/decidim/assemblies/admin/update_assembly.rb +11 -1
- data/app/commands/decidim/assemblies/admin/update_assembly_admin.rb +11 -1
- data/app/controllers/decidim/assemblies/admin/assembly_attachment_collections_controller.rb +26 -0
- data/app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb +2 -2
- data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +6 -4
- data/app/controllers/decidim/assemblies/assemblies_controller.rb +1 -0
- data/app/forms/decidim/assemblies/admin/assembly_copy_form.rb +1 -1
- data/app/forms/decidim/assemblies/admin/assembly_form.rb +7 -1
- data/app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb +4 -0
- data/app/models/decidim/assemblies/abilities/admin/assembly_role_ability.rb +2 -2
- data/app/models/decidim/assemblies/abilities/assembly_role_ability.rb +2 -2
- data/app/models/decidim/assembly.rb +11 -3
- data/app/models/decidim/assembly_user_role.rb +8 -0
- data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +61 -0
- data/app/presenters/decidim/assemblies/admin_log/assembly_user_role_presenter.rb +53 -0
- data/app/presenters/decidim/assemblies/admin_log/value_types/role_presenter.rb +22 -0
- data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +4 -0
- data/app/views/decidim/assemblies/assemblies/show.html.erb +9 -0
- data/app/views/layouts/decidim/admin/assembly.html.erb +15 -3
- data/config/locales/ca.yml +22 -2
- data/config/locales/en.yml +20 -0
- data/config/locales/es.yml +20 -0
- data/config/locales/eu.yml +20 -0
- data/config/locales/fi.yml +20 -0
- data/config/locales/fr.yml +32 -12
- data/config/locales/gl.yml +20 -0
- data/config/locales/it.yml +20 -0
- data/config/locales/nl.yml +20 -0
- data/config/locales/pl.yml +20 -5
- data/config/locales/pt-BR.yml +20 -0
- data/config/locales/pt.yml +20 -0
- data/config/locales/sv.yml +20 -0
- data/config/locales/uk.yml +28 -4
- data/db/migrate/20180125104426_add_reference_to_assemblies.rb +7 -0
- data/db/migrate/20180216091553_add_area_to_assemblies.rb +7 -0
- data/lib/decidim/assemblies/admin_engine.rb +1 -0
- data/lib/decidim/assemblies/participatory_space.rb +14 -0
- data/lib/decidim/assemblies/version.rb +1 -1
- metadata +16 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bce6f82592435d8eaf24b82b7e6268882e112d7ca1bf0a7199f8cd760cfa7e4
|
4
|
+
data.tar.gz: 01576d6f352a674f5bd0d28ab756176b07be3711167cf8050083900a5a9b2155
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d6d72634ae5a8248be2845d9827c04853c7db7f08e311bfb58873ef868d80f2545eef306b54541080781f1082721fb6380edf7ed82f82cdb8ce1e35325f718
|
7
|
+
data.tar.gz: 93e76dc2e1b02588b66d6e2b67bea301c1675c6a6b036098232e0919f7590396f92ed49c85903526f967fc7aed0db0a858bd202a85f16f50a7cbb1656887d3e0
|
@@ -21,9 +21,9 @@ module Decidim
|
|
21
21
|
# Returns nothing.
|
22
22
|
def call
|
23
23
|
return broadcast(:invalid) if form.invalid?
|
24
|
-
assembly = create_assembly
|
25
24
|
|
26
25
|
if assembly.persisted?
|
26
|
+
add_admins_as_followers(assembly)
|
27
27
|
broadcast(:ok, assembly)
|
28
28
|
else
|
29
29
|
form.errors.add(:hero_image, assembly.errors[:hero_image]) if assembly.errors.include? :hero_image
|
@@ -36,8 +36,10 @@ module Decidim
|
|
36
36
|
|
37
37
|
attr_reader :form
|
38
38
|
|
39
|
-
def
|
40
|
-
assembly
|
39
|
+
def assembly
|
40
|
+
@assembly ||= Decidim.traceability.create(
|
41
|
+
Assembly,
|
42
|
+
form.current_user,
|
41
43
|
organization: form.current_organization,
|
42
44
|
title: form.title,
|
43
45
|
subtitle: form.subtitle,
|
@@ -50,6 +52,7 @@ module Decidim
|
|
50
52
|
promoted: form.promoted,
|
51
53
|
scopes_enabled: form.scopes_enabled,
|
52
54
|
scope: form.scope,
|
55
|
+
area: form.area,
|
53
56
|
developer_group: form.developer_group,
|
54
57
|
local_area: form.local_area,
|
55
58
|
target: form.target,
|
@@ -57,10 +60,19 @@ module Decidim
|
|
57
60
|
participatory_structure: form.participatory_structure,
|
58
61
|
meta_scope: form.meta_scope
|
59
62
|
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_admins_as_followers(assembly)
|
66
|
+
assembly.organization.admins.each do |admin|
|
67
|
+
form = Decidim::FollowForm
|
68
|
+
.from_params(followable_gid: assembly.to_signed_global_id.to_s)
|
69
|
+
.with_context(
|
70
|
+
current_organization: assembly.organization,
|
71
|
+
current_user: admin
|
72
|
+
)
|
60
73
|
|
61
|
-
|
62
|
-
|
63
|
-
assembly
|
74
|
+
Decidim::CreateFollow.new(form, admin).call
|
75
|
+
end
|
64
76
|
end
|
65
77
|
end
|
66
78
|
end
|
@@ -27,8 +27,9 @@ module Decidim
|
|
27
27
|
return broadcast(:invalid) if form.invalid?
|
28
28
|
|
29
29
|
ActiveRecord::Base.transaction do
|
30
|
-
|
30
|
+
@user = @user ||= existing_user || new_user
|
31
31
|
create_role
|
32
|
+
add_admin_as_follower
|
32
33
|
end
|
33
34
|
|
34
35
|
broadcast(:ok)
|
@@ -42,15 +43,20 @@ module Decidim
|
|
42
43
|
attr_reader :form, :assembly, :current_user, :user
|
43
44
|
|
44
45
|
def create_role
|
45
|
-
Decidim
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
Decidim.traceability.perform_action!(
|
47
|
+
:create,
|
48
|
+
Decidim::AssemblyUserRole,
|
49
|
+
current_user,
|
50
|
+
resource: {
|
51
|
+
title: user.name
|
52
|
+
}
|
53
|
+
) do
|
54
|
+
Decidim::AssemblyUserRole.find_or_create_by!(
|
55
|
+
role: form.role.to_sym,
|
56
|
+
user: user,
|
57
|
+
assembly: @assembly
|
58
|
+
)
|
59
|
+
end
|
54
60
|
end
|
55
61
|
|
56
62
|
def existing_user
|
@@ -87,6 +93,19 @@ module Decidim
|
|
87
93
|
return "invite_admin" if form.role == "admin"
|
88
94
|
"invite_collaborator"
|
89
95
|
end
|
96
|
+
|
97
|
+
def add_admin_as_follower
|
98
|
+
return if user.follows?(assembly)
|
99
|
+
|
100
|
+
form = Decidim::FollowForm
|
101
|
+
.from_params(followable_gid: assembly.to_signed_global_id.to_s)
|
102
|
+
.with_context(
|
103
|
+
current_organization: assembly.organization,
|
104
|
+
current_user: user
|
105
|
+
)
|
106
|
+
|
107
|
+
Decidim::CreateFollow.new(form, user).call
|
108
|
+
end
|
90
109
|
end
|
91
110
|
end
|
92
111
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Assemblies
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic when destroying an assembly
|
7
|
+
# admin in the system.
|
8
|
+
class DestroyAssemblyAdmin < Rectify::Command
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
# role - the AssemblyUserRole to destroy
|
12
|
+
# current_user - the user performing this action
|
13
|
+
def initialize(role, current_user)
|
14
|
+
@role = role
|
15
|
+
@current_user = current_user
|
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
|
+
destroy_role!
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :role, :current_user
|
32
|
+
|
33
|
+
def destroy_role!
|
34
|
+
extra_info = {
|
35
|
+
resource: {
|
36
|
+
title: role.user.name
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
Decidim.traceability.perform_action!(
|
41
|
+
"delete",
|
42
|
+
role,
|
43
|
+
current_user,
|
44
|
+
extra_info
|
45
|
+
) do
|
46
|
+
role.destroy!
|
47
|
+
role
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -8,8 +8,10 @@ module Decidim
|
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# assembly - A Assembly that will be published
|
11
|
-
|
11
|
+
# current_user - the user performing the action
|
12
|
+
def initialize(assembly, current_user)
|
12
13
|
@assembly = assembly
|
14
|
+
@current_user = current_user
|
13
15
|
end
|
14
16
|
|
15
17
|
# Executes the command. Broadcasts these events:
|
@@ -21,13 +23,16 @@ module Decidim
|
|
21
23
|
def call
|
22
24
|
return broadcast(:invalid) if assembly.nil? || assembly.published?
|
23
25
|
|
24
|
-
|
26
|
+
Decidim.traceability.perform_action!("publish", assembly, current_user) do
|
27
|
+
assembly.publish!
|
28
|
+
end
|
29
|
+
|
25
30
|
broadcast(:ok)
|
26
31
|
end
|
27
32
|
|
28
33
|
private
|
29
34
|
|
30
|
-
attr_reader :assembly
|
35
|
+
attr_reader :assembly, :current_user
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -7,9 +7,11 @@ module Decidim
|
|
7
7
|
class UnpublishAssembly < Rectify::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
|
-
# assembly - A Assembly that will be
|
11
|
-
|
10
|
+
# assembly - A Assembly that will be published
|
11
|
+
# current_user - the user performing the action
|
12
|
+
def initialize(assembly, current_user)
|
12
13
|
@assembly = assembly
|
14
|
+
@current_user = current_user
|
13
15
|
end
|
14
16
|
|
15
17
|
# Executes the command. Broadcasts these events:
|
@@ -21,13 +23,16 @@ module Decidim
|
|
21
23
|
def call
|
22
24
|
return broadcast(:invalid) if assembly.nil? || !assembly.published?
|
23
25
|
|
24
|
-
|
26
|
+
Decidim.traceability.perform_action!("unpublish", assembly, current_user) do
|
27
|
+
assembly.unpublish!
|
28
|
+
end
|
29
|
+
|
25
30
|
broadcast(:ok)
|
26
31
|
end
|
27
32
|
|
28
33
|
private
|
29
34
|
|
30
|
-
attr_reader :assembly
|
35
|
+
attr_reader :assembly, :current_user
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -40,7 +40,16 @@ module Decidim
|
|
40
40
|
|
41
41
|
def update_assembly
|
42
42
|
@assembly.assign_attributes(attributes)
|
43
|
-
|
43
|
+
save_assembly if @assembly.valid?
|
44
|
+
end
|
45
|
+
|
46
|
+
def save_assembly
|
47
|
+
transaction do
|
48
|
+
@assembly.save!
|
49
|
+
Decidim.traceability.perform_action!(:update, @assembly, form.current_user) do
|
50
|
+
@assembly
|
51
|
+
end
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
def attributes
|
@@ -58,6 +67,7 @@ module Decidim
|
|
58
67
|
short_description: form.short_description,
|
59
68
|
scopes_enabled: form.scopes_enabled,
|
60
69
|
scope: form.scope,
|
70
|
+
area: form.area,
|
61
71
|
developer_group: form.developer_group,
|
62
72
|
local_area: form.local_area,
|
63
73
|
target: form.target,
|
@@ -34,7 +34,17 @@ module Decidim
|
|
34
34
|
attr_reader :form, :user_role
|
35
35
|
|
36
36
|
def update_role!
|
37
|
-
|
37
|
+
log_info = {
|
38
|
+
resource: {
|
39
|
+
title: user_role.user.name
|
40
|
+
}
|
41
|
+
}
|
42
|
+
Decidim.traceability.update!(
|
43
|
+
user_role,
|
44
|
+
form.current_user,
|
45
|
+
{ role: form.role },
|
46
|
+
log_info
|
47
|
+
)
|
38
48
|
end
|
39
49
|
end
|
40
50
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Assemblies
|
5
|
+
module Admin
|
6
|
+
# Controller that allows managing all the attachment collections for an assembly.
|
7
|
+
#
|
8
|
+
class AssemblyAttachmentCollectionsController < Decidim::Admin::ApplicationController
|
9
|
+
include Concerns::AssemblyAdmin
|
10
|
+
include Decidim::Admin::Concerns::HasAttachmentCollections
|
11
|
+
|
12
|
+
def after_destroy_path
|
13
|
+
assembly_attachment_collections_path(current_assembly)
|
14
|
+
end
|
15
|
+
|
16
|
+
def collection_for
|
17
|
+
current_assembly
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorization_object
|
21
|
+
@attachment_collection || AttachmentCollection
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -11,7 +11,7 @@ module Decidim
|
|
11
11
|
def create
|
12
12
|
authorize! :publish, current_assembly
|
13
13
|
|
14
|
-
PublishAssembly.call(current_assembly) do
|
14
|
+
PublishAssembly.call(current_assembly, current_user) do
|
15
15
|
on(:ok) do
|
16
16
|
flash[:notice] = I18n.t("assembly_publications.create.success", scope: "decidim.admin")
|
17
17
|
end
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
def destroy
|
28
28
|
authorize! :publish, current_assembly
|
29
29
|
|
30
|
-
UnpublishAssembly.call(current_assembly) do
|
30
|
+
UnpublishAssembly.call(current_assembly, current_user) do
|
31
31
|
on(:ok) do
|
32
32
|
flash[:notice] = I18n.t("assembly_publications.destroy.success", scope: "decidim.admin")
|
33
33
|
end
|
@@ -61,11 +61,13 @@ module Decidim
|
|
61
61
|
def destroy
|
62
62
|
@assembly_user_role = collection.find(params[:id])
|
63
63
|
authorize! :destroy, @assembly_user_role
|
64
|
-
@assembly_user_role.destroy!
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
DestroyAssemblyAdmin.call(@assembly_user_role, current_user) do
|
66
|
+
on(:ok) do
|
67
|
+
flash[:notice] = I18n.t("assembly_user_roles.destroy.success", scope: "decidim.admin")
|
68
|
+
redirect_to assembly_user_roles_path(current_assembly)
|
69
|
+
end
|
70
|
+
end
|
69
71
|
end
|
70
72
|
|
71
73
|
def resend_invitation
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
attribute :copy_categories, Boolean
|
18
18
|
attribute :copy_features, Boolean
|
19
19
|
|
20
|
-
validates :slug, presence: true, format: { with: Decidim::
|
20
|
+
validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
|
21
21
|
validates :title, translatable_presence: true
|
22
22
|
validate :slug_uniqueness
|
23
23
|
|
@@ -32,10 +32,12 @@ module Decidim
|
|
32
32
|
attribute :banner_image
|
33
33
|
attribute :remove_banner_image
|
34
34
|
attribute :show_statistics, Boolean
|
35
|
+
attribute :area_id, Integer
|
35
36
|
|
36
|
-
validates :slug, presence: true, format: { with: Decidim::
|
37
|
+
validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
|
37
38
|
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
38
39
|
validates :scope, presence: true, if: proc { |object| object.scope_id.present? }
|
40
|
+
validates :area, presence: true, if: proc { |object| object.area_id.present? }
|
39
41
|
|
40
42
|
validate :slug_uniqueness
|
41
43
|
|
@@ -50,6 +52,10 @@ module Decidim
|
|
50
52
|
@scope ||= current_organization.scopes.where(id: scope_id).first
|
51
53
|
end
|
52
54
|
|
55
|
+
def area
|
56
|
+
@area ||= current_organization.areas.where(id: area_id).first
|
57
|
+
end
|
58
|
+
|
53
59
|
private
|
54
60
|
|
55
61
|
def slug_uniqueness
|
@@ -35,6 +35,10 @@ module Decidim
|
|
35
35
|
attachment.attached_to.is_a?(Decidim::Assembly) && can_manage_assembly?(attachment.attached_to)
|
36
36
|
end
|
37
37
|
|
38
|
+
can :manage, AttachmentCollection do |attachment_collection|
|
39
|
+
attachment_collection.collection_for.is_a?(Decidim::Assembly) && can_manage_assembly?(attachment_collection.collection_for)
|
40
|
+
end
|
41
|
+
|
38
42
|
can :manage, AssemblyUserRole do |role|
|
39
43
|
can_manage_assembly?(role.assembly) && role.user != @user
|
40
44
|
end
|
@@ -29,7 +29,7 @@ module Decidim
|
|
29
29
|
def define_assembly_abilities; end
|
30
30
|
|
31
31
|
# Abstract: A subclass must define this method returning a valid role.
|
32
|
-
# See
|
32
|
+
# See AssemblyUserRole::ROLES for more information.
|
33
33
|
def role
|
34
34
|
raise "Needs implementation"
|
35
35
|
end
|
@@ -42,7 +42,7 @@ module Decidim
|
|
42
42
|
# Returns a collection of assemblies where the given user has the
|
43
43
|
# specific role privilege.
|
44
44
|
def assemblies_with_role_privileges
|
45
|
-
@
|
45
|
+
@assemblies_with_role_privileges ||= Decidim::Assemblies::AssembliesWithUserRole.for(@user, role)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Whether the user has at least one assembly to manage or not.
|
@@ -30,7 +30,7 @@ module Decidim
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Abstract: A subclass must define this method returning a valid role.
|
33
|
-
# See
|
33
|
+
# See AssemblyUserRole::ROLES for more information.
|
34
34
|
def role
|
35
35
|
raise "Needs implementation"
|
36
36
|
end
|
@@ -38,7 +38,7 @@ module Decidim
|
|
38
38
|
# Returns a collection of Participatory assemblies where the given user has the
|
39
39
|
# specific role privilege.
|
40
40
|
def assemblies_with_role_privileges
|
41
|
-
@
|
41
|
+
@assemblies_with_role_privileges ||= Decidim::Assemblies::AssembliesWithUserRole.for(@user, role)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Whether the user has at least one assembly to manage or not.
|