decidim-assemblies 0.27.9 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/assemblies/assemblies/show.erb +16 -0
  3. data/app/cells/decidim/assemblies/assemblies_cell.rb +24 -0
  4. data/app/cells/decidim/assemblies/assembly_cell.rb +7 -2
  5. data/app/cells/decidim/assemblies/assembly_dropdown_metadata_cell.rb +19 -0
  6. data/app/cells/decidim/assemblies/assembly_g_cell.rb +23 -0
  7. data/app/cells/decidim/assemblies/assembly_member/data.erb +19 -0
  8. data/app/cells/decidim/assemblies/assembly_member/name_and_position.erb +11 -0
  9. data/app/cells/decidim/assemblies/assembly_member/show.erb +8 -52
  10. data/app/cells/decidim/assemblies/assembly_metadata_g_cell.rb +46 -0
  11. data/app/cells/decidim/assemblies/assembly_s_cell.rb +15 -0
  12. data/app/cells/decidim/assemblies/content_block_cell.rb +21 -0
  13. data/app/cells/decidim/assemblies/content_blocks/children_assemblies_cell.rb +27 -0
  14. data/app/cells/decidim/assemblies/content_blocks/dates_metadata_cell.rb +23 -0
  15. data/app/cells/decidim/assemblies/content_blocks/extra_data_cell.rb +39 -0
  16. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +15 -23
  17. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_settings_form/show.erb +1 -1
  18. data/app/cells/decidim/assemblies/content_blocks/main_data_cell.rb +52 -0
  19. data/app/cells/decidim/assemblies/content_blocks/metadata_cell.rb +23 -0
  20. data/app/cells/decidim/assemblies/content_blocks/related_assemblies/content.erb +1 -0
  21. data/app/cells/decidim/assemblies/content_blocks/related_assemblies_cell.rb +34 -0
  22. data/app/cells/decidim/assemblies/content_blocks/stats_cell.rb +15 -0
  23. data/app/commands/decidim/assemblies/admin/copy_assembly.rb +2 -2
  24. data/app/commands/decidim/assemblies/admin/create_assemblies_type.rb +1 -1
  25. data/app/commands/decidim/assemblies/admin/create_assembly.rb +2 -1
  26. data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +3 -3
  27. data/app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb +1 -1
  28. data/app/commands/decidim/assemblies/admin/destroy_assembly_member.rb +1 -1
  29. data/app/commands/decidim/assemblies/admin/import_assembly.rb +1 -1
  30. data/app/commands/decidim/assemblies/admin/update_assemblies_type.rb +1 -1
  31. data/app/commands/decidim/assemblies/admin/update_assembly.rb +1 -1
  32. data/app/commands/decidim/assemblies/admin/update_assembly_member.rb +1 -1
  33. data/app/constraints/decidim/assemblies/current_assembly.rb +1 -1
  34. data/app/controllers/concerns/decidim/assemblies/admin/assembly_context.rb +1 -1
  35. data/app/controllers/concerns/decidim/assemblies/admin/assembly_members/filterable.rb +39 -0
  36. data/app/controllers/concerns/decidim/assemblies/assembly_breadcrumb.rb +36 -0
  37. data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +1 -0
  38. data/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +1 -1
  39. data/app/controllers/decidim/assemblies/admin/assembly_attachment_collections_controller.rb +5 -0
  40. data/app/controllers/decidim/assemblies/admin/assembly_attachments_controller.rb +5 -0
  41. data/app/controllers/decidim/assemblies/admin/assembly_imports_controller.rb +2 -0
  42. data/app/controllers/decidim/assemblies/admin/assembly_landing_page_content_blocks_controller.rb +35 -0
  43. data/app/controllers/decidim/assemblies/admin/assembly_landing_page_controller.rb +37 -0
  44. data/app/controllers/decidim/assemblies/admin/assembly_members_controller.rb +2 -6
  45. data/app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb +9 -29
  46. data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +8 -91
  47. data/app/controllers/decidim/assemblies/admin/concerns/assembly_admin.rb +1 -1
  48. data/app/controllers/decidim/assemblies/assemblies_controller.rb +12 -7
  49. data/app/controllers/decidim/assemblies/assembly_members_controller.rb +2 -0
  50. data/app/events/decidim/assemblies/create_assembly_member_event.rb +1 -1
  51. data/app/events/decidim/role_assigned_to_assembly_event.rb +11 -6
  52. data/app/forms/decidim/assemblies/admin/assembly_copy_form.rb +1 -1
  53. data/app/forms/decidim/assemblies/admin/assembly_form.rb +1 -1
  54. data/app/forms/decidim/assemblies/admin/assembly_import_form.rb +1 -1
  55. data/app/forms/decidim/assemblies/admin/assembly_user_role_form.rb +2 -18
  56. data/app/helpers/decidim/assemblies/admin/assembly_members_helper.rb +11 -0
  57. data/app/helpers/decidim/assemblies/application_helper.rb +12 -0
  58. data/app/helpers/decidim/assemblies/assemblies_helper.rb +21 -19
  59. data/app/helpers/decidim/assemblies/filter_assemblies_helper.rb +15 -30
  60. data/app/models/decidim/assembly.rb +6 -5
  61. data/app/models/decidim/assembly_user_role.rb +5 -33
  62. data/app/packs/entrypoints/decidim_assemblies.js +0 -1
  63. data/app/packs/src/decidim/assemblies/admin/assemblies.js +2 -2
  64. data/app/packs/src/decidim/assemblies/orgchart.js +0 -701
  65. data/app/permissions/decidim/assemblies/permissions.rb +14 -27
  66. data/app/presenters/decidim/assemblies/admin_log/assemblies_setting_presenter.rb +2 -2
  67. data/app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb +2 -2
  68. data/app/presenters/decidim/assemblies/admin_log/assembly_member_presenter.rb +2 -2
  69. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +2 -2
  70. data/app/presenters/decidim/assemblies/admin_log/assembly_user_role_presenter.rb +2 -2
  71. data/app/presenters/decidim/assemblies/assembly_presenter.rb +38 -0
  72. data/app/presenters/decidim/assemblies/assembly_stats_presenter.rb +2 -41
  73. data/app/presenters/decidim/assembly_member_presenter.rb +18 -4
  74. data/app/queries/decidim/assemblies/admin/admin_users.rb +1 -1
  75. data/app/queries/decidim/assemblies/assemblies_with_user_role.rb +2 -2
  76. data/app/serializers/decidim/assemblies/assembly_importer.rb +3 -3
  77. data/app/serializers/decidim/assemblies/assembly_serializer.rb +1 -1
  78. data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +218 -176
  79. data/app/views/decidim/assemblies/admin/assemblies/edit.html.erb +25 -11
  80. data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +105 -115
  81. data/app/views/decidim/assemblies/admin/assemblies/new.html.erb +16 -9
  82. data/app/views/decidim/assemblies/admin/assemblies_types/_form.html.erb +6 -8
  83. data/app/views/decidim/assemblies/admin/assemblies_types/edit.html.erb +11 -5
  84. data/app/views/decidim/assemblies/admin/assemblies_types/index.html.erb +34 -35
  85. data/app/views/decidim/assemblies/admin/assemblies_types/new.html.erb +16 -6
  86. data/app/views/decidim/assemblies/admin/assembly_copies/_form.html.erb +12 -20
  87. data/app/views/decidim/assemblies/admin/assembly_copies/new.html.erb +17 -5
  88. data/app/views/decidim/assemblies/admin/assembly_imports/_form.html.erb +28 -37
  89. data/app/views/decidim/assemblies/admin/assembly_imports/new.html.erb +17 -5
  90. data/app/views/decidim/assemblies/admin/assembly_members/_form.html.erb +45 -49
  91. data/app/views/decidim/assemblies/admin/assembly_members/edit.html.erb +17 -6
  92. data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +51 -88
  93. data/app/views/decidim/assemblies/admin/assembly_members/new.html.erb +17 -6
  94. data/app/views/decidim/assemblies/admin/assembly_user_roles/_form.html.erb +14 -18
  95. data/app/views/decidim/assemblies/admin/assembly_user_roles/edit.html.erb +17 -6
  96. data/app/views/decidim/assemblies/admin/assembly_user_roles/index.html.erb +54 -55
  97. data/app/views/decidim/assemblies/admin/assembly_user_roles/new.html.erb +17 -6
  98. data/app/views/decidim/assemblies/assemblies/_collection.html.erb +7 -0
  99. data/app/views/decidim/assemblies/assemblies/index.html.erb +20 -19
  100. data/app/views/decidim/assemblies/assemblies/index.js.erb +1 -8
  101. data/app/views/decidim/assemblies/assemblies/show.html.erb +17 -207
  102. data/app/views/decidim/assemblies/assembly_members/index.html.erb +7 -5
  103. data/app/views/decidim/assemblies/pages/user_profile/_member_of.html.erb +6 -9
  104. data/app/views/layouts/decidim/admin/_manage_assemblies.html.erb +36 -0
  105. data/app/views/layouts/decidim/admin/assemblies.html.erb +13 -11
  106. data/app/views/layouts/decidim/admin/assemblies_imports.html.erb +9 -0
  107. data/app/views/layouts/decidim/admin/assemblies_types.html.erb +17 -0
  108. data/app/views/layouts/decidim/admin/assembly.html.erb +12 -13
  109. data/app/views/layouts/decidim/assembly.html.erb +7 -14
  110. data/config/locales/ar.yml +7 -68
  111. data/config/locales/bg.yml +0 -466
  112. data/config/locales/ca.yml +62 -71
  113. data/config/locales/cs.yml +59 -66
  114. data/config/locales/de.yml +60 -69
  115. data/config/locales/el.yml +11 -61
  116. data/config/locales/en.yml +57 -66
  117. data/config/locales/es-MX.yml +57 -66
  118. data/config/locales/es-PY.yml +57 -66
  119. data/config/locales/es.yml +63 -72
  120. data/config/locales/eu.yml +57 -70
  121. data/config/locales/fi-plain.yml +58 -67
  122. data/config/locales/fi.yml +57 -66
  123. data/config/locales/fr-CA.yml +57 -66
  124. data/config/locales/fr.yml +57 -66
  125. data/config/locales/ga-IE.yml +4 -15
  126. data/config/locales/gl.yml +4 -62
  127. data/config/locales/hu.yml +33 -65
  128. data/config/locales/id-ID.yml +6 -47
  129. data/config/locales/is-IS.yml +5 -40
  130. data/config/locales/it.yml +5 -62
  131. data/config/locales/ja.yml +51 -66
  132. data/config/locales/kaa.yml +0 -8
  133. data/config/locales/ko.yml +0 -92
  134. data/config/locales/lb.yml +5 -61
  135. data/config/locales/lt.yml +40 -63
  136. data/config/locales/lv.yml +5 -57
  137. data/config/locales/nl.yml +4 -62
  138. data/config/locales/no.yml +5 -62
  139. data/config/locales/pl.yml +3 -93
  140. data/config/locales/pt-BR.yml +77 -132
  141. data/config/locales/pt.yml +5 -62
  142. data/config/locales/ro-RO.yml +20 -63
  143. data/config/locales/ru.yml +4 -44
  144. data/config/locales/sk.yml +0 -26
  145. data/config/locales/sl.yml +5 -48
  146. data/config/locales/sq-AL.yml +0 -364
  147. data/config/locales/sr-CS.yml +0 -5
  148. data/config/locales/sv.yml +132 -193
  149. data/config/locales/tr-TR.yml +8 -69
  150. data/config/locales/uk.yml +4 -44
  151. data/config/locales/zh-CN.yml +5 -60
  152. data/config/locales/zh-TW.yml +7 -63
  153. data/db/migrate/20200108123050_migrate_decidim_assembly_types.rb +1 -1
  154. data/lib/decidim/api/assemblies_type_type.rb +1 -1
  155. data/lib/decidim/api/assembly_member_type.rb +1 -1
  156. data/lib/decidim/api/assembly_type.rb +1 -1
  157. data/lib/decidim/assemblies/admin_engine.rb +21 -126
  158. data/lib/decidim/assemblies/content_blocks/registry_manager.rb +184 -0
  159. data/lib/decidim/assemblies/engine.rb +15 -21
  160. data/lib/decidim/assemblies/menu.rb +161 -0
  161. data/lib/decidim/assemblies/participatory_space.rb +7 -229
  162. data/lib/decidim/assemblies/query_extensions.rb +6 -6
  163. data/lib/decidim/assemblies/seeds.rb +161 -0
  164. data/lib/decidim/assemblies/test/factories.rb +47 -55
  165. data/lib/decidim/assemblies/version.rb +1 -1
  166. metadata +54 -51
  167. data/app/cells/decidim/assemblies/assembly_m/footer.erb +0 -15
  168. data/app/cells/decidim/assemblies/assembly_m/tags.erb +0 -1
  169. data/app/cells/decidim/assemblies/assembly_m_cell.rb +0 -77
  170. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies/show.erb +0 -30
  171. data/app/commands/decidim/assemblies/admin/create_assembly_admin.rb +0 -54
  172. data/app/commands/decidim/assemblies/admin/destroy_assembly_admin.rb +0 -58
  173. data/app/commands/decidim/assemblies/admin/notify_role_assigned_to_assembly.rb +0 -22
  174. data/app/commands/decidim/assemblies/admin/publish_assembly.rb +0 -39
  175. data/app/commands/decidim/assemblies/admin/unpublish_assembly.rb +0 -39
  176. data/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb +0 -46
  177. data/app/commands/decidim/assemblies/admin/update_assembly_admin.rb +0 -53
  178. data/app/controllers/decidim/assemblies/admin/assemblies_settings_controller.rb +0 -49
  179. data/app/controllers/decidim/assemblies/widgets_controller.rb +0 -33
  180. data/app/forms/decidim/assemblies/admin/assemblies_setting_form.rb +0 -14
  181. data/app/models/decidim/assemblies_setting.rb +0 -17
  182. data/app/queries/decidim/assemblies/admin/assembly_members.rb +0 -56
  183. data/app/views/decidim/assemblies/_filter_by_type.html.erb +0 -19
  184. data/app/views/decidim/assemblies/admin/assemblies_settings/_form.html.erb +0 -10
  185. data/app/views/decidim/assemblies/admin/assemblies_settings/edit.html.erb +0 -7
  186. data/app/views/decidim/assemblies/assemblies/_count.html.erb +0 -1
  187. data/app/views/decidim/assemblies/assemblies/_nav_breadcumb.html.erb +0 -11
  188. data/app/views/decidim/assemblies/assemblies/_parent_assemblies.html.erb +0 -15
  189. data/app/views/decidim/assemblies/assemblies/_promoted_assembly.html.erb +0 -27
  190. data/app/views/layouts/decidim/_assembly_header.html.erb +0 -27
  191. data/app/views/layouts/decidim/_assembly_navigation.html.erb +0 -24
  192. data/app/views/layouts/decidim/admin/assembly_members.html.erb +0 -18
  193. data/config/locales/he-IL.yml +0 -110
  194. data/db/seeds/Exampledocument.pdf +0 -0
  195. data/db/seeds/city.jpeg +0 -0
  196. data/db/seeds/city2.jpeg +0 -0
  197. data/db/seeds/homepage_image.jpg +0 -0
  198. data/decidim-assemblies.gemspec +0 -32
@@ -16,7 +16,6 @@ module Decidim
16
16
  if permission_action.scope == :public
17
17
  public_list_assemblies_action?
18
18
  public_read_assembly_action?
19
- public_embed_assembly_action?
20
19
  public_list_members_action?
21
20
  return permission_action
22
21
  end
@@ -35,7 +34,6 @@ module Decidim
35
34
  user_can_create_assembly?
36
35
  user_can_export_assembly?
37
36
  user_can_copy_assembly?
38
- user_can_read_assemblies_setting?
39
37
 
40
38
  # org admins and space admins can do everything in the admin section
41
39
  org_admin_action?
@@ -43,6 +41,8 @@ module Decidim
43
41
 
44
42
  return permission_action unless assembly
45
43
 
44
+ user_can_read_private_users?
45
+
46
46
  moderator_action?
47
47
  collaborator_action?
48
48
  valuator_action?
@@ -53,6 +53,13 @@ module Decidim
53
53
 
54
54
  private
55
55
 
56
+ def user_can_read_private_users?
57
+ return unless permission_action.subject == :space_private_user
58
+ return unless assembly.private_space?
59
+
60
+ toggle_allow(user.admin? || can_manage_assembly?(role: :admin) || can_manage_assembly?(role: :collaborator))
61
+ end
62
+
56
63
  def assemblies_type_action?
57
64
  return unless [:assembly_type, :assemblies_type].include? permission_action.subject
58
65
  return disallow! unless user.admin?
@@ -68,13 +75,13 @@ module Decidim
68
75
  end
69
76
  end
70
77
 
71
- # It's an admin user if it's an organization admin or is a space admin
78
+ # It is an admin user if it is an organization admin or is a space admin
72
79
  # for the current `assembly`.
73
80
  def admin_user?
74
81
  user.admin? || (assembly ? can_manage_assembly?(role: :admin) : has_manageable_assemblies?)
75
82
  end
76
83
 
77
- # It's an admin assembly when assembly exists and the user is allowed to
84
+ # It is an admin assembly when assembly exists and the user is allowed to
78
85
  # manage the current assembly.
79
86
  def admin_assembly?
80
87
  assembly.present? && assembly_admin_allowed_assemblies.include?(assembly)
@@ -137,18 +144,7 @@ module Decidim
137
144
  allow!
138
145
  end
139
146
 
140
- def public_embed_assembly_action?
141
- return unless permission_action.action == :embed &&
142
- [:assembly, :participatory_space].include?(permission_action.subject) &&
143
- assembly
144
-
145
- return disallow! unless assembly.published?
146
- return disallow! if assembly.private_space && !assembly.is_transparent?
147
-
148
- allow!
149
- end
150
-
151
- # All users with a relation to a assembly and organization admins can enter
147
+ # All users with a relation to an assembly and organization admins can enter
152
148
  # the space area. The sapce area is considered to be the assemblies zone,
153
149
  # not the assembly groups one.
154
150
  def user_can_enter_space_area?
@@ -197,13 +193,6 @@ module Decidim
197
193
  toggle_allow(user.admin? || admin_assembly?)
198
194
  end
199
195
 
200
- def user_can_read_assemblies_setting?
201
- return unless permission_action.action == :read &&
202
- permission_action.subject == :assemblies_setting
203
-
204
- toggle_allow(user.admin?)
205
- end
206
-
207
196
  # Everyone can read the assembly list
208
197
  def user_can_read_assembly_list?
209
198
  return unless read_assembly_list_permission_action?
@@ -247,6 +236,7 @@ module Decidim
247
236
  # Collaborators can read/preview everything inside their assembly.
248
237
  def collaborator_action?
249
238
  return unless can_manage_assembly?(role: :collaborator)
239
+ return if permission_action.subject == :space_private_user
250
240
 
251
241
  allow! if permission_action.action == :read || permission_action.action == :preview
252
242
  end
@@ -275,7 +265,6 @@ module Decidim
275
265
  :assembly,
276
266
  :assembly_user_role,
277
267
  :assembly_member,
278
- :space_private_user,
279
268
  :export_space,
280
269
  :import
281
270
  ].include?(permission_action.subject)
@@ -295,10 +284,8 @@ module Decidim
295
284
  :assembly,
296
285
  :assembly_user_role,
297
286
  :assembly_member,
298
- :space_private_user,
299
287
  :export_space,
300
- :import,
301
- :assemblies_setting
288
+ :import
302
289
  ].include?(permission_action.subject)
303
290
  allow! if is_allowed
304
291
  end
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::AssembliesSetting`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::AssembliesType`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::AssemblyMember`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::Assembly`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::AssemblyUserRole`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -3,6 +3,8 @@
3
3
  module Decidim
4
4
  module Assemblies
5
5
  class AssemblyPresenter < SimpleDelegator
6
+ include Decidim::TranslationsHelper
7
+
6
8
  def hero_image_url
7
9
  assembly.attached_uploader(:hero_image).url(host: assembly.organization.host)
8
10
  end
@@ -11,6 +13,42 @@ module Decidim
11
13
  assembly.attached_uploader(:banner_image).url(host: assembly.organization.host)
12
14
  end
13
15
 
16
+ def area_name
17
+ return if assembly.area.blank?
18
+
19
+ Decidim::AreaPresenter.new(assembly.area).translated_name_with_type
20
+ end
21
+
22
+ def creation_date
23
+ formatted_date(assembly.creation_date)
24
+ end
25
+
26
+ def included_at
27
+ formatted_date(assembly.included_at)
28
+ end
29
+
30
+ def closing_date
31
+ formatted_date(assembly.closing_date)
32
+ end
33
+
34
+ def duration
35
+ return I18n.t("indefinite_duration", scope: "decidim.assemblies.assemblies.description") if (date = assembly.duration).blank?
36
+
37
+ formatted_date(date)
38
+ end
39
+
40
+ def assembly_type
41
+ return if assembly.assembly_type.blank?
42
+
43
+ translated_attribute(assembly.assembly_type.title)
44
+ end
45
+
46
+ def formatted_date(date)
47
+ return if date.blank?
48
+
49
+ I18n.l(date, format: :decidim_short)
50
+ end
51
+
14
52
  def assembly
15
53
  __getobj__
16
54
  end
@@ -6,50 +6,11 @@ module Decidim
6
6
  class AssemblyStatsPresenter < Decidim::StatsPresenter
7
7
  include Decidim::IconHelper
8
8
 
9
- def assembly
10
- __getobj__.fetch(:assembly)
11
- end
12
-
13
- # Public: returns a collection of stats (Hash) for the Assembly Home.
14
- def collection
15
- highlighted_stats = assembly_participants_stats
16
- highlighted_stats.concat(assembly_followers_stats(priority: StatsRegistry::HIGH_PRIORITY))
17
- highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY))
18
- highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
19
- highlighted_stats.concat(comments_stats(:assemblies))
20
- highlighted_stats = highlighted_stats.reject(&:empty?)
21
- highlighted_stats = highlighted_stats.reject { |_stat_manifest, _stat_title, stat_number| stat_number.zero? }
22
- grouped_highlighted_stats = highlighted_stats.group_by(&:first)
23
-
24
- statistics(grouped_highlighted_stats)
25
- end
26
-
27
9
  private
28
10
 
29
- def assembly_participants_stats
30
- Decidim.stats.only([:participants_count]).with_context(assembly)
31
- .map { |stat_title, stat_number| [assembly.manifest.name, stat_title, stat_number] }
32
- end
33
-
34
- def component_stats(conditions)
35
- Decidim.component_manifests.map do |component_manifest|
36
- component_manifest.stats.except([:proposals_accepted])
37
- .filter(conditions)
38
- .with_context(published_components)
39
- .map { |stat_title, stat_number| [component_manifest.name, stat_title, stat_number] }.flatten
40
- end
41
- end
42
-
43
- def assembly_followers_stats(conditions)
44
- Decidim.stats.only([:followers_count])
45
- .filter(conditions)
46
- .with_context(assembly)
47
- .map { |stat_title, stat_number| [assembly.manifest.name, stat_title, stat_number] }
48
- end
11
+ def participatory_space = __getobj__.fetch(:assembly)
49
12
 
50
- def published_components
51
- @published_components ||= Component.where(participatory_space: assembly).published
52
- end
13
+ def participatory_space_sym = :assemblies
53
14
  end
54
15
  end
55
16
  end
@@ -9,7 +9,7 @@ module Decidim
9
9
  (Time.current.strftime("%Y%m%d").to_i - birthday.strftime("%Y%m%d").to_i) / 10_000 if birthday
10
10
  end
11
11
 
12
- delegate :profile_url, :avatar_url, to: :user, allow_nil: true
12
+ delegate :profile_url, to: :user, allow_nil: true
13
13
 
14
14
  def name
15
15
  user ? user.name : full_name
@@ -33,16 +33,30 @@ module Decidim
33
33
  I18n.t(__getobj__.position, scope: "decidim.admin.models.assembly_member.positions", default: "")
34
34
  end
35
35
 
36
- def non_user_avatar_path
37
- return non_user_avatar.default_url unless non_user_avatar.attached?
36
+ def avatar_url(variant = nil)
37
+ return user.avatar_url(variant) if user.present?
38
38
 
39
- non_user_avatar.path
39
+ non_user_avatar_path(variant)
40
+ end
41
+
42
+ def non_user_avatar_path(variant = nil)
43
+ return non_user_avatar.default_url(variant) unless non_user_avatar.attached?
44
+
45
+ non_user_avatar.path(variant:)
40
46
  end
41
47
 
42
48
  def non_user_avatar
43
49
  attached_uploader(:non_user_avatar)
44
50
  end
45
51
 
52
+ def has_tooltip?
53
+ false
54
+ end
55
+
56
+ def deleted?
57
+ false
58
+ end
59
+
46
60
  private
47
61
 
48
62
  def user
@@ -50,7 +50,7 @@ module Decidim
50
50
  if assembly
51
51
  [assembly]
52
52
  else
53
- Decidim::Assembly.where(organization: organization)
53
+ Decidim::Assembly.where(organization:)
54
54
  end
55
55
  end
56
56
  end
@@ -39,8 +39,8 @@ module Decidim
39
39
  attr_reader :user, :role
40
40
 
41
41
  def assembly_ids
42
- user_roles = AssemblyUserRole.where(user: user) if role == :any
43
- user_roles = AssemblyUserRole.where(user: user, role: role) if role != :any
42
+ user_roles = AssemblyUserRole.where(user:) if role == :any
43
+ user_roles = AssemblyUserRole.where(user:, role:) if role != :any
44
44
  user_roles.pluck(:decidim_assembly_id)
45
45
  end
46
46
  end
@@ -17,15 +17,15 @@ module Decidim
17
17
  # - title: The +title+ for the new Assembly
18
18
  # - slug: The +slug+ for the new Assembly
19
19
  #
20
- # Returns a Assembly.
20
+ # Returns an Assembly instance.
21
21
  def import(attributes, _user, opts)
22
22
  title = opts[:title]
23
23
  slug = opts[:slug]
24
24
  Decidim.traceability.perform_action!(:create, Assembly, @user, visibility: "all") do
25
25
  @imported_assembly = Assembly.new(
26
26
  organization: @organization,
27
- title: title,
28
- slug: slug,
27
+ title:,
28
+ slug:,
29
29
  hashtag: attributes["hashtag"],
30
30
  subtitle: attributes["subtitle"],
31
31
  short_description: attributes["short_description"],
@@ -8,7 +8,7 @@ module Decidim
8
8
  include Decidim::ResourceHelper
9
9
  include Decidim::TranslationsHelper
10
10
 
11
- # Public: Initializes the serializer with a assembly.
11
+ # Public: Initializes the serializer with an Assembly instance.
12
12
  def initialize(assembly)
13
13
  @assembly = assembly
14
14
  end