decidim-assemblies 0.15.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +1 -10
  3. data/app/controllers/decidim/assemblies/assemblies_controller.rb +8 -2
  4. data/app/helpers/decidim/assemblies/assemblies_helper.rb +2 -0
  5. data/app/helpers/decidim/assemblies/filter_assemblies_helper.rb +24 -0
  6. data/app/models/decidim/assembly.rb +13 -12
  7. data/app/permissions/decidim/assemblies/permissions.rb +7 -12
  8. data/app/queries/decidim/assemblies/filtered_assemblies.rb +28 -0
  9. data/app/queries/decidim/assemblies/visible_assemblies.rb +5 -2
  10. data/app/views/decidim/assemblies/_filter_by_type.html.erb +13 -0
  11. data/app/views/decidim/assemblies/admin/assemblies/edit.html.erb +0 -4
  12. data/app/views/decidim/assemblies/assemblies/_count.html.erb +1 -0
  13. data/app/views/decidim/assemblies/assemblies/_statistics.html.erb +1 -1
  14. data/app/views/decidim/assemblies/assemblies/index.html.erb +11 -3
  15. data/app/views/decidim/assemblies/assemblies/index.js.erb +5 -0
  16. data/app/views/decidim/assemblies/assemblies/show.html.erb +3 -1
  17. data/app/views/layouts/decidim/_assembly_header.html.erb +8 -54
  18. data/app/views/layouts/decidim/_assembly_navigation.html.erb +24 -0
  19. data/app/views/layouts/decidim/assembly.html.erb +1 -1
  20. data/config/locales/ca.yml +19 -4
  21. data/config/locales/de.yml +19 -4
  22. data/config/locales/en.yml +20 -5
  23. data/config/locales/es-PY.yml +19 -4
  24. data/config/locales/es.yml +19 -4
  25. data/config/locales/eu.yml +19 -4
  26. data/config/locales/fi-pl.yml +19 -4
  27. data/config/locales/fi.yml +19 -4
  28. data/config/locales/fr.yml +19 -4
  29. data/config/locales/gl.yml +19 -4
  30. data/config/locales/hu.yml +20 -5
  31. data/config/locales/id-ID.yml +19 -7
  32. data/config/locales/it.yml +20 -5
  33. data/config/locales/nl.yml +19 -4
  34. data/config/locales/pl.yml +19 -4
  35. data/config/locales/pt-BR.yml +19 -4
  36. data/config/locales/pt.yml +19 -4
  37. data/config/locales/ru.yml +1 -5
  38. data/config/locales/sv.yml +20 -5
  39. data/config/locales/tr-TR.yml +19 -8
  40. data/config/locales/uk.yml +1 -5
  41. data/lib/decidim/assemblies/admin_engine.rb +1 -1
  42. data/lib/decidim/assemblies/engine.rb +9 -6
  43. data/lib/decidim/assemblies/test/factories.rb +16 -0
  44. data/lib/decidim/assemblies/version.rb +1 -1
  45. metadata +15 -10
  46. data/app/views/decidim/assemblies/_order_by_assemblies.html.erb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8105c47504e59581cdaeb4d81d7c4059ffb2a735148a16ba354e090dc44faf79
4
- data.tar.gz: cda2b42ce4e419c7f395cffa2d8cab75000b04f5b32914c6fe1458cb716e31a8
3
+ metadata.gz: 93623b3d750202db5ba682221675d92c5abe68884ad81f3838bb695ae6b1bcf1
4
+ data.tar.gz: 22bd1c3b11d93e20a77aded79e1b5258e07af3f301d37d7f2038a8c685318eab
5
5
  SHA512:
6
- metadata.gz: d6d5a0b2a085b40ab2b84842a09e2d6ad0dc25bbd914fd3ccc76524f5cbedbfb10e5834f3201401e7599abd46046eddfcb34e38faf87865d2c6238302f305faf
7
- data.tar.gz: 896fd982d665e9aac54c88e50ed4d23499c807c9eaefafe911d54d3c6ec3fc5fa59dc471509781edae38caebb2f2787a8d59499b8d0be16730308e45983f3686
6
+ metadata.gz: da27795b25811e8c8d0e45e69f28071ca169761a08953814908f670bcd41e297b2bc8af431904f9f6a6b504441468589103a2b0b83d7ba6371b969b6a0a4a5f7
7
+ data.tar.gz: 64d33448389d1dcc36026959a49b6056b2c19e3581d3dd0316f578eba89d691820afdcfb76b64e13a5eb1c02a738a00fee417e2a3a4fef12d41e4260c40f6b0b
@@ -9,7 +9,7 @@ module Decidim
9
9
  helper_method :current_assembly, :parent_assembly, :parent_assemblies, :current_participatory_space
10
10
  layout "decidim/admin/assemblies"
11
11
 
12
- before_action :set_all_assemblies, except: [:index, :destroy]
12
+ before_action :set_all_assemblies, except: [:index]
13
13
 
14
14
  def index
15
15
  enforce_permission_to :read, :assembly_list
@@ -65,15 +65,6 @@ module Decidim
65
65
  end
66
66
  end
67
67
 
68
- def destroy
69
- enforce_permission_to :destroy, :assembly, assembly: current_assembly
70
- current_assembly.destroy!
71
-
72
- flash[:notice] = I18n.t("assemblies.destroy.success", scope: "decidim.admin")
73
-
74
- redirect_to assemblies_path
75
- end
76
-
77
68
  def copy
78
69
  enforce_permission_to :create, :assembly
79
70
  end
@@ -26,6 +26,12 @@ module Decidim
26
26
  render "index"
27
27
  end
28
28
 
29
+ format.js do
30
+ raise ActionController::RoutingError, "Not Found" if published_assemblies.none?
31
+
32
+ render "index"
33
+ end
34
+
29
35
  format.json do
30
36
  render json: published_assemblies.query.includes(:children).where(parent: nil).collect { |assembly|
31
37
  {
@@ -43,7 +49,7 @@ module Decidim
43
49
  end
44
50
 
45
51
  def show
46
- check_current_user_can_visit_space
52
+ enforce_permission_to :read, :assembly, assembly: current_participatory_space
47
53
  end
48
54
 
49
55
  private
@@ -65,7 +71,7 @@ module Decidim
65
71
  end
66
72
 
67
73
  def parent_assemblies
68
- @parent_assemblies ||= assemblies | ParentAssemblies.new
74
+ @parent_assemblies ||= assemblies | ParentAssemblies.new | FilteredAssemblies.new(params[:filter])
69
75
  end
70
76
 
71
77
  alias collection parent_assemblies
@@ -5,6 +5,8 @@ module Decidim
5
5
  # Helpers related to the Assemblies layout.
6
6
  module AssembliesHelper
7
7
  include Decidim::ResourceHelper
8
+ include FilterAssembliesHelper
9
+
8
10
  # Public: Returns the characteristics of an assembly in a readable format like
9
11
  # "title: close, no public, no transparent and is restricted to the members of the assembly"
10
12
  def participatory_processes_for_assembly(assembly_participatory_processes)
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ # Helpers related to the Assemblies filter by type.
6
+ module FilterAssembliesHelper
7
+ def available_filters
8
+ %w(all government executive consultative_advisory participatory working_group commission others)
9
+ end
10
+
11
+ def filter_link(filter)
12
+ link_to t(filter, scope: "decidim.assemblies.filter"), url_for(params.to_unsafe_h.merge(page: nil, filter: filter)), data: { filter: filter }, remote: true
13
+ end
14
+
15
+ def label_text
16
+ t("label", scope: "decidim.assemblies.filter")
17
+ end
18
+
19
+ def placeholder_text
20
+ t("placeholder", scope: "decidim.assemblies.filter")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -59,11 +59,14 @@ module Decidim
59
59
  has_many :children, foreign_key: "parent_id", class_name: "Decidim::Assembly", inverse_of: :parent, dependent: :destroy
60
60
  belongs_to :parent, foreign_key: "parent_id", class_name: "Decidim::Assembly", inverse_of: :children, optional: true, counter_cache: :children_count
61
61
 
62
+ mount_uploader :hero_image, Decidim::HeroImageUploader
63
+ mount_uploader :banner_image, Decidim::BannerImageUploader
64
+
62
65
  validates :slug, uniqueness: { scope: :organization }
63
66
  validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
64
67
 
65
- mount_uploader :hero_image, Decidim::HeroImageUploader
66
- mount_uploader :banner_image, Decidim::BannerImageUploader
68
+ after_create :set_parents_path
69
+ after_update :set_parents_path, :update_children_paths, if: :saved_change_to_parent_id?
67
70
 
68
71
  scope :visible_for, lambda { |user|
69
72
  joins("LEFT JOIN decidim_participatory_space_private_users ON
@@ -72,8 +75,6 @@ module Decidim
72
75
  or private_space = ? or (private_space = ? and is_transparent = ?)", true, user, false, true, true).distinct
73
76
  }
74
77
 
75
- after_create :set_parents_path
76
- after_update :set_parents_path, :update_children_paths, if: :saved_change_to_parent_id?
77
78
  # Scope to return only the promoted assemblies.
78
79
  #
79
80
  # Returns an ActiveRecord::Relation.
@@ -81,6 +82,14 @@ module Decidim
81
82
  where(promoted: true)
82
83
  end
83
84
 
85
+ def self.private_assemblies
86
+ where(private_space: true)
87
+ end
88
+
89
+ def self.public_spaces
90
+ super.where(private_space: false).or(Decidim::Assembly.where(private_space: true).where(is_transparent: true))
91
+ end
92
+
84
93
  def self.log_presenter_class_for(_log)
85
94
  Decidim::Assemblies::AdminLog::AssemblyPresenter
86
95
  end
@@ -101,14 +110,6 @@ module Decidim
101
110
  self_and_ancestors.where.not(id: id)
102
111
  end
103
112
 
104
- def self.private_assemblies
105
- where(private_space: true)
106
- end
107
-
108
- def self.public_spaces
109
- super.where(private_space: false).or(Decidim::Assembly.where(private_space: true).where(is_transparent: true))
110
- end
111
-
112
113
  def can_participate?(user)
113
114
  return true unless private_space?
114
115
  return true if private_space? && users.include?(user)
@@ -31,7 +31,6 @@ module Decidim
31
31
  user_can_read_assembly_list?
32
32
  user_can_read_current_assembly?
33
33
  user_can_create_assembly?
34
- user_can_destroy_assembly?
35
34
 
36
35
  # org admins and space admins can do everything in the admin section
37
36
  org_admin_action?
@@ -83,11 +82,17 @@ module Decidim
83
82
  [:assembly, :participatory_space].include?(permission_action.subject) &&
84
83
  assembly
85
84
 
85
+ return disallow! if cannot_view_private_space
86
86
  return allow! if user&.admin?
87
87
  return allow! if assembly.published?
88
88
  toggle_allow(can_manage_assembly?)
89
89
  end
90
90
 
91
+ def cannot_view_private_space
92
+ return unless assembly.private_space && !assembly.is_transparent
93
+ !user || !user.admin && !assembly.users.include?(user)
94
+ end
95
+
91
96
  def public_list_members_action?
92
97
  return unless permission_action.action == :list &&
93
98
  permission_action.subject == :members
@@ -137,14 +142,6 @@ module Decidim
137
142
  toggle_allow(user.admin?)
138
143
  end
139
144
 
140
- # Only organization admins can destroy a assembly
141
- def user_can_destroy_assembly?
142
- return unless permission_action.action == :destroy &&
143
- permission_action.subject == :assembly
144
-
145
- toggle_allow(user.admin?)
146
- end
147
-
148
145
  # Everyone can read the assembly list
149
146
  def user_can_read_assembly_list?
150
147
  return unless read_assembly_list_permission_action?
@@ -174,14 +171,12 @@ module Decidim
174
171
 
175
172
  # Process admins can eprform everything *inside* that assembly. They cannot
176
173
  # create a assembly or perform actions on assembly groups or other
177
- # assemblies. They cannot destroy their assembly either.
174
+ # assemblies.
178
175
  def assembly_admin_action?
179
176
  return unless can_manage_assembly?(role: :admin)
180
177
  return if user.admin?
181
178
  return disallow! if permission_action.action == :create &&
182
179
  permission_action.subject == :assembly
183
- return disallow! if permission_action.action == :destroy &&
184
- permission_action.subject == :assembly
185
180
 
186
181
  is_allowed = [
187
182
  :attachment,
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ # This query filters assemblies by type.
6
+ class FilteredAssemblies < Rectify::Query
7
+ def initialize(filter)
8
+ @filter = filter
9
+ end
10
+
11
+ def filter
12
+ return "all" if @filter.nil?
13
+
14
+ @filter
15
+ end
16
+
17
+ def assemblies
18
+ Decidim::Assembly
19
+ end
20
+
21
+ def query
22
+ return assemblies.all if filter == "all"
23
+
24
+ assemblies.where(assembly_type: filter)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -9,10 +9,13 @@ module Decidim
9
9
  end
10
10
 
11
11
  def query
12
+ assemblies = Decidim::Assembly.all
13
+
12
14
  if @user
13
- Decidim::Assembly.visible_for(@user.id)
15
+ return assemblies if @user.admin
16
+ assemblies.visible_for(@user.id)
14
17
  else
15
- Decidim::Assembly.public_spaces
18
+ assemblies.public_spaces
16
19
  end
17
20
  end
18
21
  end
@@ -0,0 +1,13 @@
1
+ <div class="inline-filters">
2
+ <label>
3
+ <span><%= label_text %></span>
4
+ <button data-toggle="inline-filter-sort"><%= placeholder_text %></button>
5
+ <div id="inline-filter-sort" class="dropdown-pane" data-position="bottom" data-alignment="right" data-dropdown data-auto-focus="true">
6
+ <ul class="list-reset">
7
+ <% available_filters.each do |filter| %>
8
+ <li><%= filter_link(filter) %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ </label>
13
+ </div>
@@ -10,9 +10,5 @@
10
10
  <%= link_to t("actions.publish", scope: "decidim.admin"), assembly_publish_path(current_assembly), method: :post, class: "button hollow" %>
11
11
  <% end %>
12
12
  <% end %>
13
-
14
- <% if allowed_to? :destroy, :assembly, assembly: current_assembly %>
15
- <%= link_to t("decidim.admin.actions.destroy"), current_assembly, method: :delete, class: "alert button", data: { confirm: t("decidim.admin.actions.confirm_destroy") } %>
16
- <% end %>
17
13
  </div>
18
14
  <% end %>
@@ -0,0 +1 @@
1
+ <%= t("assemblies.order_by_assemblies.assemblies", scope: "layouts.decidim", count: collection.count) %>
@@ -1,6 +1,6 @@
1
1
  <section class="extended" id="assembly-statistics" class="statistics">
2
2
  <div class="row column">
3
- <h4 class="section-heading"><%= t("statistics.headline", scope: "decidim.assemblies") %></h3>
3
+ <h4 class="section-heading"><%= t("statistics.headline", scope: "decidim.assemblies") %></h4>
4
4
  </div>
5
5
  <div class="row">
6
6
  <div class="columns small-centered mediumlarge-12 large-12 process_stats">
@@ -8,7 +8,7 @@ edit_link(
8
8
  )
9
9
  %>
10
10
 
11
- <main class="wrapper">
11
+ <%= participatory_space_wrapper do %>
12
12
  <% if promoted_assemblies.any? %>
13
13
  <section id="highlighted-assemblies" class="row section">
14
14
  <h1 class="section-heading"><%= t("assemblies.index.promoted_assemblies", scope: "layouts.decidim") %></h1>
@@ -17,7 +17,15 @@ edit_link(
17
17
  <% end %>
18
18
 
19
19
  <section id="assemblies-grid" class="section row collapse">
20
- <%= render partial: "decidim/assemblies/order_by_assemblies" %>
20
+ <div class="row column">
21
+ <div class="flex--sbe">
22
+ <h2 id="assemblies-count" class="section-heading collapse">
23
+ <%= render partial: "count" %>
24
+ </h2>
25
+ <%= render partial: "decidim/assemblies/filter_by_type" %>
26
+ </div>
27
+ <hr class="reset mt-s mb-s" />
28
+ </div>
21
29
  <div class="row small-up-1 medium-up-2 large-up-3 card-grid">
22
30
  <%= render(collection) %>
23
31
  </div>
@@ -31,4 +39,4 @@ edit_link(
31
39
  </article>
32
40
  </div>
33
41
  </section>
34
- </main>
42
+ <% end %>
@@ -0,0 +1,5 @@
1
+ var $grid = $('#assemblies-grid');
2
+ var $assembliesCount = $('#assemblies-count');
3
+
4
+ $grid.find('.card-grid').html('<%= j(render(collection)).strip.html_safe %>');
5
+ $assembliesCount.html('<%= j(render partial: "count").strip.html_safe %>');
@@ -14,6 +14,8 @@ edit_link(
14
14
  )
15
15
  %>
16
16
 
17
+ <%= participatory_space_floating_help %>
18
+
17
19
  <% if current_participatory_space.private_space? %>
18
20
  <%= render partial: "decidim/shared/private_participatory_space", locals: { text: t("assemblies.show.private_space", scope: "decidim") } %>
19
21
  <% end %>
@@ -93,7 +95,7 @@ edit_link(
93
95
  <div class="section columns medium-5 mediumlarge-4 large-3">
94
96
  <div class="card extra">
95
97
  <div class="card__content">
96
- <%= render partial: "decidim/shared/follow_button", locals: { followable: current_participatory_space } %>
98
+ <%= render partial: "decidim/shared/follow_button", locals: { followable: current_participatory_space, large: false } %>
97
99
  </div>
98
100
  </div>
99
101
  <div class="card extra definition-data">
@@ -1,8 +1,10 @@
1
- <div class="process-header row column">
2
- <div class="row column process-header__main"
3
- style="background-image:url(<%= current_participatory_space.banner_image.url %>);">
4
- <div class="process-header__container row">
5
- <div class="columns mediumlarge-9 process-header__info">
1
+ <div class="process-header">
2
+ <div class="process-header__inner">
3
+ <div class="row column process-header__main"
4
+ style="background-image:url(<%= current_participatory_space.banner_image.url %>);">
5
+ </div>
6
+ <div class="process-header__container row collapse column">
7
+ <div class="columns mediumlarge-8 process-header__info">
6
8
  <div>
7
9
  <h1 class="text-highlight heading2">
8
10
  <%= translated_attribute(current_participatory_space.title) %>
@@ -21,53 +23,5 @@
21
23
  </div>
22
24
  </div>
23
25
  </div>
24
- <% if current_participatory_space.components.any? || current_participatory_space.members.not_ceased.any? %>
25
- <div class="row column">
26
- <div class="process-nav">
27
- <button class="process-nav__trigger hide-for-medium" data-toggle="process-nav-content">
28
- <%= icon "caret-bottom", class: "icon--small process-nav__trigger__icon", aria_label: t(".unfold"), role: "img" %>
29
- <div class="process-nav__link">
30
- <% if self.try(:current_component) %>
31
- <%= component_icon(current_component) %>
32
- <%= translated_attribute(current_component.name) %>
33
- <% else %>
34
- <%= icon "assembly" %>
35
- <%= t ".assembly_menu_item" %>
36
- <% end %>
37
- </div>
38
- </button>
39
- <div class="row column process-nav__content is-active" id="process-nav-content" data-toggler=".is-active">
40
- <ul>
41
- <li class="<%= "is-active" if is_active_link?(decidim_assemblies.assembly_path(current_participatory_space), :exclusive) %>">
42
- <%= active_link_to decidim_assemblies.assembly_path(current_participatory_space), active: :exclusive, class: "process-nav__link", class_active: "is-active" do %>
43
- <%= external_icon "decidim/assemblies/assembly.svg" %>
44
- <%= t ".assembly_menu_item" %>
45
- <% end %>
46
- </li>
47
-
48
- <% if current_participatory_space.members.not_ceased.any? %>
49
- <li class="<%= "is-active" if is_active_link?(decidim_assemblies.assembly_assembly_members_path(current_participatory_space), :inclusive) %>">
50
- <%= active_link_to decidim_assemblies.assembly_assembly_members_path(current_participatory_space), class: "process-nav__link", active: :inclusive, class_active: "is-active" do %>
51
- <%= icon("members") %>
52
- <%= t ".assembly_member_menu_item" %>
53
- <% end %>
54
- </li>
55
- <% end %>
56
-
57
- <% current_participatory_space.components.each do |component| %>
58
- <% if component.published? || component == self.try(:current_component) %>
59
- <li class="<%= "is-active" if is_active_link?(main_component_path(component), :inclusive) %>">
60
- <%= active_link_to main_component_path(component), class: "process-nav__link", active: :inclusive, class_active: "is-active" do %>
61
- <%= component_icon(component) %>
62
-
63
- <%= translated_attribute(component.name) %>
64
- <% end %>
65
- </li>
66
- <% end %>
67
- <% end %>
68
- </ul>
69
- </div>
70
- </div>
71
- </div>
72
- <% end %>
26
+ <%= render partial: "layouts/decidim/assembly_navigation", locals: { participatory_space: current_participatory_space } %>
73
27
  </div>
@@ -0,0 +1,24 @@
1
+ <%
2
+ components = participatory_space.components.published.or(Decidim::Component.where(id: self.try(:current_component)))
3
+ %>
4
+
5
+ <%=
6
+ extended_navigation_bar(([
7
+ {
8
+ name: t(".assembly_menu_item"),
9
+ url: decidim_assemblies.assembly_path(current_participatory_space),
10
+ active: is_active_link?(decidim_assemblies.assembly_path(current_participatory_space), :exclusive)
11
+ },
12
+ participatory_space.members.not_ceased.any? ? {
13
+ name: t(".assembly_member_menu_item"),
14
+ url: decidim_assemblies.assembly_assembly_members_path(current_participatory_space),
15
+ active: is_active_link?(decidim_assemblies.assembly_assembly_members_path(current_participatory_space), :inclusive)
16
+ } : nil
17
+ ] + components.map do |component|
18
+ {
19
+ name: translated_attribute(component.name),
20
+ url: main_component_path(component),
21
+ active: is_active_link?(main_component_path(component), :inclusive)
22
+ }
23
+ end).compact)
24
+ %>