decidim 0.0.4 → 0.0.5

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 (216) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +2 -5
  3. data/.mention-bot +2 -1
  4. data/.yardopts +8 -0
  5. data/Gemfile.lock +64 -62
  6. data/README.md +11 -9
  7. data/decidim-admin/app/assets/javascripts/decidim/admin/sort_steps.js.es6 +3 -3
  8. data/decidim-admin/app/assets/stylesheets/decidim/admin/_email_preview.scss +5 -0
  9. data/decidim-admin/app/assets/stylesheets/decidim/admin/application.scss +1 -0
  10. data/decidim-admin/app/commands/decidim/admin/create_newsletter.rb +30 -0
  11. data/decidim-admin/app/commands/decidim/admin/deliver_newsletter.rb +29 -0
  12. data/decidim-admin/app/commands/decidim/admin/destroy_participatory_process_step.rb +9 -0
  13. data/decidim-admin/app/commands/decidim/admin/update_newsletter.rb +33 -0
  14. data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  15. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +2 -2
  16. data/decidim-admin/app/controllers/decidim/admin/newsletters_controller.rb +115 -0
  17. data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +4 -4
  18. data/decidim-admin/app/forms/decidim/admin/newsletter_form.rb +15 -0
  19. data/decidim-admin/app/jobs/decidim/admin/newsletter_delivery_job.rb +18 -0
  20. data/decidim-admin/app/jobs/decidim/admin/newsletter_job.rb +32 -0
  21. data/decidim-admin/app/models/decidim/admin/abilities/admin_user.rb +4 -0
  22. data/decidim-admin/app/models/decidim/admin/abilities/base.rb +4 -0
  23. data/decidim-admin/app/models/decidim/admin/abilities/collaborator_user.rb +19 -0
  24. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_admin.rb +1 -1
  25. data/decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb +1 -1
  26. data/decidim-admin/app/views/decidim/admin/newsletters/_form.html.erb +5 -0
  27. data/decidim-admin/app/views/decidim/admin/newsletters/edit.html.erb +11 -0
  28. data/decidim-admin/app/views/decidim/admin/newsletters/index.html.erb +47 -0
  29. data/decidim-admin/app/views/decidim/admin/newsletters/new.html.erb +11 -0
  30. data/decidim-admin/app/views/decidim/admin/newsletters/show.html.erb +14 -0
  31. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/_form.html.erb +1 -1
  32. data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +1 -1
  33. data/decidim-admin/app/views/decidim/admin/static_pages/_form.html.erb +1 -1
  34. data/decidim-admin/app/views/layouts/decidim/admin/_sidebar.html.erb +1 -0
  35. data/decidim-admin/config/locales/ca.yml +40 -0
  36. data/decidim-admin/config/locales/en.yml +40 -0
  37. data/decidim-admin/config/locales/es.yml +40 -0
  38. data/decidim-admin/config/routes.rb +7 -0
  39. data/decidim-admin/decidim-admin.gemspec +0 -1
  40. data/decidim-admin/lib/decidim/admin/engine.rb +1 -0
  41. data/decidim-admin/lib/decidim/admin/features/base_controller.rb +5 -1
  42. data/decidim-admin/spec/commands/create_newsletter_spec.rb +62 -0
  43. data/decidim-admin/spec/commands/deliver_newsletter_spec.rb +45 -0
  44. data/decidim-admin/spec/commands/destroy_participatory_process_step_spec.rb +12 -0
  45. data/decidim-admin/spec/commands/update_newsletter_spec.rb +64 -0
  46. data/decidim-admin/spec/features/admin_manages_newsletters_spec.rb +147 -0
  47. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +1 -5
  48. data/decidim-admin/spec/features/static_pages_spec.rb +16 -0
  49. data/decidim-admin/spec/forms/newsletter_form_spec.rb +47 -0
  50. data/decidim-admin/spec/jobs/newsletter_delivery_job_spec.rb +25 -0
  51. data/decidim-admin/spec/jobs/newsletter_job_spec.rb +29 -0
  52. data/decidim-admin/spec/models/abilities/collaborator_user_spec.rb +66 -0
  53. data/decidim-admin/spec/organization_dashboard_constraint_spec.rb +55 -0
  54. data/decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb +8 -0
  55. data/decidim-admin/spec/shared/manage_processes_examples.rb +1 -5
  56. data/decidim-api/lib/decidim/api.rb +2 -7
  57. data/decidim-api/lib/decidim/api/{types/mutation.rb → mutation_type.rb} +0 -0
  58. data/decidim-api/lib/decidim/api/{types/query.rb → query_type.rb} +0 -0
  59. data/decidim-budgets/app/assets/javascripts/decidim/budgets/projects.js.es6 +4 -4
  60. data/decidim-budgets/app/commands/decidim/budgets/add_line_item.rb +4 -2
  61. data/decidim-budgets/app/commands/decidim/budgets/checkout.rb +7 -3
  62. data/decidim-budgets/app/models/decidim/budgets/order.rb +16 -1
  63. data/decidim-budgets/app/models/decidim/budgets/project.rb +16 -0
  64. data/decidim-budgets/app/views/decidim/budgets/line_items/update_budget.js.erb +7 -7
  65. data/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb +27 -25
  66. data/decidim-budgets/app/views/decidim/budgets/projects/_budget_summary.html.erb +4 -13
  67. data/decidim-budgets/app/views/decidim/budgets/projects/_order_progress.html.erb +23 -21
  68. data/decidim-budgets/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +25 -23
  69. data/decidim-budgets/app/views/decidim/budgets/projects/_order_total_budget.html.erb +3 -1
  70. data/decidim-budgets/app/views/decidim/budgets/projects/_project.html.erb +32 -30
  71. data/decidim-budgets/app/views/decidim/budgets/projects/_projects.html.erb +1 -3
  72. data/decidim-budgets/app/views/decidim/budgets/projects/index.html.erb +0 -4
  73. data/decidim-budgets/app/views/decidim/budgets/projects/show.html.erb +5 -6
  74. data/decidim-budgets/config/i18n-tasks.yml +1 -0
  75. data/decidim-budgets/config/locales/ca.yml +7 -2
  76. data/decidim-budgets/config/locales/en.yml +17 -6
  77. data/decidim-budgets/config/locales/es.yml +7 -2
  78. data/decidim-budgets/lib/decidim/budgets/feature.rb +2 -2
  79. data/decidim-budgets/spec/commands/add_line_item_spec.rb +16 -3
  80. data/decidim-budgets/spec/commands/cancel_order_spec.rb +7 -1
  81. data/decidim-budgets/spec/commands/checkout_spec.rb +9 -2
  82. data/decidim-budgets/spec/commands/remove_line_item_spec.rb +16 -5
  83. data/decidim-budgets/spec/features/orders_spec.rb +8 -2
  84. data/decidim-budgets/spec/models/order_spec.rb +31 -2
  85. data/decidim-budgets/spec/shared/admin_shared_context.rb +1 -1
  86. data/decidim-comments/README.md +1 -1
  87. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  88. data/decidim-comments/app/frontend/comments/add_comment_form.component.jsx +156 -93
  89. data/decidim-comments/app/frontend/comments/add_comment_form.component.test.jsx +36 -23
  90. data/decidim-comments/app/frontend/comments/add_comment_form.mutation.graphql +5 -3
  91. data/decidim-comments/app/frontend/comments/add_comment_form_commentable.fragment.graphql +4 -0
  92. data/decidim-comments/app/frontend/comments/add_comment_form_session.fragment.graphql +6 -0
  93. data/decidim-comments/app/frontend/comments/comment.component.jsx +11 -13
  94. data/decidim-comments/app/frontend/comments/comment.component.test.jsx +22 -21
  95. data/decidim-comments/app/frontend/comments/comment.fragment.graphql +4 -4
  96. data/decidim-comments/app/frontend/comments/comment_data.fragment.graphql +4 -3
  97. data/decidim-comments/app/frontend/comments/comment_order_selector.component.jsx +1 -1
  98. data/decidim-comments/app/frontend/comments/comment_thread.component.jsx +3 -3
  99. data/decidim-comments/app/frontend/comments/comment_thread.component.test.jsx +3 -3
  100. data/decidim-comments/app/frontend/comments/comment_thread.fragment.graphql +1 -1
  101. data/decidim-comments/app/frontend/comments/comments.component.jsx +47 -39
  102. data/decidim-comments/app/frontend/comments/comments.component.test.jsx +51 -38
  103. data/decidim-comments/app/frontend/comments/comments.query.graphql +10 -4
  104. data/decidim-comments/app/frontend/comments/down_vote_button.component.jsx +6 -3
  105. data/decidim-comments/app/frontend/comments/up_vote_button.component.jsx +7 -4
  106. data/decidim-comments/app/frontend/support/generate_comments_data.js +4 -4
  107. data/decidim-comments/app/models/decidim/comments/comment.rb +7 -9
  108. data/decidim-comments/app/queries/decidim/comments/{comments_with_replies.rb → sorted_comments.rb} +3 -8
  109. data/decidim-comments/app/types/decidim/comments/commentable_interface.rb +44 -0
  110. data/decidim-comments/app/types/decidim/comments/commentable_mutation_type.rb +29 -0
  111. data/decidim-comments/app/types/decidim/comments/commentable_type.rb +14 -0
  112. data/decidim-comments/config/locales/ca.yml +3 -1
  113. data/decidim-comments/config/locales/en.yml +5 -2
  114. data/decidim-comments/config/locales/es.yml +3 -1
  115. data/decidim-comments/lib/decidim/comments.rb +4 -0
  116. data/decidim-comments/{app/types/decidim/comments → lib/decidim/comments/api}/add_comment_type.rb +0 -0
  117. data/decidim-comments/{app/types/decidim/comments → lib/decidim/comments/api}/comment_mutation_type.rb +0 -0
  118. data/decidim-comments/{app/types/decidim/comments → lib/decidim/comments/api}/comment_type.rb +11 -17
  119. data/decidim-comments/lib/decidim/comments/commentable.rb +45 -0
  120. data/decidim-comments/lib/decidim/comments/comments_helper.rb +15 -10
  121. data/decidim-comments/lib/decidim/comments/mutation_extensions.rb +8 -16
  122. data/decidim-comments/lib/decidim/comments/query_extensions.rb +5 -8
  123. data/decidim-comments/lib/decidim/comments/test/factories.rb +3 -3
  124. data/decidim-comments/spec/commands/vote_comment_spec.rb +3 -1
  125. data/decidim-comments/spec/features/comments_spec.rb +28 -14
  126. data/decidim-comments/spec/features/notifications_spec.rb +1 -1
  127. data/decidim-comments/spec/helpers/comments_helper_spec.rb +4 -27
  128. data/decidim-comments/spec/models/comment_spec.rb +7 -11
  129. data/decidim-comments/spec/models/comment_vote_spec.rb +3 -1
  130. data/decidim-comments/spec/models/seed_spec.rb +3 -4
  131. data/decidim-comments/spec/queries/{comments_with_replies_spec.rb → sorted_comments_spec.rb} +12 -29
  132. data/decidim-comments/spec/types/comment_type_spec.rb +23 -17
  133. data/decidim-comments/spec/types/commentable_mutation_type_spec.rb +34 -0
  134. data/decidim-comments/spec/types/commentable_type_spec.rb +48 -0
  135. data/decidim-comments/spec/types/mutation_type_spec.rb +5 -22
  136. data/decidim-comments/spec/types/query_type_spec.rb +0 -24
  137. data/decidim-dev/config/i18n-tasks.yml +4 -0
  138. data/decidim-dev/decidim-dev.gemspec +1 -1
  139. data/decidim-dev/lib/decidim/dev/test/rspec_support/action_mailer.rb +10 -4
  140. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb +6 -5
  141. data/decidim-dev/lib/decidim/dev/test/rspec_support/i18n.rb +0 -1
  142. data/decidim-meetings/app/assets/javascripts/decidim/meetings/map.js.es6.erb +8 -3
  143. data/decidim-meetings/app/assets/stylesheets/decidim/meetings/map.css +3 -1
  144. data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +2 -2
  145. data/decidim-meetings/app/forms/decidim/meetings/admin/close_meeting_form.rb +2 -1
  146. data/decidim-meetings/app/helpers/decidim/meetings/map_helper.rb +1 -0
  147. data/decidim-meetings/app/services/decidim/meetings/meeting_search.rb +7 -3
  148. data/decidim-meetings/app/views/decidim/meetings/meetings/_datetime.html.erb +1 -1
  149. data/decidim-meetings/app/views/decidim/meetings/meetings/_filters.html.erb +5 -5
  150. data/decidim-meetings/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +1 -1
  151. data/decidim-meetings/app/views/decidim/meetings/meetings/index.html.erb +1 -5
  152. data/decidim-meetings/app/views/decidim/meetings/meetings/show.html.erb +16 -9
  153. data/decidim-meetings/config/locales/ca.yml +2 -3
  154. data/decidim-meetings/config/locales/en.yml +2 -3
  155. data/decidim-meetings/config/locales/es.yml +2 -3
  156. data/decidim-meetings/spec/features/explore_meetings_spec.rb +75 -24
  157. data/decidim-meetings/spec/forms/close_meeting_form_spec.rb +1 -1
  158. data/decidim-meetings/spec/services/meeting_search_spec.rb +15 -12
  159. data/decidim-meetings/vendor/assets/javascripts/leaflet.markercluster.js +7 -0
  160. data/decidim-meetings/vendor/assets/stylesheets/MarkerCluster.Default.css +60 -0
  161. data/decidim-meetings/vendor/assets/stylesheets/MarkerCluster.css +14 -0
  162. data/decidim-pages/app/models/decidim/pages/page.rb +22 -0
  163. data/decidim-pages/app/views/decidim/pages/application/show.html.erb +2 -6
  164. data/decidim-pages/config/locales/ca.yml +2 -2
  165. data/decidim-pages/config/locales/en.yml +2 -2
  166. data/decidim-pages/config/locales/es.yml +2 -2
  167. data/decidim-pages/lib/decidim/pages/feature.rb +2 -2
  168. data/decidim-pages/spec/features/page_show_spec.rb +0 -33
  169. data/decidim-proposals/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +2 -0
  170. data/decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -0
  171. data/decidim-proposals/app/models/decidim/proposals/abilities/admin_user.rb +45 -0
  172. data/decidim-proposals/app/models/decidim/proposals/abilities/process_admin_user.rb +57 -0
  173. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +21 -0
  174. data/decidim-proposals/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
  175. data/decidim-proposals/app/views/decidim/proposals/admin/proposals/index.html.erb +16 -10
  176. data/decidim-proposals/app/views/decidim/proposals/proposal_votes/update_buttons_and_counters.js.erb +4 -4
  177. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +7 -3
  178. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +2 -6
  179. data/decidim-proposals/app/views/decidim/proposals/proposals/_remaining_votes_count.html.erb +3 -1
  180. data/decidim-proposals/app/views/decidim/proposals/proposals/_tags.html.erb +1 -1
  181. data/decidim-proposals/app/views/decidim/proposals/proposals/_vote_button.html.erb +23 -21
  182. data/decidim-proposals/app/views/decidim/proposals/proposals/_votes_count.html.erb +9 -6
  183. data/decidim-proposals/app/views/decidim/proposals/proposals/_votes_limit.html.erb +1 -3
  184. data/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +0 -4
  185. data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +1 -1
  186. data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +2 -6
  187. data/decidim-proposals/config/locales/ca.yml +8 -1
  188. data/decidim-proposals/config/locales/en.yml +8 -1
  189. data/decidim-proposals/config/locales/es.yml +8 -1
  190. data/decidim-proposals/lib/decidim/proposals/admin_engine.rb +7 -0
  191. data/decidim-proposals/lib/decidim/proposals/feature.rb +6 -2
  192. data/decidim-proposals/spec/features/proposals_spec.rb +226 -40
  193. data/decidim-proposals/spec/models/decidim/proposals/abilities/admin_user_spec.rb +62 -0
  194. data/decidim-proposals/spec/models/decidim/proposals/abilities/process_admin_user_spec.rb +63 -0
  195. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +161 -50
  196. data/decidim-results/app/models/decidim/results/result.rb +21 -0
  197. data/decidim-results/app/views/decidim/results/results/index.html.erb +0 -4
  198. data/decidim-results/app/views/decidim/results/results/show.html.erb +2 -8
  199. data/decidim-results/config/i18n-tasks.yml +1 -0
  200. data/decidim-results/config/locales/ca.yml +5 -2
  201. data/decidim-results/config/locales/en.yml +5 -2
  202. data/decidim-results/config/locales/es.yml +5 -2
  203. data/decidim-results/lib/decidim/results/feature.rb +2 -2
  204. data/decidim-results/spec/services/result_stats_calculator_spec.rb +2 -2
  205. data/decidim-results/spec/shared/admin_shared_context.rb +1 -1
  206. data/decidim-system/config/i18n-tasks.yml +1 -1
  207. data/package.json +50 -51
  208. data/yarn.lock +198 -151
  209. metadata +69 -36
  210. data/decidim-admin/spec/features/admin_access_control.rb +0 -52
  211. data/decidim-api/lib/decidim/api/types/author_interface.rb +0 -13
  212. data/decidim-api/lib/decidim/api/types/localized_string.rb +0 -13
  213. data/decidim-api/lib/decidim/api/types/translated_field.rb +0 -44
  214. data/decidim-api/spec/types/localized_string_type_spec.rb +0 -31
  215. data/decidim-api/spec/types/translated_field_type_spec.rb +0 -69
  216. data/decidim-comments/app/frontend/comments/add_comment_form.fragment.graphql +0 -6
@@ -10,9 +10,7 @@
10
10
  <div class="card card--nomargin text-center">
11
11
  <div class="card__content">
12
12
  <span class="definition-data__title"><%= t('.vote_limit.left', limit: feature_settings.vote_limit) %></span>
13
- <span id="remaining-votes-count" class="extra__suport-number">
14
- <%= render partial: "remaining_votes_count" %>
15
- </span>
13
+ <%= render partial: "remaining_votes_count" %>
16
14
  <span class="extra__suport-text"><%= t('.vote_limit.votes') %></span>
17
15
  </div>
18
16
  </div>
@@ -1,7 +1,3 @@
1
- <% add_meta_tags({
2
- title: t(".meta_title", feature_name: translated_attribute(current_feature.name))
3
- }) %>
4
-
5
1
  <%= render partial: "votes_limit" %>
6
2
  <div class="row columns">
7
3
  <div class="title-action">
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
  <% end %>
26
26
 
27
- <% if @form.scopes&.any? %>
27
+ <% if @form.scopes&.any? && feature_settings.scoped_proposals_enabled %>
28
28
  <div class="field">
29
29
  <%= form.select :scope_id, @form.scopes.map{|s| [s.name, s.id]}, prompt: t(".select_a_scope") %>
30
30
  </div>
@@ -1,4 +1,4 @@
1
- <% add_meta_tags({
1
+ <% add_decidim_meta_tags({
2
2
  description: @proposal.body,
3
3
  title: @proposal.title,
4
4
  url: proposal_url(@proposal.id)
@@ -66,11 +66,7 @@
66
66
  </div>
67
67
  </div>
68
68
 
69
- <%= content_for :expanded do %>
70
- <% if feature_settings.comments_always_enabled || current_settings.comments_enabled %>
71
- <%= comments_for @proposal, arguable: true, votable: true %>
72
- <% end %>
73
- <% end %>
69
+ <%= comments_for @proposal %>
74
70
 
75
71
  <%= javascript_include_tag "decidim/proposals/social_share" %>
76
72
  <%= stylesheet_link_tag "decidim/proposals/social_share" %>
@@ -15,8 +15,16 @@ ca:
15
15
  vote: Votar
16
16
  name: Propostes
17
17
  settings:
18
+ global:
19
+ comments_enabled: Comentaris habilitats
20
+ official_proposals_enabled: Propostes oficials habilitades
21
+ proposal_answering_enabled: Resposta oficial a propostes activades
22
+ scoped_proposals_enabled: Propostes amb àmbits
23
+ vote_limit: Límit de vot
18
24
  step:
25
+ comments_blocked: Comentaris bloquejats
19
26
  creation_enabled: Habilitar de creació de propostes
27
+ proposal_answering_enabled: Resposta oficial a propostes activades
20
28
  votes_blocked: Suports bloquejats
21
29
  votes_enabled: Suports habilitats
22
30
  proposals:
@@ -89,7 +97,6 @@ ca:
89
97
  filter_for: Filtrar per
90
98
  unfold: Desplegar
91
99
  index:
92
- meta_title: "%{feature_name}"
93
100
  new_proposal: Nova proposta
94
101
  linked_proposals:
95
102
  proposal_votes:
@@ -16,8 +16,16 @@ en:
16
16
  vote: Vote
17
17
  name: Proposals
18
18
  settings:
19
+ global:
20
+ comments_enabled: Comments enabled
21
+ official_proposals_enabled: Official proposals enabled
22
+ proposal_answering_enabled: Proposal answering enabled
23
+ scoped_proposals_enabled: Scoped proposals enabled
24
+ vote_limit: Vote limit
19
25
  step:
26
+ comments_blocked: Comments blocked
20
27
  creation_enabled: Proposal creation enabled
28
+ proposal_answering_enabled: Proposal answering enabled
21
29
  votes_blocked: Votes blocked
22
30
  votes_enabled: Votes enabled
23
31
  proposals:
@@ -90,7 +98,6 @@ en:
90
98
  filter_for: Filter by
91
99
  unfold: Unfold
92
100
  index:
93
- meta_title: "%{feature_name}"
94
101
  new_proposal: New proposal
95
102
  linked_proposals:
96
103
  proposal_votes:
@@ -15,8 +15,16 @@ es:
15
15
  vote: Votar
16
16
  name: Propuestas
17
17
  settings:
18
+ global:
19
+ comments_enabled: Comentarios habilitados
20
+ official_proposals_enabled: Propuestas oficiales habilitadas
21
+ proposal_answering_enabled: Respuesta oficial a propuestas habilitadas
22
+ scoped_proposals_enabled: Propuestas con ámbito
23
+ vote_limit: Límite de votos
18
24
  step:
25
+ comments_blocked: Comentarios bloqueados
19
26
  creation_enabled: Habilitar creación de propuestas
27
+ proposal_answering_enabled: Respuesta a propuestas activadas
20
28
  votes_blocked: Votación bloqueada
21
29
  votes_enabled: Votos habilitados
22
30
  proposals:
@@ -89,7 +97,6 @@ es:
89
97
  filter_for: Filtrar por
90
98
  unfold: Desplegar
91
99
  index:
92
- meta_title: "%{feature_name}"
93
100
  new_proposal: Nueva propuesta
94
101
  linked_proposals:
95
102
  proposal_votes:
@@ -14,6 +14,13 @@ module Decidim
14
14
  root to: "proposals#index"
15
15
  end
16
16
 
17
+ initializer "decidim_proposals.inject_abilities_to_user" do |_app|
18
+ Decidim.configure do |config|
19
+ config.admin_abilities += ["Decidim::Proposals::Abilities::AdminUser"]
20
+ config.admin_abilities += ["Decidim::Proposals::Abilities::ProcessAdminUser"]
21
+ end
22
+ end
23
+
17
24
  def load_seed
18
25
  nil
19
26
  end
@@ -17,14 +17,18 @@ Decidim.register_feature(:proposals) do |feature|
17
17
 
18
18
  feature.settings(:global) do |settings|
19
19
  settings.attribute :vote_limit, type: :integer, default: 0
20
- settings.attribute :comments_always_enabled, type: :boolean, default: true
20
+ settings.attribute :proposal_answering_enabled, type: :boolean, default: true
21
+ settings.attribute :official_proposals_enabled, type: :boolean, default: true
22
+ settings.attribute :scoped_proposals_enabled, type: :boolean, default: true
23
+ settings.attribute :comments_enabled, type: :boolean, default: true
21
24
  end
22
25
 
23
26
  feature.settings(:step) do |settings|
24
27
  settings.attribute :votes_enabled, type: :boolean
25
28
  settings.attribute :votes_blocked, type: :boolean
26
- settings.attribute :comments_enabled, type: :boolean, default: true
29
+ settings.attribute :comments_blocked, type: :boolean, default: false
27
30
  settings.attribute :creation_enabled, type: :boolean
31
+ settings.attribute :proposal_answering_enabled, type: :boolean, default: true
28
32
  end
29
33
 
30
34
  feature.register_resource do |resource|
@@ -10,15 +10,10 @@ describe "Proposals", type: :feature do
10
10
  let!(:scope) { create :scope, organization: organization }
11
11
  let!(:user) { create :user, :confirmed, organization: organization }
12
12
 
13
- before do
14
- visit_feature
15
- end
16
-
17
13
  context "creating a new proposal" do
18
14
  context "when the user is logged in" do
19
15
  before do
20
16
  login_as user, scope: :user
21
- visit_feature
22
17
  end
23
18
 
24
19
  context "with creation enabled" do
@@ -29,7 +24,41 @@ describe "Proposals", type: :feature do
29
24
  participatory_process: participatory_process)
30
25
  end
31
26
 
27
+ context "when scoped_proposals setting is enabled" do
28
+ before do
29
+ feature.update_attributes(settings: { scoped_proposals_enabled: true})
30
+ end
31
+
32
+ it "cannot be related to a scope" do
33
+ visit_feature
34
+
35
+ click_link "New proposal"
36
+
37
+ within "form.new_proposal" do
38
+ expect(page).to have_content(/Scope/i)
39
+ end
40
+ end
41
+ end
42
+
43
+ context "when scoped_proposals setting is not enabled" do
44
+ before do
45
+ feature.update_attributes(settings: { scoped_proposals_enabled: false})
46
+ end
47
+
48
+ it "cannot be related to a scope" do
49
+ visit_feature
50
+
51
+ click_link "New proposal"
52
+
53
+ within "form.new_proposal" do
54
+ expect(page).not_to have_content("Scope")
55
+ end
56
+ end
57
+ end
58
+
32
59
  it "creates a new proposal" do
60
+ visit_feature
61
+
33
62
  click_link "New proposal"
34
63
 
35
64
  within ".new_proposal" do
@@ -57,6 +86,8 @@ describe "Proposals", type: :feature do
57
86
  end
58
87
 
59
88
  it "creates a new proposal as a user group" do
89
+ visit_feature
90
+
60
91
  click_link "New proposal"
61
92
 
62
93
  within ".new_proposal" do
@@ -81,10 +112,10 @@ describe "Proposals", type: :feature do
81
112
  context "when the user isn't authorized" do
82
113
  before do
83
114
  feature.update_attribute(:permissions, create: { authorization_handler_name: "decidim/dummy_authorization_handler" })
84
- visit_feature
85
115
  end
86
116
 
87
117
  it "should show a modal dialog" do
118
+ visit_feature
88
119
  click_link "New proposal"
89
120
  expect(page).to have_content("Authorization required")
90
121
  end
@@ -93,6 +124,7 @@ describe "Proposals", type: :feature do
93
124
 
94
125
  context "when creation is not enabled" do
95
126
  it "does not show the creation button" do
127
+ visit_feature
96
128
  expect(page).to have_no_link("New proposal")
97
129
  end
98
130
  end
@@ -103,6 +135,8 @@ describe "Proposals", type: :feature do
103
135
  it "allows viewing a single proposal" do
104
136
  proposal = proposals.first
105
137
 
138
+ visit_feature
139
+
106
140
  click_link proposal.title
107
141
 
108
142
  expect(page).to have_content(proposal.title)
@@ -110,6 +144,34 @@ describe "Proposals", type: :feature do
110
144
  expect(page).to have_content(proposal.author.name)
111
145
  end
112
146
 
147
+ context "when scoped_proposals setting is enabled" do
148
+ let!(:proposal) { create(:proposal, feature: feature, scope: scope) }
149
+
150
+ before do
151
+ feature.update_attributes(settings: { scoped_proposals_enabled: true } )
152
+ end
153
+
154
+ it "can be filtered by scope" do
155
+ visit_feature
156
+ click_link proposal.title
157
+ expect(page).to have_content(scope.name)
158
+ end
159
+ end
160
+
161
+ context "when scoped_proposals setting is not enabled" do
162
+ let!(:proposal) { create(:proposal, feature: feature, scope: scope) }
163
+
164
+ before do
165
+ feature.update_attributes(settings: { scoped_proposals_enabled: false } )
166
+ end
167
+
168
+ it "cannot be filtered by scope" do
169
+ visit_feature
170
+ click_link proposal.title
171
+ expect(page).not_to have_content(scope.name)
172
+ end
173
+ end
174
+
113
175
  context "when it is an official proposal" do
114
176
  let!(:official_proposal) { create(:proposal, feature: feature, author: nil) }
115
177
 
@@ -231,82 +293,206 @@ describe "Proposals", type: :feature do
231
293
 
232
294
  context "listing proposals in a participatory process" do
233
295
  it "lists all the proposals" do
296
+ visit_feature
234
297
  expect(page).to have_css(".card--proposal", count: 3)
235
298
  end
236
299
 
237
300
  context "when there are a lot of proposals" do
238
301
  before do
239
302
  create_list(:proposal, 17, feature: feature)
240
- visit_feature
241
303
  end
242
304
 
243
305
  it "paginates them" do
306
+ visit_feature
307
+
244
308
  expect(page).to have_css(".card--proposal", count: 12)
245
309
 
246
310
  find(".pagination-next a").click
247
311
 
312
+ within ".pagination .current" do
313
+ expect(page).to have_content("2")
314
+ end
315
+
248
316
  expect(page).to have_css(".card--proposal", count: 8)
249
317
  end
250
318
  end
251
319
 
252
320
  context "when filtering" do
253
- context "by origin 'official'" do
254
- it "lists the filtered proposals" do
255
- create(:proposal, :official, feature: feature, scope: scope)
321
+ context "when official_proposals setting is enabled" do
322
+ before do
323
+ feature.update_attributes(settings: { official_proposals_enabled: true})
324
+ end
325
+
326
+ it "can be filtered by origin" do
256
327
  visit_feature
257
328
 
258
- within ".filters" do
259
- choose "Official"
329
+ within "form.new_filter" do
330
+ expect(page).to have_content(/Origin/i)
260
331
  end
261
-
262
- expect(page).to have_css(".card--proposal", count: 1)
263
- expect(page).to have_content("1 PROPOSAL")
264
332
  end
265
- end
266
333
 
267
- context "by origin 'citizenship'" do
268
- it "lists the filtered proposals" do
269
- within ".filters" do
270
- choose "Citizenship"
334
+ context "by origin 'official'" do
335
+ it "lists the filtered proposals" do
336
+ create(:proposal, :official, feature: feature, scope: scope)
337
+ visit_feature
338
+
339
+ within ".filters" do
340
+ choose "Official"
341
+ end
342
+
343
+ expect(page).to have_css(".card--proposal", count: 1)
344
+ expect(page).to have_content("1 PROPOSAL")
271
345
  end
346
+ end
347
+
348
+ context "by origin 'citizenship'" do
349
+ it "lists the filtered proposals" do
350
+ visit_feature
351
+
352
+ within ".filters" do
353
+ choose "Citizenship"
354
+ end
272
355
 
273
- expect(page).to have_css(".card--proposal", count: proposals.size)
274
- expect(page).to have_content("#{proposals.size} PROPOSALS")
356
+ expect(page).to have_css(".card--proposal", count: proposals.size)
357
+ expect(page).to have_content("#{proposals.size} PROPOSALS")
358
+ end
275
359
  end
276
360
  end
277
361
 
278
- context "by accepted" do
279
- it "lists the filtered proposals" do
280
- create(:proposal, :accepted, feature: feature, scope: scope)
362
+ context "when official_proposals setting is not enabled" do
363
+ before do
364
+ feature.update_attributes(settings: { official_proposals_enabled: false } )
365
+ end
366
+
367
+ it "cannot be filtered by origin" do
281
368
  visit_feature
282
369
 
283
- within ".filters" do
284
- choose "Accepted"
370
+ within "form.new_filter" do
371
+ expect(page).not_to have_content(/Origin/i)
285
372
  end
373
+ end
374
+ end
286
375
 
287
- expect(page).to have_css(".card--proposal", count: 1)
288
- expect(page).to have_content("1 PROPOSAL")
376
+ context "when scoped_proposals setting is enabled" do
377
+ before do
378
+ feature.update_attributes(settings: { scoped_proposals_enabled: true } )
379
+ end
380
+
381
+ it "cannot be filtered by scope" do
382
+ visit_feature
289
383
 
290
- within ".card--proposal" do
291
- expect(page).to have_content("Accepted")
384
+ within "form.new_filter" do
385
+ expect(page).to have_content(/Scopes/i)
292
386
  end
293
387
  end
294
388
  end
295
389
 
296
- context "by rejected" do
297
- it "lists the filtered proposals" do
298
- create(:proposal, :rejected, feature: feature, scope: scope)
390
+ context "when scoped_proposals setting is not enabled" do
391
+ before do
392
+ feature.update_attributes(settings: { scoped_proposals_enabled: false } )
393
+ end
394
+
395
+ it "cannot be filtered by scope" do
299
396
  visit_feature
300
397
 
301
- within ".filters" do
302
- choose "Rejected"
398
+ within "form.new_filter" do
399
+ expect(page).not_to have_content(/Scopes/i)
400
+ end
401
+ end
402
+ end
403
+
404
+ context "when proposal_answering feature setting is enabled" do
405
+ before do
406
+ feature.update_attributes(settings: { proposal_answering_enabled: true } )
407
+ end
408
+
409
+ context "when proposal_answering step setting is enabled" do
410
+ before do
411
+ feature.update_attributes(
412
+ step_settings: {
413
+ feature.participatory_process.active_step.id => {
414
+ proposal_answering_enabled: true
415
+ }
416
+ }
417
+ )
418
+ end
419
+
420
+ it "can be filtered by state" do
421
+ visit_feature
422
+
423
+ within "form.new_filter" do
424
+ expect(page).to have_content(/State/i)
425
+ end
426
+ end
427
+
428
+ context "by accepted" do
429
+ it "lists the filtered proposals" do
430
+ create(:proposal, :accepted, feature: feature, scope: scope)
431
+ visit_feature
432
+
433
+ within ".filters" do
434
+ choose "Accepted"
435
+ end
436
+
437
+ expect(page).to have_css(".card--proposal", count: 1)
438
+ expect(page).to have_content("1 PROPOSAL")
439
+
440
+ within ".card--proposal" do
441
+ expect(page).to have_content("Accepted")
442
+ end
443
+ end
303
444
  end
304
445
 
305
- expect(page).to have_css(".card--proposal", count: 1)
306
- expect(page).to have_content("1 PROPOSAL")
446
+ context "by rejected" do
447
+ it "lists the filtered proposals" do
448
+ create(:proposal, :rejected, feature: feature, scope: scope)
449
+ visit_feature
450
+
451
+ within ".filters" do
452
+ choose "Rejected"
453
+ end
454
+
455
+ expect(page).to have_css(".card--proposal", count: 1)
456
+ expect(page).to have_content("1 PROPOSAL")
457
+
458
+ within ".card--proposal" do
459
+ expect(page).to have_content("Rejected")
460
+ end
461
+ end
462
+ end
463
+ end
464
+
465
+ context "when proposal_answering step setting is disabled" do
466
+ before do
467
+ feature.update_attributes(
468
+ step_settings: {
469
+ feature.participatory_process.active_step.id => {
470
+ proposal_answering_enabled: false
471
+ }
472
+ }
473
+ )
474
+ end
475
+
476
+ it "cannot be filtered by state" do
477
+ visit_feature
478
+
479
+ within "form.new_filter" do
480
+ expect(page).not_to have_content(/State/i)
481
+ end
482
+ end
483
+ end
484
+ end
485
+
486
+ context "when proposal_answering feature setting is not enabled" do
487
+ before do
488
+ feature.update_attributes(settings: { proposal_answering_enabled: false } )
489
+ end
490
+
491
+ it "cannot be filtered by state" do
492
+ visit_feature
307
493
 
308
- within ".card--proposal" do
309
- expect(page).to have_content("Rejected")
494
+ within "form.new_filter" do
495
+ expect(page).not_to have_content(/State/i)
310
496
  end
311
497
  end
312
498
  end