decidim-dev 0.22.0 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/decidim/dummy_resources/dummy_resources_controller.rb +1 -0
  3. data/app/mailers/decidim/dummy_resources/dummy_resource_mailer.rb +17 -0
  4. data/app/views/decidim/dummy_resources/dummy_resources/show.html.erb +4 -0
  5. data/config/locales/am-ET.yml +1 -0
  6. data/config/locales/bg.yml +56 -0
  7. data/config/locales/ca.yml +1 -1
  8. data/config/locales/da.yml +1 -0
  9. data/config/locales/de.yml +1 -1
  10. data/config/locales/eo.yml +1 -0
  11. data/config/locales/es.yml +1 -1
  12. data/config/locales/et.yml +1 -0
  13. data/config/locales/fr.yml +1 -1
  14. data/config/locales/hr.yml +1 -0
  15. data/config/locales/is.yml +21 -0
  16. data/config/locales/ja.yml +56 -0
  17. data/config/locales/ko-KR.yml +1 -0
  18. data/config/locales/ko.yml +1 -0
  19. data/config/locales/lt.yml +1 -0
  20. data/config/locales/{lv-LV.yml → lv.yml} +0 -0
  21. data/config/locales/mt.yml +1 -0
  22. data/config/locales/om-ET.yml +1 -0
  23. data/config/locales/pl.yml +2 -2
  24. data/config/locales/si-LK.yml +1 -0
  25. data/config/locales/so-SO.yml +1 -0
  26. data/config/locales/sw-KE.yml +1 -0
  27. data/config/locales/ti-ER.yml +1 -0
  28. data/config/locales/tr-TR.yml +25 -9
  29. data/config/locales/vi-VN.yml +1 -0
  30. data/config/locales/vi.yml +1 -0
  31. data/config/locales/zh-CN.yml +56 -0
  32. data/config/locales/zh-TW.yml +1 -0
  33. data/lib/decidim/dev.rb +2 -0
  34. data/lib/decidim/dev/assets/5000x5000.png +0 -0
  35. data/lib/decidim/dev/assets/assemblies.json +816 -0
  36. data/lib/decidim/dev/assets/assemblies_with_null.json +135 -0
  37. data/lib/decidim/dev/assets/geocoder_result_here.json +72 -0
  38. data/lib/decidim/dev/assets/geocoder_result_osm.json +150 -0
  39. data/lib/decidim/dev/assets/import_participatory_space_private_users_nok.csv +2 -0
  40. data/lib/decidim/dev/dummy_translator.rb +32 -0
  41. data/lib/decidim/dev/test/rspec_support/capybara.rb +5 -1
  42. data/lib/decidim/dev/test/rspec_support/component.rb +40 -7
  43. data/lib/decidim/dev/test/rspec_support/component_context.rb +1 -2
  44. data/lib/decidim/dev/test/rspec_support/content_processing.rb +2 -2
  45. data/lib/decidim/dev/test/rspec_support/frontend.rb +20 -0
  46. data/lib/decidim/dev/test/rspec_support/geocoder.rb +150 -6
  47. data/lib/decidim/dev/test/rspec_support/organization.rb +7 -0
  48. data/lib/decidim/dev/test/rspec_support/rake_tasks.rb +75 -0
  49. data/lib/decidim/dev/test/rspec_support/translation_helpers.rb +2 -0
  50. data/lib/decidim/dev/version.rb +1 -1
  51. data/lib/tasks/generators.rake +2 -1
  52. data/lib/tasks/locale_checker.rake +1 -1
  53. metadata +46 -14
@@ -0,0 +1,135 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "slug": "quae-a",
5
+ "hashtag": "id",
6
+ "decidim_organization_id": 1,
7
+ "title": {
8
+ "ca": "Eius iure laborum hic et.",
9
+ "en": "Deserunt sed est quas rerum.",
10
+ "es": "Est architecto voluptas est nobis."
11
+ },
12
+ "subtitle": {
13
+ "ca": "Necessitatibus repellat.",
14
+ "en": "Porro ipsam.",
15
+ "es": "Qui quia."
16
+ },
17
+ "short_description": {
18
+ "ca": "<p>Sed et voluptatem.</p>",
19
+ "en": "<p>Provident ab et.</p>",
20
+ "es": "<p>Molestias aliquam rerum.</p>"
21
+ },
22
+ "description": {
23
+ "ca": "<p>In incidunt harum. Sit laboriosam molestiae. Officia qui quo.</p>",
24
+ "en": "<p>Occaecati nulla deserunt. Sequi voluptatem quam. Qui eligendi quod.</p>",
25
+ "es": "<p>Accusamus dolorem vitae. Et reprehenderit accusantium. Expedita consequatur nesciunt.</p>"
26
+ },
27
+ "remote_hero_image_url": "http://localhost/uploads/decidim/assembly/hero_image/1/city.jpeg",
28
+ "remote_banner_image_url": "http://localhost/uploads/decidim/assembly/banner_image/1/city2.jpeg",
29
+ "promoted": true,
30
+ "developer_group": {
31
+ "ca": "Nesciunt.",
32
+ "en": "Ad.",
33
+ "es": "Sint."
34
+ },
35
+ "meta_scope": {
36
+ "ca": "eum",
37
+ "en": "explicabo",
38
+ "es": "quas"
39
+ },
40
+ "local_area": {
41
+ "ca": "Ad ut.",
42
+ "en": "Illum nihil.",
43
+ "es": "Adipisci ut."
44
+ },
45
+ "target": {
46
+ "ca": "Sit et ea.",
47
+ "en": "Ut libero qui.",
48
+ "es": "Incidunt provident doloremque."
49
+ },
50
+ "decidim_scope_id": null,
51
+ "paticipatory_scope": {
52
+ "ca": "Assumenda.",
53
+ "en": "Quidem.",
54
+ "es": "Aspernatur."
55
+ },
56
+ "participatory_structure": {
57
+ "ca": "Voluptatem in.",
58
+ "en": "Vel qui.",
59
+ "es": "Et molestiae."
60
+ },
61
+ "show_statistics": false,
62
+ "scopes_enabled": true,
63
+ "private_space": false,
64
+ "reference": "PhD-ASSE-2020-01-1",
65
+ "purpose_of_action": {
66
+ "ca": "<p>Velit a qui. Debitis rem occaecati. Id minus est.</p>",
67
+ "en": "<p>Perspiciatis voluptas et. Officiis ratione corporis. Voluptas iusto qui.</p>",
68
+ "es": "<p>Sit pariatur et. Modi ea earum. Suscipit labore ipsum.</p>"
69
+ },
70
+ "composition": {
71
+ "ca": "<p>Quos libero nobis. Fugiat quia et. Nam non quae.</p>",
72
+ "en": "<p>Ex optio illo. Dolor sunt quam. Et fugit molestiae.</p>",
73
+ "es": "<p>Incidunt sint veniam. Illum repellendus quos. Et tenetur voluptatum.</p>"
74
+ },
75
+ "duration": "2020-01-24",
76
+ "participatory_scope": {
77
+ "ca": "Assumenda.",
78
+ "en": "Quidem.",
79
+ "es": "Aspernatur."
80
+ },
81
+ "included_at": "2020-01-27",
82
+ "closing_date": "2020-01-27",
83
+ "created_by": "others",
84
+ "creation_date": "2020-01-23",
85
+ "closing_date_reason": {
86
+ "ca": "Dolorum id voluptate.",
87
+ "en": "Voluptatibus quasi omnis.",
88
+ "es": "Similique et expedita."
89
+ },
90
+ "internal_organisation": {
91
+ "ca": "<p>Reprehenderit nisi non. Unde quia cum. Ea saepe deleniti.</p>",
92
+ "en": "<p>Optio ducimus velit. Facilis omnis asperiores. Corporis ipsa non.</p>",
93
+ "es": "<p>Est dolorum et. Quo sed ut. Corporis quos sit.</p>"
94
+ },
95
+ "is_transparent": true,
96
+ "special_features": {
97
+ "ca": "<p>Dolor et reprehenderit. Unde soluta eum. Omnis occaecati omnis.</p>",
98
+ "en": "<p>Et atque perspiciatis. Quas impedit corporis. Nesciunt blanditiis ipsa.</p>",
99
+ "es": "<p>Rerum eligendi hic. Iure aut expedita. Sapiente ut corrupti.</p>"
100
+ },
101
+ "twitter_handler": "aliquam",
102
+ "instagram_handler": "corrupti",
103
+ "facebook_handler": "velit",
104
+ "youtube_handler": "ducimus",
105
+ "github_handler": "in",
106
+ "created_by_other": {
107
+ "ca": "vitae",
108
+ "en": "ut",
109
+ "es": "rerum"
110
+ },
111
+ "decidim_assemblies_type_id": 1,
112
+ "area": {
113
+ "id": null,
114
+ "name": {
115
+ "en": "",
116
+ "ca": "",
117
+ "es": ""
118
+ }
119
+ },
120
+ "scope": {
121
+ "id": null,
122
+ "name": {
123
+ "en": "",
124
+ "ca": "",
125
+ "es": ""
126
+ }
127
+ },
128
+ "assembly_categories": null,
129
+ "attachments": {
130
+ "attachment_collections": null,
131
+ "files": null
132
+ },
133
+ "components": null
134
+ }
135
+ ]
@@ -0,0 +1,72 @@
1
+ {
2
+ "Response": {
3
+ "MetaInfo": {
4
+ "Timestamp": "2013-02-08T16:26:39.382+0000"
5
+ },
6
+ "View": [
7
+ {
8
+ "_type": "SearchResultsViewType",
9
+ "ViewId": 0,
10
+ "Result": [
11
+ {
12
+ "Relevance": 1.0,
13
+ "MatchLevel": "houseNumber",
14
+ "MatchQuality": {
15
+ "State": 1.0,
16
+ "City": 1.0,
17
+ "Street": [
18
+ 1.0
19
+ ],
20
+ "HouseNumber": 1.0
21
+ },
22
+ "MatchType": "pointAddress",
23
+ "Location": {
24
+ "LocationId": "NT_ArsGdYbpo6dqjPQel9gTID_4",
25
+ "LocationType": "point",
26
+ "DisplayPosition": {
27
+ "Latitude": 40.7504692,
28
+ "Longitude": -73.9933777
29
+ },
30
+ "NavigationPosition": [
31
+ {
32
+ "Latitude": 40.7500305,
33
+ "Longitude": -73.9942398
34
+ }
35
+ ],
36
+ "MapView": {
37
+ "TopLeft": {
38
+ "Latitude": 40.7515934,
39
+ "Longitude": -73.9948616
40
+ },
41
+ "BottomRight": {
42
+ "Latitude": 40.7493451,
43
+ "Longitude": -73.9918938
44
+ }
45
+ },
46
+ "Address": {
47
+ "Label": "4 Penn Plz, New York, NY 10001, United States",
48
+ "Country": "USA",
49
+ "State": "NY",
50
+ "County": "New York",
51
+ "City": "New York",
52
+ "Street": "Penn Plz",
53
+ "HouseNumber": "4",
54
+ "PostalCode": "10001",
55
+ "AdditionalData": [
56
+ {
57
+ "value": "United States",
58
+ "key": "CountryName"
59
+ },
60
+ {
61
+ "value": "New York",
62
+ "key": "StateName"
63
+ }
64
+ ]
65
+ }
66
+ }
67
+ }
68
+ ]
69
+ }
70
+ ]
71
+ }
72
+ }
@@ -0,0 +1,150 @@
1
+ [
2
+
3
+ {
4
+ "place_id": "30632629",
5
+ "licence": "Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
6
+ "osm_type": "way",
7
+ "osm_id": "24801588",
8
+ "boundingbox": [
9
+ "40.749828338623",
10
+ "40.7511596679688",
11
+ "-73.9943389892578",
12
+ "-73.9926528930664"
13
+ ],
14
+ "polygonpoints": [
15
+ [
16
+ "-73.9943346",
17
+ "40.7503638"
18
+ ],
19
+ [
20
+ "-73.9942745",
21
+ "40.7504158"
22
+ ],
23
+ [
24
+ "-73.9942593",
25
+ "40.750629"
26
+ ],
27
+ [
28
+ "-73.9941343",
29
+ "40.7508432"
30
+ ],
31
+ [
32
+ "-73.9939794",
33
+ "40.7509703"
34
+ ],
35
+ [
36
+ "-73.9938042",
37
+ "40.7510532"
38
+ ],
39
+ [
40
+ "-73.9938025",
41
+ "40.7511311"
42
+ ],
43
+ [
44
+ "-73.9936051",
45
+ "40.7511571"
46
+ ],
47
+ [
48
+ "-73.9935673",
49
+ "40.751105"
50
+ ],
51
+ [
52
+ "-73.9934095",
53
+ "40.7511089"
54
+ ],
55
+ [
56
+ "-73.9931235",
57
+ "40.7510548"
58
+ ],
59
+ [
60
+ "-73.9928863",
61
+ "40.7509311"
62
+ ],
63
+ [
64
+ "-73.9928068",
65
+ "40.750949"
66
+ ],
67
+ [
68
+ "-73.992721",
69
+ "40.7508515"
70
+ ],
71
+ [
72
+ "-73.9927444",
73
+ "40.7507889"
74
+ ],
75
+ [
76
+ "-73.9926693",
77
+ "40.7506457"
78
+ ],
79
+ [
80
+ "-73.9926597",
81
+ "40.7503657"
82
+ ],
83
+ [
84
+ "-73.9928305",
85
+ "40.7500953"
86
+ ],
87
+ [
88
+ "-73.9929757",
89
+ "40.7499911"
90
+ ],
91
+ [
92
+ "-73.9931281",
93
+ "40.7499238"
94
+ ],
95
+ [
96
+ "-73.993133",
97
+ "40.7498631"
98
+ ],
99
+ [
100
+ "-73.9932961",
101
+ "40.7498306"
102
+ ],
103
+ [
104
+ "-73.9933664",
105
+ "40.7498742"
106
+ ],
107
+ [
108
+ "-73.993471",
109
+ "40.7498701"
110
+ ],
111
+ [
112
+ "-73.9938023",
113
+ "40.7499263"
114
+ ],
115
+ [
116
+ "-73.9940703",
117
+ "40.7500756"
118
+ ],
119
+ [
120
+ "-73.9941876",
121
+ "40.7502038"
122
+ ],
123
+ [
124
+ "-73.9942831",
125
+ "40.7502142"
126
+ ],
127
+ [
128
+ "-73.9943346",
129
+ "40.7503638"
130
+ ]
131
+ ],
132
+ "lat": "40.7504928941818",
133
+ "lon": "-73.993466492276",
134
+ "display_name": "Madison Square Garden, West 31st Street, Long Island City, New York City, New York, 10001, United States of America",
135
+ "class": "leisure",
136
+ "type": "stadium",
137
+ "address": {
138
+ "stadium": "Madison Square Garden",
139
+ "road": "West 31st Street",
140
+ "suburb": "Long Island City",
141
+ "city": "New York City",
142
+ "county": "New York",
143
+ "state": "New York",
144
+ "postcode": "10001",
145
+ "country": "United States of America",
146
+ "country_code": "us"
147
+ }
148
+ }
149
+
150
+ ]
@@ -0,0 +1,2 @@
1
+ my_user@example.org,My User (Name)
2
+ my_private_user@example.org,My Private User Name
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Dev
5
+ # This Dummy translator recieves the field value
6
+ # and the locale of the field which has to be
7
+ # translated. It returns the appended value for both.
8
+ # This is for testing only.
9
+ class DummyTranslator
10
+ attr_reader :text, :source_locale, :target_locale, :resource, :field_name
11
+
12
+ def initialize(resource, field_name, text, target_locale, source_locale)
13
+ @resource = resource
14
+ @field_name = field_name
15
+ @text = text
16
+ @target_locale = target_locale
17
+ @source_locale = source_locale
18
+ end
19
+
20
+ def translate
21
+ translated_text = "#{target_locale} - #{text}"
22
+
23
+ MachineTranslationSaveJob.perform_later(
24
+ resource,
25
+ field_name,
26
+ target_locale,
27
+ translated_text
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
@@ -23,7 +23,11 @@ Capybara.register_driver :headless_chrome do |app|
23
23
  options = ::Selenium::WebDriver::Chrome::Options.new
24
24
  options.args << "--headless"
25
25
  options.args << "--no-sandbox"
26
- options.args << "--window-size=1024,768"
26
+ options.args << if ENV["BIG_SCREEN_SIZE"].present?
27
+ "--window-size=1920,3000"
28
+ else
29
+ "--window-size=1024,768"
30
+ end
27
31
 
28
32
  Capybara::Selenium::Driver.new(
29
33
  app,
@@ -29,6 +29,7 @@ module Decidim
29
29
  root to: proc { [200, {}, ["DUMMY ENGINE"]] }
30
30
 
31
31
  resources :dummy_resources do
32
+ resources :nested_dummy_resources
32
33
  get :foo, on: :member
33
34
  end
34
35
  end
@@ -38,6 +39,10 @@ module Decidim
38
39
  engine_name "dummy_admin"
39
40
 
40
41
  routes do
42
+ resources :dummy_resources do
43
+ resources :nested_dummy_resources
44
+ end
45
+
41
46
  root to: proc { [200, {}, ["DUMMY ADMIN ENGINE"]] }
42
47
  end
43
48
  end
@@ -53,7 +58,7 @@ module Decidim
53
58
  include Reportable
54
59
  include Authorable
55
60
  include HasCategory
56
- include ScopableComponent
61
+ include ScopableResource
57
62
  include Decidim::Comments::Commentable
58
63
  include Followable
59
64
  include Traceable
@@ -63,10 +68,12 @@ module Decidim
63
68
  include Paddable
64
69
  include Amendable
65
70
  include Decidim::NewsletterParticipant
66
- include Hashtaggable
67
71
  include ::Decidim::Endorsable
68
72
  include Decidim::HasAttachments
73
+ include Decidim::ShareableWithToken
74
+ include Decidim::TranslatableResource
69
75
 
76
+ translatable_fields :title
70
77
  searchable_fields(
71
78
  scope_id: { scope: :id },
72
79
  participatory_space: { component: :participatory_space },
@@ -99,13 +106,21 @@ module Decidim
99
106
  end
100
107
 
101
108
  def self.newsletter_participant_ids(component)
102
- Decidim::DummyResources::DummyResource.where(component: component).joins(:component)
103
- .where(decidim_author_type: Decidim::UserBaseEntity.name)
104
- .where.not(author: nil)
105
- .pluck(:decidim_author_id).flatten.compact.uniq
109
+ authors_ids = Decidim::DummyResources::DummyResource.where(component: component)
110
+ .where(decidim_author_type: Decidim::UserBaseEntity.name)
111
+ .where.not(author: nil)
112
+ .group(:decidim_author_id)
113
+ .pluck(:decidim_author_id)
114
+ commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(Decidim::DummyResources::DummyResource.where(component: component))
115
+ (authors_ids + commentators_ids).flatten.compact.uniq
106
116
  end
107
117
  end
108
118
 
119
+ class NestedDummyResource < ApplicationRecord
120
+ include Decidim::Resourceable
121
+ belongs_to :dummy_resource
122
+ end
123
+
109
124
  class CoauthorableDummyResource < ApplicationRecord
110
125
  include ::Decidim::Coauthorable
111
126
  include HasComponent
@@ -163,7 +178,10 @@ Decidim.register_component(:dummy) do |component|
163
178
  component.newsletter_participant_entities = ["Decidim::DummyResources::DummyResource"]
164
179
 
165
180
  component.settings(:global) do |settings|
181
+ settings.attribute :scopes_enabled, type: :boolean, default: false
182
+ settings.attribute :scope_id, type: :scope
166
183
  settings.attribute :comments_enabled, type: :boolean, default: true
184
+ settings.attribute :comments_max_length, type: :integer, required: false
167
185
  settings.attribute :resources_permissions_enabled, type: :boolean, default: true
168
186
  settings.attribute :dummy_global_attribute_1, type: :boolean
169
187
  settings.attribute :dummy_global_attribute_2, type: :boolean, readonly: ->(_context) { false }
@@ -195,6 +213,11 @@ Decidim.register_component(:dummy) do |component|
195
213
  resource.searchable = true
196
214
  end
197
215
 
216
+ component.register_resource(:nested_dummy_resource) do |resource|
217
+ resource.name = :nested_dummy
218
+ resource.model_class_name = "Decidim::DummyResources::NestedDummyResource"
219
+ end
220
+
198
221
  component.register_resource(:coauthorable_dummy_resource) do |resource|
199
222
  resource.name = :coauthorable_dummy
200
223
  resource.model_class_name = "Decidim::DummyResources::CoauthorableDummyResource"
@@ -226,7 +249,7 @@ RSpec.configure do |config|
226
249
  unless ActiveRecord::Base.connection.data_source_exists?("decidim_dummy_resources_dummy_resources")
227
250
  ActiveRecord::Migration.create_table :decidim_dummy_resources_dummy_resources do |t|
228
251
  t.jsonb :translatable_text
229
- t.string :title
252
+ t.jsonb :title
230
253
  t.string :body
231
254
  t.text :address
232
255
  t.float :latitude
@@ -234,6 +257,7 @@ RSpec.configure do |config|
234
257
  t.datetime :published_at
235
258
  t.integer :coauthorships_count, null: false, default: 0
236
259
  t.integer :endorsements_count, null: false, default: 0
260
+ t.integer :comments_count, null: false, default: 0
237
261
 
238
262
  t.references :decidim_component, index: false
239
263
  t.integer :decidim_author_id, index: false
@@ -246,7 +270,15 @@ RSpec.configure do |config|
246
270
  t.timestamps
247
271
  end
248
272
  end
273
+ unless ActiveRecord::Base.connection.data_source_exists?("decidim_dummy_resources_nested_dummy_resources")
274
+ ActiveRecord::Migration.create_table :decidim_dummy_resources_nested_dummy_resources do |t|
275
+ t.jsonb :translatable_text
276
+ t.string :title
249
277
 
278
+ t.references :dummy_resource, index: false
279
+ t.timestamps
280
+ end
281
+ end
250
282
  unless ActiveRecord::Base.connection.data_source_exists?("decidim_dummy_resources_coauthorable_dummy_resources")
251
283
  ActiveRecord::Migration.create_table :decidim_dummy_resources_coauthorable_dummy_resources do |t|
252
284
  t.jsonb :translatable_text
@@ -258,6 +290,7 @@ RSpec.configure do |config|
258
290
  t.datetime :published_at
259
291
  t.integer :coauthorships_count, null: false, default: 0
260
292
  t.integer :endorsements_count, null: false, default: 0
293
+ t.integer :comments_count, null: false, default: 0
261
294
 
262
295
  t.references :decidim_component, index: false
263
296
  t.references :decidim_category, index: false