decidim-core 0.10.1 → 0.11.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -11
  3. data/app/assets/images/decidim/icons.svg +25 -6
  4. data/app/assets/javascripts/decidim/account_form.js.es6 +8 -8
  5. data/app/assets/javascripts/decidim/append_elements.js.es6 +1 -1
  6. data/app/assets/javascripts/decidim/append_redirect_url_to_modals.js.es6 +5 -5
  7. data/app/assets/javascripts/decidim/data_picker.js.es6 +10 -10
  8. data/app/assets/javascripts/decidim/editor.js.es6 +37 -22
  9. data/app/assets/javascripts/decidim/filters.js.es6 +1 -1
  10. data/app/assets/javascripts/decidim/form_filter.component.js.es6 +15 -15
  11. data/app/assets/javascripts/decidim/form_filter.component.test.js +29 -29
  12. data/app/assets/javascripts/decidim/impersonation.js.es6 +3 -3
  13. data/app/assets/javascripts/decidim/input_mentions.js.es6 +100 -0
  14. data/app/assets/javascripts/decidim/input_tags.js.es6 +12 -0
  15. data/app/assets/javascripts/decidim/{map.js.es6.erb → map.js.es6} +9 -9
  16. data/app/assets/javascripts/decidim/notifications.js.es6 +10 -10
  17. data/app/assets/javascripts/decidim/orders.js.es6 +5 -5
  18. data/app/assets/javascripts/decidim/user_registrations.js.es6 +4 -4
  19. data/app/assets/javascripts/decidim/widget.js.es6 +1 -1
  20. data/app/assets/javascripts/decidim.js.es6 +10 -0
  21. data/app/assets/stylesheets/decidim/application.scss.erb +1 -1
  22. data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +39 -0
  23. data/app/assets/stylesheets/decidim/modules/_cards.scss +158 -3
  24. data/app/assets/stylesheets/decidim/modules/_definition-data.scss +6 -0
  25. data/app/assets/stylesheets/decidim/modules/_extra.scss +1 -3
  26. data/app/assets/stylesheets/decidim/modules/_icons.scss +14 -6
  27. data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +61 -0
  28. data/app/assets/stylesheets/decidim/modules/_input-mentions.scss +124 -0
  29. data/app/assets/stylesheets/decidim/modules/_input-tags.scss +55 -0
  30. data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
  31. data/app/assets/stylesheets/decidim/modules/_status-labels.scss +4 -0
  32. data/app/assets/stylesheets/decidim/modules/_typography.scss +16 -0
  33. data/app/assets/stylesheets/decidim/utils/_helpers.scss +29 -0
  34. data/app/assets/stylesheets/decidim/utils/_mixins.scss +6 -0
  35. data/app/cells/decidim/author_box/show.erb +10 -0
  36. data/app/cells/decidim/author_box_cell.rb +21 -0
  37. data/app/cells/decidim/card/show.erb +17 -0
  38. data/app/cells/decidim/card_cell.rb +29 -0
  39. data/app/cells/decidim/profile/profile_inline.erb +21 -0
  40. data/app/cells/decidim/profile/show.erb +13 -0
  41. data/app/cells/decidim/profile_cell.rb +17 -0
  42. data/app/commands/decidim/create_omniauth_registration.rb +3 -2
  43. data/app/commands/decidim/create_report.rb +1 -1
  44. data/app/commands/decidim/invite_user.rb +2 -0
  45. data/app/constraints/decidim/current_component.rb +41 -0
  46. data/app/controllers/concerns/decidim/action_authorization.rb +3 -3
  47. data/app/controllers/concerns/decidim/devise_controllers.rb +2 -1
  48. data/app/controllers/concerns/decidim/filter_resource.rb +1 -1
  49. data/app/controllers/concerns/decidim/form_factory.rb +1 -1
  50. data/app/controllers/concerns/decidim/impersonate_users.rb +6 -2
  51. data/app/controllers/concerns/decidim/needs_authorization.rb +2 -2
  52. data/app/controllers/concerns/decidim/participatory_space_context.rb +15 -0
  53. data/app/controllers/concerns/decidim/settings.rb +5 -5
  54. data/app/controllers/decidim/application_controller.rb +2 -1
  55. data/app/controllers/decidim/{features → components}/base_controller.rb +16 -8
  56. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +3 -1
  57. data/app/controllers/decidim/devise/registrations_controller.rb +1 -3
  58. data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +16 -0
  59. data/app/controllers/decidim/doorkeeper/credentials_controller.rb +46 -0
  60. data/app/controllers/decidim/doorkeeper/token_info_controller.rb +9 -0
  61. data/app/controllers/decidim/doorkeeper/tokens_controller.rb +9 -0
  62. data/app/controllers/decidim/widgets_controller.rb +1 -1
  63. data/app/forms/decidim/follow_form.rb +1 -1
  64. data/app/forms/decidim/form.rb +1 -1
  65. data/app/forms/decidim/omniauth_registration_form.rb +1 -0
  66. data/app/forms/decidim/registration_form.rb +5 -5
  67. data/app/helpers/decidim/card_helper.rb +16 -0
  68. data/app/helpers/decidim/component_path_helper.rb +36 -0
  69. data/app/helpers/decidim/icon_helper.rb +7 -7
  70. data/app/helpers/decidim/messaging/conversation_helper.rb +4 -3
  71. data/app/helpers/decidim/paginate_helper.rb +1 -1
  72. data/app/helpers/decidim/resource_helper.rb +2 -2
  73. data/app/jobs/decidim/export_job.rb +3 -3
  74. data/app/mailers/decidim/messaging/conversation_mailer.rb +0 -2
  75. data/app/middleware/decidim/current_organization.rb +2 -2
  76. data/app/models/decidim/abilities/admin_ability.rb +1 -1
  77. data/app/models/decidim/abilities/everyone_ability.rb +1 -1
  78. data/app/models/decidim/abilities/participatory_process_admin_ability.rb +2 -2
  79. data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +2 -2
  80. data/app/models/decidim/action_log.rb +7 -5
  81. data/app/models/decidim/area.rb +7 -0
  82. data/app/models/decidim/authorization.rb +14 -0
  83. data/app/models/decidim/{feature.rb → component.rb} +15 -15
  84. data/app/models/decidim/moderation.rb +1 -1
  85. data/app/models/decidim/oauth_application.rb +24 -0
  86. data/app/models/decidim/organization.rb +5 -0
  87. data/app/models/decidim/participatory_space_link.rb +20 -0
  88. data/app/models/decidim/participatory_space_private_user.rb +19 -0
  89. data/app/models/decidim/user.rb +7 -0
  90. data/app/presenters/decidim/admin_log/area_presenter.rb +38 -0
  91. data/app/presenters/decidim/admin_log/{feature_presenter.rb → component_presenter.rb} +5 -5
  92. data/app/presenters/decidim/admin_log/newsletter_resource_presenter.rb +1 -1
  93. data/app/presenters/decidim/admin_log/oauth_application_presenter.rb +50 -0
  94. data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +18 -0
  95. data/app/presenters/decidim/home_stats_presenter.rb +7 -7
  96. data/app/presenters/decidim/log/value_types/area_presenter.rb +1 -1
  97. data/app/presenters/decidim/log/value_types/area_type_presenter.rb +28 -0
  98. data/app/presenters/decidim/log/value_types/currency_presenter.rb +20 -0
  99. data/app/presenters/decidim/log/value_types/scope_presenter.rb +1 -1
  100. data/app/presenters/decidim/log/value_types/scope_type_presenter.rb +1 -1
  101. data/app/presenters/decidim/resource_locator_presenter.rb +3 -3
  102. data/app/services/decidim/action_authorizer.rb +9 -9
  103. data/app/services/decidim/action_logger.rb +9 -7
  104. data/app/services/decidim/email_notification_generator.rb +1 -1
  105. data/app/services/decidim/notification_generator_for_recipient.rb +1 -1
  106. data/app/services/decidim/resource_search.rb +8 -8
  107. data/app/services/decidim/settings_change.rb +5 -5
  108. data/app/services/decidim/static_map_generator.rb +1 -1
  109. data/app/types/decidim/core/attachment_type.rb +14 -0
  110. data/app/types/decidim/core/category_type.rb +16 -0
  111. data/app/types/decidim/core/coordinates_type.rb +19 -0
  112. data/app/types/decidim/core/scope_api_type.rb +16 -0
  113. data/app/uploaders/decidim/oauth_application_logo_uploader.rb +9 -0
  114. data/app/validators/geocoding_validator.rb +2 -2
  115. data/app/views/decidim/account/delete.html.erb +7 -7
  116. data/app/views/decidim/application/_collection.html.erb +1 -1
  117. data/app/views/decidim/application/_document.html.erb +1 -1
  118. data/app/views/decidim/application/_photos.html.erb +1 -1
  119. data/app/views/decidim/devise/invitations/edit.html.erb +1 -1
  120. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
  121. data/app/views/decidim/devise/registrations/new.html.erb +1 -1
  122. data/app/views/decidim/devise/sessions/new.html.erb +2 -2
  123. data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
  124. data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +1 -1
  125. data/app/views/decidim/doorkeeper/authorizations/new.html.erb +58 -0
  126. data/app/views/decidim/messaging/conversations/_show.html.erb +1 -1
  127. data/app/views/decidim/messaging/conversations/index.html.erb +1 -1
  128. data/app/views/decidim/notifications/index.html.erb +1 -1
  129. data/app/views/decidim/notifications_settings/show.html.erb +2 -2
  130. data/app/views/decidim/own_user_groups/index.html.erb +3 -3
  131. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +4 -4
  132. data/app/views/decidim/scopes/picker.html.erb +3 -3
  133. data/app/views/decidim/shared/_action_authorization_modal.html.erb +1 -1
  134. data/app/views/decidim/shared/_author.html.erb +1 -1
  135. data/app/views/decidim/shared/_author_reference.html.erb +1 -12
  136. data/app/views/decidim/shared/{_feature_announcement.html.erb → _component_announcement.html.erb} +2 -2
  137. data/app/views/decidim/shared/_embed_modal.html.erb +1 -1
  138. data/app/views/decidim/shared/_flag_modal.html.erb +5 -5
  139. data/app/views/decidim/shared/_login_modal.html.erb +3 -3
  140. data/app/views/decidim/shared/_private_participatory_space.html.erb +5 -0
  141. data/app/views/decidim/shared/_share_modal.html.erb +1 -1
  142. data/app/views/decidim/shared/_tags.html.erb +1 -1
  143. data/app/views/decidim/shared/_version_author.html.erb +1 -1
  144. data/app/views/decidim/widgets/_data_picker.html.erb +4 -4
  145. data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -3
  146. data/app/views/devise/mailer/invite_private_user.html.erb +17 -0
  147. data/app/views/devise/mailer/invite_private_user.text.erb +15 -0
  148. data/app/views/devise/mailer/password_change.html.erb +2 -2
  149. data/app/views/devise/mailer/reset_password_instructions.html.erb +5 -5
  150. data/app/views/kaminari/decidim/_first_page.html.erb +2 -3
  151. data/app/views/kaminari/decidim/_gap.html.erb +2 -3
  152. data/app/views/kaminari/decidim/_last_page.html.erb +2 -3
  153. data/app/views/kaminari/decidim/_next_page.html.erb +2 -3
  154. data/app/views/kaminari/decidim/_page.html.erb +2 -3
  155. data/app/views/kaminari/decidim/_paginator.html.erb +1 -2
  156. data/app/views/kaminari/decidim/_prev_page.html.erb +2 -3
  157. data/app/views/layouts/decidim/_application.html.erb +4 -4
  158. data/app/views/layouts/decidim/_component_authorization_modals.html.erb +5 -0
  159. data/app/views/layouts/decidim/_cookie_warning.html.erb +2 -2
  160. data/app/views/layouts/decidim/_head.html.erb +4 -4
  161. data/app/views/layouts/decidim/_impersonation_warning.html.erb +4 -4
  162. data/app/views/layouts/decidim/_language_chooser.html.erb +1 -1
  163. data/app/views/layouts/decidim/_social_media_links.html.erb +5 -5
  164. data/app/views/layouts/decidim/_wrapper.html.erb +5 -5
  165. data/app/views/layouts/decidim/mailer.html.erb +1 -1
  166. data/app/views/layouts/decidim/widget.html.erb +5 -5
  167. data/app/views/pages/home/_hero.html.erb +1 -1
  168. data/app/views/pages/home.html.erb +6 -6
  169. data/config/locales/ca.yml +66 -27
  170. data/config/locales/en.yml +69 -30
  171. data/config/locales/es.yml +66 -27
  172. data/config/locales/eu.yml +69 -30
  173. data/config/locales/fi.yml +69 -30
  174. data/config/locales/fr.yml +85 -46
  175. data/config/locales/gl.yml +69 -30
  176. data/config/locales/it.yml +69 -30
  177. data/config/locales/nl.yml +122 -83
  178. data/config/locales/pl.yml +69 -30
  179. data/config/locales/pt-BR.yml +69 -30
  180. data/config/locales/pt.yml +69 -30
  181. data/config/locales/ru.yml +0 -7
  182. data/config/locales/sv.yml +69 -30
  183. data/config/locales/uk.yml +0 -13
  184. data/config/routes.rb +8 -0
  185. data/db/migrate/20180206183235_create_participatory_space_private_users.rb +15 -0
  186. data/db/migrate/20180221101934_fix_nickname_index.rb +5 -6
  187. data/db/migrate/20180226140756_add_version_to_action_logs.rb +5 -1
  188. data/db/migrate/20180227131727_create_participatory_space_links.rb +12 -0
  189. data/db/migrate/20180305132906_rename_features_to_components.rb +13 -0
  190. data/db/migrate/20180308113207_doorkeeper_models.rb +85 -0
  191. data/db/migrate/20180314085339_rename_maximum_votes_per_proposal_to_threshold_per_proposal.rb +2 -2
  192. data/db/migrate/{20180326075746_change_event_name_and_class_to_rename_to_publish_proposal_event.rb → 20180323102631_change_event_name_and_class_to_rename_to_publish_proposal_event.rb} +0 -0
  193. data/db/seeds.rb +12 -2
  194. data/lib/decidim/api/attachable_interface.rb +13 -0
  195. data/lib/decidim/api/authorable_interface.rb +13 -0
  196. data/lib/decidim/api/categorizable_interface.rb +13 -0
  197. data/lib/decidim/api/participatory_space_interface.rb +4 -4
  198. data/lib/decidim/api/scopable_interface.rb +13 -0
  199. data/lib/decidim/authorable.rb +8 -0
  200. data/lib/decidim/{feature_manifest.rb → component_manifest.rb} +24 -21
  201. data/lib/decidim/{feature_validator.rb → component_validator.rb} +6 -6
  202. data/lib/decidim/{features → components}/export_manifest.rb +4 -4
  203. data/lib/decidim/components/namer.rb +35 -0
  204. data/lib/decidim/components.rb +9 -0
  205. data/lib/decidim/content_parsers/user_parser.rb +1 -1
  206. data/lib/decidim/core/api.rb +13 -0
  207. data/lib/decidim/core/engine.rb +76 -3
  208. data/lib/decidim/core/test/factories.rb +43 -10
  209. data/lib/decidim/core/test/shared_examples/announcements_examples.rb +9 -9
  210. data/lib/decidim/core/test/shared_examples/attachable_interface_examples.rb +16 -0
  211. data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +33 -0
  212. data/lib/decidim/core/test/shared_examples/categorizable_interface_examples.rb +19 -0
  213. data/lib/decidim/core/test/shared_examples/comments_examples.rb +3 -3
  214. data/lib/decidim/core/test/shared_examples/follows_examples.rb +1 -1
  215. data/lib/decidim/core/test/shared_examples/has_component.rb +21 -0
  216. data/lib/decidim/core/test/shared_examples/has_reference.rb +2 -2
  217. data/lib/decidim/core/test/shared_examples/localised_email.rb +1 -1
  218. data/lib/decidim/core/test/shared_examples/paginated_resource_examples.rb +1 -1
  219. data/lib/decidim/core/test/shared_examples/reportable.rb +8 -6
  220. data/lib/decidim/core/test/shared_examples/reports_examples.rb +1 -1
  221. data/lib/decidim/core/test/shared_examples/scopable_interface_examples.rb +19 -0
  222. data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +8 -3
  223. data/lib/decidim/core/test/shared_examples/simple_event.rb +1 -1
  224. data/lib/decidim/core/test/shared_examples/user_localised_email_examples.rb +1 -1
  225. data/lib/decidim/core/test.rb +1 -1
  226. data/lib/decidim/core/version.rb +1 -1
  227. data/lib/decidim/core.rb +35 -37
  228. data/lib/decidim/events/base_event.rb +5 -5
  229. data/lib/decidim/events/simple_event.rb +8 -8
  230. data/lib/decidim/form_builder.rb +48 -3
  231. data/lib/decidim/has_attachment_collections.rb +1 -1
  232. data/lib/decidim/has_attachments.rb +1 -1
  233. data/lib/decidim/has_category.rb +2 -2
  234. data/lib/decidim/has_component.rb +23 -0
  235. data/lib/decidim/has_private_users.rb +26 -0
  236. data/lib/decidim/has_reference.rb +3 -3
  237. data/lib/decidim/page_finder.rb +1 -1
  238. data/lib/decidim/participatory_space_manifest.rb +3 -3
  239. data/lib/decidim/participatory_space_resourceable.rb +80 -0
  240. data/lib/decidim/publicable.rb +2 -2
  241. data/lib/decidim/query_extensions.rb +2 -2
  242. data/lib/decidim/rectify_ext.rb +32 -0
  243. data/lib/decidim/reportable.rb +1 -1
  244. data/lib/decidim/resource_manifest.rb +13 -13
  245. data/lib/decidim/resourceable.rb +8 -8
  246. data/lib/decidim/scopable.rb +1 -1
  247. data/lib/decidim/{scopable_feature.rb → scopable_component.rb} +1 -1
  248. data/lib/decidim/settings_manifest.rb +1 -1
  249. data/lib/decidim/stats_registry.rb +1 -1
  250. data/lib/decidim/view_model.rb +9 -0
  251. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr.js +4 -1
  252. data/vendor/assets/javascripts/form_datepicker.js.es6 +10 -10
  253. data/vendor/assets/javascripts/quill.min.js +2 -2
  254. data/vendor/assets/javascripts/quill.min.js.map +1 -1
  255. data/vendor/assets/javascripts/tagsinput.js +683 -0
  256. data/vendor/assets/javascripts/tribute.js +1607 -0
  257. data/vendor/assets/stylesheets/quill.bubble.css +30 -16
  258. data/vendor/assets/stylesheets/quill.core.css +19 -9
  259. data/vendor/assets/stylesheets/quill.snow.css +30 -16
  260. data/vendor/assets/stylesheets/tagsinput.css +55 -0
  261. data/vendor/assets/stylesheets/tribute.css +27 -0
  262. metadata +164 -27
  263. data/app/constraints/decidim/current_feature.rb +0 -41
  264. data/app/helpers/decidim/feature_path_helper.rb +0 -36
  265. data/app/views/layouts/decidim/_feature_authorization_modals.html.erb +0 -5
  266. data/lib/decidim/core/test/shared_examples/has_feature.rb +0 -21
  267. data/lib/decidim/features/namer.rb +0 -35
  268. data/lib/decidim/features.rb +0 -9
  269. data/lib/decidim/has_feature.rb +0 -23
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Log
5
+ module ValueTypes
6
+ # This class presents the given value as a Decidim::AreaType. Check
7
+ # the `DefaultPresenter` for more info on how value
8
+ # presenters work.
9
+ class AreaTypePresenter < DefaultPresenter
10
+ # Public: Presents the value as an AreaType. If the area type can
11
+ # be found, it shows its title. Otherwise it shows its ID.
12
+ #
13
+ # Returns an HTML-safe String.
14
+ def present
15
+ return unless value
16
+ return h.translated_attribute(area_type.name) if area_type
17
+ I18n.t("not_found", id: value, scope: "decidim.log.value_types.area_type_presenter")
18
+ end
19
+
20
+ private
21
+
22
+ def area_type
23
+ @area_type ||= Decidim::AreaType.find_by(id: value)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Log
5
+ module ValueTypes
6
+ # This class presents the given value as a currency. Check
7
+ # the `DefaultPresenter` for more info on how value
8
+ # presenters work.
9
+ class CurrencyPresenter < DefaultPresenter
10
+ # Public: Presents the value as a currency.
11
+ #
12
+ # Returns an HTML-safe String.
13
+ def present
14
+ return unless value
15
+ h.number_to_currency(value, unit: Decidim.currency_unit)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -20,7 +20,7 @@ module Decidim
20
20
  private
21
21
 
22
22
  def scope
23
- @scope ||= Decidim::Scope.where(id: value).first
23
+ @scope ||= Decidim::Scope.find_by(id: value)
24
24
  end
25
25
  end
26
26
  end
@@ -20,7 +20,7 @@ module Decidim
20
20
  private
21
21
 
22
22
  def scope_type
23
- @scope_type ||= Decidim::ScopeType.where(id: value).first
23
+ @scope_type ||= Decidim::ScopeType.find_by(id: value)
24
24
  end
25
25
  end
26
26
  end
@@ -59,8 +59,8 @@ module Decidim
59
59
  resource.class.try(:participatory_space_manifest)
60
60
  end
61
61
 
62
- def feature
63
- resource.feature if resource.respond_to?(:feature)
62
+ def component
63
+ resource.component if resource.respond_to?(:component)
64
64
  end
65
65
 
66
66
  def member_route_name
@@ -72,7 +72,7 @@ module Decidim
72
72
  end
73
73
 
74
74
  def route_proxy
75
- @route_proxy ||= EngineRouter.main_proxy(feature || resource)
75
+ @route_proxy ||= EngineRouter.main_proxy(component || resource)
76
76
  end
77
77
  end
78
78
  end
@@ -2,30 +2,30 @@
2
2
 
3
3
  module Decidim
4
4
  # This class is used to authorize a user against an action in the context of a
5
- # feature.
5
+ # component.
6
6
  class ActionAuthorizer
7
7
  #
8
8
  # Initializes the ActionAuthorizer.
9
9
  #
10
10
  # user - The user to authorize against.
11
- # feature - The feature to authenticate against.
11
+ # component - The component to authenticate against.
12
12
  # action - The action to authenticate.
13
13
  #
14
- def initialize(user, feature, action)
14
+ def initialize(user, component, action)
15
15
  @user = user
16
- @feature = feature
16
+ @component = component
17
17
  @action = action.to_s if action
18
18
  end
19
19
 
20
20
  #
21
- # Authorize user to perform an action in the context of a feature.
21
+ # Authorize user to perform an action in the context of a component.
22
22
  #
23
23
  # Returns:
24
24
  # :ok an empty hash - When there is no authorization handler related to the action.
25
25
  # result of authorization handler check - When there is an authorization handler related to the action. Check Decidim::Verifications::DefaultActionAuthorizer class docs.
26
26
  #
27
27
  def authorize
28
- raise AuthorizationError, "Missing data" unless feature && action
28
+ raise AuthorizationError, "Missing data" unless component && action
29
29
 
30
30
  status_code, data = if authorization_handler_name
31
31
  authorization_handler.authorize(authorization, permission_options)
@@ -38,7 +38,7 @@ module Decidim
38
38
 
39
39
  private
40
40
 
41
- attr_reader :user, :feature, :action
41
+ attr_reader :user, :component, :action
42
42
 
43
43
  def authorization
44
44
  return nil unless user && authorization_handler_name
@@ -61,9 +61,9 @@ module Decidim
61
61
  end
62
62
 
63
63
  def permission
64
- return nil unless feature && action
64
+ return nil unless component && action
65
65
 
66
- @permission ||= feature.permissions&.fetch(action, nil)
66
+ @permission ||= component.permissions&.fetch(action, nil)
67
67
  end
68
68
 
69
69
  class AuthorizationStatus
@@ -48,8 +48,10 @@ module Decidim
48
48
  organization: organization,
49
49
  action: action,
50
50
  resource: resource,
51
+ resource_id: resource.id,
52
+ resource_type: resource.class.name,
51
53
  participatory_space: participatory_space,
52
- feature: feature,
54
+ component: component,
53
55
  version_id: version_id,
54
56
  extra: extra_data
55
57
  )
@@ -63,12 +65,12 @@ module Decidim
63
65
  user.organization
64
66
  end
65
67
 
66
- def feature
67
- resource.feature if resource.respond_to?(:feature)
68
+ def component
69
+ resource.component if resource.respond_to?(:component)
68
70
  end
69
71
 
70
72
  def participatory_space
71
- return feature.participatory_space if feature.respond_to?(:participatory_space)
73
+ return component.participatory_space if component.respond_to?(:participatory_space)
72
74
  resource.participatory_space if resource.respond_to?(:participatory_space)
73
75
  end
74
76
 
@@ -86,9 +88,9 @@ module Decidim
86
88
  # Returns a Hash.
87
89
  def extra_data
88
90
  {
89
- feature: {
90
- manifest_name: feature.try(:manifest_name),
91
- title: title_for(feature)
91
+ component: {
92
+ manifest_name: component.try(:manifest_name),
93
+ title: title_for(component)
92
94
  }.compact,
93
95
  participatory_space: {
94
96
  manifest_name: participatory_space_manifest_name,
@@ -45,7 +45,7 @@ module Decidim
45
45
  #
46
46
  # Returns nothing.
47
47
  def send_email_to(recipient_id)
48
- recipient = Decidim::User.where(id: recipient_id).first
48
+ recipient = Decidim::User.find_by(id: recipient_id)
49
49
  return unless recipient
50
50
  return unless recipient.email_on_notification?
51
51
 
@@ -49,7 +49,7 @@ module Decidim
49
49
  attr_reader :event, :event_class, :resource, :recipient_id, :extra
50
50
 
51
51
  def recipient
52
- @recipient ||= User.where(id: recipient_id).first
52
+ @recipient ||= User.find_by(id: recipient_id)
53
53
  end
54
54
  end
55
55
  end
@@ -16,12 +16,12 @@ module Decidim
16
16
  end
17
17
 
18
18
  # Creates the SearchLight base query.
19
- # Check if the option feature was provided.
19
+ # Check if the option component was provided.
20
20
  def base_query
21
21
  # raise order_start_time.inspect
22
- raise "Missing feature" unless feature
22
+ raise "Missing component" unless component
23
23
 
24
- @scope.where(feature: feature)
24
+ @scope.where(component: component)
25
25
  end
26
26
 
27
27
  # Handle the category_id filter
@@ -57,17 +57,17 @@ module Decidim
57
57
  # Private: Creates an array of category ids.
58
58
  # It contains categories' subcategories ids as well.
59
59
  def category_ids
60
- feature
60
+ component
61
61
  .categories
62
62
  .where(id: category_id)
63
- .or(feature.categories.where(parent_id: category_id))
63
+ .or(component.categories.where(parent_id: category_id))
64
64
  .pluck(:id)
65
65
  end
66
66
 
67
- # Private: Since feature is not used by a search method we need
67
+ # Private: Since component is not used by a search method we need
68
68
  # to define the method manually.
69
- def feature
70
- options[:feature]
69
+ def component
70
+ options[:component]
71
71
  end
72
72
  end
73
73
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
- # This is a helper class in order to publish feature and settings changes
4
+ # This is a helper class in order to publish component and settings changes
5
5
  # so that components can react to these changes and send notifications to users.
6
6
  class SettingsChange
7
7
  # Publishes a change to ActiveSupport::Notifications.
8
8
  #
9
- # feature - The Decidim::Feature where the changes have been applied.
9
+ # component - The Decidim::Component where the changes have been applied.
10
10
  # previous_settings - A Hash or a Decidim::SettingsManifest schema with the settings before changing them.
11
11
  # current_settings - A Hash or a Decidim::SettingsManifest schema with the current settings.
12
- def self.publish(feature, previous_settings, current_settings)
12
+ def self.publish(component, previous_settings, current_settings)
13
13
  ActiveSupport::Notifications.publish(
14
- "decidim.settings_change.#{feature.manifest_name}",
15
- feature_id: feature.id,
14
+ "decidim.settings_change.#{component.manifest_name}",
15
+ component_id: component.id,
16
16
  previous_settings: previous_settings.to_h.deep_symbolize_keys,
17
17
  current_settings: current_settings.to_h.deep_symbolize_keys
18
18
  )
@@ -42,7 +42,7 @@ module Decidim
42
42
  end
43
43
 
44
44
  def organization
45
- @organization ||= @resource.feature.organization
45
+ @organization ||= @resource.component.organization
46
46
  end
47
47
  end
48
48
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ AttachmentType = GraphQL::ObjectType.define do
6
+ name "Attachment"
7
+ description "A file attachment"
8
+
9
+ field :url, !types.String, "The url of this attachment"
10
+ field :type, !types.String, "The type of this attachment", property: :file_type
11
+ field :thumbnail, types.String, "A thumbnail of this attachment, if it's an image.", property: :thumbnail_url
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ CategoryType = GraphQL::ObjectType.define do
6
+ name "Category"
7
+ description "A category that can be applied to other resources."
8
+
9
+ field :id, !types.ID
10
+ field :name, !TranslatedFieldType, "The name of this category."
11
+
12
+ field :subcategories, !types[Decidim::Core::CategoryType], "Subcategories of this category."
13
+ field :parent, Decidim::Core::CategoryType, "This category's parent category."
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ # This type represents a Decidim's global property.
6
+ CoordinatesType = GraphQL::ObjectType.define do
7
+ name "Coordinates"
8
+ description "Physical coordinates for a location"
9
+
10
+ field :latitude, !types.Float, "Latitude of this coordinate" do
11
+ resolve ->(coordinates, _args, _ctx) { coordinates[0] }
12
+ end
13
+
14
+ field :longitude, !types.Float, "Longitude of this coordinate" do
15
+ resolve ->(coordinates, _args, _ctx) { coordinates[1] }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ ScopeApiType = GraphQL::ObjectType.define do
6
+ name "Scope"
7
+ description "A scope"
8
+
9
+ field :id, !types.ID
10
+ field :name, !TranslatedFieldType, "The name of this scope."
11
+
12
+ field :children, !types[Decidim::Core::ScopeApiType], "Descendants of this scope"
13
+ field :parent, Decidim::Core::ScopeApiType, "This scope's parent scope."
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This class deals with uploading hero images to ParticipatoryProcesses.
5
+ class OAuthApplicationLogoUploader < ImageUploader
6
+ include CarrierWave::MiniMagick
7
+ process resize_to_fit: [75, 75]
8
+ end
9
+ end
@@ -4,8 +4,8 @@
4
4
  # an existing address and computes its coordinates.
5
5
  class GeocodingValidator < ActiveModel::EachValidator
6
6
  def validate_each(record, attribute, value)
7
- if Decidim.geocoder.present? && record.feature.present?
8
- organization = record.feature.organization
7
+ if Decidim.geocoder.present? && record.component.present?
8
+ organization = record.component.organization
9
9
  Geocoder.configure(Geocoder.config.merge(http_headers: { "Referer" => organization.host }))
10
10
  coordinates = Geocoder.coordinates(value)
11
11
 
@@ -1,27 +1,27 @@
1
1
  <div class="row">
2
2
  <div class="columns large-8 end">
3
3
  <div class="callout alert">
4
- <p><%= t('.alert') %></p>
4
+ <p><%= t(".alert") %></p>
5
5
  </div>
6
- <p><%= t('.explanation') %></p>
6
+ <p><%= t(".explanation") %></p>
7
7
  <%= decidim_form_for(@form, url: account_path, method: :delete, html: { class: "user-form delete-account" }) do |f| %>
8
8
  <div>
9
9
  <label>
10
- <span class="user-form__label"><%= t('activemodel.attributes.account.delete_reason') %></span>
10
+ <span class="user-form__label"><%= t("activemodel.attributes.account.delete_reason") %></span>
11
11
  <%= f.text_area :delete_reason, rows: 2, label: false %>
12
12
  </label>
13
13
  </div>
14
- <input type="submit" class="button open-modal-button" value="<%= t('.confirm.title') %>" />
14
+ <input type="submit" class="button open-modal-button" value="<%= t(".confirm.title") %>" />
15
15
  <% end %>
16
16
  <div class="tiny reveal" id="deleteConfirm" data-reveal>
17
17
  <%= decidim_form_for(@form, url: account_path, method: :delete, html: { class: "user-form delete-account-modal" }) do |f| %>
18
18
  <%= f.hidden_field :delete_reason %>
19
19
 
20
- <p><%= t('.confirm.question') %></p>
20
+ <p><%= t(".confirm.question") %></p>
21
21
 
22
- <input type="submit" class="button expanded" value="<%= t('.confirm.ok') %>" />
22
+ <input type="submit" class="button expanded" value="<%= t(".confirm.ok") %>" />
23
23
 
24
- <button class="close-button" data-close aria-label="<%= t('.confirm.close') %>" type="button">
24
+ <button class="close-button" data-close aria-label="<%= t(".confirm.close") %>" type="button">
25
25
  <span aria-hidden="true">&times;</span>
26
26
  </button>
27
27
  <% end %>
@@ -5,7 +5,7 @@
5
5
  <small>(<%= attachment_collection.attachments.count %> <%= t(".documents", count: attachment_collection.attachments.count) %>)</small>
6
6
  </h6>
7
7
  <div id="docs-collection-<%= attachment_collection.id %>" class="docs__content hide" data-toggler=".hide">
8
- <p><%= translated_attribute(attachment_collection.description) %></p>
8
+ <p><%= translated_attribute(attachment_collection.description) %></p>
9
9
  <div class="card card--list">
10
10
  <%= render partial: "document", collection: documents %>
11
11
  </div>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
  </div>
14
14
  <div class="card--list__data">
15
- <%= link_to document.url, class: "card--list__data__icon" do %>
15
+ <%= link_to document.url, target: "_blank", class: "card--list__data__icon" do %>
16
16
  <%= icon "cloud-download" %>
17
17
  <% end %>
18
18
  </div>
@@ -5,7 +5,7 @@
5
5
  <% photos.in_groups_of(3, false).each do |group| %>
6
6
  <% group.each_with_index do |photo, index| %>
7
7
  <div class="columns small-6 medium-4 <%= (index == 2 || photo == group.last ? "end" : "") %>">
8
- <%= link_to photo.big_url do %>
8
+ <%= link_to photo.big_url, target: "_blank" do %>
9
9
  <%= image_tag photo.thumbnail_url, class:"thumbnail", alt: strip_tags(translated_attribute(photo.description)) %>
10
10
  <% end %>
11
11
  </div>
@@ -13,7 +13,7 @@
13
13
  <%= decidim_form_for resource, as: resource_name, url: invitation_path(resource_name, invite_redirect: params[:invite_redirect]), html: { method: :put, class: "register-form new_user" } do |f| %>
14
14
  <%= f.hidden_field :invitation_token %>
15
15
 
16
- <%= f.text_field :nickname, help_text: t("devise.invitations.edit.nickname_help") %>
16
+ <%= f.text_field :nickname, help_text: t("devise.invitations.edit.nickname_help", organization: current_organization.name) %>
17
17
 
18
18
  <% if f.object.class.require_password_on_accepting %>
19
19
  <%= f.password_field :password %></p>
@@ -22,7 +22,7 @@
22
22
 
23
23
  <div class="user-person">
24
24
  <div class="field">
25
- <%= f.text_field :nickname, help_text: t(".nickname_help") %>
25
+ <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name) %>
26
26
  </div>
27
27
  </div>
28
28
 
@@ -35,7 +35,7 @@
35
35
 
36
36
  <div class="user-person">
37
37
  <div class="field">
38
- <%= f.text_field :nickname, help_text: t(".nickname_help") %>
38
+ <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name) %>
39
39
  </div>
40
40
  </div>
41
41
 
@@ -6,7 +6,7 @@
6
6
  <div class="columns large-8 large-centered text-center page-title">
7
7
  <h1 class="heading1"><%= t("devise.sessions.new.sign_in") %></h1>
8
8
  <p>
9
- <%= t('.are_you_new?') %>
9
+ <%= t(".are_you_new?") %>
10
10
  <%= link_to t(".register"), new_user_registration_path %>
11
11
  </p>
12
12
  </div>
@@ -18,7 +18,7 @@
18
18
  <%= decidim_form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "register-form new_user" }) do |f| %>
19
19
  <div>
20
20
  <div class="field">
21
- <%= f.email_field :email, autofocus: true %>
21
+ <%= f.email_field :email, autofocus: true %>
22
22
  </div>
23
23
  <div class="field">
24
24
  <%= f.password_field :password, autocomplete: "off" %>
@@ -2,7 +2,7 @@
2
2
  <div class="row">
3
3
  <div class="columns large-4 mediumlarge-6 medium-8 medium-centered">
4
4
  <span class="register__separator">
5
- <span class="register__separator__text"><%= t('.or') %></span>
5
+ <span class="register__separator__text"><%= t(".or") %></span>
6
6
  </span>
7
7
  <%- resource_class.omniauth_providers.each do |provider| %>
8
8
  <% if social_provider_enabled? provider %>
@@ -2,7 +2,7 @@
2
2
  <div class="row">
3
3
  <div class="columns medium-8 medium-centered">
4
4
  <span class="register__separator">
5
- <span class="register__separator__text"><%= t('or', scope: "decidim.devise.shared.omniauth_buttons") %></span>
5
+ <span class="register__separator__text"><%= t("or", scope: "decidim.devise.shared.omniauth_buttons") %></span>
6
6
  </span>
7
7
  <div class="text-center">
8
8
  <%- Decidim::User.omniauth_providers.each do |provider| %>
@@ -0,0 +1,58 @@
1
+ <main class="wrapper">
2
+ <div class="row collapse">
3
+ <div class="row">
4
+ <div class="columns large-8 medium-centered">
5
+ <div class="card">
6
+ <div class="card__content">
7
+ <div class="row">
8
+ <div class="columns medium-2 text-center">
9
+ <img src="<%= oauth_application.organization_logo.url %>" alt="<%= oauth_application.organization_name %>" width="75" height="75" />
10
+ </div>
11
+ <div class="columns medium-10">
12
+ <h3 class="heading3"><%= t(".wants_to_use_your_account_html", application_name: oauth_application.name) %>
13
+ <br />
14
+ <%= t(".by_organization_link_html", link: link_to(oauth_application.organization_name, oauth_application.organization_url)) %>
15
+ </h3>
16
+ <br />
17
+ <p class="lead"><%= t(".connect_your_account_html", organization: current_organization.name) %></p>
18
+ <div>
19
+ <p><strong><%= t(".this_application_will_be_able_to") %></strong></p>
20
+ <ul>
21
+ <li><%= t(".see_name") %></li>
22
+ <li><%= t(".see_username") %></li>
23
+ <li><%= t(".see_email") %></li>
24
+ </ul>
25
+ </div>
26
+ <div>
27
+ <p><strong class="primary"><%= t(".this_application_will_not_be_able_to") %></strong></p>
28
+ <ul>
29
+ <li><%= t(".update_profile") %></li>
30
+ <li><%= t(".publish_content") %></li>
31
+ </ul>
32
+ </div>
33
+ <div class="row">
34
+ <%= form_tag oauth_authorization_path, method: :post, class: "column medium-5 small-7 medium-5" do %>
35
+ <%= hidden_field_tag :client_id, @pre_auth.client.uid %>
36
+ <%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
37
+ <%= hidden_field_tag :state, @pre_auth.state %>
38
+ <%= hidden_field_tag :response_type, @pre_auth.response_type %>
39
+ <%= hidden_field_tag :scope, @pre_auth.scope %>
40
+ <button class="column button button--nomargin secondary light" type="submit" name="authorize"><%= t(".authorize") %></button>
41
+ <% end %>
42
+ <%= form_tag oauth_authorization_path, method: :delete, class: "column small-4 medium-3 small-push-1 end" do %>
43
+ <%= hidden_field_tag :client_id, @pre_auth.client.uid %>
44
+ <%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
45
+ <%= hidden_field_tag :state, @pre_auth.state %>
46
+ <%= hidden_field_tag :response_type, @pre_auth.response_type %>
47
+ <%= hidden_field_tag :scope, @pre_auth.scope %>
48
+ <button class="column button button--nomargin" type="submit" name="cancel"><%= t(".cancel") %></button>
49
+ <% end %>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </main>
@@ -1,7 +1,7 @@
1
1
  <main class="wrapper">
2
2
  <div class="row">
3
3
  <div class="columns">
4
- <div class="title-action" >
4
+ <div class="title-action">
5
5
  <h1 class="heading1 title-action__title">
6
6
  <%= link_to decidim.conversations_path, class: "card--list__data__icon card--list__data__icon--back" do %>
7
7
  <%= icon "chevron-left" %>
@@ -1,7 +1,7 @@
1
1
  <main class="wrapper">
2
2
  <div class="row">
3
3
  <div class="columns">
4
- <div class="title-action" >
4
+ <div class="title-action">
5
5
  <h1 class="heading1 title-action__title">
6
6
  <%= t(".title") %>
7
7
  </h1>
@@ -1,7 +1,7 @@
1
1
  <main class="wrapper" id="notifications">
2
2
  <div class="row">
3
3
  <div class="columns">
4
- <div class="title-action" >
4
+ <div class="title-action">
5
5
  <h1 class="heading1 title-action__title"><%= t("title", scope: "layouts.decidim.notifications_dashboard") %></h1>
6
6
  <% if notifications.any? %>
7
7
  <%= link_to(
@@ -4,14 +4,14 @@
4
4
  <label>
5
5
  <%= f.check_box :email_on_notification, label: false, class: "switch-input" %>
6
6
  <span class="switch-paddle"></span>
7
- <span class="switch-label"><%= t('.email_on_notification') %></span>
7
+ <span class="switch-label"><%= t(".email_on_notification") %></span>
8
8
  </label>
9
9
  </div>
10
10
  <div class="switch tiny switch-with-label newsletter_notifications">
11
11
  <label>
12
12
  <%= f.check_box :newsletter_notifications, label: false, class: "switch-input" %>
13
13
  <span class="switch-paddle"></span>
14
- <span class="switch-label"><%= t('.newsletter_notifications') %></span>
14
+ <span class="switch-label"><%= t(".newsletter_notifications") %></span>
15
15
  </label>
16
16
  </div>
17
17
  <%= f.submit t(".update_notifications_settings"), disable_with: true %>
@@ -10,13 +10,13 @@
10
10
  </h5>
11
11
  <span class="text-small"><%= l(user_group.created_at, format: :long) %></span>
12
12
  <% if user_group.verified? %>
13
- <span class="success label"><%= t('.verified') %></span>
13
+ <span class="success label"><%= t(".verified") %></span>
14
14
  <% end %>
15
15
  <% if user_group.rejected? %>
16
- <span class="alert label"><%= t('.rejected') %></span>
16
+ <span class="alert label"><%= t(".rejected") %></span>
17
17
  <% end %>
18
18
  <% if user_group.pending? %>
19
- <span class="warning label"><%= t('.pending') %></span>
19
+ <span class="warning label"><%= t(".pending") %></span>
20
20
  <% end %>
21
21
  </div>
22
22
  </div>