decidim-initiatives 0.27.4 → 0.28.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -3
  3. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +17 -18
  4. data/app/cells/decidim/initiatives/initiative_cell.rb +6 -1
  5. data/app/cells/decidim/initiatives/initiative_dropdown_metadata_cell.rb +19 -0
  6. data/app/cells/decidim/initiatives/initiative_g_cell.rb +31 -0
  7. data/app/cells/decidim/initiatives/initiative_metadata_g_cell.rb +62 -0
  8. data/app/cells/decidim/initiatives/initiative_s_cell.rb +15 -0
  9. data/app/cells/decidim/initiatives_votes/vote/show.erb +25 -19
  10. data/app/cells/decidim/initiatives_votes/vote_cell.rb +3 -1
  11. data/app/commands/decidim/initiatives/admin/accept_initiative.rb +40 -0
  12. data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +1 -1
  13. data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +1 -1
  14. data/app/commands/decidim/initiatives/admin/discard_initiative.rb +40 -0
  15. data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
  16. data/app/commands/decidim/initiatives/admin/reject_initiative.rb +40 -0
  17. data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +2 -2
  18. data/app/commands/decidim/initiatives/admin/unpublish_initiative.rb +1 -1
  19. data/app/commands/decidim/initiatives/admin/update_initiative.rb +1 -1
  20. data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +1 -1
  21. data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +1 -1
  22. data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
  23. data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +1 -1
  24. data/app/commands/decidim/initiatives/attachment_methods.rb +2 -24
  25. data/app/commands/decidim/initiatives/create_initiative.rb +19 -14
  26. data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +2 -2
  27. data/app/commands/decidim/initiatives/spawn_committee_request.rb +1 -1
  28. data/app/commands/decidim/initiatives/unvote_initiative.rb +1 -1
  29. data/app/commands/decidim/initiatives/update_initiative.rb +9 -2
  30. data/app/commands/decidim/initiatives/validate_mobile_phone.rb +2 -2
  31. data/app/commands/decidim/initiatives/vote_initiative.rb +5 -5
  32. data/app/constraints/decidim/initiatives/current_initiative.rb +1 -1
  33. data/app/controllers/concerns/decidim/initiatives/admin/filterable.rb +2 -2
  34. data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
  35. data/app/controllers/decidim/initiatives/admin/answers_controller.rb +3 -0
  36. data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +2 -0
  37. data/app/controllers/decidim/initiatives/admin/components_controller.rb +3 -0
  38. data/app/controllers/decidim/initiatives/admin/initiative_attachments_controller.rb +2 -0
  39. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +17 -6
  40. data/app/controllers/decidim/initiatives/admin/initiatives_permissions_controller.rb +3 -0
  41. data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +2 -0
  42. data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +30 -0
  43. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +14 -0
  44. data/app/controllers/decidim/initiatives/admin/initiatives_types_permissions_controller.rb +21 -0
  45. data/app/controllers/decidim/initiatives/admin/moderations/reports_controller.rb +2 -2
  46. data/app/controllers/decidim/initiatives/admin/moderations_controller.rb +4 -2
  47. data/app/controllers/decidim/initiatives/application_controller.rb +0 -1
  48. data/app/controllers/decidim/initiatives/authorization_create_modals_controller.rb +25 -0
  49. data/app/controllers/decidim/initiatives/authorization_sign_modals_controller.rb +2 -2
  50. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +0 -2
  51. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +62 -115
  52. data/app/controllers/decidim/initiatives/initiative_signatures_controller.rb +113 -81
  53. data/app/controllers/decidim/initiatives/initiative_types_controller.rb +7 -0
  54. data/app/controllers/decidim/initiatives/initiatives_controller.rb +37 -17
  55. data/app/controllers/decidim/initiatives/versions_controller.rb +0 -1
  56. data/app/events/decidim/initiatives/admin/initiative_sent_to_technical_validation_event.rb +1 -1
  57. data/app/events/decidim/initiatives/admin/support_threshold_reached_event.rb +1 -1
  58. data/app/events/decidim/initiatives/approve_membership_request_event.rb +12 -12
  59. data/app/events/decidim/initiatives/create_initiative_event.rb +6 -6
  60. data/app/events/decidim/initiatives/endorse_initiative_event.rb +1 -1
  61. data/app/events/decidim/initiatives/extend_initiative_event.rb +1 -1
  62. data/app/events/decidim/initiatives/initiative_sent_to_technical_validation_event.rb +1 -1
  63. data/app/events/decidim/initiatives/milestone_completed_event.rb +1 -1
  64. data/app/events/decidim/initiatives/revoke_membership_request_event.rb +12 -12
  65. data/app/events/decidim/initiatives/spawn_committee_request_event.rb +12 -12
  66. data/app/forms/decidim/initiatives/admin/initiative_form.rb +1 -1
  67. data/app/forms/decidim/initiatives/initiative_form.rb +22 -31
  68. data/app/forms/decidim/initiatives/previous_form.rb +4 -0
  69. data/app/forms/decidim/initiatives/vote_form.rb +11 -11
  70. data/app/helpers/decidim/initiatives/admin/initiatives_helper.rb +1 -1
  71. data/app/helpers/decidim/initiatives/application_helper.rb +4 -61
  72. data/app/helpers/decidim/initiatives/initiative_helper.rb +48 -5
  73. data/app/helpers/decidim/initiatives/initiatives_helper.rb +33 -12
  74. data/app/jobs/decidim/initiatives/export_initiatives_job.rb +1 -1
  75. data/app/models/decidim/initiative.rb +17 -20
  76. data/app/models/decidim/initiatives_vote.rb +1 -1
  77. data/app/packs/entrypoints/decidim_initiatives.js +3 -0
  78. data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_initiatives.svg +42 -1
  79. data/app/packs/src/decidim/initiatives/application.js +0 -1
  80. data/app/packs/src/decidim/initiatives/scoped_type.js +1 -1
  81. data/app/packs/stylesheets/decidim/initiatives/initiatives-votes.scss +21 -21
  82. data/app/packs/stylesheets/decidim/initiatives/print-initiative.scss +59 -31
  83. data/app/packs/stylesheets/initiatives.scss +171 -0
  84. data/app/permissions/decidim/initiatives/permissions.rb +3 -3
  85. data/app/presenters/decidim/initiatives/admin_log/initiative_presenter.rb +2 -2
  86. data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +2 -2
  87. data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +2 -2
  88. data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
  89. data/app/queries/decidim/initiatives/similar_initiatives.rb +2 -2
  90. data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
  91. data/app/queries/decidim/initiatives/user_authorizations.rb +1 -1
  92. data/app/services/decidim/initiatives/pdf_signature_example.rb +44 -52
  93. data/app/views/decidim/initiatives/_modal.html.erb +15 -0
  94. data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +21 -19
  95. data/app/views/decidim/initiatives/admin/answers/edit.html.erb +41 -27
  96. data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +41 -48
  97. data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +8 -7
  98. data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +111 -95
  99. data/app/views/decidim/initiatives/admin/initiatives/_initiative_attachments.erb +7 -7
  100. data/app/views/decidim/initiatives/admin/initiatives/_signatures.html.erb +87 -0
  101. data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +72 -60
  102. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.html.erb +8 -0
  103. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +5 -78
  104. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +76 -75
  105. data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +7 -8
  106. data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +17 -5
  107. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/_form.html.erb +11 -6
  108. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +16 -22
  109. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +17 -15
  110. data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +93 -76
  111. data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +35 -33
  112. data/app/views/decidim/initiatives/admin/initiatives_types/edit.html.erb +16 -12
  113. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +39 -48
  114. data/app/views/decidim/initiatives/admin/initiatives_types/new.html.erb +16 -9
  115. data/app/views/decidim/initiatives/committee_requests/new.html.erb +21 -19
  116. data/app/views/decidim/initiatives/create_initiative/_share_committee_link.html.erb +15 -20
  117. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +62 -100
  118. data/app/views/decidim/initiatives/create_initiative/finish.html.erb +24 -28
  119. data/app/views/decidim/initiatives/create_initiative/promotal_committee.html.erb +15 -17
  120. data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +32 -46
  121. data/app/views/decidim/initiatives/initiative_signatures/_wizard_steps.html.erb +15 -19
  122. data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +25 -36
  123. data/app/views/decidim/initiatives/initiative_signatures/finish.html.erb +5 -16
  124. data/app/views/decidim/initiatives/initiative_signatures/sms_code.html.erb +8 -19
  125. data/app/views/decidim/initiatives/initiative_signatures/sms_phone_number.html.erb +8 -20
  126. data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +48 -66
  127. data/app/views/decidim/initiatives/initiatives/_form.html.erb +49 -95
  128. data/app/views/decidim/initiatives/initiatives/_initiative_badge.html.erb +3 -5
  129. data/app/views/decidim/initiatives/initiatives/_initiative_hero.html.erb +13 -0
  130. data/app/views/decidim/initiatives/initiatives/_initiatives.html.erb +6 -15
  131. data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +1 -1
  132. data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +28 -0
  133. data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +2 -6
  134. data/app/views/decidim/initiatives/initiatives/_result.html.erb +15 -21
  135. data/app/views/decidim/initiatives/initiatives/_send_to_technical_validation.html.erb +3 -3
  136. data/app/views/decidim/initiatives/initiatives/_tags_type.html.erb +1 -0
  137. data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +9 -9
  138. data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +7 -7
  139. data/app/views/decidim/initiatives/initiatives/edit.html.erb +63 -68
  140. data/app/views/decidim/initiatives/initiatives/index.html.erb +17 -18
  141. data/app/views/decidim/initiatives/initiatives/index.js.erb +0 -5
  142. data/app/views/decidim/initiatives/initiatives/print.html.erb +123 -120
  143. data/app/views/decidim/initiatives/initiatives/show.html.erb +188 -70
  144. data/app/views/decidim/initiatives/initiatives_mailer/notify_creation.html.erb +2 -2
  145. data/app/views/decidim/initiatives/initiatives_type_scopes/search.html.erb +2 -1
  146. data/app/views/decidim/initiatives/versions/show.html.erb +14 -5
  147. data/app/views/layouts/decidim/_initiative_creation_header.html.erb +17 -28
  148. data/app/views/layouts/decidim/_initiative_header.html.erb +3 -23
  149. data/app/views/layouts/decidim/_initiative_header_steps.html.erb +4 -12
  150. data/app/views/layouts/decidim/_initiative_signature_creation_header.html.erb +5 -26
  151. data/app/views/layouts/decidim/admin/initiative.html.erb +12 -13
  152. data/app/views/layouts/decidim/admin/initiatives.html.erb +40 -11
  153. data/app/views/layouts/decidim/initiative.html.erb +16 -11
  154. data/app/views/layouts/decidim/initiative_creation.html.erb +7 -18
  155. data/app/views/layouts/decidim/initiative_head.html.erb +15 -0
  156. data/app/views/layouts/decidim/initiative_signature_creation.html.erb +3 -11
  157. data/config/assets.rb +0 -1
  158. data/config/environment.rb +3 -0
  159. data/config/initializers/wicked_pdf.rb +1 -1
  160. data/config/locales/ar.yml +1 -92
  161. data/config/locales/ca.yml +65 -104
  162. data/config/locales/cs.yml +70 -109
  163. data/config/locales/de.yml +71 -110
  164. data/config/locales/el.yml +1 -97
  165. data/config/locales/en.yml +69 -108
  166. data/config/locales/es-MX.yml +65 -104
  167. data/config/locales/es-PY.yml +65 -104
  168. data/config/locales/es.yml +65 -104
  169. data/config/locales/eu.yml +171 -161
  170. data/config/locales/fi-plain.yml +67 -106
  171. data/config/locales/fi.yml +67 -106
  172. data/config/locales/fr-CA.yml +72 -106
  173. data/config/locales/fr.yml +70 -104
  174. data/config/locales/ga-IE.yml +0 -35
  175. data/config/locales/gl.yml +1 -87
  176. data/config/locales/hu.yml +25 -107
  177. data/config/locales/id-ID.yml +1 -88
  178. data/config/locales/is-IS.yml +1 -57
  179. data/config/locales/it.yml +6 -111
  180. data/config/locales/ja.yml +63 -109
  181. data/config/locales/lb.yml +6 -73
  182. data/config/locales/lt.yml +72 -101
  183. data/config/locales/lv.yml +1 -98
  184. data/config/locales/nl.yml +6 -103
  185. data/config/locales/no.yml +6 -114
  186. data/config/locales/pl.yml +11 -111
  187. data/config/locales/pt-BR.yml +21 -116
  188. data/config/locales/pt.yml +6 -111
  189. data/config/locales/ro-RO.yml +13 -108
  190. data/config/locales/ru.yml +1 -65
  191. data/config/locales/sk.yml +1 -84
  192. data/config/locales/sl.yml +3 -5
  193. data/config/locales/sq-AL.yml +1 -0
  194. data/config/locales/sv.yml +20 -107
  195. data/config/locales/th-TH.yml +1 -0
  196. data/config/locales/tr-TR.yml +9 -111
  197. data/config/locales/uk.yml +1 -65
  198. data/config/locales/zh-CN.yml +6 -102
  199. data/config/locales/zh-TW.yml +31 -97
  200. data/db/migrate/20171017091734_add_scopes_for_all_initiative_types.rb +1 -1
  201. data/db/migrate/20171017095143_update_initiative_scoped_type.rb +1 -1
  202. data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +1 -1
  203. data/lib/decidim/api/initiative_committee_member_type.rb +2 -2
  204. data/lib/decidim/initiatives/admin_engine.rb +13 -93
  205. data/lib/decidim/initiatives/content_blocks/registry_manager.rb +22 -0
  206. data/lib/decidim/initiatives/engine.rb +45 -23
  207. data/lib/decidim/initiatives/menu.rb +150 -0
  208. data/lib/decidim/initiatives/participatory_space.rb +6 -91
  209. data/lib/decidim/initiatives/query_extensions.rb +5 -5
  210. data/lib/decidim/initiatives/seeds.rb +95 -0
  211. data/lib/decidim/initiatives/test/factories.rb +25 -7
  212. data/lib/decidim/initiatives/version.rb +1 -1
  213. data/lib/decidim/initiatives.rb +1 -1
  214. data/lib/tasks/decidim_initiatives.rake +2 -2
  215. data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +1 -1
  216. metadata +49 -75
  217. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +0 -28
  218. data/app/cells/decidim/initiatives/initiative_m/author.erb +0 -10
  219. data/app/cells/decidim/initiatives/initiative_m/footer.erb +0 -28
  220. data/app/cells/decidim/initiatives/initiative_m/tags.erb +0 -9
  221. data/app/cells/decidim/initiatives/initiative_m_cell.rb +0 -77
  222. data/app/controllers/decidim/initiatives/widgets_controller.rb +0 -30
  223. data/app/packs/stylesheets/decidim/initiatives/admin.scss +0 -33
  224. data/app/packs/stylesheets/decidim/initiatives/initiatives.scss +0 -64
  225. data/app/packs/stylesheets/decidim/initiatives/popularity_item.scss +0 -76
  226. data/app/packs/stylesheets/decidim/initiatives/statistics.scss +0 -15
  227. data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +0 -2
  228. data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +0 -40
  229. data/app/views/decidim/initiatives/create_initiative/show_similar_initiatives.html.erb +0 -23
  230. data/app/views/decidim/initiatives/initiatives/_author.html.erb +0 -35
  231. data/app/views/decidim/initiatives/initiatives/_count.html.erb +0 -1
  232. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +0 -33
  233. data/app/views/decidim/initiatives/initiatives/_filters_small_view.html.erb +0 -18
  234. data/app/views/decidim/initiatives/initiatives/_index_header.html.erb +0 -44
  235. data/app/views/decidim/initiatives/initiatives/_tags.html.erb +0 -7
  236. data/app/views/decidim/initiatives/versions/index.html.erb +0 -8
  237. data/db/seeds/city.jpeg +0 -0
  238. data/db/seeds/city2.jpeg +0 -0
  239. data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +0 -56
  240. data/lib/gem_overrides/origami/date.rb +0 -47
@@ -0,0 +1,171 @@
1
+ .initiatives {
2
+ @apply block;
3
+
4
+ &__selection {
5
+ .form-defaults {
6
+ @apply my-10;
7
+ }
8
+
9
+ .card__highlight {
10
+ @apply pl-4 pr-20 py-4 items-center justify-between gap-4;
11
+ }
12
+
13
+ .card__highlight-authorized {
14
+ @apply w-full my-10 hover:cursor-default hover:ring-background;
15
+ }
16
+
17
+ &__icon {
18
+ @apply flex-none w-8 h-8 text-gray fill-secondary;
19
+
20
+ &.is-granted {
21
+ @apply text-success;
22
+ }
23
+ }
24
+
25
+ &__text {
26
+ @apply grow space-y-2.5 text-left;
27
+
28
+ span {
29
+ @apply inline-block text-sm text-gray-2;
30
+ }
31
+ }
32
+
33
+ &:hover {
34
+ @apply border-tertiary;
35
+ }
36
+ }
37
+
38
+ &__progress-bar {
39
+ .progress-bar__container {
40
+ @apply w-16;
41
+ }
42
+
43
+ .progress-bar__number {
44
+ @apply text-gray-2 font-normal text-sm;
45
+ }
46
+
47
+ .progress-bar__units {
48
+ @apply hidden;
49
+ }
50
+ }
51
+
52
+ &__card__grid-metadata-dates {
53
+ @apply block justify-center content-center;
54
+
55
+ svg {
56
+ @apply fill-gray;
57
+ }
58
+
59
+ span {
60
+ @apply text-gray-2;
61
+ }
62
+ }
63
+ }
64
+
65
+ .initiative {
66
+ &__hero {
67
+ @apply backdrop-brightness-[30%];
68
+
69
+ &-text {
70
+ @apply container text-center text-white md:px-16 pt-10 pb-14 md:[&_a_+_a]:ml-6;
71
+ }
72
+
73
+ &-slogan {
74
+ @apply text-lg font-normal my-4;
75
+ }
76
+
77
+ &-location {
78
+ @apply text-lg;
79
+ }
80
+
81
+ .initiatives__card__grid-metadata-dates {
82
+ svg {
83
+ @apply fill-white;
84
+ }
85
+
86
+ span {
87
+ @apply text-white;
88
+ }
89
+ }
90
+ }
91
+
92
+ &__form__committee {
93
+ @apply flex items-center px-4 py-2 border border-gray outline outline-1 outline-transparent rounded bg-background-2 focus:outline-2 focus:outline-secondary w-full;
94
+
95
+ span {
96
+ @apply text-black font-normal;
97
+ }
98
+ }
99
+
100
+ &__aside {
101
+ @apply md:px-6 md:pb-6 w-full;
102
+
103
+ .layout-aside__section {
104
+ .profile__user-nick {
105
+ @apply hidden;
106
+ }
107
+
108
+ .participatory-space__nav-container {
109
+ @apply ml-0;
110
+ }
111
+
112
+ .author {
113
+ @apply mb-6;
114
+ }
115
+
116
+ .profile__user-avatar-container {
117
+ @apply w-6 h-6;
118
+ }
119
+
120
+ .profile__user-name {
121
+ @apply text-sm ml-2;
122
+ }
123
+ }
124
+ }
125
+
126
+ &__aside__element__committee {
127
+ @apply mb-6 flex items-center;
128
+ }
129
+
130
+ &__aside__element__data {
131
+ @apply ml-2 mb-4 pb-4 border-b border-gray-3;
132
+ }
133
+
134
+ &__aside__element__data-title {
135
+ @apply text-gray-2 font-semibold text-sm mb-2;
136
+ }
137
+
138
+ &__aside__element__data-text {
139
+ @apply text-sm font-normal text-gray-2 block;
140
+ }
141
+
142
+ &__aside__element-title {
143
+ @apply inline-block text-gray-2 font-bold text-md align-middle;
144
+ }
145
+ }
146
+
147
+ #initiatives {
148
+ .card__grid {
149
+ @apply relative;
150
+ }
151
+
152
+ .card__grid-text {
153
+ @apply min-h-[120px];
154
+ }
155
+
156
+ .initiative-status {
157
+ @apply text-center ml-2;
158
+ }
159
+
160
+ .initiatives__card__grid-metadata-dates {
161
+ @apply mr-2;
162
+ }
163
+
164
+ .initiatives__progress-bar {
165
+ @apply mx-2;
166
+ }
167
+ }
168
+
169
+ .edit_initiative .profile__group__list {
170
+ @apply w-full;
171
+ }
@@ -88,9 +88,9 @@ module Decidim
88
88
  def creation_enabled?
89
89
  Decidim::Initiatives.creation_enabled && (
90
90
  Decidim::Initiatives.do_not_require_authorization ||
91
- UserAuthorizations.for(user).any? ||
92
- Decidim::UserGroups::ManageableUserGroups.for(user).verified.any?
93
- )
91
+ UserAuthorizations.for(user).any? ||
92
+ Decidim::UserGroups::ManageableUserGroups.for(user).verified.any?) &&
93
+ authorized?(:create, permissions_holder: initiative_type)
94
94
  end
95
95
 
96
96
  def request_membership?
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::Initiative`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::InitiativesSettings`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -6,8 +6,8 @@ module Decidim
6
6
  # This class holds the logic to present a `Decidim::InitiativesType`
7
7
  # for the `AdminLog` log.
8
8
  #
9
- # Usage should be automatic and you shouldn't need to call this class
10
- # directly, but here's an example:
9
+ # Usage should be automatic and you should not need to call this class
10
+ # directly, but here is an example:
11
11
  #
12
12
  # action_log = Decidim::ActionLog.last
13
13
  # view_helpers # => this comes from the views
@@ -22,7 +22,7 @@ module Decidim
22
22
  private
23
23
 
24
24
  def base_query
25
- Decidim::Initiative.where(organization: organization).published.open
25
+ Decidim::Initiative.where(organization:).published.open
26
26
  end
27
27
  end
28
28
  end
@@ -31,8 +31,8 @@ module Decidim
31
31
  .where(organization: @organization)
32
32
  .where(
33
33
  Arel.sql("GREATEST(#{title_similarity}, #{description_similarity}) >= ?").to_s,
34
- form.title,
35
- form.description,
34
+ translated_attribute(form.title),
35
+ translated_attribute(form.description),
36
36
  Decidim::Initiatives.similarity_threshold
37
37
  )
38
38
  .limit(Decidim::Initiatives.similarity_limit)
@@ -5,7 +5,7 @@ module Decidim
5
5
  # Class uses to retrieve initiatives that have been a long time in validating
6
6
  # state
7
7
  class SupportPeriodFinishedInitiatives < Decidim::Query
8
- # Retrieves the initiatives ready to be evaluated to decide if they've been
8
+ # Retrieves the initiatives ready to be evaluated to decide if they have been
9
9
  # accepted or not.
10
10
  def query
11
11
  Decidim::Initiative
@@ -22,7 +22,7 @@ module Decidim
22
22
 
23
23
  # Retrieves authorizations for the given user.
24
24
  def query
25
- Authorization.where(user: user).where.not(granted_at: nil)
25
+ Authorization.where(user:).where.not(granted_at: nil)
26
26
  end
27
27
  end
28
28
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- require "origami"
3
+ require "hexapdf"
4
4
  require "tempfile"
5
- require_relative "../../../../lib/gem_overrides/origami/date"
6
5
 
7
6
  module Decidim
8
7
  module Initiatives
@@ -18,64 +17,57 @@ module Decidim
18
17
 
19
18
  # Public: PDF signed using a new certificate generated by the service
20
19
  def signed_pdf
21
- @signed_pdf ||= StringIO.open(pdf) do |stream|
22
- parsed_pdf = Origami::PDF.read(stream)
23
- parsed_pdf.append_page do |page|
24
- page.add_annotation(signature_annotation)
25
- parsed_pdf.sign(
26
- certificate,
27
- key,
28
- method: "adbe.pkcs7.detached",
29
- annotation: signature_annotation,
30
- location: location,
31
- contact: contact,
32
- issuer: issuer
33
- )
34
- end
35
- extract_signed_pdf(parsed_pdf)
20
+ signed_file = Tempfile.new("signed_pdf")
21
+
22
+ doc = HexaPDF::Document.new(io: StringIO.new(pdf))
23
+
24
+ # Prepare the document for embedding of the digital signature
25
+ data = nil # Used for storing the to-be-signed data
26
+ signing_mechanism = lambda do |io, byte_range|
27
+ # Store the to-be-signed data in the local variable data
28
+ io.pos = byte_range[0]
29
+ data = io.read(byte_range[1])
30
+ io.pos = byte_range[2]
31
+ data << io.read(byte_range[3])
32
+ ""
36
33
  end
34
+ doc.sign(signed_file.path, signature: signature_widget(doc), reason: caption, signature_size: 10_000, external_signing: signing_mechanism)
35
+
36
+ signature = OpenSSL::PKCS7.sign(certificate, key, data,
37
+ # [HexaPDF.demo_cert.sub_ca, HexaPDF.demo_cert.root_ca],
38
+ [],
39
+ OpenSSL::PKCS7::DETACHED | OpenSSL::PKCS7::BINARY).to_der
40
+
41
+ # Embed the signature
42
+ HexaPDF::DigitalSignature::Signing.embed_signature(File.open(signed_file.path, "rb+"), signature)
43
+
44
+ File.binread(signed_file.path)
45
+ ensure
46
+ signed_file.close
47
+ signed_file.unlink
37
48
  end
38
49
 
39
50
  private
40
51
 
41
- def extract_signed_pdf(parsed_pdf)
42
- file = Tempfile.new("signed_pdf")
43
- begin
44
- parsed_pdf.save(file.path)
45
- File.binread(file.path)
46
- ensure
47
- file.close
48
- file.unlink
49
- end
50
- end
52
+ def signature_widget(doc)
53
+ doc.pages.add.document
51
54
 
52
- def text_annotation(options = {})
53
- width = options.fetch(:width, 200.0)
54
- height = options.fetch(:height, 50.0)
55
- size = options.fetch(:size, 8)
56
-
57
- Origami::Annotation::AppearanceStream.new.tap do |annotation|
58
- annotation.Type = Origami::Name.new("XObject")
59
- annotation.Resources = Origami::Resources.new
60
- annotation.Resources.ProcSet = [Origami::Name.new("Text")]
61
- annotation.set_indirect(true)
62
- annotation.Matrix = [1, 0, 0, 1, 0, 0]
63
- annotation.BBox = [0, 0, width, height]
64
- annotation.write(caption, x: size, y: (height / 2) - (size / 2), size: size)
65
- end
66
- end
55
+ form = doc.acro_form(create: true)
56
+ form.signature_flag(:append_only)
67
57
 
68
- def signature_annotation(options = {})
69
- @signature_annotation ||= begin
70
- width = options.fetch(:width, 200.0)
71
- height = options.fetch(:height, 50.0)
58
+ sig_field = form.create_signature_field("signature")
72
59
 
73
- Origami::Annotation::Widget::Signature.new.tap do |annotation|
74
- annotation.set_indirect(true)
75
- annotation.Rect = Origami::Rectangle[llx: height, lly: width + height, urx: width + height, ury: width]
76
- annotation.set_normal_appearance(text_annotation(width: width, height: height))
77
- end
78
- end
60
+ widget = sig_field.create_widget(doc.pages[doc.pages.length - 1], Rect: [60, 50, 250, 620])
61
+ widget.flag(:print)
62
+ xobject = (widget[:AP] ||= {})[:N] ||= doc.add({ Type: :XObject, Subtype: :Form }) # Create the appearance for the widget
63
+ xobject[:BBox] = [0, 0, widget[:Rect].width, widget[:Rect].height]
64
+ xobject.canvas
65
+ .font("Helvetica", size: 10)
66
+ .text(caption, at: [10, 30])
67
+
68
+ sig = doc.add({ Type: :Sig }) # set an empty signature and apply it to the field
69
+ sig_field.field_value = sig
70
+ sig
79
71
  end
80
72
 
81
73
  def certificate
@@ -0,0 +1,15 @@
1
+ <%= decidim_modal id: "not-authorized-modal" do %>
2
+ <div data-dialog-container>
3
+ <%= icon "information-line" %>
4
+ <h3 class="h3" id="dialog-title-not-authorized-modal" data-dialog-title>
5
+ <%= t(".not_authorized.title") %>
6
+ </h3>
7
+ <p id="dialog-desc-not-authorized-modal"><%= t(".not_authorized.explanation") %></p>
8
+ </div>
9
+ <div data-dialog-actions>
10
+ <%= link_to t(".not_authorized.authorizations_page"), decidim_verifications.authorizations_path(redirect_url: create_initiative_url(:select_initiative_type)), class: "button button__sm md:button__lg button__secondary" %>
11
+ <button data-dialog-close="not-authorized-modal" class="button button__sm md:button__lg button__secondary">
12
+ <%= t("ok", scope: "decidim.budgets.projects.budget_excess") %>
13
+ </button>
14
+ </div>
15
+ <% end %>
@@ -1,23 +1,25 @@
1
- <div class="card">
2
- <div class="card-divider">
3
- <h2 class="card-title">
4
- <%= link_to "#{t ".initiatives"} > ", initiatives_path %>
5
- <%= decidim_sanitize translated_attribute(initiative.title) %>
6
- </h2>
7
- </div>
8
-
9
- <div class="card-section">
10
- <div class="row column">
11
- <strong><%= t ".description" %>: </strong> <%= decidim_sanitize_editor translated_attribute(initiative.description) %>
12
- </div>
13
- <div class="row column">
14
- <strong><%= t ".created_at" %>: </strong> <%= l initiative.created_at, format: :decidim_short %>
1
+ <div class="form__wrapper">
2
+ <div class="card">
3
+ <div class="card-divider">
4
+ <h2 class="card-title">
5
+ <%= link_to "#{t ".initiatives"} > ", initiatives_path %>
6
+ <%= decidim_sanitize translated_attribute(initiative.title) %>
7
+ </h2>
15
8
  </div>
16
- <div class="row column">
17
- <strong><%= t ".state" %>: </strong> <%= I18n.t(initiative.state, scope: "decidim.initiatives.admin_states") %>
18
- </div>
19
- <div class="row column">
20
- <strong><%= t ".initiative_votes_count" %>: </strong> <%= initiative.online_votes_count %>
9
+
10
+ <div class="card-section">
11
+ <div class="row column">
12
+ <strong><%= t ".description" %>: </strong> <%= decidim_sanitize_editor translated_attribute(initiative.description) %>
13
+ </div>
14
+ <div class="row column">
15
+ <strong><%= t ".created_at" %>: </strong> <%= l initiative.created_at, format: :decidim_short %>
16
+ </div>
17
+ <div class="row column">
18
+ <strong><%= t ".state" %>: </strong> <%= I18n.t(initiative.state, scope: "decidim.initiatives.admin_states") %>
19
+ </div>
20
+ <div class="row column">
21
+ <strong><%= t ".initiative_votes_count" %>: </strong> <%= initiative.online_votes_count %>
22
+ </div>
21
23
  </div>
22
24
  </div>
23
25
  </div>
@@ -1,35 +1,49 @@
1
- <%= render partial: "info_initiative", locals: { initiative: current_initiative } %>
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <div class="item_show__header">
3
+ <h2 class="item_show__header-title">
4
+ <%= t("decidim.admin_log.helpers.answers") %>
5
+ </h2>
6
+ </div>
2
7
 
3
- <%= decidim_form_for(@form, url: initiative_answer_path(current_initiative), html: { class: "form edit_initiative_answer" }) do |f| %>
4
- <div class="card">
5
- <div class="card-divider">
6
- <h2 class="card-title"><%= t ".title", title: translated_attribute(current_initiative.title) %></h2>
7
- </div>
8
+ <div class="item__edit item__edit-1col">
9
+ <div class="item__edit-form">
10
+ <%= render partial: "info_initiative", locals: { initiative: current_initiative } %>
8
11
 
9
- <div class="card-section">
10
- <div class="row column">
11
- <%= f.translated :editor, :answer, autofocus: true, rows: 15 %>
12
- </div>
12
+ <%= decidim_form_for(@form, url: initiative_answer_path(current_initiative), html: { class: "form-defaults form edit_initiative_answer" }) do |f| %>
13
+ <div class="form__wrapper">
14
+ <div class="card">
15
+ <div class="card-divider">
16
+ <h2 class="card-title"><%= t ".title", title: translated_attribute(current_initiative.title) %></h2>
17
+ </div>
13
18
 
14
- <div class="row column">
15
- <%= f.text_field :answer_url %>
16
- </div>
19
+ <div class="card-section">
20
+ <div class="row column">
21
+ <%= f.translated :editor, :answer, autofocus: true, rows: 15 %>
22
+ </div>
17
23
 
18
- <% if @form.signature_dates_required? %>
19
- <div class="row">
20
- <div class="columns xlarge-6">
21
- <%= f.date_field :signature_start_date, disabled: !@form.signature_dates_required? %>
22
- </div>
24
+ <div class="row column">
25
+ <%= f.text_field :answer_url %>
26
+ </div>
27
+
28
+ <% if @form.signature_dates_required? %>
29
+ <div class="row">
30
+ <div class="columns">
31
+ <%= f.date_field :signature_start_date, disabled: !@form.signature_dates_required? %>
32
+ </div>
23
33
 
24
- <div class="columns xlarge-6">
25
- <%= f.date_field :signature_end_date, disabled: !@form.signature_dates_required? %>
34
+ <div class="columns">
35
+ <%= f.date_field :signature_end_date, disabled: !@form.signature_dates_required? %>
36
+ </div>
37
+ </div>
38
+ <% end %>
26
39
  </div>
27
40
  </div>
28
- <% end %>
29
- </div>
30
- </div>
31
-
32
- <div class="button--double form-general-submit">
33
- <%= f.submit t(".answer") %>
41
+ </div>
42
+ <div class="item__edit-sticky">
43
+ <div class="item__edit-sticky-container">
44
+ <%= f.submit t(".answer"), class: "button button__sm button__secondary" %>
45
+ </div>
46
+ </div>
47
+ <% end %>
34
48
  </div>
35
- <% end %>
49
+ </div>
@@ -1,9 +1,12 @@
1
+ <% add_decidim_page_title(t(".title")) %>
1
2
  <div class="card" id="committee_members">
2
- <div class="card-divider">
3
- <h2 class="card-title"><%= t ".title" %></h2>
3
+ <div class="item_show__header">
4
+ <h2 class="item_show__header-title">
5
+ <%= t ".title" %>
6
+ </h2>
4
7
  </div>
5
8
 
6
- <div class="card-section">
9
+ <div class="card-section p-4">
7
10
  <div class="row column">
8
11
  <%= t ".invite_to_committee_help" %>
9
12
  </div>
@@ -11,56 +14,46 @@
11
14
  <div class="row column">
12
15
  <div class="committee_link" id="committee_link">
13
16
  <%= decidim_initiatives.new_initiative_committee_request_url(current_initiative) %>
17
+ <%= icon_link_to "clipboard-line", "#", t(".invite_to_committee_help"), class: "card--list__data__icon invite-users-link" %>
14
18
  </div>
15
- <%= icon_link_to "clipboard", "#", t(".invite_to_committee_help"), class: "card--list__data__icon invite-users-link" %>
16
19
  </div>
17
20
  </div>
21
+ </div>
18
22
 
19
- <div class="card-section">
20
- <div class="table-scroll">
21
- <table class="table-list">
22
- <thead>
23
- <tr>
24
- <th><%= t "user", scope: "activemodel.attributes.initiatives_committee_member" %></th>
25
- <th></th>
26
- </tr>
27
- </thead>
28
- <tbody>
29
- <% if current_initiative.committee_members.empty? %>
30
- <tr>
31
- <td><%= t ".no_members_yet" %></td>
32
- <td></td>
33
- </tr>
34
- <% end %>
23
+ <div class="table-scroll mt-4">
24
+ <table class="table-list">
25
+ <thead>
26
+ <tr>
27
+ <th><%= t "user", scope: "activemodel.attributes.initiatives_committee_member" %></th>
28
+ <th></th>
29
+ </tr>
30
+ </thead>
31
+ <tbody>
32
+ <% if current_initiative.committee_members.empty? %>
33
+ <tr>
34
+ <td><%= t ".no_members_yet" %></td>
35
+ <td></td>
36
+ </tr>
37
+ <% end %>
35
38
 
36
- <% current_initiative.committee_members.each do |request| %>
37
- <tr data-id="<%= request.id %>">
38
- <td>
39
- <%= link_to request.user.name, "mailto:#{request.user.email}" %>
40
- </td>
41
- <td class="table-list__actions">
42
- <% if allowed_to? :approve, :initiative_committee_member, request: request %>
43
- <%= icon_link_to "check",
44
- approve_initiative_committee_request_path(current_initiative, request),
45
- t(".approve"),
46
- class: "action-icon--check" %>
47
- <% end %>
39
+ <% current_initiative.committee_members.each do |request| %>
40
+ <tr data-id="<%= request.id %>">
41
+ <td>
42
+ <%= link_to request.user.name, "mailto:#{request.user.email}" %>
43
+ </td>
44
+ <td class="table-list__actions">
45
+ <% if allowed_to? :approve, :initiative_committee_member, request: request %>
46
+ <%= icon_link_to "check-line", approve_initiative_committee_request_path(current_initiative, request), t(".approve"), class: "action-icon--check" %>
47
+ <% end %>
48
48
 
49
- <% if allowed_to? :revoke, :initiative_committee_member, request: request %>
50
- <%= icon_link_to "circle-x",
51
- revoke_initiative_committee_request_path(current_initiative, request),
52
- t(".revoke"),
53
- class: "action-icon--remove",
54
- method: :delete,
55
- data: { confirm: t(".confirm_revoke") } %>
56
- <% end %>
57
- </td>
58
- </tr>
59
- <% end %>
60
- </tbody>
61
- </table>
62
- </div>
63
- </div>
49
+ <% if allowed_to? :revoke, :initiative_committee_member, request: request %>
50
+ <%= icon_link_to "delete-bin-line", revoke_initiative_committee_request_path(current_initiative, request), t(".revoke"), class: "action-icon--remove", method: :delete, data: { confirm: t(".confirm_revoke") } %>
51
+ <% end %>
52
+ </td>
53
+ </tr>
54
+ <% end %>
55
+ </tbody>
56
+ </table>
64
57
  </div>
65
58
 
66
- <%= javascript_pack_tag "decidim_initiatives_admin" %>
59
+ <%= append_javascript_pack_tag "decidim_initiatives_admin" %>
@@ -1,9 +1,10 @@
1
- <span class="exports dropdown tiny button button--simple" data-toggle="<%= dropdown_id(collection_ids) %>">
1
+ <span class="exports button button__sm button__secondary button--simple" data-toggle="<%= dropdown_id(collection_ids) %>">
2
2
  <% if collection_ids.present? %>
3
3
  <%= t("actions.export-selection", scope: "decidim.admin") %>
4
- <% else %>
5
- <%= t("actions.export", scope: "decidim.admin") %>
6
- <% end %>
4
+ <% else %>
5
+ <%= t("actions.export", scope: "decidim.admin") %>
6
+ <% end %>
7
+ <%= icon "arrow-down-s-line", class: "dropdown-filter-icon" %>
7
8
  </span>
8
9
  <div class="dropdown-pane"
9
10
  id="<%= dropdown_id(collection_ids) %>"
@@ -13,11 +14,11 @@
13
14
  data-auto-focus="true"
14
15
  data-close-on-click="true">
15
16
  <ul class="vertical menu add-components">
16
- <% %w{CSV JSON}.each do |format| %>
17
+ <% %w(CSV JSON).each do |format| %>
17
18
  <li class="exports--format--<%= format.downcase %> exports--initiatives">
18
19
  <%= link_to t("decidim.admin.exports.export_as", name: t("decidim.initiatives.admin.exports.initiatives"),
19
- export_format: format.upcase),
20
- export_initiatives_path(format: format, collection_ids: collection_ids) %>
20
+ export_format: format.upcase),
21
+ export_initiatives_path(format:, collection_ids:) %>
21
22
  </li>
22
23
  <% end %>
23
24
  </ul>