decidim-assemblies 0.20.1 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/decidim/assemblies/assembly.svg +1 -3
- data/app/assets/javascripts/decidim/assemblies/orgchart.js.es6 +698 -0
- data/app/cells/decidim/assemblies/assembly_m/footer.erb +2 -2
- data/app/cells/decidim/assemblies/assembly_m_cell.rb +5 -5
- data/app/cells/decidim/assemblies/assembly_member/show.erb +4 -4
- data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies/show.erb +10 -11
- data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +1 -0
- data/app/commands/decidim/assemblies/admin/create_assemblies_type.rb +45 -0
- data/app/commands/decidim/assemblies/admin/create_assembly.rb +1 -2
- data/app/commands/decidim/assemblies/admin/create_assembly_admin.rb +2 -1
- data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +12 -3
- data/app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb +45 -0
- data/app/commands/decidim/assemblies/admin/import_assembly.rb +72 -0
- data/app/commands/decidim/assemblies/admin/notify_role_assigned_to_assembly.rb +22 -0
- data/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb +46 -0
- data/app/commands/decidim/assemblies/admin/update_assemblies_type.rb +46 -0
- data/app/commands/decidim/assemblies/admin/update_assembly.rb +11 -7
- data/app/commands/decidim/assemblies/admin/update_assembly_admin.rb +2 -1
- data/app/controllers/concerns/decidim/assemblies/admin/filterable.rb +30 -0
- data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +8 -23
- data/app/controllers/decidim/assemblies/admin/assemblies_settings_controller.rb +49 -0
- data/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +107 -0
- data/app/controllers/decidim/assemblies/admin/assembly_exports_controller.rb +24 -0
- data/app/controllers/decidim/assemblies/admin/assembly_imports_controller.rb +31 -0
- data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +2 -1
- data/app/controllers/decidim/assemblies/assemblies_controller.rb +6 -2
- data/app/controllers/decidim/assemblies/{assembly_widgets_controller.rb → widgets_controller.rb} +2 -2
- data/app/events/decidim/assemblies/create_assembly_member_event.rb +17 -0
- data/app/events/decidim/role_assigned_to_assembly_event.rb +28 -0
- data/app/forms/decidim/assemblies/admin/assemblies_setting_form.rb +14 -0
- data/app/forms/decidim/assemblies/admin/assemblies_type_form.rb +17 -0
- data/app/forms/decidim/assemblies/admin/assembly_form.rb +37 -19
- data/app/forms/decidim/assemblies/admin/assembly_import_form.rb +83 -0
- data/app/forms/decidim/assemblies/admin/assembly_user_role_form.rb +8 -2
- data/app/helpers/decidim/assemblies/admin/assemblies_helper.rb +6 -0
- data/app/helpers/decidim/assemblies/assemblies_helper.rb +6 -3
- data/app/helpers/decidim/assemblies/filter_assemblies_helper.rb +10 -7
- data/app/models/decidim/assemblies_setting.rb +17 -0
- data/app/models/decidim/assemblies_type.rb +27 -0
- data/app/models/decidim/assembly.rb +26 -3
- data/app/models/decidim/assembly_user_role.rb +1 -1
- data/app/permissions/decidim/assemblies/permissions.rb +60 -2
- data/app/presenters/decidim/assemblies/admin_log/assemblies_setting_presenter.rb +27 -0
- data/app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb +43 -0
- data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +1 -2
- data/app/presenters/decidim/assemblies/assembly_presenter.rb +29 -0
- data/app/presenters/decidim/assemblies/assembly_stats_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/assembly_type_presenter.rb +29 -0
- data/app/queries/decidim/assemblies/filtered_assemblies.rb +2 -2
- data/app/queries/decidim/assemblies/parent_assemblies_for_select.rb +42 -0
- data/app/serializers/decidim/assemblies/assembly_importer.rb +172 -0
- data/app/serializers/decidim/assemblies/assembly_serializer.rb +147 -0
- data/app/services/decidim/assemblies/assembly_search.rb +3 -3
- data/app/types/decidim/assemblies/assemblies_type_type.rb +17 -0
- data/app/types/decidim/assemblies/assembly_member_type.rb +29 -0
- data/app/types/decidim/assemblies/assembly_type.rb +67 -0
- data/app/views/decidim/assemblies/_filter_by_type.html.erb +11 -7
- data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +2 -6
- data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +18 -4
- data/app/views/decidim/assemblies/admin/assemblies_settings/_form.html.erb +10 -0
- data/app/views/decidim/assemblies/admin/assemblies_settings/edit.html.erb +6 -0
- data/app/views/decidim/assemblies/admin/assemblies_types/_form.html.erb +11 -0
- data/app/views/decidim/assemblies/admin/assemblies_types/edit.html.erb +6 -0
- data/app/views/decidim/assemblies/admin/assemblies_types/index.html.erb +43 -0
- data/app/views/decidim/assemblies/admin/assemblies_types/new.html.erb +7 -0
- data/app/views/decidim/assemblies/admin/assembly_imports/_form.html.erb +46 -0
- data/app/views/decidim/assemblies/admin/assembly_imports/new.html.erb +7 -0
- data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +30 -30
- data/app/views/decidim/assemblies/assemblies/_parent_assemblies.html.erb +2 -2
- data/app/views/decidim/assemblies/assemblies/_promoted_assembly.html.erb +3 -3
- data/app/views/decidim/assemblies/assemblies/index.html.erb +11 -8
- data/app/views/decidim/assemblies/assemblies/show.html.erb +11 -14
- data/app/views/decidim/assemblies/assembly_members/index.html.erb +1 -1
- data/app/views/layouts/decidim/admin/assemblies.html.erb +22 -0
- data/app/views/layouts/decidim/admin/assembly.html.erb +2 -2
- data/app/views/layouts/decidim/assembly.html.erb +1 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +24 -0
- data/config/locales/bg-BG.yml +7 -0
- data/config/locales/bg.yml +7 -0
- data/config/locales/ca.yml +100 -0
- data/config/locales/cs.yml +135 -35
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +99 -0
- data/config/locales/el.yml +475 -0
- data/config/locales/en.yml +100 -0
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +100 -0
- data/config/locales/es-PY.yml +100 -0
- data/config/locales/es.yml +100 -0
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +11 -0
- data/config/locales/fi-plain.yml +100 -0
- data/config/locales/fi.yml +104 -4
- data/config/locales/fr-CA.yml +478 -0
- data/config/locales/fr.yml +100 -0
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +11 -0
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +85 -2
- data/config/locales/id-ID.yml +11 -0
- data/config/locales/is-IS.yml +11 -0
- data/config/locales/is.yml +263 -0
- data/config/locales/it.yml +171 -74
- data/config/locales/ja-JP.yml +471 -0
- data/config/locales/ja.yml +471 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +454 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +97 -0
- data/config/locales/no.yml +107 -10
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +250 -151
- data/config/locales/pt-BR.yml +12 -1
- data/config/locales/pt.yml +217 -118
- data/config/locales/ro-RO.yml +441 -0
- data/config/locales/ru.yml +11 -0
- data/config/locales/sk-SK.yml +168 -0
- data/config/locales/sk.yml +172 -0
- data/config/locales/sl.yml +283 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +73 -0
- data/config/locales/sv.yml +188 -88
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +30 -0
- data/config/locales/uk.yml +11 -0
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +471 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200108113855_create_decidim_assembly_types.rb +19 -0
- data/db/migrate/20200108123050_migrate_decidim_assembly_types.rb +83 -0
- data/db/migrate/20200320105906_index_foreign_keys_in_decidim_assemblies.rb +7 -0
- data/db/migrate/20200320105907_index_foreign_keys_in_decidim_assembly_user_roles.rb +7 -0
- data/db/migrate/20200416132109_remove_legacy_decidim_assembly_type.rb +8 -0
- data/db/migrate/20200430202456_create_decidim_assemblies_settings.rb +10 -0
- data/db/seeds/city.jpeg +0 -0
- data/db/seeds/city2.jpeg +0 -0
- data/lib/decidim/assemblies/admin_engine.rb +10 -0
- data/lib/decidim/assemblies/engine.rb +8 -1
- data/lib/decidim/assemblies/participatory_space.rb +29 -15
- data/lib/decidim/assemblies/query_extensions.rb +40 -0
- data/lib/decidim/assemblies/test/factories.rb +32 -5
- data/lib/decidim/assemblies/version.rb +1 -1
- metadata +90 -12
- data/app/views/decidim/assemblies/assembly_widgets/show.html.erb +0 -11
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class RoleAssignedToAssemblyEvent < Decidim::Events::SimpleEvent
|
5
|
+
include Decidim::Events::NotificationEvent
|
6
|
+
include Decidim::Events::AuthorEvent
|
7
|
+
|
8
|
+
def notification_title
|
9
|
+
I18n.t("notification_title", i18n_options).html_safe
|
10
|
+
end
|
11
|
+
|
12
|
+
def i18n_role
|
13
|
+
I18n.t(extra["role"], "decidim.admin.models.assembly_user_role.roles", default: extra["role"])
|
14
|
+
end
|
15
|
+
|
16
|
+
def i18n_options
|
17
|
+
{
|
18
|
+
resource_path: resource_path,
|
19
|
+
resource_title: resource_title,
|
20
|
+
resource_url: resource_url,
|
21
|
+
scope: event_name,
|
22
|
+
participatory_space_title: participatory_space_title,
|
23
|
+
participatory_space_url: participatory_space_url,
|
24
|
+
role: i18n_role
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Assemblies
|
5
|
+
module Admin
|
6
|
+
# A form object used to create assembly setting from the admin dashboard.
|
7
|
+
class AssembliesSettingForm < Form
|
8
|
+
mimic :assemblies_setting
|
9
|
+
|
10
|
+
attribute :enable_organization_chart, Boolean
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Assemblies
|
5
|
+
module Admin
|
6
|
+
# A form object used to create assembly type from the admin dashboard.
|
7
|
+
class AssembliesTypeForm < Form
|
8
|
+
include TranslatableAttributes
|
9
|
+
|
10
|
+
mimic :assemblies_type
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
validates :title, translatable_presence: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -8,13 +8,12 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
class AssemblyForm < Form
|
10
10
|
include TranslatableAttributes
|
11
|
+
include Decidim::HasUploadValidations
|
11
12
|
|
12
|
-
ASSEMBLY_TYPES = %w(government executive consultative_advisory participatory working_group commission others).freeze
|
13
13
|
CREATED_BY = %w(city_council public others).freeze
|
14
14
|
|
15
15
|
mimic :assembly
|
16
16
|
|
17
|
-
translatable_attribute :assembly_type_other, String
|
18
17
|
translatable_attribute :composition, String
|
19
18
|
translatable_attribute :closing_date_reason, String
|
20
19
|
translatable_attribute :created_by_other, String
|
@@ -32,7 +31,6 @@ module Decidim
|
|
32
31
|
translatable_attribute :target, String
|
33
32
|
translatable_attribute :title, String
|
34
33
|
|
35
|
-
attribute :assembly_type, String
|
36
34
|
attribute :created_by, String
|
37
35
|
attribute :facebook_handler, String
|
38
36
|
attribute :github_handler, String
|
@@ -42,6 +40,7 @@ module Decidim
|
|
42
40
|
attribute :twitter_handler, String
|
43
41
|
attribute :youtube_handler, String
|
44
42
|
|
43
|
+
attribute :decidim_assemblies_type_id, Integer
|
45
44
|
attribute :area_id, Integer
|
46
45
|
attribute :parent_id, Integer
|
47
46
|
attribute :participatory_processes_ids, Array[Integer]
|
@@ -64,22 +63,30 @@ module Decidim
|
|
64
63
|
attribute :remove_hero_image
|
65
64
|
|
66
65
|
validates :area, presence: true, if: proc { |object| object.area_id.present? }
|
67
|
-
|
66
|
+
|
67
|
+
validates :parent, presence: true, if: ->(form) { form.parent.present? }
|
68
|
+
validate :ensure_parent_cannot_be_child, if: ->(form) { form.parent.present? }
|
69
|
+
|
68
70
|
validates :scope, presence: true, if: proc { |object| object.scope_id.present? }
|
69
71
|
validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
|
70
72
|
|
71
73
|
validate :slug_uniqueness
|
74
|
+
validate :same_type_organization, if: ->(form) { form.decidim_assemblies_type_id }
|
72
75
|
|
73
|
-
validates :assembly_type_other, translatable_presence: true, if: ->(form) { form.assembly_type == "others" }
|
74
76
|
validates :created_by_other, translatable_presence: true, if: ->(form) { form.created_by == "others" }
|
75
77
|
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
76
78
|
|
77
|
-
validates :banner_image,
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
validates :banner_image, passthru: { to: Decidim::Assembly }
|
80
|
+
validates :hero_image, passthru: { to: Decidim::Assembly }
|
81
|
+
|
82
|
+
alias organization current_organization
|
83
|
+
|
84
|
+
def ensure_parent_cannot_be_child
|
85
|
+
return if id.blank?
|
86
|
+
|
87
|
+
available_assemblies = Decidim::Assemblies::ParentAssembliesForSelect.for(current_organization, Assembly.find(id))
|
88
|
+
errors.add(:parent, :invalid) unless available_assemblies.include? parent
|
89
|
+
end
|
83
90
|
|
84
91
|
def map_model(model)
|
85
92
|
self.scope_id = model.decidim_scope_id
|
@@ -94,12 +101,8 @@ module Decidim
|
|
94
101
|
end
|
95
102
|
|
96
103
|
def assembly_types_for_select
|
97
|
-
|
98
|
-
|
99
|
-
I18n.t("assembly_types.#{type}", scope: "decidim.assemblies"),
|
100
|
-
type
|
101
|
-
]
|
102
|
-
end
|
104
|
+
@assembly_types_for_select ||= organization_assembly_types
|
105
|
+
&.map { |type| [translated_attribute(type.title), type.id] }
|
103
106
|
end
|
104
107
|
|
105
108
|
def created_by_for_select
|
@@ -117,12 +120,20 @@ module Decidim
|
|
117
120
|
|
118
121
|
def processes_for_select
|
119
122
|
@processes_for_select ||= organization_participatory_processes
|
120
|
-
|
121
|
-
|
123
|
+
&.map { |pp| [translated_attribute(pp.title), pp.id] }
|
124
|
+
&.sort_by { |arr| arr[0] }
|
125
|
+
end
|
126
|
+
|
127
|
+
def assembly_type
|
128
|
+
AssembliesType.find_by(id: decidim_assemblies_type_id)
|
122
129
|
end
|
123
130
|
|
124
131
|
private
|
125
132
|
|
133
|
+
def organization_assembly_types
|
134
|
+
AssembliesType.where(organization: current_organization)
|
135
|
+
end
|
136
|
+
|
126
137
|
def organization_participatory_processes
|
127
138
|
Decidim.find_participatory_space_manifest(:participatory_processes)
|
128
139
|
.participatory_spaces.call(current_organization)
|
@@ -140,6 +151,13 @@ module Decidim
|
|
140
151
|
|
141
152
|
errors.add(:slug, :taken)
|
142
153
|
end
|
154
|
+
|
155
|
+
def same_type_organization
|
156
|
+
return unless assembly_type
|
157
|
+
return if assembly_type.organization == current_organization
|
158
|
+
|
159
|
+
errors.add(:assembly_type, :invalid)
|
160
|
+
end
|
143
161
|
end
|
144
162
|
end
|
145
163
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Assemblies
|
5
|
+
module Admin
|
6
|
+
# A form object used to import an assembly from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class AssemblyImportForm < Form
|
10
|
+
include TranslatableAttributes
|
11
|
+
|
12
|
+
JSON_MIME_TYPE = "application/json"
|
13
|
+
# Accepted mime types
|
14
|
+
# keys: are used for dynamic help text on admin form.
|
15
|
+
# values: are used to validate the file format of imported document.
|
16
|
+
#
|
17
|
+
# WARNING: consider adding/removing the relative translation key at
|
18
|
+
# decidim.assemblies.admin.new_import.accepted_types when modifying this hash
|
19
|
+
ACCEPTED_TYPES = {
|
20
|
+
json: JSON_MIME_TYPE
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
translatable_attribute :title, String
|
24
|
+
|
25
|
+
mimic :assembly
|
26
|
+
|
27
|
+
attribute :slug, String
|
28
|
+
attribute :import_steps, Boolean, default: false
|
29
|
+
attribute :import_categories, Boolean, default: true
|
30
|
+
attribute :import_attachments, Boolean, default: true
|
31
|
+
attribute :import_components, Boolean, default: true
|
32
|
+
attribute :document
|
33
|
+
|
34
|
+
validates :document, presence: true
|
35
|
+
|
36
|
+
validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
|
37
|
+
validates :title, translatable_presence: true
|
38
|
+
validate :slug_uniqueness
|
39
|
+
|
40
|
+
validate :document_type_must_be_valid, if: :document
|
41
|
+
|
42
|
+
def document_text
|
43
|
+
@document_text ||= document&.read
|
44
|
+
end
|
45
|
+
|
46
|
+
def document_type_must_be_valid
|
47
|
+
return if valid_mime_types.include?(document_type)
|
48
|
+
|
49
|
+
errors.add(:document, i18n_invalid_document_type_text)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return ACCEPTED_MIME_TYPES plus `text/plain` for better markdown support
|
53
|
+
def valid_mime_types
|
54
|
+
ACCEPTED_TYPES.values
|
55
|
+
end
|
56
|
+
|
57
|
+
def document_type
|
58
|
+
document.content_type
|
59
|
+
end
|
60
|
+
|
61
|
+
def i18n_invalid_document_type_text
|
62
|
+
I18n.t("invalid_document_type",
|
63
|
+
scope: "activemodel.errors.models.assembly.attributes.document",
|
64
|
+
valid_mime_types: i18n_valid_mime_types_text)
|
65
|
+
end
|
66
|
+
|
67
|
+
def i18n_valid_mime_types_text
|
68
|
+
ACCEPTED_TYPES.keys.map do |mime_type|
|
69
|
+
I18n.t(mime_type, scope: "decidim.assemblies.admin.new_import.accepted_types")
|
70
|
+
end.join(", ")
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def slug_uniqueness
|
76
|
+
return unless OrganizationAssemblies.new(current_organization).query.where(slug: slug).where.not(id: id).any?
|
77
|
+
|
78
|
+
errors.add(:slug, :taken)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -12,10 +12,12 @@ module Decidim
|
|
12
12
|
attribute :email, String
|
13
13
|
attribute :role, String
|
14
14
|
|
15
|
-
validates :email, :role, presence: true
|
16
|
-
validates :name, presence: true
|
15
|
+
validates :name, :email, :role, presence: true
|
17
16
|
validates :role, inclusion: { in: Decidim::AssemblyUserRole::ROLES }
|
18
17
|
|
18
|
+
validates :name, format: { with: UserBaseEntity::REGEXP_NAME }
|
19
|
+
validate :admin_uniqueness
|
20
|
+
|
19
21
|
def roles
|
20
22
|
Decidim::AssemblyUserRole::ROLES.map do |role|
|
21
23
|
[
|
@@ -24,6 +26,10 @@ module Decidim
|
|
24
26
|
]
|
25
27
|
end
|
26
28
|
end
|
29
|
+
|
30
|
+
def admin_uniqueness
|
31
|
+
errors.add(:email, :taken) if context && context.current_organization && context.current_organization.admins.where(email: email).exists?
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -14,6 +14,12 @@ module Decidim
|
|
14
14
|
@processes_selected ||= current_assembly.linked_participatory_space_resources(:participatory_processes, "included_participatory_processes").pluck(:id)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
# Public: A collection of Assemblies that can be selected as parent
|
19
|
+
# assemblies for another assembly; to be used in forms.
|
20
|
+
def parent_assemblies_for_select
|
21
|
+
@parent_assemblies_for_select ||= ParentAssembliesForSelect.for(current_organization, current_assembly)
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -45,9 +45,12 @@ module Decidim
|
|
45
45
|
html += "<span class='definition-data__title'>#{t("assemblies.show.social_networks", scope: "decidim")}</span>".html_safe
|
46
46
|
Decidim::Assembly::SOCIAL_HANDLERS.each do |handler|
|
47
47
|
handler_name = "#{handler}_handler"
|
48
|
-
if assembly.send(handler_name).
|
49
|
-
|
50
|
-
|
48
|
+
next if assembly.send(handler_name).blank?
|
49
|
+
|
50
|
+
html += link_to handler.capitalize, "https://#{handler}.com/#{assembly.send(handler_name)}",
|
51
|
+
target: "_blank",
|
52
|
+
class: "",
|
53
|
+
title: t("assemblies.show.social_networks_title", scope: "decidim") << " " << handler.capitalize.to_s, rel: "noopener"
|
51
54
|
end
|
52
55
|
html += "</div>".html_safe
|
53
56
|
end
|
@@ -7,10 +7,10 @@ module Decidim
|
|
7
7
|
# `filter` returns a Filter object from Decidim::FilterResource
|
8
8
|
module FilterAssembliesHelper
|
9
9
|
def available_filters
|
10
|
-
|
10
|
+
@available_filters ||= [t("all", scope: "decidim.assemblies.filter")] + organization_assembly_types
|
11
11
|
end
|
12
12
|
|
13
|
-
def filter_link(
|
13
|
+
def filter_link(type_id)
|
14
14
|
Decidim::Assemblies::Engine
|
15
15
|
.routes
|
16
16
|
.url_helpers
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
filter: {
|
19
19
|
scope_id: filter.scope_id,
|
20
20
|
area_id: filter.area_id,
|
21
|
-
|
21
|
+
type_id: type_id
|
22
22
|
}
|
23
23
|
)
|
24
24
|
end
|
@@ -27,12 +27,15 @@ module Decidim
|
|
27
27
|
t("help", scope: "decidim.assemblies.filter")
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
30
|
+
def current_filter_name
|
31
|
+
type = AssembliesType.find_by(id: filter.type_id)
|
32
|
+
return translated_attribute type.title if type
|
33
|
+
|
34
|
+
t("all", scope: "decidim.assemblies.filter")
|
32
35
|
end
|
33
36
|
|
34
|
-
def
|
35
|
-
|
37
|
+
def organization_assembly_types
|
38
|
+
AssembliesType.where(organization: current_organization)&.map { |type| [translated_attribute(type.title), type.id] }
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Assemblies setting.
|
5
|
+
class AssembliesSetting < ApplicationRecord
|
6
|
+
include Decidim::Traceable
|
7
|
+
include Decidim::Loggable
|
8
|
+
|
9
|
+
belongs_to :organization,
|
10
|
+
foreign_key: "decidim_organization_id",
|
11
|
+
class_name: "Decidim::Organization"
|
12
|
+
|
13
|
+
def self.log_presenter_class_for(_log)
|
14
|
+
Decidim::Assemblies::AdminLog::AssembliesSettingPresenter
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Assembly type.
|
5
|
+
class AssembliesType < ApplicationRecord
|
6
|
+
include Decidim::Traceable
|
7
|
+
include Decidim::Loggable
|
8
|
+
include Decidim::TranslatableResource
|
9
|
+
|
10
|
+
translatable_fields :title
|
11
|
+
|
12
|
+
belongs_to :organization,
|
13
|
+
foreign_key: "decidim_organization_id",
|
14
|
+
class_name: "Decidim::Organization"
|
15
|
+
|
16
|
+
has_many :assemblies,
|
17
|
+
foreign_key: "decidim_assemblies_type_id",
|
18
|
+
class_name: "Decidim::Assembly",
|
19
|
+
dependent: :nullify
|
20
|
+
|
21
|
+
validates :title, presence: true
|
22
|
+
|
23
|
+
def self.log_presenter_class_for(_log)
|
24
|
+
Decidim::Assemblies::AdminLog::AssembliesTypePresenter
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -24,7 +24,7 @@ module Decidim
|
|
24
24
|
include Decidim::HasAttachmentCollections
|
25
25
|
include Decidim::Participable
|
26
26
|
include Decidim::Publicable
|
27
|
-
include Decidim::
|
27
|
+
include Decidim::ScopableParticipatorySpace
|
28
28
|
include Decidim::Followable
|
29
29
|
include Decidim::HasReference
|
30
30
|
include Decidim::Traceable
|
@@ -32,11 +32,16 @@ module Decidim
|
|
32
32
|
include Decidim::ParticipatorySpaceResourceable
|
33
33
|
include Decidim::HasPrivateUsers
|
34
34
|
include Decidim::Searchable
|
35
|
+
include Decidim::HasUploadValidations
|
36
|
+
include Decidim::TranslatableResource
|
35
37
|
|
36
38
|
SOCIAL_HANDLERS = [:twitter, :facebook, :instagram, :youtube, :github].freeze
|
37
|
-
ASSEMBLY_TYPES = %w(government executive consultative_advisory participatory working_group commission others).freeze
|
38
39
|
CREATED_BY = %w(city_council public others).freeze
|
39
40
|
|
41
|
+
translatable_fields :title, :subtitle, :short_description, :description, :developer_group, :meta_scope, :local_area,
|
42
|
+
:target, :participatory_scope, :participatory_structure, :purpose_of_action, :composition, :created_by_other,
|
43
|
+
:closing_date_reason, :internal_organisation, :special_features
|
44
|
+
|
40
45
|
belongs_to :organization,
|
41
46
|
foreign_key: "decidim_organization_id",
|
42
47
|
class_name: "Decidim::Organization"
|
@@ -44,6 +49,10 @@ module Decidim
|
|
44
49
|
foreign_key: "decidim_area_id",
|
45
50
|
class_name: "Decidim::Area",
|
46
51
|
optional: true
|
52
|
+
belongs_to :assembly_type,
|
53
|
+
foreign_key: "decidim_assemblies_type_id",
|
54
|
+
class_name: "Decidim::AssembliesType",
|
55
|
+
optional: true
|
47
56
|
has_many :categories,
|
48
57
|
foreign_key: "decidim_participatory_space_id",
|
49
58
|
foreign_type: "decidim_participatory_space_type",
|
@@ -60,7 +69,10 @@ module Decidim
|
|
60
69
|
has_many :children, foreign_key: "parent_id", class_name: "Decidim::Assembly", inverse_of: :parent, dependent: :destroy
|
61
70
|
belongs_to :parent, foreign_key: "parent_id", class_name: "Decidim::Assembly", inverse_of: :children, optional: true, counter_cache: :children_count
|
62
71
|
|
72
|
+
validates_upload :hero_image
|
63
73
|
mount_uploader :hero_image, Decidim::HeroImageUploader
|
74
|
+
|
75
|
+
validates_upload :banner_image
|
64
76
|
mount_uploader :banner_image, Decidim::BannerImageUploader
|
65
77
|
|
66
78
|
validates :slug, uniqueness: { scope: :organization }
|
@@ -148,6 +160,17 @@ module Decidim
|
|
148
160
|
closing_date < Date.current
|
149
161
|
end
|
150
162
|
|
163
|
+
def user_roles(role_name = nil)
|
164
|
+
roles = Decidim::AssemblyUserRole.where(assembly: self)
|
165
|
+
return roles if role_name.blank?
|
166
|
+
|
167
|
+
roles.where(role: role_name)
|
168
|
+
end
|
169
|
+
|
170
|
+
def attachment_context
|
171
|
+
:admin
|
172
|
+
end
|
173
|
+
|
151
174
|
private
|
152
175
|
|
153
176
|
# When an assembly changes their parent, we need to update the parents_path attribute
|
@@ -201,7 +224,7 @@ module Decidim
|
|
201
224
|
|
202
225
|
# Allow ransacker to search for a key in a hstore column (`title`.`en`)
|
203
226
|
ransacker :title do |parent|
|
204
|
-
Arel::Nodes::InfixOperation.new("
|
227
|
+
Arel::Nodes::InfixOperation.new("->>", parent.table[:title], Arel::Nodes.build_quoted(I18n.locale.to_s))
|
205
228
|
end
|
206
229
|
end
|
207
230
|
end
|