decidim-participatory_processes 0.17.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb +1 -2
- data/app/cells/decidim/participatory_processes/process_filters/show.erb +1 -1
- data/app/cells/decidim/participatory_processes/process_filters_cell.rb +42 -8
- data/app/cells/decidim/participatory_processes/process_group_m_cell.rb +1 -1
- data/app/cells/decidim/participatory_processes/process_m/footer.erb +1 -1
- data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +1 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +1 -0
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +1 -0
- data/app/controllers/decidim/participatory_processes/admin/application_controller.rb +5 -4
- data/app/controllers/decidim/participatory_processes/admin/concerns/participatory_process_admin.rb +6 -4
- data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +21 -5
- data/app/controllers/decidim/participatory_processes/application_controller.rb +7 -6
- data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +30 -46
- data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +44 -22
- data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +7 -0
- data/app/models/decidim/participatory_process.rb +36 -2
- data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_presenter.rb +1 -0
- data/app/queries/decidim/participatory_processes/admin/admin_users.rb +6 -5
- data/app/queries/decidim/participatory_processes/participatory_processes_by_group.rb +28 -0
- data/app/queries/decidim/participatory_processes/visible_participatory_processes.rb +1 -8
- data/app/services/decidim/participatory_processes/participatory_process_search.rb +26 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +69 -23
- data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +42 -6
- data/app/views/decidim/participatory_processes/participatory_processes/_order_by_processes.html.erb +1 -1
- data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +1 -1
- data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +2 -0
- data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +29 -14
- data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
- data/config/locales/ar-SA.yml +16 -4
- data/config/locales/ar.yml +432 -0
- data/config/locales/ca.yml +16 -4
- data/config/locales/cs.yml +16 -4
- data/config/locales/de.yml +16 -4
- data/config/locales/en.yml +16 -4
- data/config/locales/es-MX.yml +16 -4
- data/config/locales/es-PY.yml +16 -4
- data/config/locales/es.yml +16 -4
- data/config/locales/eu.yml +16 -4
- data/config/locales/fi-plain.yml +16 -4
- data/config/locales/fi.yml +16 -4
- data/config/locales/fr.yml +16 -4
- data/config/locales/gl.yml +16 -4
- data/config/locales/hu.yml +16 -4
- data/config/locales/id-ID.yml +16 -4
- data/config/locales/it.yml +16 -4
- data/config/locales/nl.yml +16 -4
- data/config/locales/pl.yml +16 -4
- data/config/locales/pt-BR.yml +16 -4
- data/config/locales/pt.yml +16 -4
- data/config/locales/ru.yml +1 -4
- data/config/locales/sv.yml +16 -4
- data/config/locales/tr-TR.yml +16 -4
- data/config/locales/uk.yml +1 -4
- data/db/migrate/20190322125517_add_area_to_participatory_processes.rb +7 -0
- data/lib/decidim/participatory_processes/test/factories.rb +1 -0
- data/lib/decidim/participatory_processes/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c5c49a8f6a410df4a057cd94c07274a98a89e743d0df6d91c46583b2ed30d67
|
|
4
|
+
data.tar.gz: 5dc3e790a54d79406f05d9c96c44e313f8263cd8f0594d3e41e3c61168609c8c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b2fdd90b1932caac47fd07f21efedfe7e9f558b9bbbdbf5db5287ce79d347863274ec41724579dfed413c6703df50d62516474db9523942926cde7a4c9ed81f
|
|
7
|
+
data.tar.gz: '05823400ffb5cd78475d1f6ad90487a2ebdfd8e508bfd47c2802a794579c1a4e25182f967ce45484a4e6ee128fa822700b984ca8937132bd5b3046ef51dd341e'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<span class="order-by__tabs ml-s">
|
|
2
|
-
<%# <span class="muted mr-s ml-s">No hay procesos activos</span> %>
|
|
3
2
|
<% if should_show_tabs? %>
|
|
4
3
|
<%= explanation %>
|
|
5
4
|
<span class="muted mr-xs"><%= t("decidim.participatory_processes.participatory_processes.filters.see") %></span>
|
|
@@ -7,7 +6,7 @@
|
|
|
7
6
|
<%= link_to filter_link(filter), remote: true, class: "order-by__tab" do %>
|
|
8
7
|
<strong>
|
|
9
8
|
<%= filter_name(filter) %>
|
|
10
|
-
</strong> <span>(<%=
|
|
9
|
+
</strong> <span>(<%= process_count_by_filter[filter] %>)</span>
|
|
11
10
|
<% end %>
|
|
12
11
|
<% end %>
|
|
13
12
|
<% else %>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<%= render :filter_tabs %>
|
|
5
5
|
</h2>
|
|
6
6
|
</div>
|
|
7
|
-
<% if
|
|
7
|
+
<% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
|
|
8
8
|
<div class="row column">
|
|
9
9
|
<div class="callout warning mb-sm">
|
|
10
10
|
<p><%= t("decidim.participatory_processes.participatory_processes.filters.explanations.no_active_nor_upcoming_callout") %></p>
|
|
@@ -9,11 +9,46 @@ module Decidim
|
|
|
9
9
|
Decidim::ParticipatoryProcesses::Engine
|
|
10
10
|
.routes
|
|
11
11
|
.url_helpers
|
|
12
|
-
.participatory_processes_path(
|
|
12
|
+
.participatory_processes_path(
|
|
13
|
+
filter: {
|
|
14
|
+
scope_id: get_filter(:scope_id),
|
|
15
|
+
area_id: get_filter(:area_id),
|
|
16
|
+
date: filter
|
|
17
|
+
}
|
|
18
|
+
)
|
|
13
19
|
end
|
|
14
20
|
|
|
15
21
|
def current_filter
|
|
16
|
-
|
|
22
|
+
get_filter(:date, model[:default_filter])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_filter(filter_name, default = nil)
|
|
26
|
+
return default unless params[:filter].try(:[], filter_name)
|
|
27
|
+
|
|
28
|
+
params[:filter][filter_name]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def filtered_processes(date_filter)
|
|
32
|
+
ParticipatoryProcessSearch.new(
|
|
33
|
+
date: date_filter,
|
|
34
|
+
scope_id: get_filter(:scope_id),
|
|
35
|
+
area_id: get_filter(:area_id),
|
|
36
|
+
current_user: current_user,
|
|
37
|
+
organization: current_organization
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def process_count_by_filter
|
|
42
|
+
return @process_count_by_filter if @process_count_by_filter
|
|
43
|
+
|
|
44
|
+
@process_count_by_filter = %w(active upcoming past).inject({}) do |collection_by_filter, filter_name|
|
|
45
|
+
filtered_processes = filtered_processes(filter_name).results
|
|
46
|
+
processes = filtered_processes.groupless
|
|
47
|
+
groups = Decidim::ParticipatoryProcessGroup.where(id: filtered_processes.grouped.group_ids)
|
|
48
|
+
collection_by_filter.merge(filter_name => processes.count + groups.count)
|
|
49
|
+
end
|
|
50
|
+
@process_count_by_filter["all"] = @process_count_by_filter.values.sum
|
|
51
|
+
@process_count_by_filter
|
|
17
52
|
end
|
|
18
53
|
|
|
19
54
|
def other_filters
|
|
@@ -22,17 +57,16 @@ module Decidim
|
|
|
22
57
|
|
|
23
58
|
def other_filters_with_value
|
|
24
59
|
@other_filters_with_value ||= other_filters.select do |filter|
|
|
25
|
-
|
|
60
|
+
process_count_by_filter[filter].positive?
|
|
26
61
|
end
|
|
27
62
|
end
|
|
28
63
|
|
|
29
64
|
def should_show_tabs?
|
|
30
|
-
other_filters_with_value.any?
|
|
31
|
-
other_filters_with_value != ["all"]
|
|
65
|
+
other_filters_with_value.any? && other_filters_with_value != ["all"]
|
|
32
66
|
end
|
|
33
67
|
|
|
34
68
|
def title
|
|
35
|
-
I18n.t(current_filter, scope: "decidim.participatory_processes.participatory_processes.filters.counters", count:
|
|
69
|
+
I18n.t(current_filter, scope: "decidim.participatory_processes.participatory_processes.filters.counters", count: process_count_by_filter[current_filter])
|
|
36
70
|
end
|
|
37
71
|
|
|
38
72
|
def filter_name(filter)
|
|
@@ -40,7 +74,7 @@ module Decidim
|
|
|
40
74
|
end
|
|
41
75
|
|
|
42
76
|
def explanation
|
|
43
|
-
return if
|
|
77
|
+
return if process_count_by_filter["active"].positive?
|
|
44
78
|
content_tag(
|
|
45
79
|
:span,
|
|
46
80
|
I18n.t(explanation_text, scope: "decidim.participatory_processes.participatory_processes.filters.explanations"),
|
|
@@ -49,7 +83,7 @@ module Decidim
|
|
|
49
83
|
end
|
|
50
84
|
|
|
51
85
|
def explanation_text
|
|
52
|
-
return "no_active" if
|
|
86
|
+
return "no_active" if process_count_by_filter["upcoming"].positive?
|
|
53
87
|
"no_active_nor_upcoming"
|
|
54
88
|
end
|
|
55
89
|
end
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
<% end %>
|
|
9
9
|
<%= link_to(
|
|
10
|
-
t("layouts.decidim.participatory_processes.participatory_process
|
|
10
|
+
t(model.cta_button_text_key, scope: "layouts.decidim.participatory_processes.participatory_process"),
|
|
11
11
|
resource_path,
|
|
12
12
|
class: "card__button button button--sc secondary light small"
|
|
13
13
|
) %>
|
|
@@ -53,6 +53,7 @@ module Decidim
|
|
|
53
53
|
scope: @participatory_process.scope,
|
|
54
54
|
developer_group: @participatory_process.developer_group,
|
|
55
55
|
local_area: @participatory_process.local_area,
|
|
56
|
+
area: @participatory_process.area,
|
|
56
57
|
target: @participatory_process.target,
|
|
57
58
|
participatory_scope: @participatory_process.participatory_scope,
|
|
58
59
|
participatory_structure: @participatory_process.participatory_structure,
|
|
@@ -54,6 +54,7 @@ module Decidim
|
|
|
54
54
|
private_space: form.private_space,
|
|
55
55
|
developer_group: form.developer_group,
|
|
56
56
|
local_area: form.local_area,
|
|
57
|
+
area: form.area,
|
|
57
58
|
target: form.target,
|
|
58
59
|
participatory_scope: form.participatory_scope,
|
|
59
60
|
participatory_structure: form.participatory_structure,
|
|
@@ -67,6 +67,7 @@ module Decidim
|
|
|
67
67
|
private_space: form.private_space,
|
|
68
68
|
developer_group: form.developer_group,
|
|
69
69
|
local_area: form.local_area,
|
|
70
|
+
area: form.area,
|
|
70
71
|
target: form.target,
|
|
71
72
|
participatory_scope: form.participatory_scope,
|
|
72
73
|
participatory_structure: form.participatory_structure,
|
|
@@ -5,6 +5,10 @@ module Decidim
|
|
|
5
5
|
module Admin
|
|
6
6
|
# The main admin application controller for participatory processes
|
|
7
7
|
class ApplicationController < Decidim::Admin::ApplicationController
|
|
8
|
+
register_permissions(::Decidim::ParticipatoryProcesses::Admin::ApplicationController,
|
|
9
|
+
::Decidim::ParticipatoryProcesses::Permissions,
|
|
10
|
+
::Decidim::Admin::Permissions)
|
|
11
|
+
|
|
8
12
|
private
|
|
9
13
|
|
|
10
14
|
def permissions_context
|
|
@@ -14,10 +18,7 @@ module Decidim
|
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
def permission_class_chain
|
|
17
|
-
|
|
18
|
-
Decidim::ParticipatoryProcesses::Permissions,
|
|
19
|
-
Decidim::Admin::Permissions
|
|
20
|
-
]
|
|
21
|
+
::Decidim.permissions_registry.chain_for(::Decidim::ParticipatoryProcesses::Admin::ApplicationController)
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
end
|
data/app/controllers/decidim/participatory_processes/admin/concerns/participatory_process_admin.rb
CHANGED
|
@@ -12,6 +12,11 @@ module Decidim
|
|
|
12
12
|
module ParticipatoryProcessAdmin
|
|
13
13
|
extend ActiveSupport::Concern
|
|
14
14
|
|
|
15
|
+
RegistersPermissions
|
|
16
|
+
.register_permissions(::Decidim::ParticipatoryProcesses::Admin::Concerns::ParticipatoryProcessAdmin,
|
|
17
|
+
::Decidim::ParticipatoryProcesses::Permissions,
|
|
18
|
+
::Decidim::Admin::Permissions)
|
|
19
|
+
|
|
15
20
|
included do
|
|
16
21
|
include Decidim::Admin::ParticipatorySpaceAdminContext
|
|
17
22
|
helper_method :current_participatory_process
|
|
@@ -33,10 +38,7 @@ module Decidim
|
|
|
33
38
|
alias_method :current_participatory_process, :current_participatory_space
|
|
34
39
|
|
|
35
40
|
def permission_class_chain
|
|
36
|
-
|
|
37
|
-
Decidim::ParticipatoryProcesses::Permissions,
|
|
38
|
-
Decidim::Admin::Permissions
|
|
39
|
-
]
|
|
41
|
+
PermissionsRegistry.chain_for(ParticipatoryProcessAdmin)
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
end
|
data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb
CHANGED
|
@@ -8,10 +8,11 @@ module Decidim
|
|
|
8
8
|
class ParticipatoryProcessesController < Decidim::ParticipatoryProcesses::Admin::ApplicationController
|
|
9
9
|
include Decidim::Admin::ParticipatorySpaceAdminContext
|
|
10
10
|
participatory_space_admin_layout only: [:edit]
|
|
11
|
+
include Decidim::Paginable
|
|
11
12
|
|
|
12
13
|
helper ProcessGroupsForSelectHelper
|
|
13
14
|
|
|
14
|
-
helper_method :current_participatory_process, :current_participatory_space
|
|
15
|
+
helper_method :current_participatory_process, :current_participatory_space, :query
|
|
15
16
|
|
|
16
17
|
layout "decidim/admin/participatory_processes"
|
|
17
18
|
|
|
@@ -74,6 +75,25 @@ module Decidim
|
|
|
74
75
|
|
|
75
76
|
private
|
|
76
77
|
|
|
78
|
+
def process_group
|
|
79
|
+
@process_group ||= ParticipatoryProcessGroup.find_by(id: params[:group_id])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def participatory_processes
|
|
83
|
+
@participatory_processes ||= Rectify::Query.merge(
|
|
84
|
+
ParticipatoryProcessesWithUserRole.for(current_user),
|
|
85
|
+
ParticipatoryProcessesByGroup.for(process_group)
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def query
|
|
90
|
+
@query ||= participatory_processes.ransack(params[:q])
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def collection
|
|
94
|
+
@collection ||= paginate(query.result)
|
|
95
|
+
end
|
|
96
|
+
|
|
77
97
|
def current_participatory_process
|
|
78
98
|
@current_participatory_process ||= collection.where(slug: params[:slug]).or(
|
|
79
99
|
collection.where(id: params[:slug])
|
|
@@ -82,10 +102,6 @@ module Decidim
|
|
|
82
102
|
|
|
83
103
|
alias current_participatory_space current_participatory_process
|
|
84
104
|
|
|
85
|
-
def collection
|
|
86
|
-
@collection ||= Decidim::ParticipatoryProcessesWithUserRole.for(current_user)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
105
|
def participatory_process_params
|
|
90
106
|
{
|
|
91
107
|
id: params[:slug],
|
|
@@ -6,17 +6,18 @@ module Decidim
|
|
|
6
6
|
# this engine inherit.
|
|
7
7
|
class ApplicationController < Decidim::ApplicationController
|
|
8
8
|
helper Decidim::ParticipatoryProcesses::ApplicationHelper
|
|
9
|
-
|
|
9
|
+
helper ParticipatoryProcessHelper
|
|
10
10
|
include NeedsPermission
|
|
11
11
|
|
|
12
|
+
register_permissions(Decidim::ParticipatoryProcesses::ApplicationController,
|
|
13
|
+
::Decidim::ParticipatoryProcesses::Permissions,
|
|
14
|
+
::Decidim::Admin::Permissions,
|
|
15
|
+
::Decidim::Permissions)
|
|
16
|
+
|
|
12
17
|
private
|
|
13
18
|
|
|
14
19
|
def permission_class_chain
|
|
15
|
-
|
|
16
|
-
Decidim::ParticipatoryProcesses::Permissions,
|
|
17
|
-
Decidim::Admin::Permissions,
|
|
18
|
-
Decidim::Permissions
|
|
19
|
-
]
|
|
20
|
+
::Decidim.permissions_registry.chain_for(::Decidim::ParticipatoryProcesses::ApplicationController)
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def permission_scope
|
data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Decidim
|
|
|
21
21
|
def participatory_processes
|
|
22
22
|
@participatory_processes ||= if current_user
|
|
23
23
|
return group.participatory_processes.published if current_user.admin
|
|
24
|
-
group.participatory_processes.visible_for(current_user
|
|
24
|
+
group.participatory_processes.visible_for(current_user).published
|
|
25
25
|
else
|
|
26
26
|
group.participatory_processes.published.public_spaces
|
|
27
27
|
end
|
|
@@ -7,20 +7,12 @@ module Decidim
|
|
|
7
7
|
class ParticipatoryProcessesController < Decidim::ParticipatoryProcesses::ApplicationController
|
|
8
8
|
include ParticipatorySpaceContext
|
|
9
9
|
participatory_space_layout only: [:show, :statistics]
|
|
10
|
+
include FilterResource
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
helper Decidim::IconHelper
|
|
13
|
-
helper Decidim::WidgetUrlsHelper
|
|
14
|
-
helper Decidim::SanitizeHelper
|
|
15
|
-
helper Decidim::ResourceReferenceHelper
|
|
16
|
-
|
|
17
|
-
helper ParticipatoryProcessHelper
|
|
18
|
-
|
|
19
|
-
helper_method :collection, :promoted_participatory_processes, :participatory_processes, :stats, :metrics, :filter
|
|
20
|
-
helper_method :process_count_by_filter
|
|
12
|
+
helper_method :collection, :promoted_participatory_processes, :participatory_processes, :stats, :metrics, :default_date_filter
|
|
21
13
|
|
|
22
14
|
def index
|
|
23
|
-
|
|
15
|
+
raise ActionController::RoutingError, "Not Found" if published_processes.none?
|
|
24
16
|
|
|
25
17
|
enforce_permission_to :list, :process
|
|
26
18
|
enforce_permission_to :list, :process_group
|
|
@@ -36,6 +28,18 @@ module Decidim
|
|
|
36
28
|
|
|
37
29
|
private
|
|
38
30
|
|
|
31
|
+
def search_klass
|
|
32
|
+
ParticipatoryProcessSearch
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def default_filter_params
|
|
36
|
+
{
|
|
37
|
+
scope_id: nil,
|
|
38
|
+
area_id: nil,
|
|
39
|
+
date: default_date_filter
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
39
43
|
def organization_participatory_processes
|
|
40
44
|
@organization_participatory_processes ||= OrganizationParticipatoryProcesses.new(current_organization).query
|
|
41
45
|
end
|
|
@@ -52,28 +56,25 @@ module Decidim
|
|
|
52
56
|
@published_processes ||= OrganizationPublishedParticipatoryProcesses.new(current_organization, current_user)
|
|
53
57
|
end
|
|
54
58
|
|
|
55
|
-
def
|
|
56
|
-
@
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def filtered_participatory_processes(filter_name = filter)
|
|
60
|
-
OrganizationPrioritizedParticipatoryProcesses.new(current_organization, filter_name, current_user)
|
|
59
|
+
def promoted_participatory_processes
|
|
60
|
+
@promoted_participatory_processes ||= published_processes | PromotedParticipatoryProcesses.new
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def
|
|
64
|
-
@
|
|
63
|
+
def collection
|
|
64
|
+
@collection ||= participatory_processes + participatory_process_groups
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
def
|
|
68
|
-
|
|
67
|
+
def filtered_processes
|
|
68
|
+
search.results
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
def
|
|
72
|
-
|
|
71
|
+
def participatory_processes
|
|
72
|
+
@participatory_processes ||= filtered_processes.groupless
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def participatory_process_groups
|
|
76
|
-
@participatory_process_groups ||=
|
|
76
|
+
@participatory_process_groups ||= Decidim::ParticipatoryProcessGroup
|
|
77
|
+
.where(id: filtered_processes.grouped.group_ids)
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
def stats
|
|
@@ -84,28 +85,11 @@ module Decidim
|
|
|
84
85
|
@metrics ||= ParticipatoryProcessMetricChartsPresenter.new(participatory_process: current_participatory_space)
|
|
85
86
|
end
|
|
86
87
|
|
|
87
|
-
def
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def default_filter
|
|
93
|
-
return "active" if process_count_by_filter["active"].positive?
|
|
94
|
-
return "upcoming" if process_count_by_filter["upcoming"].positive?
|
|
95
|
-
return "past" if process_count_by_filter["past"].positive?
|
|
96
|
-
"active"
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def process_count_by_filter
|
|
100
|
-
return @process_count_by_filter if @process_count_by_filter
|
|
101
|
-
|
|
102
|
-
@process_count_by_filter = %w(active upcoming past).inject({}) do |collection_by_filter, filter_name|
|
|
103
|
-
processes = filtered_participatory_processes(filter_name).query.where(decidim_participatory_process_group_id: nil)
|
|
104
|
-
groups = filtered_participatory_process_groups(filter_name)
|
|
105
|
-
collection_by_filter.merge(filter_name.to_s => processes.count + groups.count)
|
|
106
|
-
end
|
|
107
|
-
@process_count_by_filter["all"] = @process_count_by_filter.values.sum
|
|
108
|
-
@process_count_by_filter
|
|
88
|
+
def default_date_filter
|
|
89
|
+
return "active" if published_processes.any?(&:active?)
|
|
90
|
+
return "upcoming" if published_processes.any?(&:upcoming?)
|
|
91
|
+
return "past" if published_processes.any?(&:past?)
|
|
92
|
+
"all"
|
|
109
93
|
end
|
|
110
94
|
end
|
|
111
95
|
end
|
|
@@ -9,43 +9,54 @@ module Decidim
|
|
|
9
9
|
class ParticipatoryProcessForm < Form
|
|
10
10
|
include TranslatableAttributes
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
mimic :participatory_process
|
|
13
|
+
|
|
14
|
+
translatable_attribute :announcement, String
|
|
14
15
|
translatable_attribute :description, String
|
|
15
|
-
translatable_attribute :short_description, String
|
|
16
|
-
translatable_attribute :meta_scope, String
|
|
17
16
|
translatable_attribute :developer_group, String
|
|
18
17
|
translatable_attribute :local_area, String
|
|
19
|
-
translatable_attribute :
|
|
18
|
+
translatable_attribute :meta_scope, String
|
|
20
19
|
translatable_attribute :participatory_scope, String
|
|
21
20
|
translatable_attribute :participatory_structure, String
|
|
22
|
-
translatable_attribute :
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
translatable_attribute :subtitle, String
|
|
22
|
+
translatable_attribute :short_description, String
|
|
23
|
+
translatable_attribute :title, String
|
|
24
|
+
translatable_attribute :target, String
|
|
25
25
|
|
|
26
|
-
attribute :start_date, Decidim::Attributes::LocalizedDate
|
|
27
|
-
attribute :end_date, Decidim::Attributes::LocalizedDate
|
|
28
|
-
attribute :slug, String
|
|
29
26
|
attribute :hashtag, String
|
|
27
|
+
attribute :slug, String
|
|
28
|
+
|
|
29
|
+
attribute :area_id, Integer
|
|
30
|
+
attribute :participatory_process_group_id, Integer
|
|
31
|
+
attribute :scope_id, Integer
|
|
32
|
+
|
|
33
|
+
attribute :private_space, Boolean
|
|
30
34
|
attribute :promoted, Boolean
|
|
31
35
|
attribute :scopes_enabled, Boolean
|
|
32
|
-
attribute :
|
|
33
|
-
|
|
34
|
-
attribute :
|
|
36
|
+
attribute :show_statistics, Boolean
|
|
37
|
+
|
|
38
|
+
attribute :end_date, Decidim::Attributes::LocalizedDate
|
|
39
|
+
attribute :start_date, Decidim::Attributes::LocalizedDate
|
|
40
|
+
|
|
35
41
|
attribute :banner_image
|
|
42
|
+
attribute :hero_image
|
|
36
43
|
attribute :remove_banner_image
|
|
37
|
-
attribute :
|
|
38
|
-
attribute :show_statistics, Boolean
|
|
39
|
-
attribute :private_space, Boolean
|
|
44
|
+
attribute :remove_hero_image
|
|
40
45
|
|
|
41
|
-
validates :
|
|
42
|
-
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
|
46
|
+
validates :area, presence: true, if: proc { |object| object.area_id.present? }
|
|
43
47
|
validates :scope, presence: true, if: proc { |object| object.scope_id.present? }
|
|
48
|
+
validates :slug, presence: true, format: { with: Decidim::ParticipatoryProcess.slug_format }
|
|
44
49
|
|
|
45
50
|
validate :slug_uniqueness
|
|
46
51
|
|
|
47
|
-
validates :
|
|
48
|
-
|
|
52
|
+
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
|
53
|
+
|
|
54
|
+
validates :banner_image,
|
|
55
|
+
file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
|
|
56
|
+
file_content_type: { allow: ["image/jpeg", "image/png"] }
|
|
57
|
+
validates :hero_image,
|
|
58
|
+
file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
|
|
59
|
+
file_content_type: { allow: ["image/jpeg", "image/png"] }
|
|
49
60
|
|
|
50
61
|
def map_model(model)
|
|
51
62
|
self.scope_id = model.decidim_scope_id
|
|
@@ -56,14 +67,25 @@ module Decidim
|
|
|
56
67
|
@scope ||= current_organization.scopes.find_by(id: scope_id)
|
|
57
68
|
end
|
|
58
69
|
|
|
70
|
+
def area
|
|
71
|
+
@area ||= current_organization.areas.find_by(id: area_id)
|
|
72
|
+
end
|
|
73
|
+
|
|
59
74
|
def participatory_process_group
|
|
60
75
|
Decidim::ParticipatoryProcessGroup.find_by(id: participatory_process_group_id)
|
|
61
76
|
end
|
|
62
77
|
|
|
63
78
|
private
|
|
64
79
|
|
|
80
|
+
def organization_participatory_processes
|
|
81
|
+
OrganizationParticipatoryProcesses.new(current_organization).query
|
|
82
|
+
end
|
|
83
|
+
|
|
65
84
|
def slug_uniqueness
|
|
66
|
-
return unless
|
|
85
|
+
return unless organization_participatory_processes
|
|
86
|
+
.where(slug: slug)
|
|
87
|
+
.where.not(id: context[:process_id])
|
|
88
|
+
.any?
|
|
67
89
|
|
|
68
90
|
errors.add(:slug, :taken)
|
|
69
91
|
end
|