decidim-debates 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +15 -0
  3. data/Rakefile +3 -0
  4. data/app/assets/images/decidim/debates/icon.svg +1 -0
  5. data/app/commands/decidim/debates/admin/create_debate.rb +57 -0
  6. data/app/commands/decidim/debates/admin/update_debate.rb +46 -0
  7. data/app/commands/decidim/debates/create_debate.rb +68 -0
  8. data/app/controllers/decidim/debates/admin/application_controller.rb +15 -0
  9. data/app/controllers/decidim/debates/admin/debates_controller.rb +73 -0
  10. data/app/controllers/decidim/debates/application_controller.rb +13 -0
  11. data/app/controllers/decidim/debates/debates_controller.rb +78 -0
  12. data/app/events/decidim/debates/create_debate_event.rb +42 -0
  13. data/app/forms/decidim/debates/admin/debate_form.rb +33 -0
  14. data/app/forms/decidim/debates/debate_form.rb +25 -0
  15. data/app/helpers/decidim/debates/application_helper.rb +12 -0
  16. data/app/models/decidim/debates/abilities/admin/admin_ability.rb +21 -0
  17. data/app/models/decidim/debates/abilities/admin/participatory_process_admin_ability.rb +23 -0
  18. data/app/models/decidim/debates/abilities/admin/participatory_process_moderator_ability.rb +21 -0
  19. data/app/models/decidim/debates/abilities/current_user_ability.rb +49 -0
  20. data/app/models/decidim/debates/application_record.rb +10 -0
  21. data/app/models/decidim/debates/debate.rb +103 -0
  22. data/app/presenters/decidim/debates/debate_presenter.rb +20 -0
  23. data/app/presenters/decidim/debates/official_author_presenter.rb +34 -0
  24. data/app/services/decidim/debates/debate_search.rb +38 -0
  25. data/app/views/decidim/debates/admin/debates/_form.html.erb +36 -0
  26. data/app/views/decidim/debates/admin/debates/edit.html.erb +7 -0
  27. data/app/views/decidim/debates/admin/debates/index.html.erb +52 -0
  28. data/app/views/decidim/debates/admin/debates/new.html.erb +7 -0
  29. data/app/views/decidim/debates/debates/_count.html.erb +1 -0
  30. data/app/views/decidim/debates/debates/_debate.html.erb +42 -0
  31. data/app/views/decidim/debates/debates/_debates.html.erb +4 -0
  32. data/app/views/decidim/debates/debates/_filters.html.erb +20 -0
  33. data/app/views/decidim/debates/debates/_filters_small_view.html.erb +18 -0
  34. data/app/views/decidim/debates/debates/_share.html.erb +33 -0
  35. data/app/views/decidim/debates/debates/index.html.erb +27 -0
  36. data/app/views/decidim/debates/debates/index.js.erb +9 -0
  37. data/app/views/decidim/debates/debates/new.html.erb +43 -0
  38. data/app/views/decidim/debates/debates/show.html.erb +80 -0
  39. data/config/locales/ca.yml +114 -0
  40. data/config/locales/en.yml +117 -0
  41. data/config/locales/es.yml +114 -0
  42. data/config/locales/eu.yml +114 -0
  43. data/config/locales/fi.yml +114 -0
  44. data/config/locales/fr.yml +114 -0
  45. data/config/locales/gl.yml +114 -0
  46. data/config/locales/it.yml +114 -0
  47. data/config/locales/nl.yml +114 -0
  48. data/config/locales/pl.yml +116 -0
  49. data/config/locales/pt-BR.yml +114 -0
  50. data/config/locales/pt.yml +114 -0
  51. data/config/locales/ru.yml +5 -0
  52. data/config/locales/sv.yml +114 -0
  53. data/config/locales/uk.yml +5 -0
  54. data/db/migrate/20170118141619_create_debates.rb +18 -0
  55. data/db/migrate/20180117100413_add_debate_information_updates.rb +7 -0
  56. data/db/migrate/20180118132243_add_author_to_debates.rb +7 -0
  57. data/db/migrate/20180119150434_add_reference_to_debates.rb +12 -0
  58. data/db/migrate/20180122090505_add_user_group_author_to_debates.rb +7 -0
  59. data/lib/decidim/debates/admin.rb +10 -0
  60. data/lib/decidim/debates/admin_engine.rb +33 -0
  61. data/lib/decidim/debates/engine.rb +26 -0
  62. data/lib/decidim/debates/feature.rb +55 -0
  63. data/lib/decidim/debates/test/factories.rb +52 -0
  64. data/lib/decidim/debates/version.rb +10 -0
  65. data/lib/decidim/debates.rb +12 -0
  66. metadata +197 -0
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "searchlight"
4
+ require "kaminari"
5
+
6
+ module Decidim
7
+ module Debates
8
+ # This is the engine that runs on the public interface of `decidim-debates`.
9
+ # It mostly handles rendering the created debate associated to a participatory
10
+ # process.
11
+ class Engine < ::Rails::Engine
12
+ isolate_namespace Decidim::Debates
13
+
14
+ routes do
15
+ resources :debates, only: [:index, :show, :new, :create]
16
+ root to: "debates#index"
17
+ end
18
+
19
+ initializer "decidim_debates.inject_abilities_to_user" do |_app|
20
+ Decidim.configure do |config|
21
+ config.abilities += ["Decidim::Debates::Abilities::CurrentUserAbility"]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "decidim/features/namer"
4
+
5
+ Decidim.register_feature(:debates) do |feature|
6
+ feature.engine = Decidim::Debates::Engine
7
+ feature.admin_engine = Decidim::Debates::AdminEngine
8
+ feature.icon = "decidim/debates/icon.svg"
9
+
10
+ feature.on(:before_destroy) do |instance|
11
+ raise StandardError, "Can't remove this feature" if Decidim::Debates::Debate.where(feature: instance).any?
12
+ end
13
+
14
+ feature.settings(:global) do |settings|
15
+ settings.attribute :comments_enabled, type: :boolean, default: true
16
+ end
17
+
18
+ feature.settings(:step) do |settings|
19
+ settings.attribute :creation_enabled, type: :boolean, default: false
20
+ settings.attribute :comments_blocked, type: :boolean, default: false
21
+ end
22
+
23
+ feature.register_resource do |resource|
24
+ resource.model_class_name = "Decidim::Debates::Debate"
25
+ end
26
+
27
+ feature.actions = %w(create)
28
+
29
+ feature.seeds do |participatory_space|
30
+ feature = Decidim::Feature.create!(
31
+ name: Decidim::Features::Namer.new(participatory_space.organization.available_locales, :debates).i18n_name,
32
+ manifest_name: :debates,
33
+ published_at: Time.current,
34
+ participatory_space: participatory_space
35
+ )
36
+
37
+ 3.times do
38
+ debate = Decidim::Debates::Debate.create!(
39
+ feature: feature,
40
+ category: participatory_space.categories.sample,
41
+ title: Decidim::Faker::Localized.sentence(2),
42
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
43
+ Decidim::Faker::Localized.paragraph(3)
44
+ end,
45
+ instructions: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
46
+ Decidim::Faker::Localized.paragraph(3)
47
+ end,
48
+ start_time: 3.weeks.from_now,
49
+ end_time: 3.weeks.from_now + 4.hours
50
+ )
51
+
52
+ Decidim::Comments::Seed.comments_for(debate)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :debate, class: "Decidim::Debates::Debate" do
5
+ title { Decidim::Faker::Localized.sentence(3) }
6
+ description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
7
+ information_updates { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
8
+ instructions { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
9
+ start_time { 1.day.from_now }
10
+ end_time { start_time.advance(hours: 2) }
11
+ feature { build(:feature, manifest_name: "debates") }
12
+
13
+ trait :open_ama do
14
+ start_time { 1.day.ago }
15
+ end_time { 1.day.from_now }
16
+ end
17
+
18
+ trait :with_author do
19
+ author do
20
+ build(:user, organization: feature.organization) if feature
21
+ end
22
+ end
23
+
24
+ trait :with_user_group_author do
25
+ author do
26
+ build(:user, organization: feature.organization) if feature
27
+ end
28
+ user_group do
29
+ build(:user_group, :verified, organization: feature.organization, users: [author]) if feature
30
+ end
31
+ end
32
+ end
33
+
34
+ factory :debates_feature, parent: :feature do
35
+ name { Decidim::Features::Namer.new(participatory_space.organization.available_locales, :debates).i18n_name }
36
+ manifest_name :debates
37
+ participatory_space { create(:participatory_process, :with_steps, organization: organization) }
38
+ settings do
39
+ {
40
+ comments_enabled: true
41
+ }
42
+ end
43
+
44
+ trait :with_creation_enabled do
45
+ step_settings do
46
+ {
47
+ participatory_space.active_step.id => { creation_enabled: true }
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This holds the decidim-debates version.
5
+ module Debates
6
+ def self.version
7
+ "0.9.0"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/debates/admin"
4
+ require "decidim/debates/engine"
5
+ require "decidim/debates/admin_engine"
6
+ require "decidim/debates/feature"
7
+
8
+ module Decidim
9
+ # Base module for this engine.
10
+ module Debates
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decidim-debates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Josep Jaume Rey Peroy
8
+ - Marc Riera Casals
9
+ - Oriol Gual Oliva
10
+ - Genis Matutes Pujol
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2018-02-05 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: decidim-comments
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: decidim-core
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: kaminari
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '1.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: searchlight
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: '4.1'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '4.1'
72
+ - !ruby/object:Gem::Dependency
73
+ name: decidim-admin
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '='
77
+ - !ruby/object:Gem::Version
78
+ version: 0.9.0
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 0.9.0
86
+ - !ruby/object:Gem::Dependency
87
+ name: decidim-dev
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '='
91
+ - !ruby/object:Gem::Version
92
+ version: 0.9.0
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '='
98
+ - !ruby/object:Gem::Version
99
+ version: 0.9.0
100
+ description: A debates component for decidim's participatory spaces.
101
+ email:
102
+ - josepjaume@gmail.com
103
+ - mrc2407@gmail.com
104
+ - oriolgual@gmail.com
105
+ - genis.matutes@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - README.md
111
+ - Rakefile
112
+ - app/assets/images/decidim/debates/icon.svg
113
+ - app/commands/decidim/debates/admin/create_debate.rb
114
+ - app/commands/decidim/debates/admin/update_debate.rb
115
+ - app/commands/decidim/debates/create_debate.rb
116
+ - app/controllers/decidim/debates/admin/application_controller.rb
117
+ - app/controllers/decidim/debates/admin/debates_controller.rb
118
+ - app/controllers/decidim/debates/application_controller.rb
119
+ - app/controllers/decidim/debates/debates_controller.rb
120
+ - app/events/decidim/debates/create_debate_event.rb
121
+ - app/forms/decidim/debates/admin/debate_form.rb
122
+ - app/forms/decidim/debates/debate_form.rb
123
+ - app/helpers/decidim/debates/application_helper.rb
124
+ - app/models/decidim/debates/abilities/admin/admin_ability.rb
125
+ - app/models/decidim/debates/abilities/admin/participatory_process_admin_ability.rb
126
+ - app/models/decidim/debates/abilities/admin/participatory_process_moderator_ability.rb
127
+ - app/models/decidim/debates/abilities/current_user_ability.rb
128
+ - app/models/decidim/debates/application_record.rb
129
+ - app/models/decidim/debates/debate.rb
130
+ - app/presenters/decidim/debates/debate_presenter.rb
131
+ - app/presenters/decidim/debates/official_author_presenter.rb
132
+ - app/services/decidim/debates/debate_search.rb
133
+ - app/views/decidim/debates/admin/debates/_form.html.erb
134
+ - app/views/decidim/debates/admin/debates/edit.html.erb
135
+ - app/views/decidim/debates/admin/debates/index.html.erb
136
+ - app/views/decidim/debates/admin/debates/new.html.erb
137
+ - app/views/decidim/debates/debates/_count.html.erb
138
+ - app/views/decidim/debates/debates/_debate.html.erb
139
+ - app/views/decidim/debates/debates/_debates.html.erb
140
+ - app/views/decidim/debates/debates/_filters.html.erb
141
+ - app/views/decidim/debates/debates/_filters_small_view.html.erb
142
+ - app/views/decidim/debates/debates/_share.html.erb
143
+ - app/views/decidim/debates/debates/index.html.erb
144
+ - app/views/decidim/debates/debates/index.js.erb
145
+ - app/views/decidim/debates/debates/new.html.erb
146
+ - app/views/decidim/debates/debates/show.html.erb
147
+ - config/locales/ca.yml
148
+ - config/locales/en.yml
149
+ - config/locales/es.yml
150
+ - config/locales/eu.yml
151
+ - config/locales/fi.yml
152
+ - config/locales/fr.yml
153
+ - config/locales/gl.yml
154
+ - config/locales/it.yml
155
+ - config/locales/nl.yml
156
+ - config/locales/pl.yml
157
+ - config/locales/pt-BR.yml
158
+ - config/locales/pt.yml
159
+ - config/locales/ru.yml
160
+ - config/locales/sv.yml
161
+ - config/locales/uk.yml
162
+ - db/migrate/20170118141619_create_debates.rb
163
+ - db/migrate/20180117100413_add_debate_information_updates.rb
164
+ - db/migrate/20180118132243_add_author_to_debates.rb
165
+ - db/migrate/20180119150434_add_reference_to_debates.rb
166
+ - db/migrate/20180122090505_add_user_group_author_to_debates.rb
167
+ - lib/decidim/debates.rb
168
+ - lib/decidim/debates/admin.rb
169
+ - lib/decidim/debates/admin_engine.rb
170
+ - lib/decidim/debates/engine.rb
171
+ - lib/decidim/debates/feature.rb
172
+ - lib/decidim/debates/test/factories.rb
173
+ - lib/decidim/debates/version.rb
174
+ homepage:
175
+ licenses: []
176
+ metadata: {}
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 2.7.3
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: Decidim debates module
197
+ test_files: []