decidim-assemblies 0.11.2 → 0.12.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/admin/decidim_assemblies_manifest.js +1 -0
- data/app/assets/javascripts/decidim/assemblies/admin/assembly_members.js.es6 +37 -0
- data/app/cells/decidim/assemblies/assembly_cell.rb +19 -0
- data/app/cells/decidim/assemblies/assembly_m/footer.erb +15 -0
- data/app/cells/decidim/assemblies/assembly_m/tags.erb +1 -0
- data/app/cells/decidim/assemblies/assembly_m_cell.rb +50 -0
- data/app/cells/decidim/assemblies/assembly_member/show.erb +53 -0
- data/app/cells/decidim/assemblies/assembly_member_cell.rb +21 -0
- data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +73 -0
- data/app/commands/decidim/assemblies/admin/destroy_assembly_member.rb +56 -0
- data/app/commands/decidim/assemblies/admin/update_assembly_member.rb +69 -0
- data/app/controllers/decidim/assemblies/admin/application_controller.rb +14 -0
- data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +8 -12
- data/app/controllers/decidim/assemblies/admin/assembly_attachment_collections_controller.rb +1 -1
- data/app/controllers/decidim/assemblies/admin/assembly_attachments_controller.rb +1 -1
- data/app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb +3 -3
- data/app/controllers/decidim/assemblies/admin/assembly_members_controller.rb +86 -0
- data/app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb +3 -3
- data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +7 -7
- data/app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb +20 -8
- data/app/controllers/decidim/assemblies/admin/participatory_space_private_users_controller.rb +1 -1
- data/app/controllers/decidim/assemblies/application_controller.rb +32 -0
- data/app/controllers/decidim/assemblies/assemblies_controller.rb +2 -2
- data/app/controllers/decidim/assemblies/assembly_members_controller.rb +35 -0
- data/app/forms/decidim/assemblies/admin/assembly_member_form.rb +51 -0
- data/app/models/decidim/assembly.rb +12 -1
- data/app/models/decidim/assembly_member.rb +24 -0
- data/app/permissions/decidim/assemblies/permissions.rb +230 -0
- data/app/presenters/decidim/admin/assembly_member_presenter.rb +24 -0
- data/app/presenters/decidim/assemblies/admin_log/assembly_member_presenter.rb +52 -0
- data/app/presenters/decidim/assemblies/admin_log/value_types/member_position_presenter.rb +21 -0
- data/app/presenters/decidim/assembly_member_presenter.rb +46 -0
- data/app/queries/decidim/assemblies/admin/assembly_members.rb +55 -0
- data/app/views/decidim/assemblies/_assembly.html.erb +1 -22
- data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +2 -0
- data/app/views/decidim/assemblies/admin/assemblies/edit.html.erb +2 -2
- data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +8 -8
- data/app/views/decidim/assemblies/admin/assembly_members/_form.html.erb +66 -0
- data/app/views/decidim/assemblies/admin/assembly_members/edit.html.erb +7 -0
- data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +91 -0
- data/app/views/decidim/assemblies/admin/assembly_members/new.html.erb +7 -0
- data/app/views/decidim/assemblies/admin/assembly_user_roles/index.html.erb +4 -4
- data/app/views/decidim/assemblies/assemblies/show.html.erb +1 -2
- data/app/views/decidim/assemblies/assembly_members/index.html.erb +10 -0
- data/app/views/decidim/assemblies/pages/user_profile/_member_of.html.erb +12 -0
- data/app/views/decidim/assembly_members/_assembly_member.html.erb +1 -0
- data/app/views/layouts/decidim/_assembly_header.html.erb +10 -1
- data/app/views/layouts/decidim/admin/assemblies.html.erb +7 -10
- data/app/views/layouts/decidim/admin/assembly.html.erb +19 -11
- data/config/locales/ca.yml +84 -0
- data/config/locales/en.yml +84 -0
- data/config/locales/es.yml +84 -0
- data/config/locales/eu.yml +84 -0
- data/config/locales/fi.yml +84 -0
- data/config/locales/fr.yml +84 -0
- data/config/locales/gl.yml +84 -0
- data/config/locales/it.yml +84 -0
- data/config/locales/nl.yml +84 -0
- data/config/locales/pl.yml +90 -0
- data/config/locales/pt-BR.yml +84 -0
- data/config/locales/pt.yml +84 -0
- data/config/locales/ru.yml +96 -11
- data/config/locales/sv.yml +84 -0
- data/config/locales/uk.yml +91 -1
- data/db/migrate/20180314143822_add_assembly_members.rb +21 -0
- data/db/migrate/20180426162405_assembly_member_belongs_to_user.rb +7 -0
- data/db/migrate/20180515073049_update_assembly_members_index.rb +8 -0
- data/lib/decidim/assemblies/admin_engine.rb +2 -12
- data/lib/decidim/assemblies/engine.rb +21 -10
- data/lib/decidim/assemblies/participatory_space.rb +58 -2
- data/lib/decidim/assemblies/test/factories.rb +35 -0
- data/lib/decidim/assemblies/version.rb +1 -1
- metadata +41 -22
- data/app/controllers/decidim/assemblies/categories_controller.rb +0 -13
- data/app/models/decidim/assemblies/abilities/admin/admin_ability.rb +0 -20
- data/app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb +0 -58
- data/app/models/decidim/assemblies/abilities/admin/assembly_collaborator_ability.rb +0 -25
- data/app/models/decidim/assemblies/abilities/admin/assembly_moderator_ability.rb +0 -33
- data/app/models/decidim/assemblies/abilities/admin/assembly_role_ability.rb +0 -65
- data/app/models/decidim/assemblies/abilities/admin_ability.rb +0 -16
- data/app/models/decidim/assemblies/abilities/assembly_admin_ability.rb +0 -15
- data/app/models/decidim/assemblies/abilities/assembly_collaborator_ability.rb +0 -15
- data/app/models/decidim/assemblies/abilities/assembly_moderator_ability.rb +0 -15
- data/app/models/decidim/assemblies/abilities/assembly_role_ability.rb +0 -51
- data/app/models/decidim/assemblies/abilities/everyone_ability.rb +0 -17
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Admin
|
6
|
-
# Controller that allows managing categories for assemblies.
|
7
|
-
#
|
8
|
-
class CategoriesController < Decidim::Admin::CategoriesController
|
9
|
-
include Concerns::AssemblyAdmin
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities for an admin user. Intended to be used with `cancancan`.
|
8
|
-
class AdminAbility < Decidim::Abilities::AdminAbility
|
9
|
-
def define_abilities
|
10
|
-
super
|
11
|
-
|
12
|
-
can :manage, Assembly
|
13
|
-
can :manage, Decidim::AssemblyUserRole
|
14
|
-
can :manage, Decidim::ParticipatorySpacePrivateUser
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities for an assembly admin user. Intended to be used
|
8
|
-
# with `cancancan`.
|
9
|
-
class AssemblyAdminAbility < Decidim::Assemblies::Abilities::Admin::AssemblyRoleAbility
|
10
|
-
def define_abilities
|
11
|
-
super
|
12
|
-
|
13
|
-
can :manage, Assembly do |assembly|
|
14
|
-
can_manage_assembly?(assembly)
|
15
|
-
end
|
16
|
-
|
17
|
-
cannot :create, Assembly
|
18
|
-
cannot :destroy, Assembly
|
19
|
-
end
|
20
|
-
|
21
|
-
def role
|
22
|
-
:admin
|
23
|
-
end
|
24
|
-
|
25
|
-
def define_assembly_abilities
|
26
|
-
can :manage, Component do |component|
|
27
|
-
can_manage_assembly?(component.participatory_space)
|
28
|
-
end
|
29
|
-
|
30
|
-
can :manage, Category do |category|
|
31
|
-
can_manage_assembly?(category.participatory_space)
|
32
|
-
end
|
33
|
-
|
34
|
-
can :manage, Attachment do |attachment|
|
35
|
-
attachment.attached_to.is_a?(Decidim::Assembly) && can_manage_assembly?(attachment.attached_to)
|
36
|
-
end
|
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
|
-
|
42
|
-
can :manage, AssemblyUserRole do |role|
|
43
|
-
can_manage_assembly?(role.assembly) && role.user != @user
|
44
|
-
end
|
45
|
-
|
46
|
-
can :manage, Moderation do |moderation|
|
47
|
-
can_manage_assembly?(moderation.participatory_space)
|
48
|
-
end
|
49
|
-
|
50
|
-
can [:unreport, :hide], Reportable do |reportable|
|
51
|
-
can_manage_assembly?(reportable.component.participatory_space)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities for an assembly collaborator user. Intended to be used
|
8
|
-
# with `cancancan`.
|
9
|
-
class AssemblyCollaboratorAbility < Decidim::Assemblies::Abilities::Admin::AssemblyRoleAbility
|
10
|
-
def define_abilities
|
11
|
-
super
|
12
|
-
|
13
|
-
can [:read, :preview], Assembly do |assembly|
|
14
|
-
can_manage_assembly?(assembly)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def role
|
19
|
-
:collaborator
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities for an assembly moderator user. Intended to be used
|
8
|
-
# with `cancancan`.
|
9
|
-
class AssemblyModeratorAbility < Decidim::Assemblies::Abilities::Admin::AssemblyRoleAbility
|
10
|
-
def define_abilities
|
11
|
-
super
|
12
|
-
|
13
|
-
can [:index, :read], Assembly do |assembly|
|
14
|
-
can_manage_assembly?(assembly)
|
15
|
-
end
|
16
|
-
|
17
|
-
can :manage, Moderation do |moderation|
|
18
|
-
can_manage_assembly?(moderation.participatory_space)
|
19
|
-
end
|
20
|
-
|
21
|
-
can [:unreport, :hide], Reportable do |reportable|
|
22
|
-
can_manage_assembly?(reportable.component.participatory_space)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def role
|
27
|
-
:moderator
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities for an assembly admin user, whatever they role. Intended to be used
|
8
|
-
# with `cancancan`.
|
9
|
-
class AssemblyRoleAbility
|
10
|
-
include CanCan::Ability
|
11
|
-
|
12
|
-
def initialize(user, context)
|
13
|
-
@user = user
|
14
|
-
@context = context
|
15
|
-
|
16
|
-
# Define abilities if the user is not an admin and has at least one assembly to manage.
|
17
|
-
if not_admin? && has_manageable_assemblies?
|
18
|
-
define_abilities
|
19
|
-
|
20
|
-
define_assembly_abilities if current_assembly && can_manage_assembly?(current_assembly)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Grant access to admin panel by default.
|
25
|
-
def define_abilities
|
26
|
-
can :read, :admin_dashboard
|
27
|
-
end
|
28
|
-
|
29
|
-
def define_assembly_abilities; end
|
30
|
-
|
31
|
-
# Abstract: A subclass must define this method returning a valid role.
|
32
|
-
# See AssemblyUserRole::ROLES for more information.
|
33
|
-
def role
|
34
|
-
raise "Needs implementation"
|
35
|
-
end
|
36
|
-
|
37
|
-
# Whether the user is an admin or not.
|
38
|
-
def not_admin?
|
39
|
-
@user && !@user.admin?
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns a collection of assemblies where the given user has the
|
43
|
-
# specific role privilege.
|
44
|
-
def assemblies_with_role_privileges
|
45
|
-
@assemblies_with_role_privileges ||= Decidim::Assemblies::AssembliesWithUserRole.for(@user, role)
|
46
|
-
end
|
47
|
-
|
48
|
-
# Whether the user has at least one assembly to manage or not.
|
49
|
-
def has_manageable_assemblies?
|
50
|
-
assemblies_with_role_privileges.any?
|
51
|
-
end
|
52
|
-
|
53
|
-
# Whether the user can manage the given assembly or not.
|
54
|
-
def can_manage_assembly?(assembly)
|
55
|
-
assemblies_with_role_privileges.include? assembly
|
56
|
-
end
|
57
|
-
|
58
|
-
def current_assembly
|
59
|
-
@current_assembly ||= @context[:current_participatory_space]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
# Defines the abilities for an admin user. Intended to be used with `cancancan`.
|
7
|
-
class AdminAbility < Decidim::Abilities::AdminAbility
|
8
|
-
def define_abilities
|
9
|
-
super
|
10
|
-
|
11
|
-
can :read, Assembly
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
# Defines the abilities for an assembly admin user.
|
7
|
-
# Intended to be used with `cancancan`.
|
8
|
-
class AssemblyAdminAbility < Decidim::Assemblies::Abilities::AssemblyRoleAbility
|
9
|
-
def role
|
10
|
-
:admin
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
# Defines the abilities for an assembly collaborator user
|
7
|
-
# Intended to be used with `cancancan`.
|
8
|
-
class AssemblyCollaboratorAbility < Decidim::Assemblies::Abilities::AssemblyRoleAbility
|
9
|
-
def role
|
10
|
-
:collaborator
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
# Defines the abilities for an assembly moderator user
|
7
|
-
# Intended to be used with `cancancan`.
|
8
|
-
class AssemblyModeratorAbility < Decidim::Assemblies::Abilities::AssemblyRoleAbility
|
9
|
-
def role
|
10
|
-
:moderator
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
# Defines the abilities for any user that can manage assemblies (whatever their role).
|
7
|
-
# Intended to be used with `cancancan`.
|
8
|
-
class AssemblyRoleAbility
|
9
|
-
include CanCan::Ability
|
10
|
-
|
11
|
-
attr_reader :user
|
12
|
-
|
13
|
-
def initialize(user, context)
|
14
|
-
@user = user
|
15
|
-
@context = context
|
16
|
-
|
17
|
-
define_abilities if not_admin? && has_manageable_assemblies?
|
18
|
-
end
|
19
|
-
|
20
|
-
def define_abilities
|
21
|
-
can :read, :admin_dashboard
|
22
|
-
can :read, Assembly
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
# Whether the user is an admin or not.
|
28
|
-
def not_admin?
|
29
|
-
@user && !@user.admin?
|
30
|
-
end
|
31
|
-
|
32
|
-
# Abstract: A subclass must define this method returning a valid role.
|
33
|
-
# See AssemblyUserRole::ROLES for more information.
|
34
|
-
def role
|
35
|
-
raise "Needs implementation"
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns a collection of Participatory assemblies where the given user has the
|
39
|
-
# specific role privilege.
|
40
|
-
def assemblies_with_role_privileges
|
41
|
-
@assemblies_with_role_privileges ||= Decidim::Assemblies::AssembliesWithUserRole.for(@user, role)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Whether the user has at least one assembly to manage or not.
|
45
|
-
def has_manageable_assemblies?
|
46
|
-
assemblies_with_role_privileges.any?
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Assemblies
|
5
|
-
module Abilities
|
6
|
-
# Defines the base abilities related to assemblies for any user. Guest users
|
7
|
-
# will use these too. Intended to be used with `cancancan`.
|
8
|
-
class EveryoneAbility < Decidim::Abilities::EveryoneAbility
|
9
|
-
def initialize(user, context)
|
10
|
-
super(user, context)
|
11
|
-
|
12
|
-
can :read, Assembly, &:published?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|