decidim 0.0.2 → 0.0.3

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

Potentially problematic release.


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

Files changed (439) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -0
  3. data/Dockerfile +2 -0
  4. data/Gemfile.lock +80 -54
  5. data/README.md +15 -2
  6. data/decidim-admin/app/assets/javascripts/decidim/admin/application.js.es6 +3 -2
  7. data/decidim-admin/app/assets/javascripts/decidim/admin/tab_focus.js.es6 +1 -1
  8. data/decidim-admin/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +1 -1
  9. data/decidim-admin/app/commands/decidim/admin/{create_participatory_process_attachment.rb → create_attachment.rb} +6 -7
  10. data/decidim-admin/app/commands/decidim/admin/create_participatory_process.rb +12 -3
  11. data/decidim-admin/app/commands/decidim/admin/{update_participatory_process_attachment.rb → update_attachment.rb} +7 -6
  12. data/decidim-admin/app/commands/decidim/admin/update_feature.rb +2 -1
  13. data/decidim-admin/app/commands/decidim/admin/update_organization.rb +1 -0
  14. data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +16 -4
  15. data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  16. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +2 -2
  17. data/decidim-admin/app/controllers/decidim/admin/concerns/has_attachments.rb +116 -0
  18. data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +5 -67
  19. data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +5 -5
  20. data/decidim-admin/app/forms/decidim/admin/{participatory_process_attachment_form.rb → attachment_form.rb} +2 -2
  21. data/decidim-admin/app/forms/decidim/admin/feature_form.rb +1 -0
  22. data/decidim-admin/app/forms/decidim/admin/organization_form.rb +1 -0
  23. data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +8 -1
  24. data/decidim-admin/app/helpers/decidim/admin/application_helper.rb +1 -0
  25. data/decidim-admin/app/helpers/decidim/admin/feature_settings_helper.rb +29 -0
  26. data/decidim-admin/app/models/decidim/admin/abilities/admin_user.rb +4 -4
  27. data/decidim-admin/app/models/decidim/admin/abilities/base.rb +3 -3
  28. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_admin.rb +15 -7
  29. data/decidim-admin/app/views/decidim/admin/{participatory_process_attachments → attachments}/_form.html.erb +0 -0
  30. data/decidim-admin/app/views/decidim/admin/attachments/edit.html.erb +9 -0
  31. data/decidim-admin/app/views/decidim/admin/attachments/index.html.erb +37 -0
  32. data/decidim-admin/app/views/decidim/admin/attachments/new.html.erb +9 -0
  33. data/decidim-admin/app/views/decidim/admin/attachments/show.html.erb +25 -0
  34. data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +1 -0
  35. data/decidim-admin/app/views/decidim/admin/features/_settings_fields.html.erb +6 -3
  36. data/decidim-admin/app/views/decidim/admin/organization/_form.html.erb +4 -0
  37. data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +16 -0
  38. data/decidim-admin/app/views/decidim/admin/participatory_processes/show.html.erb +11 -1
  39. data/decidim-admin/app/views/layouts/decidim/admin/_header.html.erb +2 -2
  40. data/decidim-admin/app/views/layouts/decidim/admin/_sidebar.html.erb +1 -1
  41. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
  42. data/decidim-admin/config/locales/ca.yml +29 -27
  43. data/decidim-admin/config/locales/en.yml +29 -27
  44. data/decidim-admin/config/locales/es.yml +29 -27
  45. data/decidim-admin/config/routes.rb +1 -1
  46. data/decidim-admin/db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb +9 -0
  47. data/decidim-admin/decidim-admin.gemspec +0 -1
  48. data/decidim-admin/lib/decidim/admin/engine.rb +2 -2
  49. data/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb +103 -0
  50. data/decidim-admin/spec/commands/create_category_spec.rb +1 -1
  51. data/decidim-admin/spec/commands/create_feature_spec.rb +1 -1
  52. data/decidim-admin/spec/commands/create_participatory_process_spec.rb +32 -2
  53. data/decidim-admin/spec/commands/create_static_page_spec.rb +1 -1
  54. data/decidim-admin/spec/commands/destroy_category_spec.rb +1 -1
  55. data/decidim-admin/spec/commands/destroy_feature_spec.rb +2 -2
  56. data/decidim-admin/spec/commands/destroy_participatory_process_step_spec.rb +1 -1
  57. data/decidim-admin/spec/commands/update_category_spec.rb +1 -1
  58. data/decidim-admin/spec/commands/update_feature_spec.rb +3 -1
  59. data/decidim-admin/spec/commands/update_organization_spec.rb +12 -2
  60. data/decidim-admin/spec/commands/update_static_page_spec.rb +1 -1
  61. data/decidim-admin/spec/features/admin_manages_organization_admins_spec.rb +1 -1
  62. data/decidim-admin/spec/features/admin_manages_organization_scopes_spec.rb +1 -1
  63. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +1 -1
  64. data/decidim-admin/spec/features/static_pages_spec.rb +1 -1
  65. data/decidim-admin/spec/forms/participatory_process_form_spec.rb +32 -2
  66. data/decidim-admin/spec/forms/participatory_process_step_form_spec.rb +3 -3
  67. data/decidim-admin/spec/forms/scope_form_spec.rb +2 -2
  68. data/decidim-admin/spec/forms/static_page_form_spec.rb +2 -2
  69. data/decidim-admin/spec/helpers/feature_settings_helper_spec.rb +56 -0
  70. data/decidim-admin/spec/models/abilities/admin_user_spec.rb +7 -6
  71. data/decidim-admin/spec/models/abilities/participatory_process_admin_spec.rb +5 -8
  72. data/decidim-admin/spec/shared/manage_process_admins_examples.rb +1 -1
  73. data/decidim-admin/spec/shared/manage_process_attachments_examples.rb +4 -94
  74. data/decidim-admin/spec/shared/manage_process_categories_examples.rb +2 -1
  75. data/decidim-admin/spec/shared/manage_process_steps_examples.rb +1 -1
  76. data/decidim-admin/spec/shared/manage_processes_examples.rb +4 -3
  77. data/decidim-admin/spec/views/decidim/static_pages/_form.html.erb_spec.rb +2 -2
  78. data/decidim-api/app/views/layouts/decidim/api/documentation.html.erb +1 -1
  79. data/decidim-api/decidim-api.gemspec +1 -1
  80. data/decidim-api/lib/decidim/api.rb +1 -0
  81. data/decidim-api/lib/decidim/api/schema.rb +5 -0
  82. data/decidim-api/lib/decidim/api/test/type_context.rb +1 -0
  83. data/decidim-api/lib/decidim/api/types/author_interface.rb +13 -0
  84. data/decidim-api/spec/types/query_type_spec.rb +1 -1
  85. data/decidim-api/spec/types/translated_field_type_spec.rb +1 -1
  86. data/decidim-budgets/.gitignore +7 -0
  87. data/decidim-budgets/README.md +23 -0
  88. data/decidim-budgets/Rakefile +2 -0
  89. data/decidim-budgets/app/assets/config/decidim_budgets_manifest.js +1 -0
  90. data/decidim-budgets/app/assets/images/decidim/budgets/icon.svg +4 -0
  91. data/decidim-budgets/app/assets/javascripts/decidim/budgets/projects.js.es6 +28 -0
  92. data/decidim-budgets/app/assets/stylesheets/decidim/budgets/_budgets.scss +1 -0
  93. data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +32 -0
  94. data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_budget-meter.scss +78 -0
  95. data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_progress.scss +17 -0
  96. data/decidim-budgets/app/commands/decidim/budgets/add_line_item.rb +43 -0
  97. data/decidim-budgets/app/commands/decidim/budgets/admin/create_project.rb +52 -0
  98. data/decidim-budgets/app/commands/decidim/budgets/admin/update_project.rb +56 -0
  99. data/decidim-budgets/app/commands/decidim/budgets/cancel_order.rb +36 -0
  100. data/decidim-budgets/app/commands/decidim/budgets/checkout.rb +34 -0
  101. data/decidim-budgets/app/commands/decidim/budgets/remove_line_item.rb +35 -0
  102. data/decidim-budgets/app/controllers/concerns/decidim/budgets/needs_current_order.rb +27 -0
  103. data/decidim-budgets/app/controllers/decidim/budgets/admin/application_controller.rb +14 -0
  104. data/decidim-budgets/app/controllers/decidim/budgets/admin/projects_controller.rb +69 -0
  105. data/decidim-budgets/app/controllers/decidim/budgets/application_controller.rb +13 -0
  106. data/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb +43 -0
  107. data/decidim-budgets/app/controllers/decidim/budgets/orders_controller.rb +38 -0
  108. data/decidim-budgets/app/controllers/decidim/budgets/projects_controller.rb +44 -0
  109. data/decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb +44 -0
  110. data/decidim-budgets/app/helpers/decidim/budgets/application_helper.rb +12 -0
  111. data/decidim-budgets/app/helpers/decidim/budgets/projects_helper.rb +29 -0
  112. data/decidim-budgets/app/models/decidim/budgets/application_record.rb +9 -0
  113. data/decidim-budgets/app/models/decidim/budgets/line_item.rb +20 -0
  114. data/decidim-budgets/app/models/decidim/budgets/order.rb +52 -0
  115. data/decidim-budgets/app/models/decidim/budgets/project.rb +15 -0
  116. data/decidim-budgets/app/services/decidim/budgets/project_search.rb +58 -0
  117. data/decidim-budgets/app/views/decidim/budgets/admin/projects/_form.html.erb +31 -0
  118. data/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb +9 -0
  119. data/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb +27 -0
  120. data/{decidim-admin/app/views/decidim/admin/participatory_process_attachments → decidim-budgets/app/views/decidim/budgets/admin/projects}/new.html.erb +0 -0
  121. data/decidim-budgets/app/views/decidim/budgets/line_items/update_budget.js.erb +21 -0
  122. data/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb +30 -0
  123. data/decidim-budgets/app/views/decidim/budgets/projects/_budget_excess.html.erb +14 -0
  124. data/decidim-budgets/app/views/decidim/budgets/projects/_budget_summary.html.erb +46 -0
  125. data/decidim-budgets/app/views/decidim/budgets/projects/_count.html.erb +1 -0
  126. data/decidim-budgets/app/views/decidim/budgets/projects/_filters.html.erb +24 -0
  127. data/decidim-budgets/app/views/decidim/budgets/projects/_linked_projects.html.erb +12 -0
  128. data/decidim-budgets/app/views/decidim/budgets/projects/_order_progress.html.erb +34 -0
  129. data/decidim-budgets/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +25 -0
  130. data/decidim-budgets/app/views/decidim/budgets/projects/_order_total_budget.html.erb +1 -0
  131. data/decidim-budgets/app/views/decidim/budgets/projects/_project.html.erb +40 -0
  132. data/decidim-budgets/app/views/decidim/budgets/projects/_project_budget_button.html.erb +9 -0
  133. data/decidim-budgets/app/views/decidim/budgets/projects/_projects.html.erb +8 -0
  134. data/decidim-budgets/app/views/decidim/budgets/projects/_tags.html.erb +10 -0
  135. data/decidim-budgets/app/views/decidim/budgets/projects/index.html.erb +26 -0
  136. data/decidim-budgets/app/views/decidim/budgets/projects/index.js.erb +2 -0
  137. data/decidim-budgets/app/views/decidim/budgets/projects/show.html.erb +48 -0
  138. data/decidim-budgets/bin/rails +14 -0
  139. data/decidim-budgets/config/i18n-tasks.yml +4 -0
  140. data/decidim-budgets/config/locales/ca.yml +84 -0
  141. data/decidim-budgets/config/locales/en.yml +95 -0
  142. data/decidim-budgets/config/locales/es.yml +84 -0
  143. data/decidim-budgets/db/migrate/20170127114122_create_projects.rb +15 -0
  144. data/decidim-budgets/db/migrate/20170130095615_create_orders.rb +13 -0
  145. data/decidim-budgets/db/migrate/20170130101825_create_line_items.rb +10 -0
  146. data/decidim-budgets/decidim-budgets.gemspec +24 -0
  147. data/decidim-budgets/lib/decidim/budgets.rb +11 -0
  148. data/decidim-budgets/lib/decidim/budgets/admin.rb +9 -0
  149. data/decidim-budgets/lib/decidim/budgets/admin_engine.rb +22 -0
  150. data/decidim-budgets/lib/decidim/budgets/feature.rb +59 -0
  151. data/decidim-budgets/lib/decidim/budgets/list_engine.rb +30 -0
  152. data/decidim-budgets/lib/decidim/budgets/test/factories.rb +43 -0
  153. data/decidim-budgets/spec/commands/add_line_item_spec.rb +48 -0
  154. data/decidim-budgets/spec/commands/cancel_order_spec.rb +42 -0
  155. data/decidim-budgets/spec/commands/checkout_spec.rb +45 -0
  156. data/decidim-budgets/spec/commands/create_project_spec.rb +72 -0
  157. data/decidim-budgets/spec/commands/remove_line_item_spec.rb +31 -0
  158. data/decidim-budgets/spec/commands/update_project_spec.rb +65 -0
  159. data/decidim-budgets/spec/factories.rb +4 -0
  160. data/decidim-budgets/spec/features/admin_manages_projects_spec.rb +16 -0
  161. data/decidim-budgets/spec/features/orders_spec.rb +149 -0
  162. data/decidim-budgets/spec/features/process_admin_manages_projects_spec.rb +17 -0
  163. data/decidim-budgets/spec/forms/project_form_spec.rb +115 -0
  164. data/decidim-budgets/spec/models/line_item_spec.rb +35 -0
  165. data/decidim-budgets/spec/models/order_spec.rb +45 -0
  166. data/decidim-budgets/spec/models/project_spec.rb +30 -0
  167. data/decidim-budgets/spec/services/project_search_spec.rb +97 -0
  168. data/decidim-budgets/spec/shared/admin_shared_context.rb +11 -0
  169. data/decidim-budgets/spec/shared/manage_projects_examples.rb +104 -0
  170. data/decidim-budgets/spec/spec_helper.rb +2 -0
  171. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  172. data/decidim-comments/app/commands/decidim/comments/create_comment.rb +2 -1
  173. data/decidim-comments/app/forms/decidim/comments/comment_form.rb +1 -0
  174. data/decidim-comments/app/frontend/application/apollo_client.js +1 -1
  175. data/decidim-comments/app/frontend/application/application.component.jsx +1 -1
  176. data/decidim-comments/app/frontend/comments/add_comment_form.component.jsx +76 -20
  177. data/decidim-comments/app/frontend/comments/add_comment_form.component.test.jsx +77 -22
  178. data/decidim-comments/app/frontend/comments/add_comment_form.fragment.graphql +6 -0
  179. data/decidim-comments/app/frontend/comments/add_comment_form.mutation.graphql +2 -2
  180. data/decidim-comments/app/frontend/comments/comment.component.jsx +15 -15
  181. data/decidim-comments/app/frontend/comments/comment.component.test.jsx +42 -41
  182. data/decidim-comments/app/frontend/comments/comment_order_selector.component.jsx +1 -1
  183. data/decidim-comments/app/frontend/comments/comment_thread.component.jsx +7 -7
  184. data/decidim-comments/app/frontend/comments/comment_thread.component.test.jsx +21 -19
  185. data/decidim-comments/app/frontend/comments/comments.component.jsx +21 -17
  186. data/decidim-comments/app/frontend/comments/comments.component.test.jsx +47 -32
  187. data/decidim-comments/app/frontend/comments/comments.query.graphql +6 -3
  188. data/decidim-comments/app/frontend/comments/down_vote_button.component.jsx +21 -10
  189. data/decidim-comments/app/frontend/comments/up_vote_button.component.jsx +23 -12
  190. data/decidim-comments/app/frontend/comments/vote_button.component.jsx +15 -7
  191. data/decidim-comments/app/frontend/comments/vote_button_component.test.jsx +7 -2
  192. data/decidim-comments/app/frontend/entry.js +1 -8
  193. data/decidim-comments/app/frontend/support/generate_user_data.js +13 -0
  194. data/decidim-comments/app/frontend/support/generate_user_group_data.js +14 -0
  195. data/decidim-comments/app/helpers/decidim/comments/comments_helper.rb +10 -15
  196. data/decidim-comments/app/models/decidim/comments/comment.rb +5 -7
  197. data/decidim-comments/app/types/decidim/comments/comment_type.rb +5 -1
  198. data/decidim-comments/config/locales/ca.yml +5 -1
  199. data/decidim-comments/config/locales/en.yml +4 -1
  200. data/decidim-comments/config/locales/es.yml +5 -1
  201. data/decidim-comments/db/migrate/20170123102043_add_user_group_id_to_comments.rb +5 -0
  202. data/decidim-comments/decidim-comments.gemspec +0 -1
  203. data/decidim-comments/lib/decidim/comments/engine.rb +0 -1
  204. data/decidim-comments/lib/decidim/comments/mutation_extensions.rb +2 -1
  205. data/decidim-comments/spec/commands/create_comment_spec.rb +6 -3
  206. data/decidim-comments/spec/commands/vote_comment_spec.rb +4 -4
  207. data/decidim-comments/spec/features/comments_spec.rb +27 -3
  208. data/decidim-comments/spec/forms/comment_form_spec.rb +6 -3
  209. data/decidim-comments/spec/models/comment_spec.rb +25 -32
  210. data/decidim-comments/spec/queries/comments_with_replies_spec.rb +2 -2
  211. data/decidim-comments/spec/types/comment_type_spec.rb +2 -2
  212. data/decidim-comments/spec/types/query_type_spec.rb +5 -5
  213. data/decidim-dev/app/views/decidim/dummy_resource/_linked_dummys.html.erb +5 -0
  214. data/decidim-dev/config/locales/en.yml +5 -0
  215. data/decidim-dev/decidim-dev.gemspec +3 -3
  216. data/decidim-dev/lib/decidim/dev/assets/avatar.jpg +0 -0
  217. data/decidim-dev/lib/decidim/dev/assets/icon.png +0 -0
  218. data/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb +1 -0
  219. data/decidim-dev/lib/decidim/dev/test/rspec_support/action_mailer.rb +1 -1
  220. data/decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb +9 -5
  221. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb +24 -0
  222. data/decidim-meetings/app/assets/config/decidim_meetings_manifest.js +2 -0
  223. data/decidim-meetings/app/assets/javascripts/decidim/meetings/map.js.es6.erb +92 -0
  224. data/decidim-meetings/app/assets/stylesheets/decidim/meetings/map.css +1 -0
  225. data/decidim-meetings/app/commands/decidim/meetings/admin/close_meeting.rb +53 -0
  226. data/decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb +15 -3
  227. data/decidim-meetings/app/commands/decidim/meetings/admin/update_meeting.rb +15 -3
  228. data/decidim-meetings/app/controllers/decidim/meetings/admin/application_controller.rb +9 -0
  229. data/decidim-meetings/app/controllers/decidim/meetings/admin/attachments_controller.rb +29 -0
  230. data/decidim-meetings/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +38 -0
  231. data/decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb +0 -12
  232. data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +11 -9
  233. data/decidim-meetings/app/forms/decidim/meetings/admin/close_meeting_form.rb +31 -0
  234. data/decidim-meetings/app/forms/decidim/meetings/admin/meeting_form.rb +0 -2
  235. data/decidim-meetings/app/helpers/decidim/meetings/admin/application_helper.rb +12 -0
  236. data/decidim-meetings/app/helpers/decidim/meetings/application_helper.rb +1 -0
  237. data/decidim-meetings/app/helpers/decidim/meetings/map_helper.rb +46 -0
  238. data/decidim-meetings/app/models/decidim/meetings/meeting.rb +11 -15
  239. data/decidim-meetings/app/services/decidim/meetings/meeting_search.rb +0 -1
  240. data/decidim-meetings/app/services/decidim/meetings/static_map_generator.rb +50 -0
  241. data/decidim-meetings/app/views/decidim/meetings/admin/meeting_closes/_form.html.erb +23 -0
  242. data/decidim-meetings/app/views/decidim/meetings/admin/meeting_closes/edit.html.erb +9 -0
  243. data/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb +2 -6
  244. data/decidim-meetings/app/views/decidim/meetings/admin/meetings/index.html.erb +14 -0
  245. data/decidim-meetings/app/views/decidim/meetings/meetings/_datetime.html.erb +8 -0
  246. data/decidim-meetings/app/views/decidim/meetings/meetings/_filters.html.erb +2 -2
  247. data/decidim-meetings/app/views/decidim/meetings/meetings/_filters_small_view.html.erb +18 -0
  248. data/decidim-meetings/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +22 -0
  249. data/decidim-meetings/app/views/decidim/meetings/meetings/_meetings.html.erb +3 -10
  250. data/decidim-meetings/app/views/decidim/meetings/meetings/index.html.erb +42 -0
  251. data/decidim-meetings/app/views/decidim/meetings/meetings/index.js.erb +6 -0
  252. data/decidim-meetings/app/views/decidim/meetings/meetings/show.html.erb +33 -7
  253. data/decidim-meetings/bin/rails +1 -1
  254. data/decidim-meetings/config/i18n-tasks.yml +2 -0
  255. data/decidim-meetings/config/locales/ca.yml +37 -4
  256. data/decidim-meetings/config/locales/en.yml +34 -1
  257. data/decidim-meetings/config/locales/es.yml +36 -3
  258. data/decidim-meetings/db/migrate/20170110142105_close_a_meeting.rb +9 -0
  259. data/decidim-meetings/db/migrate/20170123151650_add_latitude_and_longitude_to_meetings.rb +6 -0
  260. data/decidim-meetings/db/migrate/20170129153716_remove_short_description_from_meetings.rb +5 -0
  261. data/decidim-meetings/decidim-meetings.gemspec +7 -0
  262. data/decidim-meetings/lib/decidim/meetings/admin_engine.rb +31 -1
  263. data/decidim-meetings/lib/decidim/meetings/feature.rb +20 -6
  264. data/decidim-meetings/lib/decidim/meetings/list_engine.rb +10 -1
  265. data/decidim-meetings/lib/decidim/meetings/seeds/Exampledocument.pdf +0 -0
  266. data/decidim-meetings/lib/decidim/meetings/seeds/city.jpeg +0 -0
  267. data/decidim-meetings/lib/decidim/meetings/test/factories.rb +23 -0
  268. data/decidim-meetings/spec/commands/close_meeting_spec.rb +78 -0
  269. data/decidim-meetings/spec/commands/create_meeting_spec.rb +22 -3
  270. data/decidim-meetings/spec/commands/update_meeting_spec.rb +32 -3
  271. data/decidim-meetings/spec/controllers/meetings_controller_spec.rb +41 -0
  272. data/decidim-meetings/spec/factories.rb +3 -13
  273. data/decidim-meetings/spec/features/admin_manages_meetings_attachments_spec.rb +10 -0
  274. data/decidim-meetings/spec/features/explore_meetings_spec.rb +55 -1
  275. data/decidim-meetings/spec/features/process_admin_manages_meetings_attachments_spec.rb +12 -0
  276. data/decidim-meetings/spec/forms/close_meeting_form_spec.rb +90 -0
  277. data/decidim-meetings/spec/forms/meeting_form_spec.rb +1 -7
  278. data/decidim-meetings/spec/models/meeting_spec.rb +42 -24
  279. data/decidim-meetings/spec/services/meeting_search_spec.rb +1 -17
  280. data/decidim-meetings/spec/services/static_map_generator_spec.rb +33 -0
  281. data/decidim-meetings/spec/shared/manage_attachments_examples.rb +17 -0
  282. data/decidim-meetings/spec/shared/manage_meetings_examples.rb +58 -8
  283. data/decidim-meetings/spec/spec_helper.rb +5 -0
  284. data/decidim-meetings/spec/support/geocoder.rb +7 -0
  285. data/decidim-meetings/vendor/assets/javascripts/leaflet-svg-icon.js +179 -0
  286. data/decidim-meetings/vendor/assets/javascripts/leaflet-tilelayer-here.js +166 -0
  287. data/decidim-meetings/vendor/assets/javascripts/leaflet.js +9 -0
  288. data/decidim-meetings/vendor/assets/stylesheets/leaflet.css +624 -0
  289. data/decidim-pages/app/models/decidim/pages/page.rb +10 -1
  290. data/decidim-pages/app/views/decidim/pages/application/show.html.erb +2 -1
  291. data/decidim-pages/spec/commands/create_page_spec.rb +2 -2
  292. data/decidim-pages/spec/commands/destroy_page_spec.rb +1 -1
  293. data/decidim-pages/spec/commands/update_page_spec.rb +1 -1
  294. data/decidim-pages/spec/factories.rb +1 -1
  295. data/decidim-pages/spec/features/admin_spec.rb +1 -0
  296. data/decidim-pages/spec/models/page_spec.rb +15 -0
  297. data/decidim-proposals/app/assets/stylesheets/decidim/proposals/social_share.css.scss +5 -0
  298. data/decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb +43 -0
  299. data/decidim-proposals/app/commands/decidim/proposals/create_proposal.rb +1 -0
  300. data/decidim-proposals/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +37 -0
  301. data/decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb +1 -0
  302. data/decidim-proposals/app/controllers/decidim/proposals/proposal_votes_controller.rb +18 -7
  303. data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +8 -7
  304. data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_answer_form.rb +18 -0
  305. data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +1 -0
  306. data/decidim-proposals/app/helpers/decidim/proposals/application_helper.rb +17 -0
  307. data/decidim-proposals/app/helpers/decidim/proposals/proposal_votes_helper.rb +19 -0
  308. data/decidim-proposals/app/models/decidim/proposals/abilities/current_user.rb +59 -0
  309. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +30 -33
  310. data/decidim-proposals/app/models/decidim/proposals/proposal_vote.rb +2 -0
  311. data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +11 -0
  312. data/decidim-proposals/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +15 -0
  313. data/decidim-proposals/app/views/decidim/proposals/admin/proposals/index.html.erb +8 -0
  314. data/decidim-proposals/app/views/decidim/proposals/proposal_votes/update_buttons_and_counters.js.erb +20 -0
  315. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +3 -1
  316. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +18 -0
  317. data/decidim-proposals/app/views/decidim/proposals/proposals/_linked_proposals.html.erb +27 -0
  318. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +3 -2
  319. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +3 -0
  320. data/decidim-proposals/app/views/decidim/proposals/proposals/_remaining_votes_count.html.erb +1 -0
  321. data/decidim-proposals/app/views/decidim/proposals/proposals/_share.html.erb +1 -1
  322. data/decidim-proposals/app/views/decidim/proposals/proposals/_vote_button.html.erb +16 -4
  323. data/decidim-proposals/app/views/decidim/proposals/proposals/_votes_limit.html.erb +23 -0
  324. data/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +13 -3
  325. data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +6 -0
  326. data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +15 -2
  327. data/decidim-proposals/config/i18n-tasks.yml +3 -0
  328. data/decidim-proposals/config/locales/ca.yml +54 -1
  329. data/decidim-proposals/config/locales/en.yml +54 -0
  330. data/decidim-proposals/config/locales/es.yml +54 -1
  331. data/decidim-proposals/db/migrate/20170120151202_add_user_group_id_to_proposals.rb +5 -0
  332. data/decidim-proposals/db/migrate/20170131092413_add_answers_to_proposals.rb +7 -0
  333. data/decidim-proposals/decidim-proposals.gemspec +3 -0
  334. data/decidim-proposals/lib/decidim/proposals/admin_engine.rb +3 -1
  335. data/decidim-proposals/lib/decidim/proposals/engine.rb +7 -1
  336. data/decidim-proposals/lib/decidim/proposals/feature.rb +28 -1
  337. data/decidim-proposals/lib/decidim/proposals/test/factories.rb +83 -0
  338. data/decidim-proposals/spec/commands/decidim/proposals/admin_create_proposal_spec.rb +14 -0
  339. data/decidim-proposals/spec/commands/decidim/proposals/answer_proposal_spec.rb +53 -0
  340. data/decidim-proposals/spec/commands/decidim/proposals/create_proposal_spec.rb +3 -56
  341. data/decidim-proposals/spec/controllers/decidim/admin/proposal_answers_controller_spec.rb +45 -0
  342. data/decidim-proposals/spec/controllers/decidim/proposal_votes_controller_spec.rb +113 -0
  343. data/decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb +53 -0
  344. data/decidim-proposals/spec/factories.rb +1 -23
  345. data/decidim-proposals/spec/features/proposals_spec.rb +201 -38
  346. data/decidim-proposals/spec/features/vote_proposal_spec.rb +83 -11
  347. data/decidim-proposals/spec/forms/decidim/proposals/admin_proposal_form_spec.rb +13 -0
  348. data/decidim-proposals/spec/forms/decidim/proposals/proposal_answer_form_spec.rb +50 -0
  349. data/decidim-proposals/spec/forms/decidim/proposals/proposal_form_spec.rb +5 -93
  350. data/decidim-proposals/spec/helpers/application_helper_spec.rb +33 -0
  351. data/decidim-proposals/spec/helpers/proposal_votes_helper_spec.rb +53 -0
  352. data/decidim-proposals/spec/lib/decidim/proposals/feature_spec.rb +1 -1
  353. data/decidim-proposals/spec/models/decidim/proposals/proposal_spec.rb +21 -19
  354. data/decidim-proposals/spec/models/decidim/proposals/proposal_vote_spec.rb +19 -1
  355. data/decidim-proposals/spec/services/decidim/proposals/proposal_search_spec.rb +66 -25
  356. data/decidim-proposals/spec/shared/create_proposal_examples.rb +69 -0
  357. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +49 -0
  358. data/decidim-proposals/spec/shared/proposal_form_examples.rb +100 -0
  359. data/decidim-results/.gitignore +7 -0
  360. data/decidim-results/README.md +23 -0
  361. data/decidim-results/Rakefile +2 -0
  362. data/decidim-results/app/assets/images/decidim/results/icon.svg +1 -0
  363. data/decidim-results/app/commands/decidim/results/admin/create_result.rb +65 -0
  364. data/decidim-results/app/commands/decidim/results/admin/update_result.rb +69 -0
  365. data/decidim-results/app/controllers/decidim/results/admin/application_controller.rb +14 -0
  366. data/decidim-results/app/controllers/decidim/results/admin/results_controller.rb +69 -0
  367. data/decidim-results/app/controllers/decidim/results/application_controller.rb +13 -0
  368. data/decidim-results/app/controllers/decidim/results/results_controller.rb +42 -0
  369. data/decidim-results/app/forms/decidim/results/admin/result_form.rb +40 -0
  370. data/decidim-results/app/helpers/decidim/results/application_helper.rb +11 -0
  371. data/decidim-results/app/models/decidim/results/application_record.rb +9 -0
  372. data/decidim-results/app/models/decidim/results/result.rb +15 -0
  373. data/decidim-results/app/services/decidim/results/result_search.rb +44 -0
  374. data/decidim-results/app/services/decidim/results/result_stats_calculator.rb +51 -0
  375. data/decidim-results/app/views/decidim/results/admin/results/_form.html.erb +23 -0
  376. data/decidim-results/app/views/decidim/results/admin/results/edit.html.erb +9 -0
  377. data/decidim-results/app/views/decidim/results/admin/results/index.html.erb +27 -0
  378. data/decidim-results/app/views/decidim/results/admin/results/new.html.erb +9 -0
  379. data/decidim-results/app/views/decidim/results/results/_count.html.erb +1 -0
  380. data/decidim-results/app/views/decidim/results/results/_filters.html.erb +22 -0
  381. data/decidim-results/app/views/decidim/results/results/_linked_results.html.erb +12 -0
  382. data/decidim-results/app/views/decidim/results/results/_results.html.erb +16 -0
  383. data/decidim-results/app/views/decidim/results/results/_tags.html.erb +10 -0
  384. data/decidim-results/app/views/decidim/results/results/index.html.erb +22 -0
  385. data/decidim-results/app/views/decidim/results/results/index.js.erb +2 -0
  386. data/decidim-results/app/views/decidim/results/results/show.html.erb +52 -0
  387. data/decidim-results/bin/rails +14 -0
  388. data/decidim-results/config/i18n-tasks.yml +5 -0
  389. data/decidim-results/config/locales/ca.yml +61 -0
  390. data/decidim-results/config/locales/en.yml +62 -0
  391. data/decidim-results/config/locales/es.yml +61 -0
  392. data/decidim-results/db/migrate/20170116104125_create_results.rb +14 -0
  393. data/decidim-results/db/migrate/20170129164553_remove_short_description_from_results.rb +5 -0
  394. data/decidim-results/decidim-results.gemspec +26 -0
  395. data/decidim-results/lib/decidim/results.rb +11 -0
  396. data/decidim-results/lib/decidim/results/admin.rb +9 -0
  397. data/decidim-results/lib/decidim/results/admin_engine.rb +22 -0
  398. data/decidim-results/lib/decidim/results/feature.rb +52 -0
  399. data/decidim-results/lib/decidim/results/list_engine.rb +19 -0
  400. data/decidim-results/lib/decidim/results/test/factories.rb +11 -0
  401. data/decidim-results/spec/commands/create_result_spec.rb +90 -0
  402. data/decidim-results/spec/commands/update_result_spec.rb +83 -0
  403. data/decidim-results/spec/factories.rb +6 -0
  404. data/decidim-results/spec/features/admin_manages_results_spec.rb +16 -0
  405. data/decidim-results/spec/features/explore_results_spec.rb +186 -0
  406. data/decidim-results/spec/features/process_admin_manages_results_spec.rb +17 -0
  407. data/decidim-results/spec/forms/result_form_spec.rb +91 -0
  408. data/decidim-results/spec/models/result_spec.rb +18 -0
  409. data/decidim-results/spec/services/result_search_spec.rb +97 -0
  410. data/decidim-results/spec/services/result_stats_calculator_spec.rb +93 -0
  411. data/decidim-results/spec/shared/admin_shared_context.rb +11 -0
  412. data/decidim-results/spec/shared/manage_results_examples.rb +96 -0
  413. data/decidim-results/spec/spec_helper.rb +2 -0
  414. data/decidim-system/app/assets/javascripts/decidim/system/application.js.es6 +1 -3
  415. data/decidim-system/app/views/layouts/decidim/system/_header.html.erb +2 -2
  416. data/decidim-system/decidim-system.gemspec +0 -1
  417. data/decidim-system/lib/decidim/system/engine.rb +0 -1
  418. data/decidim-system/spec/features/manage_admins_spec.rb +1 -1
  419. data/decidim-system/spec/features/organizations_spec.rb +1 -1
  420. data/decidim.gemspec +2 -0
  421. data/docs/how_to_create_a_plugin.md +0 -2
  422. data/lib/decidim.rb +2 -0
  423. data/lib/generators/decidim/install_generator.rb +1 -0
  424. data/lib/generators/decidim/templates/Gemfile.erb +10 -1
  425. data/lib/generators/decidim/templates/initializer.rb +9 -0
  426. data/lib/generators/decidim/templates/secrets.yml.erb +3 -0
  427. data/lib/generators/decidim/templates/social_share_button.rb +1 -1
  428. data/package.json +2 -3
  429. data/yarn.lock +10 -8
  430. metadata +265 -32
  431. data/decidim-admin/app/helpers/decidim/admin/aria_selected_link_to_helper.rb +0 -28
  432. data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/edit.html.erb +0 -9
  433. data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/index.html.erb +0 -37
  434. data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/show.html.erb +0 -25
  435. data/decidim-comments/app/frontend/support/generate_current_user_data.js +0 -13
  436. data/decidim-comments/app/types/decidim/comments/author_type.rb +0 -15
  437. data/decidim-comments/spec/types/author_type_spec.rb +0 -21
  438. data/decidim-dev/lib/decidim/dev/assets/avatar.svg +0 -14
  439. data/decidim-proposals/app/views/decidim/proposals/proposal_votes/create.js.erb +0 -5
@@ -12,15 +12,26 @@ import commentDataFragment from './comment_data.fragment.graphql';
12
12
  import upVoteFragment from './up_vote.fragment.graphql';
13
13
  import downVoteFragment from './down_vote.fragment.graphql';
14
14
 
15
- export const UpVoteButton = ({ comment: { upVotes, upVoted, downVoted }, upVote }) => (
16
- <VoteButton
17
- buttonClassName="comment__votes--up"
18
- iconName="icon-chevron-top"
19
- votes={upVotes}
20
- voteAction={upVote}
21
- disabled={upVoted || downVoted}
22
- />
23
- );
15
+ export const UpVoteButton = ({ comment: { upVotes, upVoted, downVoted }, upVote }) => {
16
+ let selectedClass = '';
17
+
18
+ if (upVoted) {
19
+ selectedClass = 'is-vote-selected';
20
+ } else if (downVoted) {
21
+ selectedClass = 'is-vote-notselected';
22
+ }
23
+
24
+ return (
25
+ <VoteButton
26
+ buttonClassName="comment__votes--up"
27
+ iconName="icon-chevron-top"
28
+ votes={upVotes}
29
+ voteAction={upVote}
30
+ disabled={upVoted || downVoted}
31
+ selectedClass={selectedClass}
32
+ />
33
+ );
34
+ }
24
35
 
25
36
  UpVoteButton.fragments = {
26
37
  comment: gql`
@@ -58,10 +69,10 @@ const UpVoteButtonWithMutation = graphql(gql`
58
69
  }
59
70
  },
60
71
  updateQueries: {
61
- GetComments: (prev, { mutationResult: { data } }) => {
72
+ GetComments: (prev, { mutationResult: { data } }) => {
62
73
  const commentReducer = (comment) => {
63
74
  const replies = comment.replies || [];
64
-
75
+
65
76
  if (comment.id === ownProps.comment.id) {
66
77
  return data.comment.upVote;
67
78
  }
@@ -78,7 +89,7 @@ const UpVoteButtonWithMutation = graphql(gql`
78
89
  }
79
90
  }
80
91
  })
81
- })
92
+ })
82
93
  })(UpVoteButton);
83
94
 
84
95
  export default UpVoteButtonWithMutation;
@@ -1,18 +1,26 @@
1
- import { PropTypes } from 'react';
1
+ import { Component, PropTypes } from 'react';
2
2
  import Icon from '../application/icon.component';
3
3
 
4
- const VoteButton = ({ buttonClassName, iconName, votes, voteAction, disabled }) => (
5
- <button className={buttonClassName} onClick={() => voteAction()} disabled={disabled}>
6
- <Icon name={iconName} iconExtraClassName="icon--small" />
7
- { ` ${votes}` }
8
- </button>
9
- );
4
+ class VoteButton extends Component {
5
+ render() {
6
+ const { buttonClassName, iconName, votes, voteAction, disabled, selectedClass } = this.props;
7
+ let voteClasses = `${buttonClassName} ${selectedClass}`;
8
+
9
+ return (
10
+ <button className={voteClasses} onClick={() => voteAction()} disabled={disabled}>
11
+ <Icon name={iconName} iconExtraClassName="icon--small" />
12
+ { ` ${votes}` }
13
+ </button>
14
+ );
15
+ }
16
+ }
10
17
 
11
18
  VoteButton.propTypes = {
12
19
  buttonClassName: PropTypes.string.isRequired,
13
20
  iconName: PropTypes.string.isRequired,
14
21
  votes: PropTypes.number.isRequired,
15
22
  voteAction: PropTypes.func.isRequired,
23
+ selectedClass: PropTypes.string,
16
24
  disabled: PropTypes.bool
17
25
  };
18
26
 
@@ -21,7 +21,7 @@ describe("<VoteButton />", () => {
21
21
  });
22
22
 
23
23
  it("should render a Icon component with the correct name prop", () => {
24
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
24
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
25
25
  expect(wrapper.find(Icon)).to.have.prop("name").equal('vote-icon');
26
26
  });
27
27
 
@@ -32,7 +32,12 @@ describe("<VoteButton />", () => {
32
32
  });
33
33
 
34
34
  it("should disable the button based on the disabled prop", () => {
35
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled />);
35
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled />);
36
36
  expect(wrapper.find('button')).to.be.disabled();
37
37
  })
38
+
39
+ it("should render a button with the given selectedClass", () => {
40
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled selectedClass="is-vote-selected" />);
41
+ expect(wrapper.find('.is-vote-selected')).to.be.present();
42
+ })
38
43
  });
@@ -8,16 +8,9 @@ window.DecidimComments.renderCommentsComponent = (nodeId, props) => {
8
8
  var node = $(`#${nodeId}`)[0];
9
9
 
10
10
  ReactDOM.render(
11
- React.createElement(Comments,props),
11
+ React.createElement(Comments, props),
12
12
  node
13
13
  );
14
-
15
- function unmountComponent() {
16
- ReactDOM.unmountComponentAtNode(node);
17
- $(document).off('turbolinks:before-render', unmountComponent);
18
- }
19
-
20
- $(document).on('turbolinks:before-render', unmountComponent);
21
14
  };
22
15
 
23
16
  // Load component locales from yaml files
@@ -0,0 +1,13 @@
1
+ import { name } from 'faker/locale/en';
2
+
3
+ /**
4
+ * Generate random user data to emulate a database real content
5
+ * @returns {Object} - An object representing user data
6
+ */
7
+ const generateUserData = () => {
8
+ return {
9
+ name: name.findName()
10
+ };
11
+ };
12
+
13
+ export default generateUserData;
@@ -0,0 +1,14 @@
1
+ import { random, company } from 'faker/locale/en';
2
+
3
+ /**
4
+ * Generate random user group data to emulate a database real content
5
+ * @returns {Object} - An object representing user group data
6
+ */
7
+ const generateUserGrouprData = () => {
8
+ return {
9
+ id: random.uuid(),
10
+ name: company.companyName()
11
+ };
12
+ };
13
+
14
+ export default generateUserGrouprData;
@@ -28,22 +28,17 @@ module Decidim
28
28
  # props - A hash corresponding to Comments component props
29
29
  def react_comments_component(node_id, props)
30
30
  content_tag("div", "", id: node_id) +
31
+ javascript_include_tag("decidim/comments/comments") +
31
32
  javascript_tag(%{
32
- jQuery.ajax({
33
- url: '#{asset_path("decidim/comments/comments.js")}',
34
- dataType: 'script',
35
- cache: true
36
- }).then(function () {
37
- window.DecidimComments.renderCommentsComponent(
38
- '#{node_id}',
39
- {
40
- commentableType: "#{props[:commentableType]}",
41
- commentableId: "#{props[:commentableId]}",
42
- options: JSON.parse("#{j(props[:options].to_json)}"),
43
- locale: "#{props[:locale]}"
44
- }
45
- );
46
- });
33
+ window.DecidimComments.renderCommentsComponent(
34
+ '#{node_id}',
35
+ {
36
+ commentableType: "#{props[:commentableType]}",
37
+ commentableId: "#{props[:commentableId]}",
38
+ options: JSON.parse("#{j(props[:options].to_json)}"),
39
+ locale: "#{props[:locale]}"
40
+ }
41
+ );
47
42
  })
48
43
  end
49
44
  end
@@ -5,6 +5,8 @@ module Decidim
5
5
  # comment on them. The will be able to create conversations between users
6
6
  # to discuss or share their thoughts about the resource.
7
7
  class Comment < ApplicationRecord
8
+ include Decidim::Authorable
9
+
8
10
  # Limit the max depth of a comment tree. If C is a comment and R is a reply:
9
11
  # C (depth 0)
10
12
  # |--R (depth 1)
@@ -13,16 +15,16 @@ module Decidim
13
15
  # |--R (depth 3)
14
16
  MAX_DEPTH = 3
15
17
 
16
- belongs_to :author, foreign_key: "decidim_author_id", class_name: Decidim::User
17
18
  belongs_to :commentable, foreign_key: "decidim_commentable_id", foreign_type: "decidim_commentable_type", polymorphic: true
18
19
  has_many :replies, as: :commentable, foreign_key: "decidim_commentable_id", foreign_type: "decidim_commentable_type", class_name: Comment
19
20
  has_many :up_votes, -> { where(weight: 1) }, foreign_key: "decidim_comment_id", class_name: CommentVote, dependent: :destroy
20
21
  has_many :down_votes, -> { where(weight: -1) }, foreign_key: "decidim_comment_id", class_name: CommentVote, dependent: :destroy
22
+
21
23
  validates :author, :commentable, :body, presence: true
22
- validate :commentable_can_have_replies
23
24
  validates :depth, numericality: { greater_than_or_equal_to: 0 }
24
25
  validates :alignment, inclusion: { in: [0, 1, -1] }
25
- validate :same_organization
26
+
27
+ validate :commentable_can_have_replies
26
28
 
27
29
  before_save :compute_depth
28
30
 
@@ -61,10 +63,6 @@ module Decidim
61
63
  def compute_depth
62
64
  self.depth = commentable.depth + 1 if commentable.respond_to?(:depth)
63
65
  end
64
-
65
- def same_organization
66
- errors.add(:commentable, :invalid) unless author.organization == organization
67
- end
68
66
  end
69
67
  end
70
68
  end
@@ -16,7 +16,11 @@ module Decidim
16
16
  }
17
17
  end
18
18
 
19
- field :author, !AuthorType, "The comment's author"
19
+ field :author, !Decidim::Api::AuthorInterface, "The comment's author" do
20
+ resolve lambda { |obj, _args, _ctx|
21
+ obj.user_group || obj.author
22
+ }
23
+ end
20
24
 
21
25
  field :replies, !types[CommentType], "The comment's replies" do
22
26
  resolve lambda { |obj, _args, _ctx|
@@ -11,6 +11,8 @@ ca:
11
11
  label: Comentari
12
12
  placeholder: Què en penses d'això?
13
13
  submit: Envia
14
+ user_group_id:
15
+ label: Comentar com a
14
16
  opinion:
15
17
  against: Hi estic en contra
16
18
  in_favor: Hi estic a favor
@@ -23,13 +25,15 @@ ca:
23
25
  reply: Respondre
24
26
  comment_order_selector:
25
27
  order:
26
- most_voted: Més votat
28
+ best_rated: Més ben valorats
29
+ most_discussed: Més discutit
27
30
  older: Més antic
28
31
  recent: Recent
29
32
  title: 'Ordenar per:'
30
33
  comment_thread:
31
34
  title: Conversa amb %{authorName}
32
35
  comments:
36
+ loading: Carregant els comentaris ...
33
37
  title: "%{count} comentaris"
34
38
  featured_comment:
35
39
  title: Comentari destacat
@@ -12,6 +12,8 @@ en:
12
12
  label: Comment
13
13
  placeholder: What do you think about this?
14
14
  submit: Send
15
+ user_group_id:
16
+ label: Comment as
15
17
  opinion:
16
18
  against: I am against
17
19
  in_favor: I am in favor
@@ -24,7 +26,8 @@ en:
24
26
  reply: Reply
25
27
  comment_order_selector:
26
28
  order:
27
- most_voted: Most voted
29
+ best_rated: Best rated
30
+ most_discussed: Most discussed
28
31
  older: Older
29
32
  recent: Recent
30
33
  title: 'Order by:'
@@ -11,6 +11,8 @@ es:
11
11
  label: Comentario
12
12
  placeholder: '¿Qué piensas sobre esto?'
13
13
  submit: Enviar
14
+ user_group_id:
15
+ label: Comentar como
14
16
  opinion:
15
17
  against: Estoy en contra
16
18
  in_favor: Estoy a favor
@@ -23,13 +25,15 @@ es:
23
25
  reply: Respuesta
24
26
  comment_order_selector:
25
27
  order:
26
- most_voted: Más votado
28
+ best_rated: Mejor valoración
29
+ most_discussed: Más discutidos
27
30
  older: Más antiguo
28
31
  recent: Reciente
29
32
  title: 'Ordenar por:'
30
33
  comment_thread:
31
34
  title: Conversación con %{authorName}
32
35
  comments:
36
+ loading: Cargando los comentarios ...
33
37
  title: "%{count} comentarios"
34
38
  featured_comment:
35
39
  title: Comentario destacado
@@ -0,0 +1,5 @@
1
+ class AddUserGroupIdToComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :decidim_comments_comments, :decidim_user_group_id, :integer, index: true
4
+ end
5
+ end
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency "decidim-core", Decidim.version
17
17
  s.add_dependency "rails", *Decidim.rails_version
18
18
  s.add_dependency "jquery-rails", "~> 4.0"
19
- s.add_dependency "turbolinks", *Decidim.rails_version
20
19
 
21
20
  s.add_development_dependency "decidim-dev", Decidim.version
22
21
  end
@@ -5,7 +5,6 @@ require "active_support/all"
5
5
  require "decidim/core"
6
6
  require "jquery-rails"
7
7
  require "sassc-rails"
8
- require "turbolinks"
9
8
  require "foundation-rails"
10
9
  require "foundation_rails_helper"
11
10
 
@@ -17,9 +17,10 @@ module Decidim
17
17
  argument :commentableType, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`"
18
18
  argument :body, !types.String, "The comments's body"
19
19
  argument :alignment, types.Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'", default_value: 0
20
+ argument :userGroupId, types.ID, "The comment's user group id. Replaces the author."
20
21
 
21
22
  resolve lambda { |_obj, args, ctx|
22
- params = { "comment" => { "body" => args[:body], "alignment" => args[:alignment] } }
23
+ params = { "comment" => { "body" => args[:body], "alignment" => args[:alignment], "user_group_id" => args[:userGroupId] } }
23
24
  form = Decidim::Comments::CommentForm.from_params(params)
24
25
  commentable = args[:commentableType].constantize.find(args[:commentableId])
25
26
  Decidim::Comments::CreateComment.call(form, ctx[:current_user], commentable) do
@@ -10,11 +10,13 @@ module Decidim
10
10
  let(:commentable) { create :participatory_process, organization: organization }
11
11
  let(:body) { ::Faker::Lorem.paragraph }
12
12
  let(:alignment) { 1 }
13
+ let(:user_group_id) { nil }
13
14
  let(:form_params) do
14
15
  {
15
16
  "comment" => {
16
17
  "body" => body,
17
- "alignment" => alignment
18
+ "alignment" => alignment,
19
+ "user_group_id" => user_group_id
18
20
  }
19
21
  }
20
22
  end
@@ -37,7 +39,7 @@ module Decidim
37
39
  it "doesn't create a comment" do
38
40
  expect do
39
41
  command.call
40
- end.to_not change { Comment.count }
42
+ end.not_to change { Comment.count }
41
43
  end
42
44
  end
43
45
 
@@ -51,7 +53,8 @@ module Decidim
51
53
  author: author,
52
54
  commentable: commentable,
53
55
  body: body,
54
- alignment: alignment
56
+ alignment: alignment,
57
+ decidim_user_group_id: user_group_id
55
58
  }).and_call_original
56
59
  expect do
57
60
  command.call
@@ -23,7 +23,7 @@ module Decidim
23
23
  it "doesn't create a comment vote" do
24
24
  expect do
25
25
  command.call
26
- end.to_not change { CommentVote.count }
26
+ end.not_to change { CommentVote.count }
27
27
  end
28
28
  end
29
29
 
@@ -39,7 +39,7 @@ module Decidim
39
39
  it "doesn't create a comment vote" do
40
40
  expect do
41
41
  command.call
42
- end.to_not change { CommentVote.count }
42
+ end.not_to change { CommentVote.count }
43
43
  end
44
44
  end
45
45
 
@@ -74,7 +74,7 @@ module Decidim
74
74
  it "doesn't create a comment vote" do
75
75
  expect do
76
76
  command.call
77
- end.to_not change { CommentVote.count }
77
+ end.not_to change { CommentVote.count }
78
78
  end
79
79
  end
80
80
 
@@ -90,7 +90,7 @@ module Decidim
90
90
  it "doesn't create a comment vote" do
91
91
  expect do
92
92
  command.call
93
- end.to_not change { CommentVote.count }
93
+ end.not_to change { CommentVote.count }
94
94
  end
95
95
  end
96
96
 
@@ -36,7 +36,7 @@ describe "Comments", type: :feature do
36
36
  visit decidim.dummy_path(participatory_process)
37
37
  page.find("div.order-by__dropdown.order-by__dropdown--right").hover
38
38
  within "div.order-by__dropdown.order-by__dropdown--right" do
39
- click_link "Best Rated"
39
+ click_link "Best rated"
40
40
  end
41
41
 
42
42
  within "#comments" do
@@ -47,7 +47,7 @@ describe "Comments", type: :feature do
47
47
  context "when not authenticated" do
48
48
  it "user should not see the form to add comments" do
49
49
  visit decidim.dummy_path(participatory_process)
50
- expect(page).to_not have_selector(".add-comment form")
50
+ expect(page).not_to have_selector(".add-comment form")
51
51
  end
52
52
  end
53
53
 
@@ -76,6 +76,30 @@ describe "Comments", type: :feature do
76
76
  end
77
77
  end
78
78
 
79
+ context "when the user has verified organizations" do
80
+ let(:user_group) { create(:user_group, :verified) }
81
+
82
+ before do
83
+ create(:user_group_membership, user: user, user_group: user_group)
84
+ end
85
+
86
+ it "user can add a new comment as a user group" do
87
+ visit decidim.dummy_path(participatory_process)
88
+ expect(page).to have_selector(".add-comment form")
89
+
90
+ within ".add-comment form" do
91
+ fill_in "add-comment-#{participatory_process.class.name}-#{participatory_process.id}", with: "This is a new comment"
92
+ select user_group.name, from: "Comment as"
93
+ click_button "Send"
94
+ end
95
+
96
+ within "#comments" do
97
+ expect(page).to have_content user_group.name
98
+ expect(page).to have_content "This is a new comment"
99
+ end
100
+ end
101
+ end
102
+
79
103
  it "user can reply a comment" do
80
104
  comment = create(:comment, commentable: participatory_process)
81
105
  visit decidim.dummy_path(participatory_process)
@@ -84,7 +108,7 @@ describe "Comments", type: :feature do
84
108
 
85
109
  within "#comments #comment_#{comment.id}" do
86
110
  click_button "Reply"
87
- fill_in "add-comment-#{comment.class.name}-#{comment.id}", with: "This is a reply"
111
+ find("textarea").set("This is a reply")
88
112
  click_button "Send"
89
113
 
90
114
  expect(page).to have_content "This is a reply"