decidim-decidim_awesome 0.12.0 → 0.12.4

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 (184) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/README.md +25 -15
  4. data/Rakefile +12 -0
  5. data/app/cells/concerns/decidim/decidim_awesome/global_menu_cell_override.rb +14 -2
  6. data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +5 -4
  7. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +3 -3
  8. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/vote_block_for.erb +1 -1
  9. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +39 -5
  10. data/app/commands/decidim/decidim_awesome/admin/create_authorization_group.rb +42 -0
  11. data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +10 -14
  12. data/app/commands/decidim/decidim_awesome/admin/create_menu_hack.rb +9 -8
  13. data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +3 -8
  14. data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +4 -8
  15. data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +3 -7
  16. data/app/commands/decidim/decidim_awesome/admin/destroy_authorization_group.rb +37 -0
  17. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +10 -9
  18. data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +8 -7
  19. data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +7 -13
  20. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +7 -10
  21. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +6 -11
  22. data/app/commands/decidim/decidim_awesome/admin/update_config.rb +12 -1
  23. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +11 -11
  24. data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +10 -8
  25. data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +0 -28
  26. data/app/controllers/concerns/decidim/decidim_awesome/enforce_access_authorizations.rb +49 -0
  27. data/app/controllers/concerns/decidim/decidim_awesome/needs_hashcash.rb +43 -0
  28. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +2 -2
  29. data/app/controllers/decidim/decidim_awesome/admin/admin_authorizations_controller.rb +2 -2
  30. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +0 -4
  31. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +2 -1
  32. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +2 -0
  33. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +1 -2
  34. data/app/controllers/decidim/decidim_awesome/admin/force_authorizations_controller.rb +44 -0
  35. data/app/controllers/decidim/decidim_awesome/admin/hashcash_controller.rb +39 -0
  36. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +1 -1
  37. data/app/controllers/decidim/decidim_awesome/admin/{maintenance_controller.rb → private_data_controller.rb} +9 -9
  38. data/app/controllers/decidim/decidim_awesome/required_authorizations_controller.rb +51 -13
  39. data/app/controllers/decidim/decidim_awesome/utils_controller.rb +17 -0
  40. data/app/forms/concerns/decidim/decidim_awesome/proposals/admin/proposal_form_customizations.rb +59 -0
  41. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations.rb +28 -28
  42. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations_base.rb +36 -0
  43. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +7 -1
  44. data/app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb +66 -0
  45. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +23 -24
  46. data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +2 -0
  47. data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +2 -1
  48. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +21 -18
  49. data/app/helpers/decidim/decidim_awesome/map_helper.rb +4 -2
  50. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +1 -1
  51. data/app/overrides/decidim/assemblies/admin/assemblies/_form/add_visibility_callout.html.erb.deface +3 -0
  52. data/app/overrides/decidim/conferences/admin/conferences/_form/add_visibility_callout.html.erb.deface +3 -0
  53. data/app/overrides/decidim/devise/registrations/new/add_hashcash.html.erb.deface +3 -0
  54. data/app/overrides/decidim/devise/sessions/new/add_hashcash.html.erb.deface +3 -0
  55. data/app/overrides/decidim/participatory_processes/admin/participatory_process_groups/_form/add_visibility_callout.html.erb.deface +3 -0
  56. data/app/overrides/decidim/participatory_processes/admin/participatory_processes/_form/add_visibility_callout.html.erb.deface +3 -0
  57. data/app/overrides/decidim/shared/_login_modal/add_hashcash.html.erb.deface +3 -0
  58. data/app/overrides/layouts/decidim/_head/add_awesome_custom_styles.html.erb.deface +3 -0
  59. data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +0 -2
  60. data/app/packs/entrypoints/decidim_decidim_awesome_hashcash.js +4 -0
  61. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +25 -6
  62. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +4 -2
  63. data/app/packs/src/decidim/decidim_awesome/admin/verifications.js +6 -3
  64. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +0 -1
  65. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +1 -1
  66. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +1 -1
  67. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +1 -1
  68. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +6 -6
  69. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +1 -1
  70. data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +3 -3
  71. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +1 -113
  72. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +1 -1
  73. data/app/packs/src/vendor/form_builder_langs/ar-SA.lang +111 -0
  74. data/app/packs/src/vendor/form_builder_langs/ar-TN.lang +94 -0
  75. data/app/packs/src/vendor/form_builder_langs/ca-ES.lang +110 -0
  76. data/app/packs/src/vendor/form_builder_langs/cs-CZ.lang +105 -0
  77. data/app/packs/src/vendor/form_builder_langs/da-DK.lang +110 -0
  78. data/app/packs/src/vendor/form_builder_langs/de-DE.lang +109 -0
  79. data/app/packs/src/vendor/form_builder_langs/el-GR.lang +110 -0
  80. data/app/packs/src/vendor/form_builder_langs/en-US.lang +117 -0
  81. data/app/packs/src/vendor/form_builder_langs/es-ES.lang +103 -0
  82. data/app/packs/src/vendor/form_builder_langs/fa-IR.lang +108 -0
  83. data/app/packs/src/vendor/form_builder_langs/fi-FI.lang +107 -0
  84. data/app/packs/src/vendor/form_builder_langs/fr-FR.lang +117 -0
  85. data/app/packs/src/vendor/form_builder_langs/he-IL.lang +108 -0
  86. data/app/packs/src/vendor/form_builder_langs/hi-IN.lang +110 -0
  87. data/app/packs/src/vendor/form_builder_langs/hu-HU.lang +108 -0
  88. data/app/packs/src/vendor/form_builder_langs/id-ID.lang +110 -0
  89. data/app/packs/src/vendor/form_builder_langs/it-IT.lang +107 -0
  90. data/app/packs/src/vendor/form_builder_langs/ja-JP.lang +108 -0
  91. data/app/packs/src/vendor/form_builder_langs/my-MM.lang +108 -0
  92. data/app/packs/src/vendor/form_builder_langs/nb-NO.lang +94 -0
  93. data/app/packs/src/vendor/form_builder_langs/nl-NL.lang +94 -0
  94. data/app/packs/src/vendor/form_builder_langs/pl-PL.lang +122 -0
  95. data/app/packs/src/vendor/form_builder_langs/pt-BR.lang +110 -0
  96. data/app/packs/src/vendor/form_builder_langs/pu-IN.lang +110 -0
  97. data/app/packs/src/vendor/form_builder_langs/qz-MM.lang +108 -0
  98. data/app/packs/src/vendor/form_builder_langs/ro-RO.lang +94 -0
  99. data/app/packs/src/vendor/form_builder_langs/ru-RU.lang +110 -0
  100. data/app/packs/src/vendor/form_builder_langs/sl-SI.lang +110 -0
  101. data/app/packs/src/vendor/form_builder_langs/th-TH.lang +111 -0
  102. data/app/packs/src/vendor/form_builder_langs/tr-TR.lang +115 -0
  103. data/app/packs/src/vendor/form_builder_langs/uk-UA.lang +108 -0
  104. data/app/packs/src/vendor/form_builder_langs/vi-VN.lang +94 -0
  105. data/app/packs/src/vendor/form_builder_langs/zh-CN.lang +100 -0
  106. data/app/packs/src/vendor/form_builder_langs/zh-TW.lang +94 -0
  107. data/app/packs/src/vendor/hashcash.js +83 -0
  108. data/app/packs/src/vendor/sha1.js +143 -0
  109. data/app/packs/src/vendor/stamp.js +50 -0
  110. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +6 -1
  111. data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +5 -0
  112. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +1 -2
  113. data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +2 -12
  114. data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +2 -2
  115. data/app/queries/decidim/decidim_awesome/space_constraint_finder.rb +43 -0
  116. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +3 -2
  117. data/app/services/decidim/decidim_awesome/access_authorization_service.rb +79 -0
  118. data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +2 -1
  119. data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +4 -4
  120. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/callout.html.erb +2 -2
  121. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/conflict.html.erb +4 -4
  122. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/edit.html.erb +6 -5
  123. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +6 -6
  124. data/app/views/decidim/decidim_awesome/admin/config/_authorization_options_form.html.erb +19 -0
  125. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +2 -2
  126. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +3 -3
  127. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +4 -3
  128. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +1 -1
  129. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +4 -4
  130. data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_styles.html.erb +3 -3
  131. data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +40 -2
  132. data/app/views/decidim/decidim_awesome/admin/config/_form_verifications.html.erb +71 -9
  133. data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +5 -4
  134. data/app/views/decidim/decidim_awesome/admin/hashcash/_filters.html.erb +55 -0
  135. data/app/views/decidim/decidim_awesome/admin/hashcash/index.html.erb +33 -0
  136. data/app/views/decidim/decidim_awesome/admin/hashcash/ip_addresses.html.erb +29 -0
  137. data/app/views/decidim/decidim_awesome/admin/hashcash/show.html.erb +42 -0
  138. data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +2 -2
  139. data/app/views/decidim/decidim_awesome/admin/{maintenance → private_data}/_private_data.html.erb +2 -2
  140. data/app/views/decidim/decidim_awesome/admin/{maintenance/show.html.erb → private_data/index.html.erb} +2 -3
  141. data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +1 -1
  142. data/app/views/decidim/decidim_awesome/admin/shared/_visibility_notice.html.erb +8 -0
  143. data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +2 -2
  144. data/app/views/decidim/decidim_awesome/hashcash/_hidden_field.html.erb +4 -0
  145. data/app/views/decidim/decidim_awesome/required_authorizations/index.html.erb +14 -4
  146. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +2 -2
  147. data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +2 -11
  148. data/config/assets.rb +1 -0
  149. data/config/i18n-tasks.yml +2 -0
  150. data/config/locales/ca.yml +100 -37
  151. data/config/locales/cs.yml +100 -36
  152. data/config/locales/de.yml +98 -35
  153. data/config/locales/en.yml +117 -44
  154. data/config/locales/es.yml +100 -36
  155. data/config/locales/eu.yml +34 -39
  156. data/config/locales/fr.yml +77 -31
  157. data/config/locales/ja.yml +99 -36
  158. data/config/locales/sv.yml +49 -0
  159. data/lib/decidim/decidim_awesome/admin_engine.rb +9 -5
  160. data/lib/decidim/decidim_awesome/{authorizator.rb → authorizer.rb} +1 -1
  161. data/lib/decidim/decidim_awesome/awesome.rb +34 -24
  162. data/lib/decidim/decidim_awesome/awesome_helpers.rb +14 -5
  163. data/lib/decidim/decidim_awesome/checksums.yml +26 -40
  164. data/lib/decidim/decidim_awesome/config.rb +18 -7
  165. data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +1 -1
  166. data/lib/decidim/decidim_awesome/engine.rb +14 -3
  167. data/lib/decidim/decidim_awesome/menu.rb +151 -138
  168. data/lib/decidim/decidim_awesome/middleware/current_config.rb +5 -10
  169. data/lib/decidim/decidim_awesome/test/initializer.rb +5 -2
  170. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +1 -3
  171. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +2 -1
  172. data/lib/decidim/decidim_awesome/test/shared_examples/proposal_form_examples.rb +191 -0
  173. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +15 -4
  174. data/lib/decidim/decidim_awesome/version.rb +1 -1
  175. data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -1
  176. data/package.json +7 -8
  177. metadata +86 -13
  178. data/app/controllers/concerns/decidim/decidim_awesome/check_login_authorizations.rb +0 -60
  179. data/app/packs/src/decidim/decidim_awesome/admin/verification_selects.js +0 -21
  180. data/config/rubocop/disabled.yml +0 -11
  181. data/config/rubocop/faker.yml +0 -480
  182. data/config/rubocop/rails.yml +0 -88
  183. data/config/rubocop/rspec.yml +0 -65
  184. data/config/rubocop/ruby.yml +0 -1210
@@ -1,17 +1,43 @@
1
1
  sv:
2
+ active_hashcash:
3
+ submit_filter: Filtrera
4
+ waiting_label: Väntar på verifiering ...
2
5
  activemodel:
3
6
  attributes:
4
7
  config:
8
+ additional_proposal_sortings: Ytterligare sorteringsalternativ aktiva
9
+ allow_images_in_editors: Tillåt bilder i HTML-redigeraren
5
10
  allow_images_in_proposals: Tillåt bilder i förslagsfältet
11
+ allow_videos_in_editors: Tillåt videor i HTML-redigeraren
6
12
  auto_save_forms: Spara formulär automatiskt i lokal lagring
13
+ hashcash_login: Aktivera Hashcash bot-skydd för befintliga användare (inloggning)
14
+ hashcash_login_bits: Antal bitar för Hashcash-algoritmen (inloggning)
15
+ hashcash_signup: Aktivera Hashcash bot-skydd för nya användare (registrering)
16
+ hashcash_signup_bits: Antal bitar för Hashcash-algoritmen (registrering)
17
+ intergram_auto_no_response: Ett meddelande som skickas en minut efter att användaren skickar sitt första meddelande och inget svar tagits emot
18
+ intergram_auto_response: Ett meddelande som skickas omedelbart efter att användaren skickar sitt första meddelande
7
19
  intergram_chat_id: Chatt ID
8
20
  intergram_color: Huvudfärg för widget
21
+ intergram_for_admins: Aktivera Intergram-chatt i admin-backend
9
22
  intergram_intro_message: Första meddelandet när användaren öppnar chatten för första gången
10
23
  intergram_require_login: Endast för inloggade användare
24
+ intergram_title_closed: Rubrik för stängd chatt
25
+ intergram_title_open: Rubrik för öppen chatt
26
+ intergram_use_floating_button: Om markerad är den stängda chatten alltid en knapp istället för en text
11
27
  proposal_custom_fields: Tilläggsfält %{id}
12
28
  scoped_styles: Tilläggsstilar %{id}
29
+ user_timezone: Tillåt användare att ställa in tidszon i sin profil
30
+ validate_body_max_caps_percent: Maximal tillåten procentandel versaler för brödtexten
31
+ validate_body_max_marks_together: Maximalt antal symboler i rad tillåtna i brödtexten
32
+ validate_body_min_length: Minst tillåtna antal tecken för brödtexten
33
+ validate_body_start_with_caps: Tvinga brödtexten att börja med en stor bokstav
34
+ validate_title_max_caps_percent: Maximal tillåten procentandel versaler för titeln
35
+ validate_title_max_marks_together: Maximalt antal symboler i rad tillåtna i titeln
36
+ validate_title_min_length: Minst tillåtna antal tecken för titeln
37
+ validate_title_start_with_caps: Tvinga titeln att börja med en versal
13
38
  constraint:
14
39
  component_id: eller specifikt i
40
+ component_manifest: Endast i komponenter av typ
15
41
  participatory_space_slug: Endast i
16
42
  custom_redirect:
17
43
  active: Aktiv
@@ -24,8 +50,27 @@ sv:
24
50
  target: Öppna i
25
51
  url: Webbadress
26
52
  visibility: Synlighet
53
+ organization:
54
+ awesome_admins_available_authorizations: Tillåt administratörer att manuellt verifiera användare med dessa auktoriseringar
55
+ user:
56
+ user_time_zone: Personlig tidszon
27
57
  decidim:
28
58
  admin:
59
+ actions:
60
+ manage: Hantera
61
+ filters:
62
+ admin_accountability:
63
+ admin_role_type:
64
+ label: Rolltyp
65
+ role:
66
+ label: Roll
67
+ role_type_eq:
68
+ label: Rolltyp
69
+ label:
70
+ search_field_end_date: 'Till datum:'
71
+ search_field_start_date: 'Från datum:'
72
+ search_placeholder:
73
+ user_name_or_user_email_cont: Sök på användarnamn, e-post
29
74
  menu:
30
75
  decidim_awesome: Decidim Awesome
31
76
  components:
@@ -35,6 +80,7 @@ sv:
35
80
  global:
36
81
  announcement: Meddelande
37
82
  iframe: Iframe kod
83
+ iframe_help: 'Ange din kod som html: <iframe width="100%" height="700" frameBorder="0" allowFullscreen src="..."></iframe>. Innehållet kommer att saneras från andra HTML-taggar. Se till att använda 100% som bredd för att fylla skärmen.'
38
84
  step:
39
85
  announcement: Meddelande
40
86
  iframe: Iframe kod
@@ -43,7 +89,10 @@ sv:
43
89
  settings:
44
90
  global:
45
91
  announcement: Meddelande
92
+ collapse: Börja med kollapsad meny
93
+ map_center: Kartans centrum (Latitud, Longitud)
46
94
  map_height: Karthöjd (px)
95
+ map_zoom: Zoom (valfritt tal mellan 0 och 18)
47
96
  menu_amendments: Visa ändringsförslag
48
97
  menu_meetings: Visa möten
49
98
  step:
@@ -24,13 +24,17 @@ module Decidim
24
24
  resources :scoped_styles, param: :var, only: [:create, :destroy]
25
25
  resources :proposal_custom_fields, param: :var, only: [:create, :destroy]
26
26
  resources :scoped_admins, param: :var, only: [:create, :destroy]
27
+ resources :force_authorizations, param: :var, only: [:create, :destroy]
27
28
  get :admin_accountability, to: "admin_accountability#index", as: "admin_accountability"
28
29
  post :export_admin_accountability, to: "admin_accountability#export", as: "export_admin_accountability"
29
30
  get :users, to: "config#users"
30
31
  post :rename_scope_label, to: "config#rename_scope_label"
31
- resources :maintenance, only: [:show] do
32
- delete :destroy_private_data, on: :member
33
- get :checks, on: :collection, to: "checks#index"
32
+ scope :maintenance do
33
+ get :checks, to: "checks#index"
34
+ resources :private_data, only: [:index, :destroy]
35
+ resources :hashcash, only: [:index, :show], as: "hashcashes" do
36
+ get :ip_addresses, on: :collection
37
+ end
34
38
  end
35
39
  resources :admin_authorizations, only: [:edit, :update, :destroy]
36
40
  post :migrate_images, to: "checks#migrate_images"
@@ -52,14 +56,14 @@ module Decidim
52
56
  if first_available
53
57
  decidim_admin_decidim_awesome.config_path(first_available)
54
58
  else
55
- decidim_admin_decidim_awesome.checks_maintenance_index_path
59
+ decidim_admin_decidim_awesome.checks_path
56
60
  end,
57
61
  icon_name: "fire",
58
62
  position: 7.5,
59
63
  active: if first_available
60
64
  is_active_link?(decidim_admin_decidim_awesome.config_path(first_available), :inclusive)
61
65
  else
62
- is_active_link?(decidim_admin_decidim_awesome.checks_maintenance_index_path)
66
+ is_active_link?(decidim_admin_decidim_awesome.checks_path)
63
67
  end,
64
68
  if: defined?(current_user) && current_user&.read_attribute("admin")
65
69
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module DecidimAwesome
5
- class Authorizator
5
+ class Authorizer
6
6
  def initialize(user, admin_authorizations)
7
7
  @user = user
8
8
  @admin_authorizations = admin_authorizations
@@ -15,7 +15,7 @@ module Decidim
15
15
  autoload :Lock, "decidim/decidim_awesome/lock"
16
16
  autoload :TranslatedCustomFieldsType, "decidim/decidim_awesome/api/types/translated_custom_fields_type"
17
17
  autoload :LocalizedCustomFieldsType, "decidim/decidim_awesome/api/types/localized_custom_fields_type"
18
- autoload :Authorizator, "decidim/decidim_awesome/authorizator"
18
+ autoload :Authorizer, "decidim/decidim_awesome/authorizer"
19
19
 
20
20
  # Awesome comes with some components for participatory spaces
21
21
  # Currently :awesome_map and :awesome_iframe, list them here
@@ -129,6 +129,31 @@ module Decidim
129
129
  false
130
130
  end
131
131
 
132
+ # This is an anti-spam mechanism that uses the Hashcash algorithm to increase the cost of brute-force attacks
133
+ # on the login and signup forms. It works by requiring a Hashcash stamp to be sent with the form.
134
+ # See http://www.hashcash.org/docs/hashcash.html
135
+ # This configuration enables Hashcash for the signup forms.
136
+ # If set to :disabled, the feature will be completely removed (only on the signup form).
137
+ config_accessor :hashcash_signup do
138
+ false
139
+ end
140
+
141
+ # This configuration enables Hashcash for the login forms.
142
+ # If set to :disabled, the feature will be completely removed (only on the login form).
143
+ config_accessor :hashcash_login do
144
+ false
145
+ end
146
+
147
+ # The Hashcash bits are the number of bits of the stamp. The higher the number, the more difficult it is to generate a valid stamp.
148
+ # The default value is 20 bits for the signup form and 16 bits for the login form.
149
+ config_accessor :hashcash_signup_bits do
150
+ 20
151
+ end
152
+
153
+ config_accessor :hashcash_login_bits do
154
+ 16
155
+ end
156
+
132
157
  # allows admins to created specific CSS snippets affecting only some public frontend specific parts
133
158
  # Valid values differ a little from the previous convention:
134
159
  # :disabled => false and non available, hidden from admins
@@ -178,22 +203,10 @@ module Decidim
178
203
  false
179
204
  end
180
205
 
181
- # Forces the user to authorize using some registered verification flow in order to access the platform
182
- # if set to an empty array, the user will be able to access the platform without any verification but admins can still enforce it
183
- # if set to :disabled the feature will be completely removed
184
- # You can initialize some default verification workflow manifests
185
- config_accessor :force_authorization_after_login do
186
- []
187
- end
188
-
189
- # By default all methods specified in force_authorization_after_login must be granted in order to access the platform
190
- # if set to true, the user will be able to access the platform if any of the methods is granted
191
- config_accessor :force_authorization_with_any_method do
192
- false
193
- end
194
-
195
- # When force_authorization_after_login is enabled, this text will be shown to the user as a help text (ie: add a contact information)
196
- config_accessor :force_authorization_help_text do
206
+ # Allows to enforce specific authorizations to access the platform
207
+ # Constraints can be defined for each group
208
+ # Set to :disabled to completely remove this feature
209
+ config_accessor :force_authorizations do
197
210
  {}
198
211
  end
199
212
 
@@ -234,6 +247,10 @@ module Decidim
234
247
  []
235
248
  end
236
249
 
250
+ config_accessor :mobile_menu do
251
+ []
252
+ end
253
+
237
254
  config_accessor :home_content_block_menu do
238
255
  []
239
256
  end
@@ -340,13 +357,6 @@ module Decidim
340
357
  [:proposals, :reporting_proposals]
341
358
  end
342
359
 
343
- # A URL where to obtain the translations for the FormBuilder component
344
- # you can a custom place if you are worried about the CDN geolocation
345
- # Download them from https://github.com/kevinchappell/formBuilder-languages
346
- config_accessor :form_builder_langs_location do
347
- "https://cdn.jsdelivr.net/npm/formbuilder-languages@1.1.0/"
348
- end
349
-
350
360
  # Public: Stores an instance of ContentBlockRegistry
351
361
  def self.voting_registry
352
362
  @voting_registry ||= Decidim::ManifestRegistry.new("decidim_awesome/voting")
@@ -10,11 +10,13 @@ module Decidim
10
10
 
11
11
  # Returns the normalized config for an Organization and the current url
12
12
  def awesome_config_instance
13
- memoize("current_config") do
13
+ @awesome_config_instance ||= memoize("current_config") do
14
14
  config = Config.new(request.env["decidim.current_organization"])
15
- config.context_from_request(request)
15
+ config.context_from_request!(request)
16
16
  config
17
17
  end
18
+ @awesome_config_instance.application_context!(current_user:) if respond_to?(:current_user)
19
+ @awesome_config_instance
18
20
  end
19
21
 
20
22
  def awesome_config
@@ -86,6 +88,13 @@ module Decidim
86
88
  end
87
89
  end
88
90
 
91
+ # Collects all the force authorizations that is applied in the current URL context
92
+ def awesome_force_authorizations
93
+ memoize("awesome_force_authorizations") do
94
+ awesome_config_instance.collect_sub_configs_values("force_authorization")
95
+ end
96
+ end
97
+
89
98
  # this will check if the current component has been configured to use a custom voting manifest
90
99
  def awesome_voting_manifest_for(component)
91
100
  memoize("awesome_voting_manifest_for_#{component.id}") do
@@ -93,11 +102,11 @@ module Decidim
93
102
  end
94
103
  end
95
104
 
96
- # Retrives all the "admins_available_authorizations" for the user along with other possible authorizations
97
- # returns an instance of Decidim::DecidimAwesome::Authorizator
105
+ # Retrieves all the "admins_available_authorizations" for the user along with other possible authorizations
106
+ # returns an instance of Decidim::DecidimAwesome::Authorizer
98
107
  def awesome_authorizations_for(user)
99
108
  memoize("awesome_authorizations_for_#{user.id}") do
100
- Authorizator.new(user, awesome_config[:admins_available_authorizations])
109
+ Authorizer.new(user, awesome_config[:admins_available_authorizations])
101
110
  end
102
111
  end
103
112
 
@@ -1,105 +1,91 @@
1
1
  decidim-admin:
2
2
  /app/views/layouts/decidim/admin/_header.html.erb:
3
- decidim-0.28: 25bf272ac5a70eb8a975f4889fa46095
4
- decidim-0.28.c4d3889: 6391da1f357f9b260622ddd404a47987
5
- decidim-0.28.1: b2ae319d5bcf43954bbe0edb9a4e3ffb
6
3
  decidim-0.29.1: b2ae319d5bcf43954bbe0edb9a4e3ffb
4
+ decidim-assemblies:
5
+ /app/views/decidim/assemblies/admin/assemblies/_form.html.erb:
6
+ decidim-0.29.4: 020a06e40fd3b8dae4ec63b2afcac9cb
7
+ decidim-participatory_processes:
8
+ /app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb:
9
+ decidim-0.29.4: 41d304c7583bdd51cbd5b6e98b27fded
10
+ decidim-conferences:
11
+ /app/views/decidim/conferences/admin/conferences/_form.html.erb:
12
+ decidim-0.29.4: 40c04d3e64936598f2c3acedf8e99372
7
13
  decidim-core:
8
14
  /app/packs/entrypoints/decidim_editor.js:
9
- decidim-0.28: beddd77e3893fd0b7cd2679a7ee6e536
10
15
  decidim-0.29.1: beddd77e3893fd0b7cd2679a7ee6e536
11
16
  /app/packs/src/decidim/editor/index.js:
12
- decidim-0.28: 90dfac3acae97202dec083955e2249e4
13
17
  decidim-0.29.1: 90dfac3acae97202dec083955e2249e4
14
18
  /app/validators/etiquette_validator.rb:
15
- decidim-0.28: e9ad91d824ad48ac2075a088a0d21349
16
19
  decidim-0.29.1: e9ad91d824ad48ac2075a088a0d21349
17
20
  /app/views/layouts/decidim/_head.html.erb:
18
- decidim-0.28: e51e400a98821f4ca0fff26ebd4d0741
19
- decidim-0.28.1: 8ac1af4e223d9a7a98136760b6194a75
20
- decidim-0.28.4: 59abccd8b1c5315d5c0b772be0c26d45
21
21
  decidim-0.29.1: 8ac1af4e223d9a7a98136760b6194a75
22
+ decidim-0.29.2: 59abccd8b1c5315d5c0b772be0c26d45
22
23
  /app/views/layouts/decidim/_decidim_javascript.html.erb:
23
- decidim-0.28: dc60ed8abf7649611f18804b67b1408d
24
24
  decidim-0.29.1: 8d51790de859ee66f305d9111cdfb324
25
25
  /app/presenters/decidim/menu_presenter.rb:
26
- decidim-0.28: 220c8865a43bd8b7b12a7f926f7f4324
27
26
  decidim-0.29.1: 220c8865a43bd8b7b12a7f926f7f4324
28
27
  /app/presenters/decidim/menu_item_presenter.rb:
29
- decidim-0.28: 4e4cd366a8a313079ac5fab466bd3679
30
- decidim-0.28.4: f04f0f5112499a86079119d5f9ae8487
31
28
  decidim-0.29.1: f04f0f5112499a86079119d5f9ae8487
32
29
  /app/helpers/decidim/amendments_helper.rb:
33
- decidim-0.28: df28f9321d1bc07757746ed608274e3d
34
30
  decidim-0.29.1: 36072334cba7a58841a6b2fb007d24a6
35
31
  /app/presenters/decidim/admin_log/component_presenter.rb:
36
- decidim-0.28: 77e80d527727acdf117a0c4517a69a7c
37
32
  decidim-0.29.1: 77e80d527727acdf117a0c4517a69a7c
38
33
  /app/forms/decidim/account_form.rb:
39
- decidim-0.28: 11a022ae6ae18ad89da168bec4207935
40
34
  decidim-0.29.1: 11a022ae6ae18ad89da168bec4207935
35
+ decidim-0.29.3: 5872f17965919c0754a453ac4eb614df
41
36
  /app/commands/decidim/update_account.rb:
42
- decidim-0.28: 363872116fb99372c046b7394d618333
43
37
  decidim-0.29.1: d24090fdd9358c38e6e15c4607a78e18
44
38
  /app/views/decidim/account/show.html.erb:
45
- decidim-0.28: a0647f1740d696018f73ec8db8c7587a
46
39
  decidim-0.29.1: f13218e2358a2d611996c2a197c0de25
40
+ /app/cells/decidim/content_blocks/global_menu_cell.rb:
41
+ decidim-0.28.0: d224370c364a9cf4b2e244063274e5ef
42
+ /app/views/decidim/devise/registrations/new.html.erb:
43
+ decidim-0.29.1: b30423406afd43bb9af2c98d59d43632
44
+ /app/views/decidim/devise/sessions/new.html.erb:
45
+ decidim-0.29.1: a8fe60cd10c1636822c252d5488a979d
46
+ /app/views/decidim/shared/_login_modal.html.erb:
47
+ decidim-0.29.1: 0d615603bb45f7b209032578dda9fc72
47
48
  decidim-proposals:
48
49
  /lib/decidim/proposals/proposal_serializer.rb:
49
- decidim-0.28: bbd33bdc60defb734b3fb814666bb622
50
- decidim-0.28.1: 7bd5cadb1127a4e81bd5f333670351bd
51
- decidim-0.28.2: ab146c54850a4486d96cf50211679671
52
50
  decidim-0.29.1: 58915ff3a7528463587d3762a93ff51b
51
+ decidim-0.29.2: f52f5770d8596134624ecb79457a21de
53
52
  /lib/decidim/api/proposal_type.rb:
54
- decidim-0.26: e38e4875e408ec4f658e28725c5a94d4
55
53
  decidim-0.29.1: 25d61a67a4b969ac8c472237d3f64b66
54
+ decidim-0.29.2: cd24561962f6fb6038678795f60bdec3
56
55
  /app/forms/decidim/proposals/proposal_form.rb:
57
56
  decidim-0.29.1: 0b19bfeb4f7bd15cd378a69c3935de6b
57
+ decidim-0.29.2: ad4ff4bde6ee2e802d394382ef7859a4
58
58
  /app/forms/decidim/proposals/admin/proposal_form.rb:
59
- decidim-0.28: 422632395194b19beed4c7c65f127ff5
60
59
  decidim-0.29.1: 422632395194b19beed4c7c65f127ff5
60
+ decidim-0.29.2: ad4ff4bde6ee2e802d394382ef7859a4
61
61
  /app/helpers/decidim/proposals/application_helper.rb:
62
- decidim-0.28: 89df14045349cc2eaaec78f79f6140b1
63
- decidim-0.28.2: 317b0347528e697fa405a792bcfa3db8
64
62
  decidim-0.29.1: 940488938f644b63a2ef6177f3757ca2
63
+ decidim-0.29.3: e6039a99268845c5038f913309fde432
65
64
  /app/controllers/decidim/proposals/proposal_votes_controller.rb:
66
- decidim-0.28: f983e72c1ee8d31222d537533c762cd2
67
65
  decidim-0.29.1: f983e72c1ee8d31222d537533c762cd2
68
66
  /app/views/decidim/proposals/admin/proposals/_form.html.erb:
69
- decidim-0.28: 824463b320562c15fdb530bfebbf2f0f
70
67
  decidim-0.29.1: 667c2ef6ffbf3369f59bd1e8eb0ba421
68
+ decidim-0.29.3: 59a7ed11d05a633cd4bf23881254b7f1
71
69
  /app/views/decidim/proposals/proposals/_vote_button.html.erb:
72
- decidim-0.27: 3d087d807238f33b71e6b385db8ffc70
73
70
  decidim-0.29.1: 06dd4c9bf7fc4953fc330b7ba081b2f6
74
71
  /app/views/decidim/proposals/proposals/_votes_count.html.erb:
75
- decidim-0.27: 6e663e5c82c27291b63f29f346df8737
76
72
  decidim-0.29.1: 6e663e5c82c27291b63f29f346df8737
77
73
  /app/cells/decidim/proposals/proposal_l_cell.rb:
78
- decidim-0.27.4: 5e111ed30bca9475bed8247e5e056747
79
- decidim-0.28.3: 6d955d56d9d9f0cba46ba157fa923cfc
80
74
  decidim-0.29.1: e38d1cd0ea6c7f14c8f8b56d3ceb0db5
75
+ decidim-0.29.2: 5043d8560a26fce2e296b3a0f6ba6cf6
81
76
  /app/cells/decidim/proposals/proposal_metadata_cell.rb:
82
- decidim-0.26: eedfd7f813aedbd819b519e03ae4a680
83
77
  decidim-0.29.1: 6859b77805227c4cf71ae0a1351a4551
84
78
  /app/commands/decidim/proposals/create_proposal.rb:
85
- decidim-0.28: 95c7bba44dbe477abdfbf450b7eee258
86
79
  decidim-0.29.1: 02a6f54a032457e68be580e6a539c47b
87
80
  /app/commands/decidim/proposals/create_collaborative_draft.rb:
88
- decidim-0.28: ab3f937f15c6ed945e776fef34b18abf
89
81
  decidim-0.29.1: ab3f937f15c6ed945e776fef34b18abf
90
82
  /app/commands/decidim/proposals/admin/create_proposal.rb:
91
- decidim-0.28: aa0c093cb10b3ccfb046edd0018eae1d
92
- decidim-0.28.3: 8d73a8c852f473c118f978ddfab323b1
93
83
  decidim-0.29.1: 837d86d2eb1f2d7579a0cef82d68caf7
94
84
  /app/commands/decidim/proposals/update_proposal.rb:
95
- decidim-0.28: 1cc15b946512f4d5a54d1cf5aea8450a
96
85
  decidim-0.29.1: e81268a1f9b3770387944d44d7704291
97
86
  /app/commands/decidim/proposals/update_collaborative_draft.rb:
98
- decidim-0.28: 7df5266382bd57db72832da391fe7e11
99
87
  decidim-0.29.1: 7df5266382bd57db72832da391fe7e11
100
88
  /app/commands/decidim/proposals/admin/update_proposal.rb:
101
- decidim-0.28: 67b691b6d1ce61cb198592ac25f76f74
102
89
  decidim-0.29.1: 67b691b6d1ce61cb198592ac25f76f74
103
90
  /app/presenters/decidim/proposals/proposal_presenter.rb:
104
- decidim-0.28: 72910541010305f25baf297f4a58497b
105
91
  decidim-0.29.1: bbc7cee02125c1f8cf909219e48af337
@@ -11,12 +11,13 @@ module Decidim
11
11
  participatory_space_manifest: nil,
12
12
  participatory_space_slug: nil,
13
13
  component_id: nil,
14
- component_manifest: nil
14
+ component_manifest: nil,
15
+ application_context: "anonymous"
15
16
  }
16
17
  @sub_configs = {}
17
18
  end
18
19
 
19
- attr_reader :context, :organization, :vars
20
+ attr_reader :context, :organization, :vars, :application_context
20
21
  attr_writer :defaults
21
22
 
22
23
  def defaults
@@ -29,23 +30,33 @@ module Decidim
29
30
  end
30
31
 
31
32
  # convert context to manifest, slug and id
32
- def context_from_request(request)
33
+ def context_from_request!(request)
33
34
  @config = nil
34
35
  @context = Decidim::DecidimAwesome::ContextAnalyzers::RequestAnalyzer.context_for request
35
36
  end
36
37
 
37
38
  # convert component to manifest, slug and id
38
- def context_from_component(component)
39
+ def context_from_component!(component)
39
40
  @config = nil
40
41
  @context = Decidim::DecidimAwesome::ContextAnalyzers::ComponentAnalyzer.context_for component
41
42
  end
42
43
 
43
44
  # convert participatory space to manifest, slug and id
44
- def context_from_participatory_space(space)
45
+ def context_from_participatory_space!(space)
45
46
  @config = nil
46
47
  @context = Decidim::DecidimAwesome::ContextAnalyzers::ParticipatorySpaceAnalyzer.context_for space
47
48
  end
48
49
 
50
+ def application_context!(ctx = {})
51
+ @application_context = ctx
52
+ @context[:application_context] = case ctx[:current_user]
53
+ when Decidim::User
54
+ "user_logged_in"
55
+ else
56
+ "anonymous"
57
+ end
58
+ end
59
+
49
60
  # config processed in context
50
61
  def config
51
62
  @config ||= calculate_config
@@ -93,7 +104,7 @@ module Decidim
93
104
  # if no constraints defined, applies to everything
94
105
  return true if constraints.blank?
95
106
 
96
- # if containts the "none" constraints, deactivate everything else
107
+ # if contains the "none" constraints, deactivate everything else
97
108
  return false if constraints.detect { |c| c.settings["participatory_space_manifest"] == "none" }
98
109
 
99
110
  # check if current context matches some constraint
@@ -117,7 +128,7 @@ module Decidim
117
128
  sub_configs_for(singular_key)[subkey.to_sym]&.add_constraints constraints
118
129
  end
119
130
 
120
- # Merges all subconfigs values for custom_styles or any other scoped confs
131
+ # Merges all sub-configs values for custom_styles or any other scoped configs
121
132
  # by default filtered according to the current scope, a block can be passed for custom filtering
122
133
  # ie, collect everything:
123
134
  # collect_sub_configs_values("scoped_style") { true }
@@ -34,7 +34,7 @@ module Decidim
34
34
  attr_reader :request, :context
35
35
 
36
36
  def extract_context!
37
- path = URI.parse(@request.url).path
37
+ path = @request.is_a?(String) ? @request : URI.parse(@request.url).path
38
38
  context_from_path path
39
39
  end
40
40
 
@@ -6,6 +6,7 @@ require "decidim/core"
6
6
  require "decidim/decidim_awesome/awesome_helpers"
7
7
  require "decidim/decidim_awesome/menu"
8
8
  require "decidim/decidim_awesome/middleware/current_config"
9
+ require "active_hashcash" if Decidim::DecidimAwesome.enabled?(:hashcash_signup, :hashcash_login)
9
10
 
10
11
  module Decidim
11
12
  module DecidimAwesome
@@ -18,12 +19,19 @@ module Decidim
18
19
  routes do
19
20
  get :required_authorizations, to: "required_authorizations#index"
20
21
  post :editor_images, to: "editor_images#create"
22
+ get "form_builder_i18n(/:lang)", to: "utils#form_builder_i18n", as: :form_builder_i18n
21
23
  end
22
24
 
23
25
  # Prepare a zone to create overrides
24
26
  # https://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers
25
27
  # overrides
26
28
  config.to_prepare do
29
+ if DecidimAwesome.enabled?(:hashcash_signup, :hashcash_login)
30
+ # Add hashcash to signup and login
31
+ Decidim::Devise::SessionsController.include(Decidim::DecidimAwesome::NeedsHashcash)
32
+ Decidim::Devise::RegistrationsController.include(Decidim::DecidimAwesome::NeedsHashcash)
33
+ Decidim::ApplicationController.include(Decidim::DecidimAwesome::NeedsHashcash)
34
+ end
27
35
  # Include additional helpers globally
28
36
  ActiveSupport.on_load(:action_view) { include Decidim::DecidimAwesome::AwesomeHelpers }
29
37
  # Also for cells
@@ -49,6 +57,7 @@ module Decidim
49
57
  :validate_body_max_marks_together,
50
58
  :validate_body_start_with_caps)
51
59
  Decidim::Proposals::ProposalForm.include(Decidim::DecidimAwesome::Proposals::ProposalFormCustomizations)
60
+ Decidim::Proposals::Admin::ProposalForm.include(Decidim::DecidimAwesome::Proposals::Admin::ProposalFormCustomizations)
52
61
  end
53
62
 
54
63
  if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields)
@@ -92,8 +101,8 @@ module Decidim
92
101
  # override user's admin property
93
102
  Decidim::User.include(Decidim::DecidimAwesome::UserOverride) if DecidimAwesome.enabled?(:scoped_admins)
94
103
 
95
- if DecidimAwesome.enabled?(:menu, :content_block_main_menu)
96
- Decidim::ContentBlocks::GlobalMenuCell.include(Decidim::DecidimAwesome::GlobalMenuCellOverride)
104
+ if DecidimAwesome.enabled?(:menu, :mobile_menu, :home_content_block_menu)
105
+ Decidim::ContentBlocks::GlobalMenuCell.include(Decidim::DecidimAwesome::GlobalMenuCellOverride) if DecidimAwesome.enabled?(:home_content_block_menu)
97
106
  Decidim::BreadcrumbHelper.include(Decidim::DecidimAwesome::BreadcrumbHelperOverride)
98
107
  Decidim::MenuPresenter.include(Decidim::DecidimAwesome::MenuPresenterOverride)
99
108
  Decidim::MenuItemPresenter.include(Decidim::DecidimAwesome::MenuItemPresenterOverride)
@@ -111,7 +120,7 @@ module Decidim
111
120
 
112
121
  initializer "decidim_decidim_awesome.overrides", after: "decidim.action_controller" do
113
122
  config.to_prepare do
114
- Decidim::ApplicationController.include(Decidim::DecidimAwesome::CheckLoginAuthorizations) if DecidimAwesome.enabled?(:force_authorization_after_login)
123
+ Decidim::ApplicationController.include(Decidim::DecidimAwesome::EnforceAccessAuthorizations) if DecidimAwesome.enabled?(:force_authorizations)
115
124
  Decidim::ApplicationController.include(Decidim::DecidimAwesome::UseUserTimeZone) if Decidim::DecidimAwesome.enabled?(:user_timezone)
116
125
 
117
126
  # Auto-insert some csp directives
@@ -291,6 +300,8 @@ module Decidim
291
300
  Decidim.icons.register(name: "spy", icon: "spy-fill", category: "system", description: "", engine: :decidim_awesome)
292
301
  Decidim.icons.register(name: "forbid-line", icon: "forbid-line", category: "system", description: "", engine: :decidim_awesome)
293
302
  Decidim.icons.register(name: "file-settings-line", icon: "file-settings-line", category: "system", description: "", engine: :decidim_awesome)
303
+ Decidim.icons.register(name: "hashtag", icon: "hashtag", category: "system", description: "", engine: :decidim_awesome)
304
+ Decidim.icons.register(name: "smartphone", icon: "smartphone-line", category: "system", description: "", engine: :decidim_awesome)
294
305
  end
295
306
  end
296
307
  end