decidim 0.2.0 → 0.3.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 might be problematic. Click here for more details.

Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -1
  3. data/.codeclimate.yml +2 -3
  4. data/.rubocop.yml +1 -48
  5. data/.travis.yml +1 -0
  6. data/Dockerfile +1 -0
  7. data/Gemfile +1 -0
  8. data/Gemfile.lock +119 -115
  9. data/README.md +24 -9
  10. data/Rakefile +14 -10
  11. data/decidim-admin/app/assets/javascripts/decidim/admin/application.js.es6 +21 -9
  12. data/decidim-admin/app/assets/javascripts/decidim/admin/sort_list.component.js.es6 +35 -0
  13. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_language-chooser.scss +4 -0
  14. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_sort.scss +12 -0
  15. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +1 -0
  16. data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +4 -0
  17. data/decidim-admin/app/helpers/decidim/admin/menu_helper.rb +0 -1
  18. data/decidim-admin/app/models/decidim/admin/participatory_process_user_role.rb +2 -2
  19. data/decidim-admin/app/views/decidim/admin/categories/index.html.erb +7 -1
  20. data/decidim-admin/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  21. data/decidim-admin/app/views/decidim/admin/moderations/index.html.erb +6 -2
  22. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/index.html.erb +1 -0
  23. data/decidim-admin/app/views/layouts/decidim/admin/_title_bar.html.erb +10 -0
  24. data/decidim-admin/bin/rails +3 -3
  25. data/decidim-admin/config/locales/ca.yml +3 -1
  26. data/decidim-admin/config/locales/en.yml +3 -1
  27. data/decidim-admin/config/locales/es.yml +3 -1
  28. data/decidim-admin/config/locales/eu.yml +0 -1
  29. data/decidim-admin/config/locales/fi.yml +0 -1
  30. data/decidim-admin/config/locales/fr.yml +0 -1
  31. data/decidim-admin/config/locales/it.yml +490 -0
  32. data/decidim-admin/db/migrate/20161102144648_add_admin_participatory_process_user_roles.rb +5 -3
  33. data/decidim-admin/db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb +2 -0
  34. data/decidim-admin/decidim-admin.gemspec +2 -1
  35. data/decidim-admin/lib/decidim/admin/engine.rb +1 -1
  36. data/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb +3 -3
  37. data/decidim-admin/spec/commands/reject_user_group_spec.rb +2 -2
  38. data/decidim-admin/spec/features/admin_copy_participatory_process_spec.rb +2 -2
  39. data/decidim-admin/spec/features/admin_invite_spec.rb +1 -1
  40. data/decidim-admin/spec/features/admin_manages_features_spec.rb +2 -2
  41. data/decidim-admin/spec/features/admin_manages_newsletters_spec.rb +4 -4
  42. data/decidim-admin/spec/features/admin_manages_organization_spec.rb +6 -6
  43. data/decidim-admin/spec/features/admin_manages_participatory_process_groups_spec.rb +4 -4
  44. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +4 -4
  45. data/decidim-admin/spec/features/static_pages_spec.rb +4 -4
  46. data/decidim-admin/spec/forms/organization_form_spec.rb +1 -1
  47. data/decidim-admin/spec/shared/manage_process_categories_examples.rb +44 -29
  48. data/decidim-admin/spec/shared/manage_process_steps_examples.rb +3 -3
  49. data/decidim-admin/spec/shared/manage_processes_examples.rb +1 -1
  50. data/decidim-admin/spec/shared/participatory_admin_shared_context.rb +3 -3
  51. data/decidim-admin/spec/spec_helper.rb +3 -2
  52. data/decidim-api/bin/rails +3 -3
  53. data/decidim-api/decidim-api.gemspec +2 -1
  54. data/decidim-api/lib/decidim/api/engine.rb +1 -1
  55. data/decidim-api/spec/spec_helper.rb +3 -2
  56. data/decidim-budgets/app/controllers/decidim/budgets/application_controller.rb +1 -1
  57. data/decidim-budgets/app/models/decidim/budgets/line_item.rb +1 -2
  58. data/decidim-budgets/app/models/decidim/budgets/order.rb +2 -2
  59. data/decidim-budgets/app/views/decidim/budgets/projects/_linked_projects.html.erb +1 -1
  60. data/decidim-budgets/bin/rails +3 -3
  61. data/decidim-budgets/config/locales/it.yml +126 -0
  62. data/decidim-budgets/db/migrate/20170127114122_create_projects.rb +2 -0
  63. data/decidim-budgets/db/migrate/20170130095615_create_orders.rb +2 -0
  64. data/decidim-budgets/db/migrate/20170130101825_create_line_items.rb +2 -0
  65. data/decidim-budgets/db/migrate/20170207101750_remove_short_description_from_decidim_projects.rb +2 -0
  66. data/decidim-budgets/db/migrate/20170215132708_add_reference_to_projects.rb +2 -0
  67. data/decidim-budgets/db/migrate/20170410074214_remove_not_null_reference_budgets.rb +2 -0
  68. data/decidim-budgets/db/migrate/20170612101846_migrate_projects_category.rb +15 -0
  69. data/decidim-budgets/decidim-budgets.gemspec +3 -1
  70. data/decidim-budgets/lib/decidim/budgets/feature.rb +2 -2
  71. data/decidim-budgets/spec/features/admin_manages_project_attachments_spec.rb +5 -3
  72. data/decidim-budgets/spec/features/admin_manages_projects_spec.rb +5 -7
  73. data/decidim-budgets/spec/features/process_admin_manages_project_attachments_spec.rb +4 -4
  74. data/decidim-budgets/spec/features/process_admin_manages_projects_spec.rb +5 -8
  75. data/decidim-budgets/spec/shared/manage_attachments_examples.rb +0 -4
  76. data/decidim-budgets/spec/shared/manage_projects_examples.rb +3 -3
  77. data/decidim-budgets/spec/spec_helper.rb +2 -1
  78. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  79. data/decidim-comments/app/commands/decidim/comments/create_comment.rb +2 -2
  80. data/decidim-comments/app/frontend/comments/add_comment_form.component.tsx +1 -0
  81. data/decidim-comments/app/frontend/comments/comment.component.test.tsx +12 -1
  82. data/decidim-comments/app/frontend/comments/comment.component.tsx +42 -4
  83. data/decidim-comments/app/frontend/comments/comment_thread.component.test.tsx +11 -0
  84. data/decidim-comments/app/frontend/comments/comment_thread.component.tsx +5 -1
  85. data/decidim-comments/app/frontend/fragments/comment_data.fragment.graphql +3 -0
  86. data/decidim-comments/app/frontend/support/generate_comments_data.ts +3 -0
  87. data/decidim-comments/app/frontend/support/schema.ts +18 -12
  88. data/decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb +6 -4
  89. data/decidim-comments/app/models/decidim/comments/comment.rb +6 -4
  90. data/decidim-comments/app/models/decidim/comments/comment_vote.rb +1 -2
  91. data/decidim-comments/app/models/decidim/comments/seed.rb +5 -2
  92. data/decidim-comments/app/resolvers/decidim/comments/vote_comment_resolver.rb +3 -0
  93. data/decidim-comments/app/types/decidim/comments/commentable_interface.rb +3 -3
  94. data/decidim-comments/app/views/decidim/comments/comment_notification_mailer/comment_created.html.erb +1 -1
  95. data/decidim-comments/app/views/decidim/comments/comment_notification_mailer/reply_created.html.erb +1 -1
  96. data/decidim-comments/bin/rails +3 -3
  97. data/decidim-comments/config/locales/ca.yml +5 -0
  98. data/decidim-comments/config/locales/en.yml +5 -0
  99. data/decidim-comments/config/locales/es.yml +5 -0
  100. data/decidim-comments/config/locales/it.yml +65 -0
  101. data/decidim-comments/db/migrate/20161130143508_create_comments.rb +2 -0
  102. data/decidim-comments/db/migrate/20161214082645_add_depth_to_comments.rb +2 -0
  103. data/decidim-comments/db/migrate/20161216102820_add_alignment_to_comments.rb +2 -0
  104. data/decidim-comments/db/migrate/20161219150806_create_comment_votes.rb +3 -1
  105. data/decidim-comments/db/migrate/20170123102043_add_user_group_id_to_comments.rb +2 -0
  106. data/decidim-comments/db/migrate/20170504085413_add_root_commentable_to_comments.rb +2 -0
  107. data/decidim-comments/db/migrate/20170510091348_update_root_commentable_for_comments.rb +3 -2
  108. data/decidim-comments/db/migrate/20170510091409_set_root_commentable_null_constraints.rb +2 -0
  109. data/decidim-comments/decidim-comments.gemspec +2 -1
  110. data/decidim-comments/lib/decidim/comments/comment_serializer.rb +1 -1
  111. data/decidim-comments/lib/decidim/comments/commentable.rb +4 -4
  112. data/decidim-comments/spec/commands/create_comment_spec.rb +2 -2
  113. data/decidim-comments/spec/features/admin_manages_comments_spec.rb +4 -9
  114. data/decidim-comments/spec/features/process_admin_manages_comments_spec.rb +5 -11
  115. data/decidim-comments/spec/mailers/comment_notification_mailer_spec.rb +12 -7
  116. data/decidim-comments/spec/shared/author_localised_email.rb +26 -0
  117. data/decidim-comments/spec/spec_helper.rb +1 -1
  118. data/decidim-dev/config/locales/it.yml +9 -0
  119. data/decidim-dev/decidim-dev.gemspec +8 -3
  120. data/decidim-dev/lib/decidim/dev.rb +1 -8
  121. data/decidim-dev/lib/decidim/dev/railtie.rb +1 -1
  122. data/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb +6 -4
  123. data/decidim-dev/lib/decidim/dev/test/rspec_support/capybara.rb +2 -2
  124. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb +4 -2
  125. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature_context.rb +28 -8
  126. data/decidim-dev/lib/decidim/dev/test/rspec_support/translation_helpers.rb +7 -2
  127. data/decidim-dev/lib/decidim/dev/test/spec_helper.rb +2 -2
  128. data/decidim-dev/lib/generators/decidim/dummy_generator.rb +1 -1
  129. data/decidim-meetings/README.md +1 -1
  130. data/decidim-meetings/app/controllers/decidim/meetings/application_controller.rb +1 -1
  131. data/decidim-meetings/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +1 -1
  132. data/decidim-meetings/bin/rails +3 -3
  133. data/decidim-meetings/config/locales/it.yml +87 -0
  134. data/decidim-meetings/db/migrate/20161130121354_create_meetings.rb +2 -0
  135. data/decidim-meetings/db/migrate/20170110142105_close_a_meeting.rb +2 -0
  136. data/decidim-meetings/db/migrate/20170123151650_add_latitude_and_longitude_to_meetings.rb +2 -0
  137. data/decidim-meetings/db/migrate/20170129153716_remove_short_description_from_meetings.rb +2 -0
  138. data/decidim-meetings/db/migrate/20170215132546_add_reference_to_meetings.rb +2 -0
  139. data/decidim-meetings/db/migrate/20170410074252_remove_not_null_reference_meetings.rb +2 -0
  140. data/decidim-meetings/db/migrate/20170612101925_migrate_meetings_category.rb +15 -0
  141. data/decidim-meetings/decidim-meetings.gemspec +3 -1
  142. data/decidim-meetings/lib/decidim/meetings/feature.rb +2 -2
  143. data/decidim-meetings/spec/features/admin_manages_meetings_attachments_spec.rb +5 -1
  144. data/decidim-meetings/spec/features/admin_manages_meetings_spec.rb +5 -7
  145. data/decidim-meetings/spec/features/explore_meetings_spec.rb +32 -6
  146. data/decidim-meetings/spec/features/process_admin_manages_meetings_attachments_spec.rb +4 -2
  147. data/decidim-meetings/spec/features/process_admin_manages_meetings_spec.rb +5 -8
  148. data/decidim-meetings/spec/shared/manage_attachments_examples.rb +0 -3
  149. data/decidim-meetings/spec/shared/manage_meetings_examples.rb +11 -11
  150. data/decidim-meetings/spec/spec_helper.rb +2 -1
  151. data/decidim-pages/bin/rails +3 -3
  152. data/decidim-pages/config/locales/it.yml +22 -0
  153. data/decidim-pages/db/migrate/20161116121353_create_decidim_pages.rb +2 -0
  154. data/decidim-pages/db/migrate/20161214150429_add_commentable_to_pages.rb +2 -0
  155. data/decidim-pages/db/migrate/20170110145040_remove_commentable_flag_from_pages.rb +2 -0
  156. data/decidim-pages/db/migrate/20170220091402_remove_page_feature_titles.rb +2 -0
  157. data/decidim-pages/decidim-pages.gemspec +3 -1
  158. data/decidim-pages/spec/features/admin_spec.rb +1 -1
  159. data/decidim-pages/spec/spec_helper.rb +2 -3
  160. data/decidim-proposals/app/commands/decidim/proposals/unvote_proposal.rb +34 -0
  161. data/decidim-proposals/app/commands/decidim/proposals/vote_proposal.rb +39 -0
  162. data/decidim-proposals/app/controllers/concerns/decidim/proposals/orderable.rb +7 -3
  163. data/decidim-proposals/app/controllers/decidim/proposals/proposal_votes_controller.rb +18 -8
  164. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +3 -3
  165. data/decidim-proposals/app/models/decidim/proposals/proposal_vote.rb +0 -1
  166. data/decidim-proposals/app/views/decidim/proposals/proposals/_author.html.erb +23 -0
  167. data/decidim-proposals/app/views/decidim/proposals/proposals/_linked_proposals.html.erb +2 -2
  168. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +1 -9
  169. data/decidim-proposals/app/views/decidim/proposals/proposals/_vote_button.html.erb +2 -6
  170. data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +1 -1
  171. data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +1 -11
  172. data/decidim-proposals/bin/rails +3 -3
  173. data/decidim-proposals/config/locales/ca.yml +6 -0
  174. data/decidim-proposals/config/locales/en.yml +6 -0
  175. data/decidim-proposals/config/locales/es.yml +6 -0
  176. data/decidim-proposals/config/locales/eu.yml +0 -2
  177. data/decidim-proposals/config/locales/fi.yml +0 -2
  178. data/decidim-proposals/config/locales/fr.yml +0 -2
  179. data/decidim-proposals/config/locales/it.yml +147 -0
  180. data/decidim-proposals/db/migrate/20161212110850_create_decidim_proposals.rb +2 -0
  181. data/decidim-proposals/db/migrate/20170112115253_create_proposal_votes.rb +3 -1
  182. data/decidim-proposals/db/migrate/20170113114245_add_text_search_indexes.rb +2 -0
  183. data/decidim-proposals/db/migrate/20170118120151_add_counter_cache_votes_to_proposals.rb +2 -0
  184. data/decidim-proposals/db/migrate/20170120151202_add_user_group_id_to_proposals.rb +2 -0
  185. data/decidim-proposals/db/migrate/20170131092413_add_answers_to_proposals.rb +2 -0
  186. data/decidim-proposals/db/migrate/20170205082832_add_index_to_decidim_proposals_proposals_proposal_votes_count.rb +2 -0
  187. data/decidim-proposals/db/migrate/20170215113152_create_proposal_reports.rb +2 -0
  188. data/decidim-proposals/db/migrate/20170215131720_add_report_count_to_proposals.rb +2 -0
  189. data/decidim-proposals/db/migrate/20170215132030_add_reference_to_proposals.rb +2 -0
  190. data/decidim-proposals/db/migrate/20170220152416_add_hidden_at_to_proposals.rb +2 -0
  191. data/decidim-proposals/db/migrate/20170228105156_add_geolocalization_fields_to_proposals.rb +2 -0
  192. data/decidim-proposals/db/migrate/20170307085300_migrate_proposal_reports_data_to_reports.rb +8 -10
  193. data/decidim-proposals/db/migrate/20170410073742_remove_not_null_reference_proposals.rb +2 -0
  194. data/decidim-proposals/db/migrate/20170612101809_migrate_proposals_category.rb +15 -0
  195. data/decidim-proposals/decidim-proposals.gemspec +4 -2
  196. data/decidim-proposals/lib/decidim/proposals/feature.rb +5 -1
  197. data/decidim-proposals/lib/decidim/proposals/proposal_serializer.rb +1 -6
  198. data/decidim-proposals/spec/commands/decidim/proposals/unvote_proposal_spec.rb +26 -0
  199. data/decidim-proposals/spec/commands/decidim/proposals/vote_proposal_spec.rb +47 -0
  200. data/decidim-proposals/spec/features/admin_manages_proposals_spec.rb +6 -11
  201. data/decidim-proposals/spec/features/process_admin_manages_proposals_spec.rb +6 -12
  202. data/decidim-proposals/spec/features/proposals_spec.rb +38 -12
  203. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +3 -6
  204. data/decidim-proposals/spec/spec_helper.rb +2 -1
  205. data/decidim-results/app/controllers/decidim/results/application_controller.rb +1 -1
  206. data/decidim-results/app/views/decidim/results/results/_linked_results.html.erb +1 -1
  207. data/decidim-results/bin/rails +3 -3
  208. data/decidim-results/config/locales/it.yml +78 -0
  209. data/decidim-results/db/migrate/20170116104125_create_results.rb +2 -0
  210. data/decidim-results/db/migrate/20170129164553_remove_short_description_from_results.rb +2 -0
  211. data/decidim-results/db/migrate/20170215132624_add_reference_to_results.rb +2 -0
  212. data/decidim-results/db/migrate/20170410074358_remove_not_null_reference_results.rb +2 -0
  213. data/decidim-results/db/migrate/20170612101951_migrate_results_category.rb +15 -0
  214. data/decidim-results/decidim-results.gemspec +3 -1
  215. data/decidim-results/spec/features/admin_manages_results_spec.rb +5 -7
  216. data/decidim-results/spec/features/process_admin_manages_results_spec.rb +5 -8
  217. data/decidim-results/spec/shared/manage_results_examples.rb +3 -3
  218. data/decidim-results/spec/spec_helper.rb +2 -1
  219. data/decidim-surveys/README.md +24 -0
  220. data/decidim-surveys/Rakefile +3 -0
  221. data/decidim-surveys/app/assets/config/admin/decidim_surveys_manifest.js +1 -0
  222. data/decidim-surveys/app/assets/images/decidim/surveys/icon.svg +1 -0
  223. data/decidim-surveys/app/assets/javascripts/decidim/surveys/admin/auto_label_by_position.component.js.es6 +33 -0
  224. data/decidim-surveys/app/assets/javascripts/decidim/surveys/admin/dynamic_fields.component.js.es6 +95 -0
  225. data/decidim-surveys/app/assets/javascripts/decidim/surveys/admin/surveys.js.es6 +85 -0
  226. data/decidim-surveys/app/assets/stylesheets/decidim/surveys/surveys.scss +9 -0
  227. data/decidim-surveys/app/commands/decidim/surveys/admin/update_survey.rb +65 -0
  228. data/decidim-surveys/app/commands/decidim/surveys/answer_survey.rb +43 -0
  229. data/decidim-surveys/app/commands/decidim/surveys/create_survey.rb +19 -0
  230. data/decidim-surveys/app/controllers/decidim/surveys/admin/application_controller.rb +15 -0
  231. data/decidim-surveys/app/controllers/decidim/surveys/admin/surveys_controller.rb +55 -0
  232. data/decidim-surveys/app/controllers/decidim/surveys/application_controller.rb +13 -0
  233. data/decidim-surveys/app/controllers/decidim/surveys/surveys_controller.rb +39 -0
  234. data/decidim-surveys/app/forms/decidim/surveys/admin/survey_form.rb +19 -0
  235. data/decidim-surveys/app/forms/decidim/surveys/admin/survey_question_answer_option_form.rb +15 -0
  236. data/decidim-surveys/app/forms/decidim/surveys/admin/survey_question_form.rb +24 -0
  237. data/decidim-surveys/app/forms/decidim/surveys/survey_answer_form.rb +36 -0
  238. data/decidim-surveys/app/forms/decidim/surveys/survey_form.rb +22 -0
  239. data/decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb +39 -0
  240. data/decidim-surveys/app/models/decidim/surveys/abilities/admin_user.rb +34 -0
  241. data/decidim-surveys/app/models/decidim/surveys/abilities/current_user.rb +47 -0
  242. data/decidim-surveys/app/models/decidim/surveys/abilities/process_admin_user.rb +44 -0
  243. data/decidim-surveys/app/models/decidim/surveys/application_record.rb +10 -0
  244. data/decidim-surveys/app/models/decidim/surveys/survey.rb +25 -0
  245. data/decidim-surveys/app/models/decidim/surveys/survey_answer.rb +27 -0
  246. data/decidim-surveys/app/models/decidim/surveys/survey_question.rb +18 -0
  247. data/decidim-surveys/app/queries/decidim/surveys/survey_user_answers.rb +28 -0
  248. data/decidim-surveys/app/views/decidim/surveys/admin/surveys/_answer_option.html.erb +23 -0
  249. data/decidim-surveys/app/views/decidim/surveys/admin/surveys/_form.html.erb +47 -0
  250. data/decidim-surveys/app/views/decidim/surveys/admin/surveys/_question.html.erb +57 -0
  251. data/decidim-surveys/app/views/decidim/surveys/admin/surveys/edit.html.erb +7 -0
  252. data/decidim-surveys/app/views/decidim/surveys/surveys/show.html.erb +102 -0
  253. data/decidim-surveys/bin/rails +15 -0
  254. data/decidim-surveys/config/i18n-tasks.yml +11 -0
  255. data/decidim-surveys/config/locales/ca.yml +69 -0
  256. data/decidim-surveys/config/locales/en.yml +73 -0
  257. data/decidim-surveys/config/locales/es.yml +69 -0
  258. data/decidim-surveys/config/locales/eu.yml +5 -0
  259. data/decidim-surveys/config/locales/fi.yml +5 -0
  260. data/decidim-surveys/config/locales/fr.yml +5 -0
  261. data/decidim-surveys/config/locales/it.yml +5 -0
  262. data/decidim-surveys/config/locales/nl.yml +5 -0
  263. data/decidim-surveys/db/migrate/20170511092231_create_decidim_surveys.rb +15 -0
  264. data/decidim-surveys/db/migrate/20170515090916_create_decidim_survey_questions.rb +12 -0
  265. data/decidim-surveys/db/migrate/20170515144119_create_decidim_survey_answers.rb +14 -0
  266. data/decidim-surveys/db/migrate/20170518085302_add_position_to_surveys_questions.rb +7 -0
  267. data/decidim-surveys/db/migrate/20170522075938_add_mandatory_to_surveys_questions.rb +7 -0
  268. data/decidim-surveys/db/migrate/20170524122229_add_question_type_to_surveys_questions.rb +7 -0
  269. data/decidim-surveys/db/migrate/20170525132233_add_answer_options_to_surveys_questions.rb +7 -0
  270. data/decidim-surveys/decidim-surveys.gemspec +22 -0
  271. data/decidim-surveys/lib/decidim/surveys.rb +14 -0
  272. data/decidim-surveys/lib/decidim/surveys/admin.rb +10 -0
  273. data/decidim-surveys/lib/decidim/surveys/admin_engine.rb +34 -0
  274. data/decidim-surveys/lib/decidim/surveys/engine.rb +25 -0
  275. data/decidim-surveys/lib/decidim/surveys/feature.rb +85 -0
  276. data/decidim-surveys/lib/decidim/surveys/survey_user_answers_serializer.rb +23 -0
  277. data/decidim-surveys/lib/decidim/surveys/test/factories.rb +39 -0
  278. data/decidim-surveys/spec/commands/decidim/surveys/admin/update_survey_spec.rb +147 -0
  279. data/decidim-surveys/spec/commands/decidim/surveys/answer_survey_spec.rb +71 -0
  280. data/decidim-surveys/spec/commands/decidim/surveys/create_survey_spec.rb +44 -0
  281. data/decidim-surveys/spec/factories.rb +3 -0
  282. data/decidim-surveys/spec/features/admin_manages_surveys_spec.rb +13 -0
  283. data/decidim-surveys/spec/features/process_admin_manages_surveys_spec.rb +13 -0
  284. data/decidim-surveys/spec/features/survey_spec.rb +235 -0
  285. data/decidim-surveys/spec/forms/decidim/surveys/admin/survey_form_spec.rb +64 -0
  286. data/decidim-surveys/spec/forms/decidim/surveys/admin/survey_question_form_spec.rb +36 -0
  287. data/decidim-surveys/spec/forms/decidim/surveys/survey_answer_form_spec.rb +36 -0
  288. data/decidim-surveys/spec/forms/decidim/surveys/survey_form_spec.rb +32 -0
  289. data/decidim-surveys/spec/models/decidim/surveys/abilities/admin_user_spec.rb +22 -0
  290. data/decidim-surveys/spec/models/decidim/surveys/abilities/current_user_spec.rb +19 -0
  291. data/decidim-surveys/spec/models/decidim/surveys/abilities/process_admin_user_spec.rb +23 -0
  292. data/decidim-surveys/spec/models/decidim/surveys/survey_answer_spec.rb +55 -0
  293. data/decidim-surveys/spec/models/decidim/surveys/survey_question_spec.rb +19 -0
  294. data/decidim-surveys/spec/models/decidim/surveys/survey_spec.rb +65 -0
  295. data/decidim-surveys/spec/queries/decidim/surveys/survey_user_answers_spec.rb +21 -0
  296. data/decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb +34 -0
  297. data/decidim-surveys/spec/shared/edit_survey_examples.rb +213 -0
  298. data/decidim-surveys/spec/shared/export_survey_user_answers_examples.rb +47 -0
  299. data/decidim-surveys/spec/spec_helper.rb +4 -0
  300. data/decidim-system/app/controllers/decidim/system/devise/passwords_controller.rb +2 -0
  301. data/decidim-system/app/helpers/decidim/system/menu_helper.rb +0 -1
  302. data/decidim-system/bin/rails +3 -3
  303. data/decidim-system/config/locales/it.yml +66 -0
  304. data/decidim-system/db/migrate/20160919105637_devise_create_decidim_admins.rb +2 -0
  305. data/decidim-system/decidim-system.gemspec +2 -1
  306. data/decidim-system/spec/spec_helper.rb +3 -2
  307. data/decidim.gemspec +5 -4
  308. data/docs/geocoding.md +2 -2
  309. data/docs/how_to_create_a_plugin.md +11 -11
  310. data/lib/decidim.rb +1 -0
  311. data/lib/generators/decidim/app_generator.rb +3 -2
  312. data/lib/generators/decidim/demo_generator.rb +1 -1
  313. data/lib/generators/decidim/docker_generator.rb +2 -2
  314. data/lib/generators/decidim/install_generator.rb +3 -6
  315. data/lib/generators/decidim/templates/initializer.rb +2 -2
  316. metadata +130 -47
  317. data/decidim-admin/app/assets/javascripts/decidim/admin/sort_steps.js.es6 +0 -30
  318. data/decidim-budgets/spec/shared/admin_shared_context.rb +0 -13
  319. data/decidim-comments/spec/shared/admin_shared_context.rb +0 -13
  320. data/decidim-meetings/spec/shared/admin_shared_context.rb +0 -13
  321. data/decidim-proposals/spec/shared/admin_shared_context.rb +0 -13
  322. data/decidim-results/spec/shared/admin_shared_context.rb +0 -13
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ # The data store for a SurveyAnswer in the Decidim::Surveys component.
6
+ class SurveyAnswer < Surveys::ApplicationRecord
7
+ belongs_to :user, class_name: "Decidim::User", foreign_key: "decidim_user_id"
8
+ belongs_to :survey, class_name: "Survey", foreign_key: "decidim_survey_id"
9
+ belongs_to :question, class_name: "SurveyQuestion", foreign_key: "decidim_survey_question_id"
10
+
11
+ validates :body, presence: true, if: -> { question.mandatory? }
12
+ validate :user_survey_same_organization
13
+ validate :question_belongs_to_survey
14
+
15
+ private
16
+
17
+ def user_survey_same_organization
18
+ return if user&.organization == survey&.organization
19
+ errors.add(:user, :invalid)
20
+ end
21
+
22
+ def question_belongs_to_survey
23
+ errors.add(:survey, :invalid) if question&.survey != survey
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ # The data store for a SurveyQuestion in the Decidim::Surveys component.
6
+ class SurveyQuestion < Surveys::ApplicationRecord
7
+ TYPES = %w(short_answer long_answer single_option multiple_option).freeze
8
+
9
+ belongs_to :survey, class_name: "Survey", foreign_key: "decidim_survey_id"
10
+
11
+ # Rectify can't handle a hash when using the from_model method so
12
+ # the answer options must be converted to struct.
13
+ def answer_options
14
+ self[:answer_options].map { |option| OpenStruct.new(option) }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ # A class used to collect user answers for a survey
6
+ class SurveyUserAnswers < Rectify::Query
7
+ # Syntactic sugar to initialize the class and return the queried objects.
8
+ #
9
+ # survey - a Survey object
10
+ def self.for(survey)
11
+ new(survey).query
12
+ end
13
+
14
+ # Initializes the class.
15
+ #
16
+ # survey = a Survey object
17
+ def initialize(survey)
18
+ @survey = survey
19
+ end
20
+
21
+ # Finds and group answers by user for each survey's question.
22
+ def query
23
+ answers = SurveyAnswer.where(survey: @survey)
24
+ answers.sort_by { |answer| answer.question.position }.group_by(&:user).values
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ <div class="card survey-question-answer-option">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <span><%= t(".answer_option") %></span>
5
+ <% if survey.questions_editable? %>
6
+ <button class="button small alert hollow remove-answer-option button--title"><%= t('.remove_answer_option') %></button>
7
+ <% end %>
8
+ </h2>
9
+ </div>
10
+
11
+ <div class="card-section">
12
+ <div class="row column">
13
+ <%=
14
+ translated_field_tag :text_field_tag, "survey[questions][][answer_options][]", "body", answer_option.body, {
15
+ tabs_id: tabs_id_for_question_answer_option(question, idx),
16
+ label: t('.statement'),
17
+ disabled: question.nil? || disabled_for_question(survey, question),
18
+ enable_tabs: question.present?
19
+ }
20
+ %>
21
+ </div>
22
+ </div>
23
+ </div>
@@ -0,0 +1,47 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <%= title %>
5
+ <div class="button--title">
6
+ <%= export_dropdown %>
7
+ </div>
8
+ </h2>
9
+ </div>
10
+ <div class="card-section">
11
+ <div class="row column">
12
+ <%= form.translated :text_field, :title, autofocus: true %>
13
+ </div>
14
+ <div class="row column">
15
+ <%= form.translated :editor, :description, toolbar: :full, lines: 30, label: t("models.components.description", scope: "decidim.surveys.admin") %>
16
+ </div>
17
+ <div class="row column">
18
+ <%= form.translated :editor, :tos, toolbar: :full, lines: 10, label: t("models.components.tos", scope: "decidim.surveys.admin") %>
19
+ </div>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="survey-questions">
24
+ <% if survey.questions_editable? %>
25
+ <button class="button add-question"><%= t('.add_question') %></button>
26
+
27
+ <template id="survey-question-tmpl">
28
+ <%= render "question", question: blank_question %>
29
+ </template>
30
+
31
+ <template id="survey-question-answer-option-tmpl">
32
+ <%= render "answer_option", answer_option: blank_answer_option, question: nil, idx: nil %>
33
+ </template>
34
+ <% else %>
35
+ <div class="callout warning">
36
+ <%= t('.already_answered_warning') %>
37
+ </div>
38
+ <% end %>
39
+
40
+ <div class="survey-questions-list">
41
+ <% @form.questions.each_with_index do |question, idx| %>
42
+ <%= render "question", question: question %>
43
+ <% end %>
44
+ </div>
45
+ </div>
46
+
47
+ <%= javascript_include_tag "decidim/surveys/admin/surveys" %>
@@ -0,0 +1,57 @@
1
+ <div class="card survey-question" id="survey-question-<%= question.id %>-field">
2
+ <div class="card-divider question-divider">
3
+ <h2 class="card-title">
4
+ <span><%= label_for_question(survey, question) %></span>
5
+ <% if survey.questions_editable? %>
6
+ <button class="button small alert hollow remove-question button--title"><%= t('.remove_question') %></button>
7
+ <% end %>
8
+ </h2>
9
+ </div>
10
+
11
+ <div class="card-section">
12
+ <div class="row column">
13
+ <%=
14
+ translated_field_tag :text_field_tag, "survey[questions][]", "body", question.body, {
15
+ tabs_id: tabs_id_for_question(question),
16
+ label: t('.statement'),
17
+ disabled: disabled_for_question(survey, question),
18
+ enable_tabs: question.persisted?
19
+ }
20
+ %>
21
+ </div>
22
+
23
+ <div class="row column">
24
+ <%=
25
+ check_box_tag "survey[questions][][mandatory]", "1", question.mandatory, {
26
+ id: mandatory_id_for_question(question),
27
+ disabled: disabled_for_question(survey, question)
28
+ }
29
+ %>
30
+ <%= label_tag "", t('activemodel.attributes.survey_question.mandatory'), for: mandatory_id_for_question(question) %>
31
+ </div>
32
+
33
+ <div class="row column">
34
+ <%= label_tag "", t('activemodel.attributes.survey_question.question_type'), for: question_type_id_for_question(question) %>
35
+ <%= select_tag "survey[questions][][question_type]", options_from_collection_for_select(question_types, :first, :last, question.question_type), id: question_type_id_for_question(question), disabled: disabled_for_question(survey, question) %>
36
+ </div>
37
+
38
+ <% if question.persisted? %>
39
+ <%= hidden_field_tag "survey[questions][][id]", question.id, disabled: disabled_for_question(survey, question) %>
40
+ <% end %>
41
+
42
+ <%= hidden_field_tag "survey[questions][][position]", question.position || 0, disabled: disabled_for_question(survey, question) %>
43
+ <%= hidden_field_tag "survey[questions][][deleted]", false, disabled: disabled_for_question(survey, question) %>
44
+
45
+ <div class="survey-question-answer-options">
46
+ <% if survey.questions_editable? %>
47
+ <button class="button add-answer-option"><%= t('.add_answer_option') %></button>
48
+ <% end %>
49
+
50
+ <div class="survey-question-answer-options-list">
51
+ <% question.answer_options.each_with_index do |answer_option, idx| %>
52
+ <%= render "answer_option", question: question, answer_option: answer_option, idx: idx %>
53
+ <% end %>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= decidim_form_for(@form, url: survey_path, method: :post, html: { class: "form edit_survey" }) do |form| %>
2
+ <%= render partial: 'form', object: form, locals: { title: t('.title') } %>
3
+
4
+ <div class="button--double form-general-submit">
5
+ <%= form.submit t(".save"), class: "button" %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,102 @@
1
+ <% add_decidim_meta_tags({
2
+ title: translated_attribute(survey.title),
3
+ description: translated_attribute(survey.description),
4
+ }) %>
5
+
6
+ <div class="row columns">
7
+ <h2 class="section-heading"><%= translated_attribute survey.title %></h2>
8
+ <div class="row">
9
+ <div class="columns large-6 medium-centered lead">
10
+ <%== translated_attribute survey.description %>
11
+ </div>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="row">
16
+ <div class="columns large-6 medium-centered">
17
+ <div class="card">
18
+ <div class="card__content">
19
+ <% if current_settings.allow_answers? %>
20
+ <% if current_user %>
21
+ <% if survey.answered_by?(current_user) %>
22
+ <div class="section">
23
+ <div class="callout success">
24
+ <h5><%= t('.survey_answered.title') %></h5>
25
+ <p><%= t('.survey_answered.body') %></p>
26
+ </div>
27
+ </div>
28
+ <% else %>
29
+ <div class="answer-survey">
30
+ <%= decidim_form_for(@form, url: answer_survey_path(survey), method: :post, html: { class: "form answer-survey" }) do |form| %>
31
+ <% @form.answers.each_with_index do |answer, answer_idx| %>
32
+ <div class="row column">
33
+ <% field_id = "survey_#{survey.id}_question_#{answer.question.id}_answer_body" %>
34
+ <%= label_tag field_id , "#{answer_idx + 1}. #{translated_attribute(answer.question.body)} #{'*' if answer.question.mandatory?}" %>
35
+
36
+ <% case answer.question.question_type %>
37
+ <% when "short_answer" %>
38
+ <%= text_field_tag "survey[answers][#{answer_idx}][body][]", answer.body.try(:first), id: field_id, class: "#{'is-invalid-input' unless answer.errors.empty?}" %>
39
+ <% when "long_answer" %>
40
+ <%= text_area_tag "survey[answers][#{answer_idx}][body][]", answer.body.try(:first), id: field_id, class: "#{'is-invalid-input' unless answer.errors.empty?}", rows: 10 %>
41
+ <% when "single_option" %>
42
+ <div id="<%= field_id %>_answer_options" class="radio-button-collection">
43
+ <% answer.question.answer_options.each_with_index do |answer_option, idx| %>
44
+ <%= label_tag "#{field_id}_option_#{idx}" do %>
45
+ <%= radio_button_tag "survey[answers][#{answer_idx}][body][]", translated_attribute(answer_option["body"]), answer.body.try(:include?, translated_attribute(answer_option["body"])), id: "#{field_id}_option_#{idx}" %>
46
+ <%= translated_attribute(answer_option["body"]) %>
47
+ <% end %>
48
+ <% end %>
49
+ </div>
50
+ <% when "multiple_option" %>
51
+ <div id="<%= field_id %>_answer_options" class="check-box-collection">
52
+ <% answer.question.answer_options.each_with_index do |answer_option, idx| %>
53
+ <%= label_tag "#{field_id}_option_#{idx}" do %>
54
+ <%= check_box_tag "survey[answers][#{answer_idx}][body][]", translated_attribute(answer_option["body"]), answer.body.try(:include?, translated_attribute(answer_option["body"])), id: "#{field_id}_option_#{idx}" %>
55
+ <%= translated_attribute(answer_option["body"]) %>
56
+ <% end %>
57
+ <% end %>
58
+ </div>
59
+ <% end %>
60
+
61
+ <%= hidden_field_tag "survey[answers][#{answer_idx}][question_id]", answer.question.id %>
62
+
63
+ <% answer.errors.full_messages.each do |msg| %>
64
+ <%= content_tag :small, msg, class: "form-error is-visible" %>
65
+ <% end %>
66
+ </div>
67
+ <% end %>
68
+
69
+ <% if translated_attribute(survey.tos).present? %>
70
+ <div class="row column">
71
+ <%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "survey_tos_agreement" %>
72
+ <div class="tos-agreement-help-text help-text">
73
+ <%== translated_attribute survey.tos %>
74
+ </div>
75
+ </div>
76
+ <% end %>
77
+
78
+ <div class="button--double form-general-submit">
79
+ <%= form.submit t(".submit"), class: "button", data: { confirm: t('.are_you_sure') } %>
80
+ </div>
81
+ <% end %>
82
+ </div>
83
+ <% end %>
84
+ <% else %>
85
+ <div class="answer-survey">
86
+ <h5 class="section-heading"><%= t('.answer_survey.title') %></h5>
87
+ <p>
88
+ <%= t('.answer_survey.anonymous_user_message', sign_in_link: decidim.new_user_session_path, sign_up_link: decidim.new_user_registration_path).html_safe %>
89
+ </p>
90
+ </div>
91
+ <% end %>
92
+ <% else %>
93
+ <div class="section">
94
+ <div class="callout warning">
95
+ <h5><%= t('.survey_closed.title') %></h5>
96
+ <p><%= t('.survey_closed.body') %></p>
97
+ </div>
98
+ </div>
99
+ <% end %>
100
+ </div>
101
+ </div>
102
+ </div>
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This command will automatically be run when you run "rails" with Rails gems
5
+ # installed from the root of your application.
6
+
7
+ ENGINE_ROOT = File.expand_path("..", __dir__)
8
+ ENGINE_PATH = File.expand_path("../lib/decidim/surveys/engine", __dir__)
9
+
10
+ # Set up gems listed in the Gemfile.
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
13
+
14
+ require "rails/all"
15
+ require "rails/engine/commands"
@@ -0,0 +1,11 @@
1
+ base_locale: en
2
+ locales: [en]
3
+ ignore_unused:
4
+ - "decidim.features.surveys.name"
5
+ - "decidim.features.surveys.actions.*"
6
+ - "decidim.features.surveys.settings.*"
7
+ - "decidim.surveys.admin.surveys.question.question"
8
+ - "decidim.surveys.admin.exports.*"
9
+ - "activemodel.attributes.survey_answer.*"
10
+ ignore_missing:
11
+ - decidim.participatory_processes.scopes.global
@@ -0,0 +1,69 @@
1
+ ca:
2
+ activemodel:
3
+ attributes:
4
+ survey_answer:
5
+ body: Resposta
6
+ survey_question:
7
+ mandatory: Obligatori
8
+ question_type: Tipus
9
+ decidim:
10
+ features:
11
+ surveys:
12
+ actions:
13
+ answer: Resposta
14
+ name: Enquesta
15
+ settings:
16
+ step:
17
+ allow_answers: Permetre respostes
18
+ surveys:
19
+ admin:
20
+ application_helper:
21
+ label_for_question:
22
+ question: Pregunta
23
+ exports:
24
+ survey_user_answers: Respostes dels usuaris
25
+ models:
26
+ components:
27
+ description: Descripció
28
+ tos: Termes del servei
29
+ surveys:
30
+ answer_option:
31
+ answer_option: Opció de resposta
32
+ remove_answer_option: Elimina l'opció de resposta
33
+ statement: Enunciat
34
+ edit:
35
+ save: Desar
36
+ title: Títol
37
+ form:
38
+ add_question: Afegir pregunta
39
+ already_answered_warning: L'enquesta ja està contestada per alguns usuaris i per tant no pots modificar les seves preguntes.
40
+ question:
41
+ add_answer_option: Afegir opció de resposta
42
+ question: Pregunta
43
+ remove_question: Elimina pregunta
44
+ statement: Enunciat
45
+ update:
46
+ invalid: Hi ha hagut errors en desar l'enquesta.
47
+ success: Enquesta desada correctament.
48
+ question_types:
49
+ long_answer: Resposta llarga
50
+ multiple_option: Opció múltiple
51
+ short_answer: Resposta curta
52
+ single_option: Única opció
53
+ surveys:
54
+ answer:
55
+ invalid: Hi ha hagut errors en respondre a l'enquesta.
56
+ success: Enquesta resposta correctament.
57
+ show:
58
+ answer_survey:
59
+ anonymous_user_message: <a href="%{sign_in_link}">Entra amb el teu compte</a> o <a href="%{sign_up_link}">dona't d'alta</a> per contestar l'enquesta.
60
+ title: Respon a l'enquesta
61
+ are_you_sure: Aquesta acció no es pot desfer i no podràs editar les respostes. N'estàs segur?
62
+ submit: Enviar
63
+ survey_answered:
64
+ body: Ja ha respost a aquesta enquesta.
65
+ title: Enquesta resposta
66
+ survey_closed:
67
+ body: L'enquesta està tancada i no s'hi pot participar.
68
+ title: Enquesta tancada
69
+ tos_agreement: En participar en aquesta enquesta acceptes els Termes de Servei
@@ -0,0 +1,73 @@
1
+ ---
2
+ en:
3
+ activemodel:
4
+ attributes:
5
+ survey_answer:
6
+ body: Answer
7
+ survey_question:
8
+ mandatory: Mandatory
9
+ question_type: Type
10
+ decidim:
11
+ features:
12
+ surveys:
13
+ actions:
14
+ answer: Answer
15
+ name: Survey
16
+ settings:
17
+ step:
18
+ allow_answers: Allow answers
19
+ surveys:
20
+ admin:
21
+ application_helper:
22
+ label_for_question:
23
+ question: Question
24
+ exports:
25
+ survey_user_answers: Survey user answers
26
+ models:
27
+ components:
28
+ description: Description
29
+ tos: Terms of service
30
+ surveys:
31
+ answer_option:
32
+ answer_option: Answer option
33
+ remove_answer_option: Remove answer option
34
+ statement: Statement
35
+ edit:
36
+ save: Save
37
+ title: Title
38
+ form:
39
+ add_question: Add question
40
+ already_answered_warning: The survey is already answered by some users
41
+ so you cannot modify its questions.
42
+ question:
43
+ add_answer_option: Add answer option
44
+ question: Question
45
+ remove_question: Remove question
46
+ statement: Statement
47
+ update:
48
+ invalid: There's been errors when saving the survey.
49
+ success: Survey saved successfully.
50
+ question_types:
51
+ long_answer: Long answer
52
+ multiple_option: Multiple option
53
+ short_answer: Short answer
54
+ single_option: Single option
55
+ surveys:
56
+ answer:
57
+ invalid: There's been errors when answering the survey.
58
+ success: Survey answered successfully.
59
+ show:
60
+ answer_survey:
61
+ anonymous_user_message: <a href="%{sign_in_link}">Sign in with your account</a>
62
+ or <a href="%{sign_up_link}">sign up</a> to answer the survey.
63
+ title: Answer the survey
64
+ are_you_sure: This action cannot be undone and you will not be able to edit
65
+ your answers. Are you sure?
66
+ submit: Submit
67
+ survey_answered:
68
+ body: You have already answered this survey.
69
+ title: Survey answered
70
+ survey_closed:
71
+ body: The survey is closed and cannot be answered.
72
+ title: Survey closed
73
+ tos_agreement: By participating in this survey you accept its Terms of Service