decidim-initiatives 0.29.4 → 0.30.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_settings_form/show.erb +1 -1
  3. data/app/commands/decidim/initiatives/create_initiative.rb +16 -4
  4. data/app/commands/decidim/initiatives/update_initiative.rb +23 -9
  5. data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
  6. data/app/controllers/decidim/initiatives/admin/application_controller.rb +2 -0
  7. data/app/controllers/decidim/initiatives/admin/component_share_tokens_controller.rb +18 -0
  8. data/app/controllers/decidim/initiatives/admin/initiative_share_tokens_controller.rb +18 -0
  9. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +8 -8
  10. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +3 -2
  11. data/app/controllers/decidim/initiatives/initiative_types_controller.rb +1 -1
  12. data/app/controllers/decidim/initiatives/initiatives_controller.rb +3 -0
  13. data/app/forms/decidim/initiatives/admin/initiative_answer_form.rb +1 -1
  14. data/app/forms/decidim/initiatives/vote_form.rb +1 -1
  15. data/app/helpers/decidim/initiatives/initiative_helper.rb +1 -39
  16. data/app/helpers/decidim/initiatives/initiatives_helper.rb +8 -5
  17. data/app/helpers/decidim/initiatives/scopes_helper.rb +43 -0
  18. data/app/jobs/decidim/initiatives/export_initiatives_job.rb +5 -1
  19. data/app/models/decidim/initiative.rb +34 -27
  20. data/app/models/decidim/initiatives_type_scope.rb +9 -0
  21. data/app/permissions/decidim/initiatives/admin/permissions.rb +7 -0
  22. data/app/permissions/decidim/initiatives/permissions.rb +10 -3
  23. data/app/queries/decidim/initiatives/outdated_validating_initiatives.rb +1 -1
  24. data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +2 -2
  25. data/app/serializers/decidim/initiatives/download_your_data_initiative_serializer.rb +15 -0
  26. data/app/serializers/decidim/initiatives/initiative_serializer.rb +5 -24
  27. data/app/serializers/decidim/initiatives/open_data_initiative_serializer.rb +54 -0
  28. data/app/services/decidim/initiatives/data_encryptor.rb +1 -1
  29. data/app/services/decidim/initiatives/pdf_signature_example.rb +0 -2
  30. data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +1 -2
  31. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +7 -0
  32. data/app/views/decidim/initiatives/committee_requests/new.html.erb +1 -2
  33. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +3 -3
  34. data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +10 -2
  35. data/app/views/decidim/initiatives/initiatives/_form.html.erb +3 -3
  36. data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +16 -13
  37. data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +9 -3
  38. data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +0 -1
  39. data/app/views/decidim/initiatives/initiatives/show.html.erb +7 -8
  40. data/app/views/layouts/decidim/admin/_manage_initiatives.html.erb +11 -0
  41. data/app/views/layouts/decidim/admin/initiatives.html.erb +1 -9
  42. data/config/assets.rb +1 -3
  43. data/config/locales/ar.yml +7 -8
  44. data/config/locales/bg.yml +3 -22
  45. data/config/locales/ca.yml +58 -24
  46. data/config/locales/cs.yml +56 -22
  47. data/config/locales/de.yml +57 -23
  48. data/config/locales/el.yml +2 -9
  49. data/config/locales/en.yml +53 -19
  50. data/config/locales/es-MX.yml +61 -27
  51. data/config/locales/es-PY.yml +61 -27
  52. data/config/locales/es.yml +61 -27
  53. data/config/locales/eu.yml +80 -46
  54. data/config/locales/fi-plain.yml +57 -23
  55. data/config/locales/fi.yml +55 -21
  56. data/config/locales/fr-CA.yml +13 -25
  57. data/config/locales/fr.yml +13 -25
  58. data/config/locales/ga-IE.yml +0 -3
  59. data/config/locales/gl.yml +4 -12
  60. data/config/locales/hu.yml +4 -21
  61. data/config/locales/id-ID.yml +3 -9
  62. data/config/locales/is-IS.yml +1 -13
  63. data/config/locales/it.yml +4 -17
  64. data/config/locales/ja.yml +56 -22
  65. data/config/locales/lb.yml +6 -8
  66. data/config/locales/lt.yml +3 -22
  67. data/config/locales/lv.yml +2 -9
  68. data/config/locales/nl.yml +4 -13
  69. data/config/locales/no.yml +3 -13
  70. data/config/locales/pl.yml +5 -23
  71. data/config/locales/pt-BR.yml +5 -29
  72. data/config/locales/pt.yml +3 -11
  73. data/config/locales/ro-RO.yml +3 -20
  74. data/config/locales/ru.yml +1 -13
  75. data/config/locales/sk.yml +3 -9
  76. data/config/locales/sl.yml +4 -1
  77. data/config/locales/sv.yml +18 -26
  78. data/config/locales/tr-TR.yml +5 -13
  79. data/config/locales/uk.yml +1 -13
  80. data/config/locales/zh-CN.yml +2 -10
  81. data/config/locales/zh-TW.yml +3 -21
  82. data/db/migrate/20241127104718_add_taxonomy_to_initiatives_type_scope.rb +7 -0
  83. data/decidim-initiatives.gemspec +1 -3
  84. data/lib/decidim/api/initiative_api_type.rb +9 -10
  85. data/lib/decidim/api/initiative_committee_member_type.rb +3 -4
  86. data/lib/decidim/api/initiative_type.rb +15 -21
  87. data/lib/decidim/api/initiative_type_interface.rb +1 -5
  88. data/lib/decidim/exporters/initiative_votes_pdf.rb +163 -0
  89. data/lib/decidim/initiatives/admin_engine.rb +68 -49
  90. data/lib/decidim/initiatives/application_form_pdf.rb +181 -0
  91. data/lib/decidim/initiatives/engine.rb +6 -0
  92. data/lib/decidim/initiatives/menu.rb +8 -0
  93. data/lib/decidim/initiatives/participatory_space.rb +8 -1
  94. data/lib/decidim/initiatives/test/factories.rb +5 -8
  95. data/lib/decidim/initiatives/version.rb +1 -1
  96. data/lib/decidim/initiatives.rb +7 -1
  97. metadata +25 -60
  98. data/app/cells/decidim/initiatives_votes/vote/show.erb +0 -39
  99. data/app/cells/decidim/initiatives_votes/vote_cell.rb +0 -58
  100. data/app/packs/entrypoints/decidim_initiatives_initiatives_votes.js +0 -1
  101. data/app/packs/entrypoints/decidim_initiatives_initiatives_votes.scss +0 -1
  102. data/app/packs/entrypoints/decidim_initiatives_print.js +0 -1
  103. data/app/packs/entrypoints/decidim_initiatives_print.scss +0 -1
  104. data/app/packs/stylesheets/decidim/initiatives/initiatives-votes.scss +0 -96
  105. data/app/packs/stylesheets/decidim/initiatives/print-initiative.scss +0 -172
  106. data/app/views/decidim/initiatives/admin/initiatives/_signatures.html.erb +0 -87
  107. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.html.erb +0 -8
  108. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +0 -5
  109. data/app/views/decidim/initiatives/initiatives/_linked_initiatives.html.erb +0 -0
  110. data/app/views/decidim/initiatives/initiatives/print.html.erb +0 -161
  111. data/app/views/layouts/decidim/admin/initiatives_votes.pdf.erb +0 -11
  112. data/config/initializers/wicked_pdf.rb +0 -22
  113. data/config/locales/ca-IT.yml +0 -628
@@ -72,7 +72,6 @@ zh-CN:
72
72
  accepted: 足够的签名
73
73
  created: 已创建
74
74
  discarded: 丢弃的
75
- published: 已发布
76
75
  rejected: 签名不足
77
76
  validating: 技术验证
78
77
  type_id_eq:
@@ -114,8 +113,6 @@ zh-CN:
114
113
  initiative_title: 倡议标题
115
114
  name_and_surname: 姓名:
116
115
  postal_code: 邮政编码
117
- scope: 范围
118
- time_and_date: 时间和日期
119
116
  timestamp: 时间戳
120
117
  titles:
121
118
  initiatives: 倡议
@@ -150,8 +147,8 @@ zh-CN:
150
147
  badges:
151
148
  initiatives:
152
149
  conditions:
153
- - 转到Intiatives的参与空间
154
- - 跟随步骤创建新的倡议
150
+ - 转到Intiatives的参与空间
151
+ - 跟随步骤创建新的倡议
155
152
  description: 当你发起新的倡议,与其他人合作执行这些倡议时,将颁发这个徽章。
156
153
  description_another: 此参与者已经发布了 %{score} 项倡议。
157
154
  name: 已发布的活动
@@ -238,7 +235,6 @@ zh-CN:
238
235
  accepted: 足够的签名
239
236
  created: 已创建
240
237
  discarded: 丢弃的
241
- published: 已发布
242
238
  rejected: 签名不足
243
239
  validating: 技术验证
244
240
  application_helper:
@@ -344,14 +340,12 @@ zh-CN:
344
340
  recently_published: 最近发布的
345
341
  print:
346
342
  city: 城市
347
- print: 打印
348
343
  result:
349
344
  initiative_rejected_reason: 这项倡议由于没有签字而被拒绝。
350
345
  signatures_count:
351
346
  other: " 签名"
352
347
  vote_cabin:
353
348
  already_voted: 已签名
354
- verification_required: 验证您的帐户以签署倡议
355
349
  vote: 签名
356
350
  votes_blocked: 签名已禁用
357
351
  votes_count:
@@ -378,7 +372,6 @@ zh-CN:
378
372
  accepted: 足够的签名
379
373
  created: 已创建
380
374
  discarded: 丢弃的
381
- published: 已发布
382
375
  rejected: 签名不足
383
376
  validating: 技术验证
384
377
  states:
@@ -390,7 +383,6 @@ zh-CN:
390
383
  resources:
391
384
  initiatives_type:
392
385
  actions:
393
- create: 创建
394
386
  title: 行动
395
387
  vote: 签名
396
388
  layouts:
@@ -88,7 +88,6 @@ zh-TW:
88
88
  accepted: 足夠的簽署數
89
89
  created: 已建立
90
90
  discarded: 已捨棄
91
- published: 已發佈
92
91
  rejected: 不足夠的簽署數
93
92
  validating: 技術驗證
94
93
  type_id_eq:
@@ -97,7 +96,6 @@ zh-TW:
97
96
  title_or_description_or_id_string_or_author_name_or_author_nickname_cont: 透過標題、描述、ID 或作者姓名搜尋 %{collection}
98
97
  initiatives_settings:
99
98
  update:
100
- error: 出現了一個錯誤.
101
99
  success: 倡議設定已成功更新.
102
100
  menu:
103
101
  attachments: 附件
@@ -138,8 +136,6 @@ zh-TW:
138
136
  initiative_title: 倡議標題
139
137
  name_and_surname: 名字與姓氏
140
138
  postal_code: 郵政編碼
141
- scope: 範圍
142
- time_and_date: 時間與日期
143
139
  timestamp: 時間戳記
144
140
  titles:
145
141
  initiatives: 倡議
@@ -182,8 +178,8 @@ zh-TW:
182
178
  badges:
183
179
  initiatives:
184
180
  conditions:
185
- - 前往倡議參與空間
186
- - '"按照以下步驟創建新的倡議'
181
+ - 前往倡議參與空間
182
+ - '"按照以下步驟創建新的倡議'
187
183
  description: 此徽章是當你發起新的倡議,與他人合作進行時所授予的。
188
184
  description_another: 該參與者已成功發佈 %{score} 項倡議。
189
185
  description_own: 你已經發佈了 %{score} 項倡議。
@@ -253,7 +249,6 @@ zh-TW:
253
249
  new: 新的
254
250
  photos: 圖片
255
251
  update:
256
- error: 出現了一個錯誤.
257
252
  success: 倡議已成功更新.
258
253
  initiatives_settings:
259
254
  edit:
@@ -267,7 +262,6 @@ zh-TW:
267
262
  title: 倡議設定
268
263
  initiatives_type_scopes:
269
264
  create:
270
- error: 出現了一個錯誤.
271
265
  success: 已為給定的倡議類型建立新範圍.
272
266
  destroy:
273
267
  success: 範圍已成功刪除.
@@ -278,11 +272,8 @@ zh-TW:
278
272
  create: 建立
279
273
  title: 建立倡議類型範圍
280
274
  update:
281
- error: 出現了一個錯誤.
282
275
  success: 範圍已成功更新.
283
276
  initiatives_types:
284
- create:
285
- error: 出現了一個錯誤.
286
277
  destroy:
287
278
  success: 該倡議類型已成功刪除.
288
279
  edit:
@@ -296,7 +287,6 @@ zh-TW:
296
287
  create: 建立
297
288
  title: 新的倡議類型
298
289
  update:
299
- error: 出現了一個錯誤.
300
290
  success: 該倡議類型已成功更新.
301
291
  admin_log:
302
292
  initiative:
@@ -314,7 +304,6 @@ zh-TW:
314
304
  accepted: 足夠的簽署數
315
305
  created: 已建立
316
306
  discarded: 已捨棄
317
- published: 已發佈
318
307
  rejected: 不足夠的簽署數
319
308
  validating: 技術驗證
320
309
  application_helper:
@@ -351,6 +340,7 @@ zh-TW:
351
340
  finish:
352
341
  back: 返回
353
342
  back_to_initiatives: 回到倡議
343
+ callout_text: 恭喜您!您的倡議已成功建立。
354
344
  confirm: 您即將發送倡議給管理員進行審核和發佈。一旦發佈,您將無法編輯它。您確定要繼續嗎?"
355
345
  edit_my_initiative: 編輯我的倡議
356
346
  go_to_my_initiatives: 前往我的倡議
@@ -409,8 +399,6 @@ zh-TW:
409
399
  email_outro: '你收到這個通知是因為你是該倡議 %{resource_title} 的作者。'
410
400
  email_subject: "%{applicant_nickname} 想加入你的倡議"
411
401
  notification_title: <a href="%{applicant_profile_url}">%{applicant_nickname}</a> 申請加入你的倡議 <a href="%{resource_url}">%{resource_title}</a> 的推動委員會。點擊<a href="%{resource_url}/edit">這裡</a>接受或拒絕申請。
412
- form:
413
- attachment_legend: "(可選) 新增附件"
414
402
  index:
415
403
  uninitialized: 尚未由管理員設置倡議。
416
404
  initiative_signatures:
@@ -491,9 +479,7 @@ zh-TW:
491
479
  phone_number: 電話號碼
492
480
  place_date: 地點、日期
493
481
  postal_code: 郵遞區號/郵政編碼
494
- print: 列印
495
482
  province: 省份/州
496
- section: '如果組織要求,請打印並填寫此表格,並按指示提交:'
497
483
  signature: 簽名
498
484
  result:
499
485
  answer_title: 這個倡議已經有回應了。
@@ -506,7 +492,6 @@ zh-TW:
506
492
  other: " 簽名"
507
493
  vote_cabin:
508
494
  already_voted: 已簽署
509
- verification_required: 驗證您的帳戶以簽署該倡議
510
495
  vote: 簽署
511
496
  votes_blocked: 簽署已禁用
512
497
  votes_count:
@@ -535,7 +520,6 @@ zh-TW:
535
520
  accepted: 足夠的簽署數
536
521
  created: 已建立
537
522
  discarded: 已捨棄
538
- published: 已發佈
539
523
  rejected: 簽署數不足
540
524
  validating: 技術驗證
541
525
  states:
@@ -543,7 +527,6 @@ zh-TW:
543
527
  expired: 已過期
544
528
  unavailable_scope: 不可用的範圍
545
529
  update:
546
- error: 出現了一個錯誤.
547
530
  success: 倡議已成功更新.
548
531
  menu:
549
532
  initiatives: 倡議
@@ -553,7 +536,6 @@ zh-TW:
553
536
  comment: 評論
554
537
  initiatives_type:
555
538
  actions:
556
- create: 建立
557
539
  title: 操作
558
540
  vote: 簽署
559
541
  layouts:
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddTaxonomyToInitiativesTypeScope < ActiveRecord::Migration[7.0]
4
+ def change
5
+ add_reference :decidim_initiatives_type_scopes, :decidim_taxonomy, index: true
6
+ end
7
+ end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  "homepage_uri" => "https://decidim.org",
18
18
  "source_code_uri" => "https://github.com/decidim/decidim"
19
19
  }
20
- s.required_ruby_version = "~> 3.2.0"
20
+ s.required_ruby_version = "~> 3.3.0"
21
21
 
22
22
  s.name = "decidim-initiatives"
23
23
  s.summary = "Decidim initiatives module"
@@ -34,8 +34,6 @@ Gem::Specification.new do |s|
34
34
  s.add_dependency "decidim-comments", Decidim::Initiatives.version
35
35
  s.add_dependency "decidim-core", Decidim::Initiatives.version
36
36
  s.add_dependency "decidim-verifications", Decidim::Initiatives.version
37
- s.add_dependency "hexapdf", "~> 0.32.0"
38
- s.add_dependency "wicked_pdf", "~> 2.1"
39
37
 
40
38
  s.add_development_dependency "decidim-dev", Decidim::Initiatives.version
41
39
  s.add_development_dependency "decidim-meetings", Decidim::Initiatives.version
@@ -3,24 +3,23 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  class InitiativeApiType < Decidim::Api::Types::BaseObject
6
+ implements Decidim::Core::TimestampsInterface
7
+
6
8
  graphql_name "InitiativeType"
7
9
  description "An initiative type"
8
10
 
9
- field :id, GraphQL::Types::ID, "The internal ID for this initiative type", null: false
10
- field :title, Decidim::Core::TranslatedFieldType, "Initiative type name", null: true
11
- field :description, Decidim::Core::TranslatedFieldType, "This is the initiative type description", null: true
12
- field :created_at, Decidim::Core::DateTimeType, "The date this initiative type was created", null: true
13
- field :updated_at, Decidim::Core::DateTimeType, "The date this initiative type was updated", null: true
14
11
  field :banner_image, GraphQL::Types::String, "Banner image", null: true
15
12
  field :collect_user_extra_fields, GraphQL::Types::Boolean, "Collect participant personal data on signature", null: true
13
+ field :description, Decidim::Core::TranslatedFieldType, "This is the initiative type description", null: true
16
14
  field :extra_fields_legal_information, GraphQL::Types::String, "Legal information about the collection of personal data", null: true
15
+ field :id, GraphQL::Types::ID, "The internal ID for this initiative type", null: false
16
+ field :initiatives, [Decidim::Initiatives::InitiativeType, { null: true }], "The initiatives that have this type", null: false
17
17
  field :minimum_committee_members, GraphQL::Types::Int, "Minimum of committee members", null: true
18
- field :validate_sms_code_on_votes, GraphQL::Types::Boolean, "Add SMS code validation step to signature process", null: true
19
- field :undo_online_signatures_enabled, GraphQL::Types::Boolean, "Enable participants to undo their online signatures", null: true
20
- field :promoting_committee_enabled, GraphQL::Types::Boolean, "If promoting committee is enabled", method: :promoting_committee_enabled, null: true
18
+ field :promoting_committee_enabled, GraphQL::Types::Boolean, "If promoting committee is enabled", null: true
21
19
  field :signature_type, GraphQL::Types::String, "Signature type of the initiative", null: true
22
-
23
- field :initiatives, [Decidim::Initiatives::InitiativeType, { null: true }], "The initiatives that have this type", null: false
20
+ field :title, Decidim::Core::TranslatedFieldType, "Initiative type name", null: true
21
+ field :undo_online_signatures_enabled, GraphQL::Types::Boolean, "Enable participants to undo their online signatures", null: true
22
+ field :validate_sms_code_on_votes, GraphQL::Types::Boolean, "Add SMS code validation step to signature process", null: true
24
23
 
25
24
  def banner_image
26
25
  object.attached_uploader(:banner_image).url
@@ -4,15 +4,14 @@ module Decidim
4
4
  module Initiatives
5
5
  # This type represents an initiative committee member.
6
6
  class InitiativeCommitteeMemberType < Decidim::Api::Types::BaseObject
7
+ implements Decidim::Core::TimestampsInterface
8
+
7
9
  graphql_name "InitiativeCommitteeMemberType"
8
10
  description "An initiative committee member"
9
11
 
10
12
  field :id, GraphQL::Types::ID, "Internal ID for this member of the committee", null: false
11
- field :user, Decidim::Core::UserType, "The decidim user for this initiative committee member", null: true
12
-
13
13
  field :state, GraphQL::Types::String, "Type of the committee member", null: true
14
- field :created_at, Decidim::Core::DateTimeType, "The date this initiative committee member was created", null: true
15
- field :updated_at, Decidim::Core::DateTimeType, "The date this initiative committee member was updated", null: true
14
+ field :user, Decidim::Core::UserType, "The decidim user for this initiative committee member", null: true
16
15
  end
17
16
  end
18
17
  end
@@ -12,38 +12,32 @@ module Decidim
12
12
 
13
13
  description "A initiative"
14
14
 
15
+ field :author, Decidim::Core::AuthorInterface, "The initiative author", null: false
16
+ field :committee_members, [Decidim::Initiatives::InitiativeCommitteeMemberType, { null: true }], "The committee members list", null: true
15
17
  field :description, Decidim::Core::TranslatedFieldType, "The description of this initiative.", null: true
16
- field :slug, GraphQL::Types::String, null: false
17
18
  field :hashtag, GraphQL::Types::String, "The hashtag for this initiative", null: true
18
- field :published_at, Decidim::Core::DateTimeType, "The time this initiative was published", null: false
19
- field :reference, GraphQL::Types::String, "Reference prefix for this initiative", null: false
20
- field :state, GraphQL::Types::String, "Current status of the initiative", null: true
21
- field :signature_type, GraphQL::Types::String, "Signature type of the initiative", null: true
22
- field :signature_start_date, Decidim::Core::DateType, "The signature start date", null: false
23
- field :signature_end_date, Decidim::Core::DateType, "The signature end date", null: false
24
- field :offline_votes, GraphQL::Types::Int, "The number of offline votes in this initiative", method: :offline_votes_count, null: true
25
- field :online_votes, GraphQL::Types::Int, "The number of online votes in this initiative", method: :online_votes_count, null: true
26
- field :initiative_votes_count, GraphQL::Types::Int,
27
- description: "The number of votes in this initiative",
28
- deprecation_reason: "initiativeVotesCount has been collapsed in onlineVotes parameter",
29
- null: true
30
19
  field :initiative_supports_count, GraphQL::Types::Int,
31
20
  description: "The number of supports in this initiative",
32
21
  method: :online_votes_count,
33
22
  deprecation_reason: "initiativeSupportsCount has been collapsed in onlineVotes parameter",
34
23
  null: true
35
-
36
- field :author, Decidim::Core::AuthorInterface, "The initiative author", null: false
37
-
38
- def initiative_votes_count
39
- object.online_votes_count
40
- end
24
+ field :initiative_votes_count, GraphQL::Types::Int,
25
+ description: "The number of votes in this initiative",
26
+ deprecation_reason: "initiativeVotesCount has been collapsed in onlineVotes parameter",
27
+ null: true, method: :online_votes_count
28
+ field :offline_votes, GraphQL::Types::Int, "The number of offline votes in this initiative", method: :offline_votes_count, null: true
29
+ field :online_votes, GraphQL::Types::Int, "The number of online votes in this initiative", method: :online_votes_count, null: true
30
+ field :published_at, Decidim::Core::DateTimeType, "The time this initiative was published", null: false
31
+ field :reference, GraphQL::Types::String, "Reference prefix for this initiative", null: false
32
+ field :signature_end_date, Decidim::Core::DateType, "The signature end date", null: false
33
+ field :signature_start_date, Decidim::Core::DateType, "The signature start date", null: false
34
+ field :signature_type, GraphQL::Types::String, "Signature type of the initiative", null: true
35
+ field :slug, GraphQL::Types::String, "The slug of the initiative", null: false
36
+ field :state, GraphQL::Types::String, "Current status of the initiative", null: true
41
37
 
42
38
  def author
43
39
  object.user_group || object.author
44
40
  end
45
-
46
- field :committee_members, [Decidim::Initiatives::InitiativeCommitteeMemberType, { null: true }], null: true
47
41
  end
48
42
  end
49
43
  end
@@ -8,11 +8,7 @@ module Decidim
8
8
  include Decidim::Api::Types::BaseInterface
9
9
  description "An interface that can be used in Initiative objects."
10
10
 
11
- field :initiative_type, Decidim::Initiatives::InitiativeApiType, "The object's initiative type", null: true
12
-
13
- def initiative_type
14
- object.type
15
- end
11
+ field :initiative_type, Decidim::Initiatives::InitiativeApiType, "The object's initiative type", null: true, method: :type
16
12
  end
17
13
  end
18
14
  end
@@ -0,0 +1,163 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Exporters
5
+ # Inherits from abstract PDF exporter. This class is used to set
6
+ # the parameters used to create a PDF when exporting Survey Answers.
7
+ #
8
+ class InitiativeVotesPDF < PDF
9
+ def initialize(collection, initiative, serializer = Serializer)
10
+ @initiative = initiative
11
+ super(collection, serializer)
12
+ end
13
+
14
+ protected
15
+
16
+ attr_reader :initiative
17
+
18
+ def page_orientation
19
+ :landscape
20
+ end
21
+
22
+ def add_data!
23
+ composer.formatted_text([translated_attribute(initiative.title)], style: :initiative_title)
24
+
25
+ add_initiative_data
26
+ add_signature_data
27
+ end
28
+
29
+ def styles
30
+ {
31
+ initiative_title: { font: bold_font, text_align: :center, font_size: 12, margin: [0, 0, 10, 0] },
32
+ initiative_th: { font: bold_font, font_size: 10 },
33
+ initiative_td: { font:, font_size: 10 },
34
+ vote_th: { font: bold_font, font_size: 11 },
35
+ vote_td: { font:, font_size: 10 }
36
+ }
37
+ end
38
+
39
+ def add_initiative_data
40
+ data_header = [
41
+ layout.text(I18n.t("models.initiatives_votes.fields.initiative_id", scope: "decidim.admin"), style: :initiative_th),
42
+ layout.text(I18n.t("models.initiatives_votes.fields.initiative_title", scope: "decidim.admin"), style: :initiative_th),
43
+ layout.text(I18n.t("models.initiatives_votes.fields.initiative_start_date", scope: "decidim.admin"), style: :initiative_th),
44
+ layout.text(I18n.t("models.initiatives_votes.fields.initiative_end_date", scope: "decidim.admin"), style: :initiative_th),
45
+ layout.text(I18n.t("models.initiatives_votes.fields.initiative_signatures_count", scope: "decidim.admin"), style: :initiative_th),
46
+ layout.text(I18n.t("models.initiatives_votes.fields.initiative_scope", scope: "decidim.admin"), style: :initiative_th)
47
+ ]
48
+
49
+ data_row = [
50
+ layout.text(initiative.reference, style: :initiative_td),
51
+ layout.text(translated_attribute(initiative.title), style: :initiative_td),
52
+ layout.text(I18n.l(initiative.signature_start_date, format: :long), style: :initiative_td),
53
+ layout.text(I18n.l(initiative.signature_end_date, format: :long), style: :initiative_td),
54
+ layout.text(collection.count.to_s, style: :initiative_td),
55
+ layout.text(scope(initiative), style: :initiative_td)
56
+ ]
57
+
58
+ column_widths = [-1, -1.75, -0.55, -0.55, -1, -1]
59
+
60
+ cells = [
61
+ [layout.table([data_header], column_widths:, cell_style: row_style)],
62
+ [layout.table([data_row], column_widths:, cell_style: row_style)]
63
+ ]
64
+ composer.table(cells, cell_style:)
65
+ end
66
+
67
+ def add_signature_data
68
+ cells = [[layout.table([header], column_widths: signature_column_widths, cell_style: row_style)]]
69
+
70
+ collection.map.with_index do |vote, index|
71
+ cells.push([layout.table(vote_row(vote, index), column_widths: signature_column_widths, cell_style: row_style)])
72
+ end
73
+
74
+ composer.table(cells, margin: [20, 0, 0, 0], cell_style:)
75
+ end
76
+
77
+ def signature_column_widths
78
+ if collect_user_extra_fields
79
+ [-0.5, -1, -0.75, -0.75, -0.75, -0.75, -0.75, -0.5, -0.75]
80
+ else
81
+ [-0.5, -1, -0.75, -0.75, -0.75]
82
+ end
83
+ end
84
+
85
+ def vote_row(model, index)
86
+ cell = [
87
+ layout.text((index + 1).to_s, style: :vote_td),
88
+ layout.text(model.author.nickname, style: :vote_td),
89
+ layout.text(I18n.l(model.created_at, format: "%Y-%m-%d %H:%M:%S %Z"), style: :vote_td),
90
+ layout.text(truncate(model.hash_id), style: :vote_td)
91
+ ]
92
+
93
+ if collect_user_extra_fields
94
+ metadata ||= model.encrypted_metadata ? encryptor.decrypt(model.encrypted_metadata) : {}
95
+
96
+ cell += [
97
+ layout.text(metadata[:name_and_surname].presence || "", style: :vote_td),
98
+ layout.text(metadata[:document_number].presence || "", style: :vote_td),
99
+ layout.text(metadata[:date_of_birth].presence || "", style: :vote_td),
100
+ layout.text(metadata[:postal_code].presence || "", style: :vote_td)
101
+ ]
102
+ end
103
+
104
+ cell += [
105
+ layout.text(truncate(model.timestamp.presence || ""), style: :vote_td)
106
+ ]
107
+ [cell]
108
+ end
109
+
110
+ def scope(model)
111
+ return I18n.t("decidim.initiatives.unavailable_scope") if model.scope.blank?
112
+
113
+ translated_attribute(model.scope.name)
114
+ end
115
+
116
+ def header
117
+ header = [
118
+ layout.text(I18n.t("models.initiatives_votes.fields.signature_count", scope: "decidim.admin"), style: :vote_th),
119
+ layout.text(I18n.t("models.initiatives_votes.fields.nickname", scope: "decidim.admin"), style: :vote_th),
120
+ layout.text(I18n.t("models.initiatives_votes.fields.date_and_time", scope: "decidim.admin"), style: :vote_th),
121
+ layout.text(I18n.t("models.initiatives_votes.fields.hash", scope: "decidim.admin"), style: :vote_th)
122
+ ]
123
+
124
+ if collect_user_extra_fields
125
+ header += [
126
+ layout.text(I18n.t("models.initiatives_votes.fields.name_and_surname", scope: "decidim.admin"), style: :vote_th),
127
+ layout.text(I18n.t("models.initiatives_votes.fields.document_number", scope: "decidim.admin"), style: :vote_th),
128
+ layout.text(I18n.t("models.initiatives_votes.fields.date_of_birth", scope: "decidim.admin"), style: :vote_th),
129
+ layout.text(I18n.t("models.initiatives_votes.fields.postal_code", scope: "decidim.admin"), style: :vote_th)
130
+ ]
131
+ end
132
+
133
+ header += [
134
+ layout.text(I18n.t("models.initiatives_votes.fields.timestamp", scope: "decidim.admin"), style: :vote_th)
135
+ ]
136
+ header
137
+ end
138
+
139
+ def collect_user_extra_fields = initiative.type.collect_user_extra_fields
140
+
141
+ def cell_style
142
+ lambda do |cell|
143
+ cell.style.margin = 0
144
+ cell.style.padding = 0
145
+ cell.style.border(width: 1)
146
+ cell.style.background_color = "cccccc" if cell.row.zero?
147
+ end
148
+ end
149
+
150
+ def encryptor
151
+ @encryptor ||= Decidim::Initiatives::DataEncryptor.new(secret: "personal user metadata")
152
+ end
153
+
154
+ def truncate(text, length = 50)
155
+ text.truncate(length)
156
+ end
157
+
158
+ def row_style
159
+ { margin: 0, padding: [10, 0, 10, 5], border: { width: 0 } }
160
+ end
161
+ end
162
+ end
163
+ end
@@ -15,75 +15,94 @@ module Decidim
15
15
  paths["lib/tasks"] = nil
16
16
 
17
17
  routes do
18
- resources :initiatives_types, except: :show do
19
- resource :permissions, controller: "initiatives_types_permissions"
20
- resources :initiatives_type_scopes, except: [:index, :show]
21
- end
22
-
23
- resources :initiatives_settings, only: [:edit, :update], controller: "initiatives_settings"
24
-
25
- resources :initiatives, only: [:index, :edit, :update], param: :slug do
26
- member do
27
- get :send_to_technical_validation
28
- post :publish
29
- delete :unpublish
30
- delete :discard
31
- get :export_votes
32
- get :export_pdf_signatures
33
- post :accept
34
- delete :reject
18
+ constraints(->(request) { Decidim::Admin::OrganizationDashboardConstraint.new(request).matches? }) do
19
+ resources :initiatives_types, except: :show do
20
+ resource :permissions, controller: "initiatives_types_permissions"
21
+ resources :initiatives_type_scopes, except: [:index, :show]
35
22
  end
36
23
 
37
- collection do
38
- get :export
39
- end
24
+ resources :initiatives_settings, only: [:edit, :update], controller: "initiatives_settings"
40
25
 
41
- resources :attachments, controller: "initiative_attachments", except: [:show]
42
-
43
- resources :committee_requests, only: [:index] do
26
+ resources :initiatives, only: [:index, :edit, :update], param: :slug do
44
27
  member do
45
- get :approve
46
- delete :revoke
28
+ get :send_to_technical_validation
29
+ post :publish
30
+ delete :unpublish
31
+ delete :discard
32
+ get :export_votes
33
+ get :export_pdf_signatures
34
+ post :accept
35
+ delete :reject
47
36
  end
48
- end
49
37
 
50
- resource :permissions, controller: "initiatives_permissions"
38
+ collection do
39
+ get :export
40
+ end
51
41
 
52
- resource :answer, only: [:edit, :update]
53
- end
42
+ resources :attachments, controller: "initiative_attachments", except: [:show]
54
43
 
55
- scope "/initiatives/:initiative_slug" do
56
- resources :components do
57
- resource :permissions, controller: "component_permissions"
58
- member do
59
- put :publish
60
- put :unpublish
61
- get :share
44
+ resources :committee_requests, only: [:index] do
45
+ member do
46
+ get :approve
47
+ delete :revoke
48
+ end
62
49
  end
63
- resources :exports, only: :create
50
+
51
+ resource :permissions, controller: "initiatives_permissions"
52
+
53
+ resource :answer, only: [:edit, :update]
64
54
  end
65
55
 
66
- resources :moderations do
67
- member do
68
- put :unreport
69
- put :hide
70
- put :unhide
56
+ scope "/initiatives/:initiative_slug" do
57
+ resources :components do
58
+ collection do
59
+ put :reorder
60
+ get :manage_trash, to: "components#manage_trash"
61
+ end
62
+ resource :permissions, controller: "component_permissions"
63
+ member do
64
+ put :publish
65
+ put :unpublish
66
+ get :share
67
+ put :hide
68
+ patch :soft_delete
69
+ patch :restore
70
+ end
71
+ resources :component_share_tokens, except: [:show], path: "share_tokens", as: "share_tokens"
72
+ resources :exports, only: :create
71
73
  end
72
- resources :reports, controller: "moderations/reports", only: [:index, :show]
74
+
75
+ resources :moderations do
76
+ member do
77
+ put :unreport
78
+ put :hide
79
+ put :unhide
80
+ end
81
+ patch :bulk_action, on: :collection
82
+ resources :reports, controller: "moderations/reports", only: [:index, :show]
83
+ end
84
+
85
+ resources :initiative_share_tokens, except: [:show], path: "share_tokens"
73
86
  end
74
- end
75
87
 
76
- scope "/initiatives/:initiative_slug/components/:component_id/manage" do
77
- Decidim.component_manifests.each do |manifest|
78
- next unless manifest.admin_engine
88
+ scope "/initiatives/:initiative_slug/components/:component_id/manage" do
89
+ Decidim.component_manifests.each do |manifest|
90
+ next unless manifest.admin_engine
79
91
 
80
- constraints CurrentComponent.new(manifest) do
81
- mount manifest.admin_engine, at: "/", as: "decidim_admin_initiative_#{manifest.name}"
92
+ constraints CurrentComponent.new(manifest) do
93
+ mount manifest.admin_engine, at: "/", as: "decidim_admin_initiative_#{manifest.name}"
94
+ end
82
95
  end
83
96
  end
84
97
  end
85
98
  end
86
99
 
100
+ initializer "decidim_initiatives_admin.mount_routes" do |_app|
101
+ Decidim::Core::Engine.routes do
102
+ mount Decidim::Initiatives::AdminEngine, at: "/admin", as: "decidim_admin_initiatives"
103
+ end
104
+ end
105
+
87
106
  initializer "decidim_initiatives_admin.menu" do
88
107
  Decidim::Initiatives::Menu.register_admin_menu_modules!
89
108
  Decidim::Initiatives::Menu.register_admin_initiatives_components_menu!