decidim-core 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_core_manifest.js +1 -0
  3. data/app/assets/images/decidim/process.svg +10 -0
  4. data/app/assets/javascripts/decidim.js.es6 +2 -0
  5. data/app/assets/javascripts/decidim/editor.js.es6 +2 -2
  6. data/app/assets/javascripts/decidim/filters.js.es6 +1 -1
  7. data/app/assets/javascripts/decidim/form_filter.component.js.es6 +26 -5
  8. data/app/assets/javascripts/decidim/form_filter.component.test.js +1 -18
  9. data/app/assets/javascripts/decidim/foundation.js.es6 +1 -0
  10. data/app/assets/javascripts/decidim/history.js.es6 +35 -0
  11. data/app/assets/javascripts/decidim/orders.js.es6 +28 -0
  12. data/app/assets/stylesheets/decidim/_decidim.scss +1 -0
  13. data/app/assets/stylesheets/decidim/email.css +21 -3
  14. data/app/assets/stylesheets/decidim/extras/_leaflet.scss +4 -2
  15. data/app/assets/stylesheets/decidim/extras/_quill.scss +8 -0
  16. data/app/assets/stylesheets/decidim/extras/_register_form.scss +9 -0
  17. data/app/assets/stylesheets/decidim/modules/_buttons.scss +19 -3
  18. data/app/assets/stylesheets/decidim/utils/_mixins.scss +8 -4
  19. data/app/commands/decidim/authorize_user.rb +9 -4
  20. data/app/commands/decidim/create_omniauth_registration.rb +4 -2
  21. data/app/commands/decidim/create_registration.rb +4 -1
  22. data/app/commands/decidim/invite_user.rb +3 -1
  23. data/app/commands/decidim/update_notifications_settings.rb +31 -0
  24. data/app/constraints/decidim/current_feature.rb +16 -15
  25. data/app/controllers/concerns/decidim/action_authorization.rb +73 -0
  26. data/app/controllers/concerns/decidim/feature_settings.rb +2 -5
  27. data/app/controllers/concerns/decidim/needs_authorization.rb +5 -1
  28. data/app/controllers/concerns/decidim/user_profile.rb +1 -0
  29. data/app/controllers/decidim/application_controller.rb +12 -0
  30. data/app/controllers/decidim/authorizations_controller.rb +10 -12
  31. data/app/controllers/decidim/cookie_policy_controller.rb +15 -0
  32. data/app/controllers/decidim/devise/confirmations_controller.rb +4 -0
  33. data/app/controllers/decidim/devise/invitations_controller.rb +4 -0
  34. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +10 -3
  35. data/app/controllers/decidim/devise/passwords_controller.rb +4 -0
  36. data/app/controllers/decidim/devise/registrations_controller.rb +21 -0
  37. data/app/controllers/decidim/devise/sessions_controller.rb +4 -0
  38. data/app/controllers/decidim/notifications_settings_controller.rb +31 -0
  39. data/app/controllers/decidim/pages_controller.rb +17 -6
  40. data/app/controllers/decidim/participatory_processes_controller.rb +5 -5
  41. data/app/forms/decidim/notifications_settings_form.rb +17 -0
  42. data/app/forms/decidim/registration_form.rb +2 -1
  43. data/app/helpers/decidim/action_authorization_helper.rb +82 -0
  44. data/app/helpers/decidim/application_helper.rb +2 -0
  45. data/app/helpers/decidim/authorization_form_helper.rb +1 -1
  46. data/app/helpers/decidim/cookies_helper.rb +11 -0
  47. data/app/helpers/decidim/decidim_form_helper.rb +18 -0
  48. data/app/helpers/decidim/language_chooser_helper.rb +18 -0
  49. data/app/helpers/decidim/layout_helper.rb +0 -5
  50. data/app/helpers/decidim/localized_locales_helper.rb +1 -1
  51. data/app/helpers/decidim/meta_tags_helper.rb +104 -0
  52. data/app/helpers/decidim/orders_helper.rb +28 -0
  53. data/app/helpers/decidim/resource_helper.rb +46 -6
  54. data/app/mailers/decidim/application_mailer.rb +2 -2
  55. data/app/mailers/decidim/decidim_devise_mailer.rb +0 -1
  56. data/app/mailers/decidim/newsletter_mailer.rb +24 -0
  57. data/app/models/decidim/abilities/everyone.rb +2 -0
  58. data/app/models/decidim/feature.rb +30 -0
  59. data/app/models/decidim/newsletter.rb +24 -0
  60. data/app/models/decidim/organization.rb +2 -0
  61. data/app/models/decidim/user.rb +3 -2
  62. data/app/queries/decidim/highlighted_participatory_processes.rb +10 -0
  63. data/app/queries/decidim/promoted_participatory_processes.rb +9 -0
  64. data/app/queries/decidim/public_participatory_processes.rb +10 -0
  65. data/app/services/decidim/action_authorizer.rb +102 -0
  66. data/app/services/decidim/resource_search.rb +1 -1
  67. data/app/uploaders/decidim/official_image_footer_uploader.rb +12 -0
  68. data/app/uploaders/decidim/official_image_header_uploader.rb +12 -0
  69. data/app/validators/etiquette_validator.rb +42 -0
  70. data/app/views/decidim/account/show.html.erb +1 -1
  71. data/app/views/decidim/authorizations/index.html.erb +4 -4
  72. data/app/views/decidim/authorizations/new.html.erb +2 -2
  73. data/app/views/decidim/cookie_policy/accept.js.erb +3 -0
  74. data/app/views/decidim/devise/confirmations/new.html.erb +3 -1
  75. data/app/views/decidim/devise/invitations/edit.html.erb +1 -1
  76. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
  77. data/app/views/decidim/devise/passwords/edit.html.erb +1 -1
  78. data/app/views/decidim/devise/passwords/new.html.erb +3 -1
  79. data/app/views/decidim/devise/registrations/edit.html.erb +2 -1
  80. data/app/views/decidim/devise/registrations/new.html.erb +13 -1
  81. data/app/views/decidim/devise/sessions/new.html.erb +3 -1
  82. data/app/views/decidim/newsletter_mailer/newsletter.html.erb +5 -0
  83. data/app/views/decidim/notifications_settings/show.html.erb +26 -0
  84. data/app/views/decidim/pages/index.html.erb +34 -0
  85. data/app/views/decidim/participatory_process_steps/index.html.erb +1 -1
  86. data/app/views/decidim/participatory_processes/_participatory_process.html.erb +4 -2
  87. data/app/views/decidim/participatory_processes/_promoted_process.html.erb +1 -1
  88. data/app/views/decidim/participatory_processes/index.html.erb +3 -3
  89. data/app/views/decidim/participatory_processes/show.html.erb +30 -9
  90. data/app/views/decidim/shared/_action_authorization_modal.html.erb +55 -0
  91. data/app/views/decidim/shared/_login_modal.html.erb +2 -3
  92. data/app/views/decidim/shared/_orders.html.erb +15 -0
  93. data/app/views/decidim/shared/_share_modal.html.erb +33 -0
  94. data/app/views/devise/mailer/organization_admin_invitation_instructions.html.erb +1 -1
  95. data/app/views/layouts/decidim/_application.html.erb +12 -0
  96. data/app/views/layouts/decidim/_cookie_warning.html.erb +8 -0
  97. data/app/views/layouts/decidim/_footer.html.erb +6 -0
  98. data/app/views/layouts/decidim/_header.html.erb +7 -9
  99. data/app/views/layouts/decidim/_language_chooser.html.erb +3 -3
  100. data/app/views/layouts/decidim/_logo.html.erb +1 -1
  101. data/app/views/layouts/decidim/_mailer_logo.html.erb +31 -0
  102. data/app/views/layouts/decidim/_main_nav.html.erb +11 -0
  103. data/app/views/layouts/decidim/_process_header.html.erb +9 -7
  104. data/app/views/layouts/decidim/_social_media_links.html.erb +39 -0
  105. data/app/views/layouts/decidim/_social_meta.html.erb +8 -8
  106. data/app/views/layouts/decidim/mailer.html.erb +110 -62
  107. data/app/views/layouts/decidim/participatory_process.html.erb +14 -3
  108. data/app/views/layouts/decidim/user_profile.html.erb +1 -0
  109. data/app/views/pages/decidim_page.html.erb +5 -0
  110. data/app/views/pages/home.html.erb +4 -0
  111. data/app/views/pages/home/_extended.html.erb +2 -2
  112. data/app/views/pages/home/_footer_sub_hero.html.erb +12 -0
  113. data/app/views/pages/home/_hero.html.erb +2 -2
  114. data/app/views/pages/home/_highlighted_processes.html.erb +2 -2
  115. data/config/i18n-tasks.yml +6 -2
  116. data/config/initializers/invisible_captcha.rb +10 -0
  117. data/config/initializers/mail_previews.rb +4 -0
  118. data/config/locales/ca.yml +129 -23
  119. data/config/locales/en.yml +98 -13
  120. data/config/locales/es.yml +128 -22
  121. data/config/locales/eu.yml +5 -0
  122. data/config/routes.rb +13 -5
  123. data/db/migrate/20170131134349_add_action_permissions_to_decidim_features.rb +5 -0
  124. data/db/migrate/20170202084913_add_comments_and_replies_notifications_to_users.rb +6 -0
  125. data/db/migrate/20170203150545_add_newsletter_notifications_to_users.rb +5 -0
  126. data/db/migrate/20170206083118_rename_extra_info_on_processes.rb +12 -0
  127. data/db/migrate/20170206142116_add_published_at_to_decidim_features.rb +6 -0
  128. data/db/migrate/20170207091021_add_social_media_handlers_to_organization.rb +8 -0
  129. data/db/migrate/20170207093048_add_organization_logo_and_url.rb +7 -0
  130. data/db/migrate/20170213081133_create_decidim_newsletters.rb +15 -0
  131. data/db/seeds.rb +29 -4
  132. data/lib/decidim/attributes.rb +6 -0
  133. data/lib/decidim/attributes/time_with_zone.rb +13 -0
  134. data/lib/decidim/authorable.rb +2 -2
  135. data/lib/decidim/core.rb +11 -0
  136. data/lib/decidim/core/api.rb +11 -0
  137. data/lib/decidim/core/api/author_interface.rb +11 -0
  138. data/lib/decidim/core/api/localized_string_type.rb +11 -0
  139. data/{app/types/decidim → lib/decidim/core/api}/process_step_type.rb +2 -2
  140. data/{app/types/decidim → lib/decidim/core/api}/process_type.rb +1 -1
  141. data/{app/types/decidim → lib/decidim/core/api}/session_type.rb +0 -0
  142. data/lib/decidim/core/api/translated_field_type.rb +42 -0
  143. data/{app/types/decidim → lib/decidim/core/api}/user_group_type.rb +1 -1
  144. data/{app/types/decidim → lib/decidim/core/api}/user_type.rb +1 -1
  145. data/lib/decidim/core/engine.rb +7 -1
  146. data/lib/decidim/core/test.rb +1 -0
  147. data/lib/decidim/core/test/factories.rb +41 -8
  148. data/lib/decidim/core/test/shared_examples/localised_email.rb +24 -0
  149. data/lib/decidim/core/version.rb +1 -1
  150. data/lib/decidim/feature_manifest.rb +11 -0
  151. data/{app/validators → lib/decidim}/feature_validator.rb +1 -3
  152. data/lib/decidim/features/base_controller.rb +6 -1
  153. data/lib/decidim/form_builder.rb +166 -1
  154. data/lib/decidim/has_feature.rb +2 -1
  155. data/lib/decidim/resourceable.rb +26 -0
  156. data/vendor/assets/javascripts/morphdom.js +679 -0
  157. metadata +174 -49
  158. data/lib/decidim/has_attachment.rb +0 -32
@@ -37,7 +37,10 @@ module Decidim
37
37
  password: form.password,
38
38
  password_confirmation: form.password_confirmation,
39
39
  organization: form.current_organization,
40
- tos_agreement: form.tos_agreement)
40
+ tos_agreement: form.tos_agreement,
41
+ newsletter_notifications: form.newsletter_notifications,
42
+ comments_notifications: true,
43
+ replies_notifications: true)
41
44
  end
42
45
 
43
46
  def create_user_group
@@ -40,7 +40,9 @@ module Decidim
40
40
  name: form.name,
41
41
  email: form.email.downcase,
42
42
  organization: form.organization,
43
- roles: form.roles
43
+ roles: form.roles,
44
+ comments_notifications: true,
45
+ replies_notifications: true
44
46
  },
45
47
  form.invited_by,
46
48
  invitation_instructions: form.invitation_instructions
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # This command updates the user's notifictions settings.
4
+ class UpdateNotificationsSettings < Rectify::Command
5
+ # Updates a user's notifications settings.
6
+ #
7
+ # user - The user to be updated.
8
+ # form - The form with the data.
9
+ def initialize(user, form)
10
+ @user = user
11
+ @form = form
12
+ end
13
+
14
+ def call
15
+ return broadcast(:invalid) unless @form.valid?
16
+
17
+ update_notifications_settings
18
+ @user.save!
19
+
20
+ broadcast(:ok, @user)
21
+ end
22
+
23
+ private
24
+
25
+ def update_notifications_settings
26
+ @user.comments_notifications = @form.comments_notifications
27
+ @user.replies_notifications = @form.replies_notifications
28
+ @user.newsletter_notifications = @form.newsletter_notifications
29
+ end
30
+ end
31
+ end
@@ -17,11 +17,21 @@ module Decidim
17
17
  #
18
18
  # Returns nothing.
19
19
  def matches?(request)
20
+ env = request.env
21
+ params = request.params
22
+
23
+ organization = env["decidim.current_organization"]
24
+
25
+ @participatory_process = request.env["decidim.current_participatory_process"] ||
26
+ organization.participatory_processes.find_by_id(params["participatory_process_id"])
27
+
28
+ env["decidim.current_participatory_process"] ||= @participatory_process
29
+
20
30
  feature = detect_current_feature(request)
31
+
21
32
  return false unless feature
22
33
 
23
- request.env["decidim.current_participatory_process"] ||= feature.participatory_process
24
- request.env["decidim.current_feature"] ||= feature
34
+ env["decidim.current_feature"] ||= feature
25
35
  true
26
36
  end
27
37
 
@@ -29,20 +39,11 @@ module Decidim
29
39
 
30
40
  def detect_current_feature(request)
31
41
  params = request.params
32
- env = request.env
33
-
34
- return nil unless params[:feature_id]
35
-
36
- organization = env["decidim.current_organization"]
42
+ return nil unless params["feature_id"]
37
43
 
38
- Feature.includes(:participatory_process).where(
39
- id: params[:feature_id],
40
- manifest_name: @manifest.name,
41
- decidim_participatory_processes: {
42
- id: params[:participatory_process_id],
43
- decidim_organization_id: organization.id
44
- }
45
- ).first
44
+ @participatory_process.features.to_a.find do |feature|
45
+ params["feature_id"].to_s == feature.id.to_s && feature.manifest_name == @manifest.name.to_s
46
+ end
46
47
  end
47
48
  end
48
49
  end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+ require "active_support/concern"
3
+
4
+ module Decidim
5
+ module ActionAuthorization
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ helper_method :authorize_action_path, :action_authorization
10
+ end
11
+
12
+ # Public: Authorizes an action of a feature given an action name.
13
+ #
14
+ # action_name - The action name to authorize. Actions are set up on the
15
+ # feature's permissions panel.
16
+ # redirect_url - Url to be redirected to when the authorization is finished.
17
+ def authorize_action!(action_name, redirect_url: nil)
18
+ @action_authorizations ||= {}
19
+ @action_authorizations[action_name] = _action_authorizer(action_name).authorize
20
+ status = @action_authorizations[action_name]
21
+
22
+ return if status.ok?
23
+ raise Unauthorized if status.code == :invalid
24
+
25
+ redirect_to authorize_action_path_from_status(status, redirect_url)
26
+ end
27
+
28
+ # Public: Returns the authorization object for an authorization.
29
+ #
30
+ # action_name - The action to authorize against.
31
+ #
32
+ # Returns an ActionAuthorizer::AuthorizationStatus
33
+ def action_authorization(action_name)
34
+ _action_authorizer(action_name).authorize
35
+ end
36
+
37
+ # Public: Returns the authorization path for a failed authorization with
38
+ # the populated redirect url.
39
+ #
40
+ # action_name - The action name to authorize against.
41
+ # redirect_url - The url to redirect to when finished.
42
+ #
43
+ # Returns a String.
44
+ def authorize_action_path(action_name, redirect_url: nil)
45
+ redirect_url ||= request.path
46
+
47
+ authorize_action_path_from_status(
48
+ action_authorization(action_name),
49
+ redirect_url: redirect_url
50
+ )
51
+ end
52
+
53
+ # Public: Returns the authorization path for a failed authorization with
54
+ # the populated redirect url.
55
+ #
56
+ # status - The status after an authorization check.
57
+ # redirect_url - The url to redirect to when finished.
58
+ #
59
+ # Returns a String.
60
+ def authorize_action_path_from_status(status, redirect_url: nil)
61
+ decidim.new_authorization_path(
62
+ handler: status.data[:handler],
63
+ redirect_url: redirect_url
64
+ )
65
+ end
66
+
67
+ def _action_authorizer(action_name)
68
+ ActionAuthorizer.new(current_user, current_feature, action_name)
69
+ end
70
+
71
+ class Unauthorized < StandardError; end
72
+ end
73
+ end
@@ -13,14 +13,11 @@ module Decidim
13
13
  helper_method :feature_settings, :current_settings
14
14
 
15
15
  def feature_settings
16
- current_feature.settings
16
+ @feature_settings ||= current_feature.settings
17
17
  end
18
18
 
19
19
  def current_settings
20
- active_step = current_participatory_process.active_step
21
- return nil unless active_step
22
-
23
- current_feature.step_settings.fetch(active_step.id.to_s)
20
+ @current_settings ||= current_feature.active_step_settings
24
21
  end
25
22
  end
26
23
  end
@@ -11,6 +11,7 @@ module Decidim
11
11
  check_authorization
12
12
 
13
13
  rescue_from CanCan::AccessDenied, with: :user_not_authorized
14
+ rescue_from ActionAuthorization::Unauthorized, with: :user_not_authorized
14
15
 
15
16
  private
16
17
 
@@ -26,8 +27,11 @@ module Decidim
26
27
 
27
28
  def ability_context
28
29
  {
30
+ current_settings: try(:current_settings),
31
+ feature_settings: try(:feature_settings),
29
32
  current_organization: try(:current_organization),
30
- current_feature: try(:current_feature)
33
+ current_feature: try(:current_feature),
34
+ current_participatory_process: try(:current_participatory_process)
31
35
  }
32
36
  end
33
37
 
@@ -18,6 +18,7 @@ module Decidim
18
18
  helper_method :available_authorization_handlers,
19
19
  :user_groups
20
20
 
21
+ before_action :current_user
21
22
  authorize_resource :current_user
22
23
  end
23
24
 
@@ -5,12 +5,24 @@ module Decidim
5
5
  include Decidim::NeedsOrganization
6
6
  include Decidim::LocaleSwitcher
7
7
  include NeedsAuthorization
8
+ helper Decidim::MetaTagsHelper
9
+ helper Decidim::DecidimFormHelper
10
+ helper Decidim::LanguageChooserHelper
11
+
8
12
  protect_from_forgery with: :exception, prepend: true
13
+ after_action :add_vary_header
9
14
 
10
15
  layout "layouts/decidim/application"
11
16
 
12
17
  def user_not_authorized_path
13
18
  decidim.root_path
14
19
  end
20
+
21
+ # Make sure Chrome doesn't use the cache from a different format. This
22
+ # prevents a bug where clicking the back button of the browser
23
+ # displays the JS response instead of the HTML one.
24
+ def add_vary_header
25
+ response.headers["Vary"] = "Accept"
26
+ end
15
27
  end
16
28
  end
@@ -9,6 +9,7 @@ module Decidim
9
9
  before_action :valid_handler, only: [:new, :create]
10
10
 
11
11
  include Decidim::UserProfile
12
+ helper Decidim::DecidimFormHelper
12
13
 
13
14
  layout "layouts/decidim/user_profile", only: [:index]
14
15
 
@@ -19,14 +20,20 @@ module Decidim
19
20
  end
20
21
 
21
22
  def first_login
22
- redirect_to(action: :new, handler: handlers.first.handler_name) if handlers.length == 1
23
+ if handlers.length == 1
24
+ redirect_to(
25
+ action: :new,
26
+ handler: handlers.first.handler_name,
27
+ redirect_url: account_path
28
+ )
29
+ end
23
30
  end
24
31
 
25
32
  def create
26
33
  AuthorizeUser.call(handler) do
27
34
  on(:ok) do
28
35
  flash[:notice] = t("authorizations.create.success", scope: "decidim")
29
- redirect_to account_path
36
+ redirect_to params[:redirect_url] || authorizations_path
30
37
  end
31
38
 
32
39
  on(:invalid) do
@@ -36,15 +43,6 @@ module Decidim
36
43
  end
37
44
  end
38
45
 
39
- def destroy
40
- @authorization = current_user.authorizations.find(params[:id])
41
- authorize! :destroy, @authorization
42
-
43
- @authorization.destroy
44
- flash[:notice] = t("authorizations.destroy.success", scope: "decidim")
45
- redirect_to account_path
46
- end
47
-
48
46
  def handler
49
47
  @handler ||= AuthorizationHandler.handler_for(handler_name, handler_params)
50
48
  end
@@ -73,7 +71,7 @@ module Decidim
73
71
  end
74
72
 
75
73
  def only_one_handler?
76
- redirect_to(action: :new, handler: handlers.first.handler_name) && return if handlers.length == 1
74
+ redirect_to(action: :new, handler: available_handlers.first.handler_name) && return if available_handlers.length == 1
77
75
  end
78
76
 
79
77
  def handlers
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ require_dependency "decidim/application_controller"
3
+
4
+ module Decidim
5
+ # This controller allows the user to accept the cookie policy.
6
+ class CookiePolicyController < ApplicationController
7
+ skip_authorization_check
8
+
9
+ def accept
10
+ response.set_cookie "decidim-cc", value: "true",
11
+ path: "/",
12
+ expires: 1.year.from_now.utc
13
+ end
14
+ end
15
+ end
@@ -6,6 +6,10 @@ module Decidim
6
6
  include Decidim::NeedsOrganization
7
7
  include Decidim::LocaleSwitcher
8
8
  helper Decidim::TranslationsHelper
9
+ helper Decidim::MetaTagsHelper
10
+ helper Decidim::DecidimFormHelper
11
+ helper Decidim::LanguageChooserHelper
12
+ helper Decidim::CookiesHelper
9
13
 
10
14
  layout "layouts/decidim/application"
11
15
  end
@@ -6,6 +6,10 @@ module Decidim
6
6
  include Decidim::NeedsOrganization
7
7
  include Decidim::LocaleSwitcher
8
8
  helper Decidim::TranslationsHelper
9
+ helper Decidim::MetaTagsHelper
10
+ helper Decidim::DecidimFormHelper
11
+ helper Decidim::LanguageChooserHelper
12
+ helper Decidim::CookiesHelper
9
13
 
10
14
  layout "layouts/decidim/application"
11
15
 
@@ -8,6 +8,10 @@ module Decidim
8
8
  include Decidim::NeedsOrganization
9
9
  include Decidim::LocaleSwitcher
10
10
  helper Decidim::TranslationsHelper
11
+ helper Decidim::MetaTagsHelper
12
+ helper Decidim::DecidimFormHelper
13
+ helper Decidim::LanguageChooserHelper
14
+ helper Decidim::CookiesHelper
11
15
 
12
16
  layout "layouts/decidim/application"
13
17
 
@@ -37,9 +41,12 @@ module Decidim
37
41
  render :new
38
42
  end
39
43
 
40
- on(:error) do
41
- redirect_to decidim.new_user_registration_path
42
- set_flash_message :alert, :failure, kind: @form.provider, reason: t("decidim.devise.omniauth_registrations.create.email_already_exists")
44
+ on(:error) do |user|
45
+ if user.errors[:email]
46
+ set_flash_message :alert, :failure, kind: @form.provider.capitalize, reason: t("decidim.devise.omniauth_registrations.create.email_already_exists")
47
+ end
48
+
49
+ render :new
43
50
  end
44
51
  end
45
52
  end
@@ -6,6 +6,10 @@ module Decidim
6
6
  include Decidim::NeedsOrganization
7
7
  include Decidim::LocaleSwitcher
8
8
  helper Decidim::TranslationsHelper
9
+ helper Decidim::MetaTagsHelper
10
+ helper Decidim::DecidimFormHelper
11
+ helper Decidim::LanguageChooserHelper
12
+ helper Decidim::CookiesHelper
9
13
 
10
14
  layout "layouts/decidim/application"
11
15
  end
@@ -9,9 +9,18 @@ module Decidim
9
9
  include FormFactory
10
10
  helper Decidim::TranslationsHelper
11
11
  helper Decidim::OmniauthHelper
12
+ helper Decidim::MetaTagsHelper
13
+ helper Decidim::DecidimFormHelper
14
+ helper Decidim::LanguageChooserHelper
15
+ helper Decidim::CookiesHelper
16
+
17
+ helper_method :terms_and_conditions_page
12
18
 
13
19
  layout "layouts/decidim/application"
14
20
  before_action :configure_permitted_parameters
21
+ helper_method :terms_and_conditions_page
22
+
23
+ invisible_captcha
15
24
 
16
25
  def new
17
26
  @form = form(RegistrationForm).from_params(
@@ -43,6 +52,12 @@ module Decidim
43
52
  end
44
53
  end
45
54
 
55
+ private
56
+
57
+ def terms_and_conditions_page
58
+ @terms_and_conditions_page ||= Decidim::StaticPage.find_by_slug("terms-and-conditions")
59
+ end
60
+
46
61
  protected
47
62
 
48
63
  def configure_permitted_parameters
@@ -54,6 +69,12 @@ module Decidim
54
69
  super(hash)
55
70
  resource.organization = current_organization
56
71
  end
72
+
73
+ private
74
+
75
+ def terms_and_conditions_page
76
+ @terms_and_conditions_page ||= Decidim::StaticPage.find_by_slug("terms-and-conditions")
77
+ end
57
78
  end
58
79
  end
59
80
  end
@@ -7,6 +7,10 @@ module Decidim
7
7
  include Decidim::LocaleSwitcher
8
8
  helper Decidim::TranslationsHelper
9
9
  helper Decidim::OmniauthHelper
10
+ helper Decidim::MetaTagsHelper
11
+ helper Decidim::DecidimFormHelper
12
+ helper Decidim::LanguageChooserHelper
13
+ helper Decidim::CookiesHelper
10
14
 
11
15
  layout "layouts/decidim/application"
12
16
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require_dependency "decidim/application_controller"
3
+
4
+ module Decidim
5
+ # The controller to handle the user's notifications settings page.
6
+ class NotificationsSettingsController < ApplicationController
7
+ include Decidim::UserProfile
8
+
9
+ def show
10
+ authorize! :show, current_user
11
+ @notifications_settings = form(NotificationsSettingsForm).from_model(current_user)
12
+ end
13
+
14
+ def update
15
+ authorize! :update, current_user
16
+ @notifications_settings = form(NotificationsSettingsForm).from_params(params)
17
+
18
+ UpdateNotificationsSettings.call(current_user, @notifications_settings) do
19
+ on(:ok) do
20
+ flash.now[:notice] = t("notifications_settings.update.success", scope: "decidim")
21
+ end
22
+
23
+ on(:invalid) do
24
+ flash.now[:alert] = t("notifications_settings.update.error", scope: "decidim")
25
+ end
26
+ end
27
+
28
+ render action: :show
29
+ end
30
+ end
31
+ end