decidim-core 0.14.4 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-core might be problematic. Click here for more details.

Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -0
  3. data/app/assets/images/decidim/cc-badge.png +0 -0
  4. data/app/assets/images/decidim/gamification/badges/continuity.svg +73 -0
  5. data/app/assets/images/decidim/gamification/badges/followers.svg +115 -0
  6. data/app/assets/images/decidim/icons.svg +1 -0
  7. data/app/assets/javascripts/decidim/vizzs/areachart.js.es6 +186 -208
  8. data/app/assets/javascripts/decidim/vizzs/linechart.js.es6 +263 -0
  9. data/app/assets/javascripts/decidim/vizzs/metrics.js.es6 +36 -26
  10. data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +3 -2
  11. data/app/assets/javascripts/decidim/vizzs/rowchart.js.es6 +324 -0
  12. data/app/assets/stylesheets/decidim/_decidim.scss +1 -0
  13. data/app/assets/stylesheets/decidim/modules/_cards.scss +1 -0
  14. data/app/assets/stylesheets/decidim/modules/_conference-diploma.scss +75 -0
  15. data/app/assets/stylesheets/decidim/modules/_conference-media.scss +44 -0
  16. data/app/assets/stylesheets/decidim/modules/_conference-programme.scss +5 -1
  17. data/app/assets/stylesheets/decidim/modules/_conference-registration.scss +34 -0
  18. data/app/assets/stylesheets/decidim/modules/_list-request.scss +16 -0
  19. data/app/assets/stylesheets/decidim/modules/_modules.scss +4 -4
  20. data/app/assets/stylesheets/decidim/modules/_process-phase.scss +1 -0
  21. data/app/assets/stylesheets/decidim/modules/_reveal.scss +6 -1
  22. data/app/assets/stylesheets/decidim/utils/_helpers.scss +1 -1
  23. data/app/assets/stylesheets/decidim/{modules → vizzs}/_areachart.scss +8 -11
  24. data/app/assets/stylesheets/decidim/{modules → vizzs}/_chart-tooltip.scss +0 -0
  25. data/app/assets/stylesheets/decidim/vizzs/_linechart.scss +115 -0
  26. data/app/assets/stylesheets/decidim/vizzs/_rowchart.scss +77 -0
  27. data/app/cells/decidim/activities/show.erb +3 -0
  28. data/app/cells/decidim/activities_cell.rb +38 -0
  29. data/app/cells/decidim/activity/show.erb +21 -0
  30. data/app/cells/decidim/activity_cell.rb +85 -0
  31. data/app/cells/decidim/address/details.erb +7 -0
  32. data/app/cells/decidim/address/show.erb +14 -0
  33. data/app/cells/decidim/address_cell.rb +19 -0
  34. data/app/cells/decidim/author/contact.erb +1 -1
  35. data/app/cells/decidim/author_cell.rb +1 -0
  36. data/app/cells/decidim/badge/show.erb +2 -2
  37. data/app/cells/decidim/badge/small.erb +5 -0
  38. data/app/cells/decidim/badge_cell.rb +36 -14
  39. data/app/cells/decidim/badges/show.erb +6 -3
  40. data/app/cells/decidim/badges_cell.rb +4 -4
  41. data/app/cells/decidim/coauthorships_cell.rb +8 -2
  42. data/app/cells/decidim/collapsible_authors/show.erb +9 -7
  43. data/app/cells/decidim/content_blocks/html/show.erb +3 -0
  44. data/app/cells/decidim/content_blocks/html_cell.rb +11 -0
  45. data/app/cells/decidim/content_blocks/html_settings_form/show.erb +3 -0
  46. data/app/cells/decidim/content_blocks/html_settings_form_cell.rb +17 -0
  47. data/app/cells/decidim/content_blocks/last_activity/show.erb +17 -0
  48. data/app/cells/decidim/content_blocks/last_activity_cell.rb +60 -0
  49. data/app/cells/decidim/content_blocks/metrics/show.erb +13 -0
  50. data/app/cells/decidim/content_blocks/metrics_cell.rb +18 -0
  51. data/app/cells/decidim/content_blocks/stats/show.erb +2 -1
  52. data/app/cells/decidim/groups/show.erb +10 -0
  53. data/app/cells/decidim/groups_cell.rb +19 -0
  54. data/app/cells/decidim/members/show.erb +9 -0
  55. data/app/cells/decidim/members_cell.rb +32 -0
  56. data/app/cells/decidim/profile/show.erb +3 -11
  57. data/app/cells/decidim/profile/user_group_tabs.erb +5 -0
  58. data/app/cells/decidim/profile/user_tabs.erb +12 -0
  59. data/app/cells/decidim/profile_cell.rb +7 -2
  60. data/app/cells/decidim/profile_sidebar/show.erb +108 -23
  61. data/app/cells/decidim/profile_sidebar_cell.rb +36 -2
  62. data/app/cells/decidim/user_group_admin_membership_profile/footer.erb +29 -0
  63. data/app/cells/decidim/user_group_admin_membership_profile_cell.rb +14 -0
  64. data/app/cells/decidim/user_group_membership_profile/tags.erb +1 -0
  65. data/app/cells/decidim/user_group_membership_profile_cell.rb +8 -0
  66. data/app/cells/decidim/user_group_pending_invitations_list/show.erb +23 -0
  67. data/app/cells/decidim/user_group_pending_invitations_list_cell.rb +26 -0
  68. data/app/cells/decidim/user_group_pending_requests_list/show.erb +23 -0
  69. data/app/cells/decidim/user_group_pending_requests_list_cell.rb +26 -0
  70. data/app/cells/decidim/user_profile/header.erb +1 -1
  71. data/app/cells/decidim/user_profile_cell.rb +15 -9
  72. data/app/commands/decidim/accept_group_invitation.rb +43 -0
  73. data/app/commands/decidim/accept_user_group_join_request.rb +53 -0
  74. data/app/commands/decidim/create_follow.rb +6 -0
  75. data/app/commands/decidim/create_registration.rb +13 -23
  76. data/app/commands/decidim/create_user_group.rb +57 -0
  77. data/app/commands/decidim/delete_follow.rb +7 -0
  78. data/app/commands/decidim/demote_membership.rb +57 -0
  79. data/app/commands/decidim/destroy_account.rb +6 -0
  80. data/app/commands/decidim/invite_user.rb +1 -3
  81. data/app/commands/decidim/invite_user_to_group.rb +62 -0
  82. data/app/commands/decidim/join_user_group.rb +63 -0
  83. data/app/commands/decidim/leave_user_group.rb +41 -0
  84. data/app/commands/decidim/promote_membership.rb +55 -0
  85. data/app/commands/decidim/reject_group_invitation.rb +42 -0
  86. data/app/commands/decidim/reject_user_group_join_request.rb +53 -0
  87. data/app/commands/decidim/remove_user_from_group.rb +53 -0
  88. data/app/commands/decidim/update_user_group.rb +53 -0
  89. data/app/controllers/concerns/decidim/locale_switcher.rb +3 -3
  90. data/app/controllers/concerns/decidim/paginable.rb +1 -0
  91. data/app/controllers/decidim/application_controller.rb +7 -0
  92. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -1
  93. data/app/controllers/decidim/devise/sessions_controller.rb +1 -1
  94. data/app/controllers/decidim/gamification/badges_controller.rb +11 -0
  95. data/app/controllers/decidim/group_admins_controller.rb +41 -0
  96. data/app/controllers/decidim/group_invites_controller.rb +74 -0
  97. data/app/controllers/decidim/group_members_controller.rb +59 -0
  98. data/app/controllers/decidim/groups_controller.rb +85 -0
  99. data/app/controllers/decidim/last_activities_controller.rb +46 -0
  100. data/app/controllers/decidim/pages_controller.rb +9 -1
  101. data/app/controllers/decidim/profiles_controller.rb +35 -5
  102. data/app/controllers/decidim/user_group_join_requests_controller.rb +69 -0
  103. data/app/events/decidim/demoted_membership_event.rb +28 -0
  104. data/app/events/decidim/invited_to_group_event.rb +33 -0
  105. data/app/events/decidim/join_request_accepted_event.rb +28 -0
  106. data/app/events/decidim/join_request_created_event.rb +28 -0
  107. data/app/events/decidim/join_request_rejected_event.rb +28 -0
  108. data/app/events/decidim/promoted_to_admin_event.rb +28 -0
  109. data/app/events/decidim/removed_from_group_event.rb +28 -0
  110. data/app/forms/decidim/account_form.rb +1 -1
  111. data/app/forms/decidim/invite_user_to_group_form.rb +29 -0
  112. data/app/forms/decidim/notifications_settings_form.rb +4 -0
  113. data/app/forms/decidim/registration_form.rb +0 -27
  114. data/app/forms/decidim/user_group_form.rb +81 -0
  115. data/app/helpers/decidim/component_path_helper.rb +10 -0
  116. data/app/helpers/decidim/filters_helper.rb +3 -2
  117. data/app/helpers/decidim/icon_helper.rb +3 -1
  118. data/app/helpers/decidim/map_helper.rb +1 -1
  119. data/app/jobs/decidim/metric_job.rb +14 -0
  120. data/app/mailers/decidim/newsletter_mailer.rb +2 -0
  121. data/app/mailers/decidim/notification_mailer.rb +1 -1
  122. data/app/models/decidim/action_log.rb +66 -0
  123. data/app/models/decidim/coauthorship.rb +9 -0
  124. data/app/models/decidim/component.rb +5 -0
  125. data/app/models/decidim/continuity_badge_status.rb +9 -0
  126. data/app/models/decidim/gamification/badge_score.rb +1 -1
  127. data/app/models/decidim/messaging/message.rb +1 -0
  128. data/app/models/decidim/metric.rb +13 -0
  129. data/app/models/decidim/participatory_space_private_user.rb +4 -0
  130. data/app/models/decidim/user.rb +14 -38
  131. data/app/models/decidim/user_base_entity.rb +52 -0
  132. data/app/models/decidim/user_group.rb +48 -9
  133. data/app/models/decidim/user_group_membership.rb +8 -0
  134. data/app/permissions/decidim/permissions.rb +21 -0
  135. data/app/presenters/decidim/admin_log/organization_presenter.rb +0 -2
  136. data/app/presenters/decidim/admin_log/participatory_space_private_user_presenter.rb +38 -0
  137. data/app/presenters/decidim/metric_charts_presenter.rb +53 -0
  138. data/app/presenters/decidim/metric_object_presenter.rb +28 -0
  139. data/app/presenters/decidim/user_group_presenter.rb +16 -8
  140. data/app/presenters/decidim/user_presenter.rb +14 -0
  141. data/app/queries/decidim/metric_manage.rb +59 -0
  142. data/app/queries/decidim/metrics/users_metric_manage.rb +26 -0
  143. data/app/queries/decidim/user_groups/accepted_memberships.rb +36 -0
  144. data/app/queries/decidim/user_groups/accepted_user_groups.rb +38 -0
  145. data/app/queries/decidim/user_groups/accepted_users.rb +36 -0
  146. data/app/queries/decidim/user_groups/admin_memberships.rb +37 -0
  147. data/app/queries/decidim/user_groups/invited_memberships.rb +36 -0
  148. data/app/queries/decidim/user_groups/manageable_user_groups.rb +39 -0
  149. data/app/queries/decidim/user_groups/member_memberships.rb +37 -0
  150. data/app/resolvers/decidim/core/metric_resolver.rb +38 -0
  151. data/app/services/decidim/action_logger.rb +4 -2
  152. data/app/services/decidim/activity_search.rb +76 -0
  153. data/app/services/decidim/continuity_badge_tracker.rb +64 -0
  154. data/app/services/decidim/resource_search.rb +0 -1
  155. data/app/types/decidim/core/metric_history_type.rb +17 -0
  156. data/app/types/decidim/core/metric_type.rb +14 -0
  157. data/app/types/decidim/core/session_type.rb +1 -1
  158. data/app/types/decidim/core/user_group_type.rb +2 -2
  159. data/app/views/decidim/authorization_modals/show.html.erb +40 -27
  160. data/app/views/decidim/devise/registrations/new.html.erb +0 -19
  161. data/app/views/decidim/gamification/badges/index.html.erb +42 -0
  162. data/app/views/decidim/group_admins/index.html.erb +18 -0
  163. data/app/views/decidim/group_invites/index.html.erb +27 -0
  164. data/app/views/decidim/group_members/index.html.erb +19 -0
  165. data/app/views/decidim/groups/_form.html.erb +23 -0
  166. data/app/views/decidim/groups/edit.html.erb +26 -0
  167. data/app/views/decidim/groups/new.html.erb +26 -0
  168. data/app/views/decidim/last_activities/_activities.html.erb +13 -0
  169. data/app/views/decidim/last_activities/index.html.erb +18 -0
  170. data/app/views/decidim/last_activities/index.js.erb +6 -0
  171. data/app/views/decidim/profiles/show.html.erb +1 -1
  172. data/app/views/layouts/decidim/_user_menu.html.erb +0 -1
  173. data/app/views/layouts/decidim/_wrapper.html.erb +1 -1
  174. data/config/initializers/devise.rb +1 -1
  175. data/config/initializers/foundation_rails_helper.rb +1 -0
  176. data/config/locales/ca.yml +325 -32
  177. data/config/locales/de.yml +325 -32
  178. data/config/locales/en.yml +325 -32
  179. data/config/locales/es-PY.yml +325 -32
  180. data/config/locales/es.yml +325 -32
  181. data/config/locales/eu.yml +325 -32
  182. data/config/locales/fi.yml +330 -37
  183. data/config/locales/fr.yml +325 -32
  184. data/config/locales/gl.yml +325 -32
  185. data/config/locales/hu.yml +327 -34
  186. data/config/locales/it.yml +325 -32
  187. data/config/locales/nl.yml +325 -32
  188. data/config/locales/pl.yml +329 -32
  189. data/config/locales/pt-BR.yml +326 -33
  190. data/config/locales/pt.yml +325 -32
  191. data/config/locales/ru.yml +4 -33
  192. data/config/locales/sv.yml +346 -53
  193. data/config/locales/uk.yml +4 -33
  194. data/config/routes.rb +27 -1
  195. data/db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb +11 -0
  196. data/db/migrate/20180705134647_create_decidim_metrics.rb +16 -0
  197. data/db/migrate/20180730071851_add_core_content_blocks.rb +3 -3
  198. data/db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb +4 -2
  199. data/db/migrate/20180918072506_add_visibility_to_action_logs.rb +8 -0
  200. data/db/migrate/20181001124950_move_users_groups_to_users_table.rb +84 -0
  201. data/db/migrate/20181008102144_add_badge_switch_to_organizations.rb +8 -0
  202. data/db/migrate/20181010044613_create_decidim_continuity_badge_statuses.rb +11 -0
  203. data/db/migrate/20181011080252_add_roles_to_memberships.rb +24 -0
  204. data/db/migrate/20181016091601_make_authors_polymorphic.rb +31 -0
  205. data/db/migrate/20181029112820_fix_user_follows.rb +18 -0
  206. data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +16 -0
  207. data/db/seeds.rb +18 -4
  208. data/lib/decidim/attributes.rb +1 -0
  209. data/lib/decidim/attributes/localized_date.rb +16 -0
  210. data/lib/decidim/attributes/time_with_zone.rb +3 -1
  211. data/lib/decidim/authorable.rb +5 -4
  212. data/lib/decidim/authorization_form_builder.rb +2 -2
  213. data/lib/decidim/coauthorable.rb +68 -18
  214. data/lib/decidim/content_block_manifest.rb +7 -0
  215. data/lib/decidim/content_processor.rb +17 -7
  216. data/lib/decidim/core.rb +12 -0
  217. data/lib/decidim/core/engine.rb +54 -6
  218. data/lib/decidim/core/test/factories.rb +63 -17
  219. data/lib/decidim/core/test/shared_examples/coauthorable.rb +27 -9
  220. data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +2 -2
  221. data/lib/decidim/core/version.rb +1 -1
  222. data/lib/decidim/data_portability.rb +3 -1
  223. data/lib/decidim/data_portability_file_reader.rb +1 -1
  224. data/lib/decidim/events/author_event.rb +4 -1
  225. data/lib/decidim/events/coauthor_event.rb +4 -1
  226. data/lib/decidim/faker/localized.rb +5 -4
  227. data/lib/decidim/form_builder.rb +18 -17
  228. data/lib/decidim/gamification.rb +8 -2
  229. data/lib/decidim/gamification/badge.rb +34 -0
  230. data/lib/decidim/gamification/badge_scorer.rb +29 -14
  231. data/lib/decidim/gamification/badge_status.rb +2 -0
  232. data/lib/decidim/hashtaggable.rb +1 -1
  233. data/lib/decidim/manifest_registry.rb +5 -3
  234. data/lib/decidim/metric_manifest.rb +20 -0
  235. data/lib/decidim/metric_registry.rb +71 -0
  236. data/lib/decidim/participable.rb +1 -1
  237. data/lib/decidim/participatory_space_resourceable.rb +0 -1
  238. data/lib/decidim/query_extensions.rb +19 -0
  239. data/lib/decidim/resourceable.rb +1 -0
  240. data/lib/decidim/searchable.rb +2 -1
  241. data/lib/tasks/decidim_metrics_tasks.rake +41 -0
  242. data/lib/tasks/decidim_tasks.rake +1 -0
  243. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ca.js +1 -2
  244. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.es.js +1 -2
  245. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr.js +1 -2
  246. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.gl.js +1 -2
  247. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt.js +1 -2
  248. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ru.js +1 -2
  249. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +1 -2
  250. data/vendor/assets/javascripts/form_datepicker.js.es6 +1 -11
  251. metadata +144 -23
  252. data/app/cells/decidim/invitations_toggle/content.erb +0 -1
  253. data/app/cells/decidim/invitations_toggle/label.erb +0 -1
  254. data/app/cells/decidim/invitations_toggle_cell.rb +0 -27
  255. data/app/cells/decidim/toggle/show.erb +0 -8
  256. data/app/cells/decidim/toggle_cell.rb +0 -42
  257. data/app/commands/decidim/invite_friends.rb +0 -48
  258. data/app/controllers/decidim/invitations_controller.rb +0 -32
  259. data/app/forms/decidim/invitations_form.rb +0 -37
  260. data/app/views/decidim/invitations/index.html.erb +0 -48
  261. data/app/views/devise/mailer/invite_friend.html.erb +0 -27
  262. data/app/views/devise/mailer/invite_friend.text.erb +0 -19
  263. data/lib/decidim/rectify_ext.rb +0 -32
@@ -1,10 +1,12 @@
1
- <%= cell(
2
- "decidim/collapsible_list",
3
- list,
4
- cell_name: cell_name,
5
- cell_options: options.merge(has_actions: false),
6
- size: size
7
- ) %>
1
+ <div class="author--inline">
2
+ <%= cell(
3
+ "decidim/collapsible_list",
4
+ list,
5
+ cell_name: cell_name,
6
+ cell_options: options.merge(has_actions: false),
7
+ size: size
8
+ ) %>
9
+ </div>
8
10
  <% if actionable? %>
9
11
  <div class="author-data__extra">
10
12
  <% author_cell= cell("decidim/author", model, from: from_context) %>
@@ -0,0 +1,3 @@
1
+ <section class="extended home-section" id="html-block">
2
+ <%= html_content %>
3
+ </section>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ContentBlocks
5
+ class HtmlCell < Decidim::ViewModel
6
+ def html_content
7
+ translated_attribute(model.settings.html_content).html_safe
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
+ <%= settings_fields.translated :text_area, :html_content, label: label %>
3
+ <% end %>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ContentBlocks
5
+ class HtmlSettingsFormCell < Decidim::ViewModel
6
+ alias form model
7
+
8
+ def content_block
9
+ options[:content_block]
10
+ end
11
+
12
+ def label
13
+ I18n.t("decidim.content_blocks.html.html_content")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ <section class="wrapper-home upcoming-events home-section">
2
+ <div class="row">
3
+ <h3 class="section-heading"><%= t("decidim.content_blocks.last_activity.title") %></h3>
4
+ <div class="row">
5
+ <% valid_activities.each_slice(4) do |column_activities| %>
6
+ <div class="columns medium-6">
7
+ <%= cell "decidim/activities", column_activities %>
8
+ </div>
9
+ <% end %>
10
+ </div>
11
+ <div class="row">
12
+ <div class="column">
13
+ <%= link_to t("decidim.content_blocks.last_activity.view_all"), last_activities_path, class: "button hollow button--sc pull-right" %>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ </section>
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ContentBlocks
5
+ # A cell to be rendered as a content block with the latest activities performed
6
+ # in a Decidim Organization.
7
+ class LastActivityCell < Decidim::ViewModel
8
+ include Decidim::Core::Engine.routes.url_helpers
9
+
10
+ delegate :current_organization, to: :controller
11
+
12
+ def show
13
+ return if activities.empty?
14
+ render
15
+ end
16
+
17
+ # The activities to be displayed at the content block.
18
+ #
19
+ # We need to build the collection this way because an ActionLog has
20
+ # polymorphic relations to different kind of models, and these models
21
+ # might not be available (a proposal might have been hidden or withdrawn).
22
+ #
23
+ # Since these conditions can't always be filtered with a database search
24
+ # we ask for more activities than we actually need and then loop until there
25
+ # are enough of them.
26
+ #
27
+ # Returns an Array of ActionLogs.
28
+ def valid_activities
29
+ return @valid_activities if defined?(@valid_activities)
30
+
31
+ valid_activities_count = 0
32
+ @valid_activities = []
33
+
34
+ activities.each do |activity|
35
+ break if valid_activities_count == activities_to_show
36
+
37
+ if activity.resource_lazy.present? && activity.participatory_space_lazy.present?
38
+ @valid_activities << activity
39
+ valid_activities_count += 1
40
+ end
41
+ end
42
+
43
+ @valid_activities
44
+ end
45
+
46
+ private
47
+
48
+ def activities
49
+ @activities ||= ActivitySearch.new(
50
+ organization: current_organization,
51
+ resource_type: "all"
52
+ ).results.limit(activities_to_show * 6)
53
+ end
54
+
55
+ def activities_to_show
56
+ options[:activities_count] || 8
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,13 @@
1
+ <section class="extended" id="metrics">
2
+ <div class="wrapper-home">
3
+ <div class="row column text-center mb-sm">
4
+ <h2 class="heading2"><%= t("decidim.pages.home.metrics.headline", organization: current_organization.name) %></h2>
5
+ </div>
6
+ <div class="row mb-sm">
7
+ <%= metrics.highlighted %>
8
+ </div>
9
+ <div class="row collapse section">
10
+ <%= metrics.not_highlighted %>
11
+ </div>
12
+ </div>
13
+ </section>
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ContentBlocks
5
+ class MetricsCell < Decidim::ViewModel
6
+ delegate :current_organization, to: :controller
7
+
8
+ def show
9
+ return unless current_organization.show_statistics?
10
+ render
11
+ end
12
+
13
+ def metrics
14
+ @metrics ||= MetricChartsPresenter.new(organization: current_organization)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -11,4 +11,5 @@
11
11
  </div>
12
12
  </div>
13
13
  </div>
14
- </section>
14
+ </div>
15
+ </section>
@@ -0,0 +1,10 @@
1
+ <%= cell "decidim/user_group_pending_invitations_list", model %>
2
+ <div class="empty-notifications callout secondary <%= "hide" if user_groups.any? %>">
3
+ <p><%= t("decidim.groups.no_user_groups") %></p>
4
+ </div>
5
+ <div class="row small-up-1 medium-up-2 card-grid">
6
+ <% user_groups.each do |user_group| %>
7
+ <%= card_for user_group %>
8
+ <% end %>
9
+ </div>
10
+ <%= decidim_paginate user_groups %>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This cell is intended to be used on profiles.
5
+ class GroupsCell < Decidim::ViewModel
6
+ include Decidim::CellsPaginateHelper
7
+ include Decidim::ApplicationHelper
8
+ include Decidim::Core::Engine.routes.url_helpers
9
+ include Decidim::CardHelper
10
+
11
+ def show
12
+ render :show
13
+ end
14
+
15
+ def user_groups
16
+ @user_groups ||= Decidim::UserGroups::AcceptedUserGroups.for(model).page(params[:page]).per(20)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ <div class="empty-notifications callout secondary <%= "hide" if memberships.any? %>">
2
+ <p><%= t("decidim.members.no_members") %></p>
3
+ </div>
4
+ <div class="row small-up-1 medium-up-2 card-grid">
5
+ <% memberships.each do |membership| %>
6
+ <%= cell membership_cell_name, membership %>
7
+ <% end %>
8
+ </div>
9
+ <%= decidim_paginate memberships %>
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This cell is intended to be used on profiles.
5
+ # Lists the members of the given user group.
6
+ class MembersCell < Decidim::ViewModel
7
+ include Decidim::CellsPaginateHelper
8
+ include Decidim::ApplicationHelper
9
+ include Decidim::Core::Engine.routes.url_helpers
10
+ include Decidim::CardHelper
11
+
12
+ def show
13
+ render :show
14
+ end
15
+
16
+ def membership_cell_name
17
+ return "decidim/user_group_admin_membership_profile" if options[:from_admin].presence
18
+ "decidim/user_group_membership_profile"
19
+ end
20
+
21
+ def memberships
22
+ @memberships ||= case options[:role].to_s
23
+ when "member"
24
+ Decidim::UserGroups::MemberMemberships.for(model).page(params[:page]).per(20)
25
+ when "admin"
26
+ Decidim::UserGroups::AdminMemberships.for(model).page(params[:page]).per(20)
27
+ else
28
+ Decidim::UserGroups::AcceptedMemberships.for(model).page(params[:page]).per(20)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,25 +1,17 @@
1
1
  <main class="wrapper">
2
2
  <div class="row">
3
3
  <div class="columns medium-9 medium-offset-3">
4
- <ul class="tabs" id="profile-tabs">
5
- <% if own_profile? %>
6
- <%= user_profile_tab t("decidim.profiles.show.notifications"), notifications_path %>
7
- <%= user_profile_tab t("decidim.profiles.show.conversations"), conversations_path %>
8
- <% end %>
9
- <%= user_profile_tab t("decidim.profiles.show.following"), profile_following_path(nickname: user.nickname) %>
10
- <%= user_profile_tab t("decidim.profiles.show.followers"), profile_followers_path(nickname: user.nickname) %>
11
- <%= user_profile_tab t("decidim.profiles.show.badges"), profile_badges_path(nickname: user.nickname) %>
12
- </ul>
4
+ <%= profile_tabs %>
13
5
  </div>
14
6
  </div>
15
7
  <div class="row">
16
8
  <div class="columns medium-3">
17
- <%= cell "decidim/profile_sidebar", user %>
9
+ <%= cell "decidim/profile_sidebar", profile_holder %>
18
10
  </div>
19
11
  <div class="columns medium-9">
20
12
  <div class="tabs-content" data-tabs-content="profile-tabs">
21
13
  <div class="tabs-panel is-active">
22
- <%= cell content_cell, user, context %>
14
+ <%= cell content_cell, profile_holder, context %>
23
15
  </div>
24
16
  </div>
25
17
  </div>
@@ -0,0 +1,5 @@
1
+ <ul class="tabs" id="profile-tabs">
2
+ <%= user_profile_tab t("decidim.profiles.show.members"), profile_members_path(nickname: profile_holder.nickname) %>
3
+ <%= user_profile_tab t("decidim.profiles.show.followers"), profile_followers_path(nickname: profile_holder.nickname) %>
4
+ <%= user_profile_tab t("decidim.profiles.show.badges"), profile_badges_path(nickname: profile_holder.nickname) %>
5
+ </ul>
@@ -0,0 +1,12 @@
1
+ <ul class="tabs" id="profile-tabs">
2
+ <% if own_profile? %>
3
+ <%= user_profile_tab t("decidim.profiles.show.notifications"), notifications_path %>
4
+ <%= user_profile_tab t("decidim.profiles.show.conversations"), conversations_path %>
5
+ <% end %>
6
+ <%= user_profile_tab t("decidim.profiles.show.following"), profile_following_path(nickname: profile_holder.nickname) %>
7
+ <%= user_profile_tab t("decidim.profiles.show.followers"), profile_followers_path(nickname: profile_holder.nickname) %>
8
+ <% if current_organization.badges_enabled? %>
9
+ <%= user_profile_tab t("decidim.profiles.show.badges"), profile_badges_path(nickname: profile_holder.nickname) %>
10
+ <% end %>
11
+ <%= user_profile_tab t("decidim.profiles.show.groups"), profile_groups_path(nickname: profile_holder.nickname) %>
12
+ </ul>
@@ -14,7 +14,7 @@ module Decidim
14
14
  render :show
15
15
  end
16
16
 
17
- def user
17
+ def profile_holder
18
18
  model
19
19
  end
20
20
 
@@ -27,7 +27,12 @@ module Decidim
27
27
  end
28
28
 
29
29
  def own_profile?
30
- current_user && current_user == user
30
+ current_user && current_user == profile_holder
31
+ end
32
+
33
+ def profile_tabs
34
+ return render :user_group_tabs if profile_holder.is_a?(Decidim::UserGroup)
35
+ render :user_tabs
31
36
  end
32
37
  end
33
38
  end
@@ -1,4 +1,4 @@
1
- <div class="card">
1
+ <div class="card profile--sidebar">
2
2
  <%= image_tag profile_user.avatar_url(:profile), class: "card__image card__image--larger" %>
3
3
  <div class="card__content">
4
4
  <h5>
@@ -6,7 +6,7 @@
6
6
  <span class="text-small"><%= profile_user.nickname %></span>
7
7
  <% if can_contact_user? %>
8
8
  <span class="user-contact_link">
9
- <%= link_to_current_or_new_conversation_with(user) %>
9
+ <%= link_to_current_or_new_conversation_with(profile_holder) %>
10
10
  </span>
11
11
  <% end %>
12
12
  </h5>
@@ -21,37 +21,122 @@
21
21
  <%= icon profile_user.badge, class: "author__verified" %>
22
22
  </span>
23
23
  <span>
24
- <%= translated_attribute(profile_user.officialized_as).presence || t("decidim.profiles.default_officialization_text") %>
24
+ <%= officialization_text %>
25
25
  </span>
26
26
  </div>
27
27
  <% end %>
28
28
  <%= render_hook(:user_profile_bottom) %>
29
29
  <div class="card__footer card__footer--transparent">
30
30
  <div class="flex--cc p-s text-center">
31
- <div class="mr-s">
32
- <%= link_to profile_followers_path(nickname: user.nickname) do %>
33
- <%= t("decidim.profiles.show.followers") %>
34
- <h1 class="heading1"><%= profile_user.followers_count %></h1>
31
+ <% if profile_user_can_follow? %>
32
+ <div class="mr-s">
33
+ <%= link_to profile_followers_path(nickname: profile_holder.nickname) do %>
34
+ <%= t("decidim.profiles.show.followers") %>
35
+ <h1 class="heading1"><%= profile_user.followers_count %></h1>
36
+ <% end %>
37
+ </div>
38
+ <div class="ml-s">
39
+ <%= link_to profile_following_path(nickname: profile_holder.nickname) do %>
40
+ <%= t("decidim.profiles.show.following") %>
41
+ <h1 class="heading1"><%= profile_user.following_count %></h1>
42
+ <% end %>
43
+ </div>
44
+ <% else %>
45
+ <div class="mr-s">
46
+ <%= link_to profile_followers_path(nickname: profile_holder.nickname) do %>
47
+ <%= t("decidim.profiles.show.followers") %>
48
+ <h1 class="heading1"><%= profile_user.followers_count %></h1>
49
+ <% end %>
50
+ </div>
51
+ <div class="ml-s">
52
+ <%= link_to profile_members_path(nickname: profile_holder.nickname) do %>
53
+ <%= t("decidim.profiles.show.members") %>
54
+ <h1 class="heading1"><%= profile_user.members_count %></h1>
55
+ <% end %>
56
+ </div>
57
+ <% end %>
58
+ </div>
59
+ </div>
60
+
61
+ <% if current_organization.badges_enabled? && badge_statuses.any? %>
62
+ <div class="card__footer card__footer--transparent">
63
+ <div class="card__support">
64
+ <div class="row column mb-s">
65
+ <strong class="muted"><%= t("decidim.profiles.sidebar.badges.title") %></strong>
66
+ <div class="badge-tip badge-tip--inline">
67
+ <div data-tooltip data-position="top" title="<%= t("decidim.profiles.sidebar.badges.info") %>" aria-describedby="badges-tooltip" data-yeti-box="badges-tooltip" data-toggle="badges-tooltip" data-resize="badges-tooltip" class="has-tip" data-events="resize">
68
+ <%= icon "info", class: "icon--small" %>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ <div class="collapsible-list is-filtered row small-up-2 medium-up-4 collapse">
73
+ <% badge_statuses.each do |status| %>
74
+ <div class="column">
75
+ <div class="badge-container pr-xs">
76
+ <%= cell("decidim/badge", profile_holder, badge: status.badge, status: status).(:small) %>
77
+ </div>
78
+ </div>
79
+ <% end %>
80
+ </div>
81
+ </div>
82
+ </div>
83
+ <% end %>
84
+ </div>
85
+
86
+ <div class="row">
87
+ <div class="column medium-8 medium-centered">
88
+ <% if own_profile? %>
89
+ <div class="text-center">
90
+ <%= link_to decidim.account_path, class: "button" do %>
91
+ <span>
92
+ <%= t("decidim.profiles.user.edit_profile") %>
93
+ </span>
35
94
  <% end %>
36
95
  </div>
37
- <div class="ml-s">
38
- <%= link_to profile_following_path(nickname: user.nickname) do %>
39
- <%= t("decidim.profiles.show.following") %>
40
- <h1 class="heading1"><%= profile_user.following_count %></h1>
96
+ <div class="text-center">
97
+ <%= link_to decidim.new_group_path, class: "button secondary light" do %>
98
+ <span>
99
+ <%= t("decidim.profiles.user.create_user_group") %>
100
+ </span>
41
101
  <% end %>
42
102
  </div>
43
- </div>
44
- </div>
45
- </div>
103
+ <% elsif logged_in? %>
104
+ <%= cell "decidim/follow_button", profile_holder, inline: false, context: { current_user: current_user } %>
105
+ <% end %>
46
106
 
47
- <% if own_profile? %>
48
- <div class="text-center">
49
- <%= link_to decidim.account_path, class: "button" do %>
50
- <span>
51
- <%= t("decidim.profiles.user.edit_profile") %>
52
- </span>
107
+ <% if can_edit_user_group_profile? %>
108
+ <div class="text-center">
109
+ <%= link_to t("decidim.profiles.user.edit_user_group"), edit_group_path(profile_holder.nickname) %>
110
+ </div>
111
+ <div class="text-center">
112
+ <%= link_to t("decidim.profiles.user.manage_user_group_users"), group_manage_users_path(profile_holder.nickname) %>
113
+ </div>
114
+ <div class="text-center">
115
+ <%= link_to t("decidim.profiles.user.manage_user_group_admins"), group_manage_admins_path(profile_holder.nickname) %>
116
+ </div>
117
+ <div class="text-center">
118
+ <%= link_to t("decidim.profiles.user.invite_user"), group_invites_path(profile_holder.nickname) %>
119
+ </div>
120
+ <% end %>
121
+
122
+ <% if can_join_user_group? %>
123
+ <div class="text-center">
124
+ <%= link_to decidim.group_join_requests_path(model.nickname), method: :post, class: "button light expanded" do %>
125
+ <span>
126
+ <%= t("decidim.profiles.user.join_user_group") %>
127
+ </span>
128
+ <% end %>
129
+ </div>
130
+ <% end %>
131
+
132
+ <% if can_leave_group? %>
133
+ <div class="text-center">
134
+ <%= link_to decidim.leave_group_path(model.nickname), method: :delete, data: { confirm: t("decidim.groups.actions.are_you_sure") }, class: "button light expanded" do %>
135
+ <span>
136
+ <%= t("decidim.profiles.user.leave_user_group") %>
137
+ </span>
138
+ <% end %>
139
+ </div>
53
140
  <% end %>
54
141
  </div>
55
- <% elsif logged_in? %>
56
- <%= cell "decidim/follow_button", user, inline: false, context: { current_user: current_user } %>
57
- <% end %>
142
+ </div>