decidim-core 0.3.2 → 0.4.0
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.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/decidim/extras/_add_comments.scss +9 -0
- data/app/assets/stylesheets/decidim/extras/_label-required.scss +3 -0
- data/app/assets/stylesheets/decidim/extras/_reference.scss +3 -0
- data/app/assets/stylesheets/decidim/extras/_social_icons_mini.scss +10 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/update_account.rb +2 -6
- data/app/constraints/decidim/current_feature.rb +11 -18
- data/app/constraints/decidim/current_participatory_process.rb +35 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +1 -0
- data/app/controllers/concerns/decidim/locale_switcher.rb +2 -2
- data/app/controllers/concerns/decidim/needs_authorization.rb +1 -2
- data/app/controllers/concerns/decidim/needs_organization.rb +1 -2
- data/app/controllers/concerns/decidim/needs_participatory_process.rb +19 -10
- data/app/controllers/decidim/account_controller.rb +13 -9
- data/app/controllers/decidim/application_controller.rb +3 -8
- data/app/controllers/decidim/devise/registrations_controller.rb +0 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +0 -1
- data/app/controllers/decidim/errors_controller.rb +15 -0
- data/app/controllers/decidim/features/base_controller.rb +1 -0
- data/app/controllers/decidim/participatory_process_groups_controller.rb +6 -2
- data/app/controllers/decidim/participatory_process_steps_controller.rb +1 -0
- data/app/controllers/decidim/participatory_processes_controller.rb +3 -3
- data/app/helpers/decidim/application_helper.rb +3 -0
- data/app/helpers/decidim/feature_path_helper.rb +35 -0
- data/app/helpers/decidim/feature_reference_helper.rb +4 -2
- data/app/helpers/decidim/icon_helper.rb +20 -0
- data/app/helpers/decidim/menu_helper.rb +1 -1
- data/app/helpers/decidim/participatory_process_helper.rb +0 -14
- data/app/models/decidim/feature.rb +9 -1
- data/app/models/decidim/static_page.rb +1 -0
- data/app/models/decidim/user.rb +2 -0
- data/app/queries/decidim/highlighted_participatory_processes.rb +1 -1
- data/app/views/decidim/account/show.html.erb +1 -3
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +20 -0
- data/app/views/{pages/500.html.erb → decidim/errors/internal_server_error.html.erb} +0 -0
- data/app/views/{pages/404.html.erb → decidim/errors/not_found.html.erb} +1 -1
- data/app/views/decidim/shared/_login_modal.html.erb +4 -0
- data/app/views/decidim/shared/_share_modal.html.erb +1 -1
- data/app/views/layouts/decidim/_process_header.html.erb +2 -2
- data/config/i18n-tasks.yml +2 -0
- data/config/initializers/invisible_captcha.rb +2 -2
- data/config/locales/ca.yml +14 -8
- data/config/locales/en.yml +13 -7
- data/config/locales/es.yml +13 -7
- data/config/locales/eu.yml +0 -7
- data/config/locales/fi.yml +0 -7
- data/config/locales/fr.yml +4 -11
- data/config/locales/it.yml +0 -7
- data/config/locales/nl.yml +0 -7
- data/config/routes.rb +2 -8
- data/db/migrate/20160817115213_devise_create_decidim_users.rb +6 -6
- data/db/migrate/20160920140207_devise_invitable_add_to_decidim_users.rb +9 -9
- data/db/seeds.rb +2 -2
- data/lib/decidim/core.rb +25 -1
- data/lib/decidim/core/engine.rb +0 -1
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/test/factories.rb +11 -6
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +69 -66
- data/lib/decidim/core/test/shared_examples/errors.rb +21 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +18 -2
- data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +2 -2
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/devise_failure_app.rb +1 -1
- data/lib/decidim/form_builder.rb +89 -5
- data/lib/decidim/has_reference.rb +3 -15
- data/lib/decidim/notifiable.rb +22 -0
- data/lib/devise/models/decidim_validatable.rb +4 -4
- metadata +41 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f13f38a692e1e440b837466cfef145041b4731a
|
4
|
+
data.tar.gz: 23544d83481adcedf009ee8696d6d3369b900fd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dcf4943c0d07fd5293b1b3a2114b98bfcda43ac5980b9904f26050310d2a2ae9b673ba20cb07ac33696fcdabce843d6b0b0b51bcb9e952078ae716ff88748ff
|
7
|
+
data.tar.gz: 47108ee568bbdd48e9a7d2f1ea6f0161edb7c5d76d27d20faa02166ca5dbcdad3036b1f96d7b549de9b9a0171132bce460f2452898d252228685ba9b8e22fc3b
|
@@ -21,7 +21,6 @@ module Decidim
|
|
21
21
|
|
22
22
|
if @user.valid?
|
23
23
|
@user.save!
|
24
|
-
@form.remove_avatar = false
|
25
24
|
broadcast(:ok, @user.unconfirmed_email.present?)
|
26
25
|
else
|
27
26
|
if @user.errors.has_key? :avatar
|
@@ -39,11 +38,8 @@ module Decidim
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def update_avatar
|
42
|
-
|
43
|
-
|
44
|
-
elsif @form.remove_avatar
|
45
|
-
@user.remove_avatar = true
|
46
|
-
end
|
41
|
+
@user.avatar = @form.avatar
|
42
|
+
@user.remove_avatar = @form.remove_avatar
|
47
43
|
end
|
48
44
|
|
49
45
|
def update_password
|
@@ -11,36 +11,29 @@ module Decidim
|
|
11
11
|
@manifest = manifest
|
12
12
|
end
|
13
13
|
|
14
|
-
# Public:
|
14
|
+
# Public: Matches the request against a feature and injects it into the
|
15
|
+
# environment.
|
15
16
|
#
|
16
|
-
# request - The request that holds the current feature relevant
|
17
|
-
# information.
|
17
|
+
# request - The request that holds the current feature relevant information.
|
18
18
|
#
|
19
|
-
# Returns
|
19
|
+
# Returns a true if the request matched, false otherwise
|
20
20
|
def matches?(request)
|
21
21
|
env = request.env
|
22
|
-
params = request.params
|
23
22
|
|
24
|
-
|
23
|
+
return false unless CurrentParticipatoryProcess.new.matches?(request)
|
25
24
|
|
26
|
-
@participatory_process =
|
27
|
-
organization.participatory_processes.find_by_id(params["participatory_process_id"])
|
25
|
+
@participatory_process = env["decidim.current_participatory_process"]
|
28
26
|
|
29
|
-
env
|
30
|
-
|
31
|
-
feature = detect_current_feature(params)
|
32
|
-
|
33
|
-
return false unless feature
|
34
|
-
|
35
|
-
env["decidim.current_feature"] ||= feature
|
36
|
-
true
|
27
|
+
current_feature(env, request.params) ? true : false
|
37
28
|
end
|
38
29
|
|
39
30
|
private
|
40
31
|
|
41
|
-
def
|
42
|
-
|
32
|
+
def current_feature(env, params)
|
33
|
+
env["decidim.current_feature"] ||= detect_current_feature(params)
|
34
|
+
end
|
43
35
|
|
36
|
+
def detect_current_feature(params)
|
44
37
|
@participatory_process.features.find do |feature|
|
45
38
|
params["feature_id"] == feature.id.to_s && feature.manifest_name == @manifest.name.to_s
|
46
39
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This class infers the current participatory process we're scoped to by
|
5
|
+
# looking at the request parameters and the organization in the request
|
6
|
+
# environment, and injects it into the environment.
|
7
|
+
class CurrentParticipatoryProcess
|
8
|
+
# Public: Matches the request against a participatory process and injects it
|
9
|
+
# into the environment.
|
10
|
+
#
|
11
|
+
# request - The request that holds the participatory process relevant
|
12
|
+
# information.
|
13
|
+
#
|
14
|
+
# Returns a true if the request matched, false otherwise
|
15
|
+
def matches?(request)
|
16
|
+
env = request.env
|
17
|
+
|
18
|
+
@organization = env["decidim.current_organization"]
|
19
|
+
return false unless @organization
|
20
|
+
|
21
|
+
current_participatory_process(env, request.params) ? true : false
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def current_participatory_process(env, params)
|
27
|
+
env["decidim.current_participatory_process"] ||=
|
28
|
+
detect_current_participatory_process(params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def detect_current_participatory_process(params)
|
32
|
+
@organization.participatory_processes.find_by_id(params["participatory_process_id"])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -46,14 +46,14 @@ module Decidim
|
|
46
46
|
#
|
47
47
|
# Returns an Array of Strings.
|
48
48
|
def available_locales
|
49
|
-
@available_locales ||= current_organization.available_locales
|
49
|
+
@available_locales ||= current_organization.available_locales
|
50
50
|
end
|
51
51
|
|
52
52
|
# The default locale of this organization.
|
53
53
|
#
|
54
54
|
# Returns a String with the default locale.
|
55
55
|
def default_locale
|
56
|
-
@default_locale ||= current_organization.default_locale
|
56
|
+
@default_locale ||= (current_organization || Decidim).public_send(:default_locale)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -30,8 +30,7 @@ module Decidim
|
|
30
30
|
current_settings: try(:current_settings),
|
31
31
|
feature_settings: try(:feature_settings),
|
32
32
|
current_organization: try(:current_organization),
|
33
|
-
current_feature: try(:current_feature)
|
34
|
-
current_participatory_process: try(:current_participatory_process)
|
33
|
+
current_feature: try(:current_feature)
|
35
34
|
}
|
36
35
|
end
|
37
36
|
|
@@ -22,9 +22,8 @@ module Decidim
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
# Raises a 404 if no organization is present.
|
26
25
|
def verify_organization
|
27
|
-
|
26
|
+
redirect_to decidim_system.root_path unless current_organization
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
@@ -1,19 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support/concern"
|
4
|
-
|
5
3
|
module Decidim
|
6
4
|
# This module, when injected into a controller, ensures there's a
|
7
5
|
# Participatory Process available and deducts it from the context.
|
8
6
|
module NeedsParticipatoryProcess
|
9
|
-
|
7
|
+
def self.enhance_controller(instance_or_module)
|
8
|
+
instance_or_module.class_eval do
|
9
|
+
helper_method :current_participatory_process
|
10
|
+
end
|
11
|
+
end
|
10
12
|
|
11
|
-
|
13
|
+
def self.extended(base)
|
14
|
+
base.extend NeedsOrganization, InstanceMethods
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
enhance_controller(base)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.included(base)
|
20
|
+
base.include NeedsOrganization, InstanceMethods
|
21
|
+
|
22
|
+
enhance_controller(base)
|
23
|
+
end
|
16
24
|
|
25
|
+
module InstanceMethods
|
17
26
|
# Public: Finds the current Participatory Process given this controller's
|
18
27
|
# context.
|
19
28
|
#
|
@@ -24,13 +33,13 @@ module Decidim
|
|
24
33
|
|
25
34
|
private
|
26
35
|
|
27
|
-
def
|
28
|
-
|
36
|
+
def ability_context
|
37
|
+
super.merge(current_participatory_process: current_participatory_process)
|
29
38
|
end
|
30
39
|
|
31
40
|
def detect_participatory_process
|
32
41
|
request.env["current_participatory_process"] ||
|
33
|
-
current_organization.participatory_processes.
|
42
|
+
current_organization.participatory_processes.find(params[:participatory_process_id] || params[:id])
|
34
43
|
end
|
35
44
|
end
|
36
45
|
end
|
@@ -15,25 +15,25 @@ module Decidim
|
|
15
15
|
|
16
16
|
def update
|
17
17
|
authorize! :update, current_user
|
18
|
-
@account = form(AccountForm).from_params(
|
18
|
+
@account = form(AccountForm).from_params(account_params)
|
19
19
|
|
20
20
|
UpdateAccount.call(current_user, @account) do
|
21
21
|
on(:ok) do |email_is_unconfirmed|
|
22
|
-
flash
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
flash[:notice] = if email_is_unconfirmed
|
23
|
+
t("account.update.success_with_email_confirmation", scope: "decidim")
|
24
|
+
else
|
25
|
+
t("account.update.success", scope: "decidim")
|
26
|
+
end
|
27
27
|
|
28
28
|
bypass_sign_in(current_user)
|
29
|
+
redirect_to account_path
|
29
30
|
end
|
30
31
|
|
31
32
|
on(:invalid) do
|
32
|
-
flash
|
33
|
+
flash[:alert] = t("account.update.error", scope: "decidim")
|
34
|
+
render action: :show
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
36
|
-
render action: :show
|
37
37
|
end
|
38
38
|
|
39
39
|
def delete
|
@@ -64,5 +64,9 @@ module Decidim
|
|
64
64
|
def authorizations
|
65
65
|
@authorizations ||= current_user.authorizations
|
66
66
|
end
|
67
|
+
|
68
|
+
def account_params
|
69
|
+
{ avatar: current_user.avatar }.merge(params[:user].to_unsafe_h)
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
# The main application controller that inherits from Rails.
|
5
5
|
class ApplicationController < ::DecidimController
|
6
|
-
include
|
7
|
-
include
|
6
|
+
include NeedsOrganization
|
7
|
+
include LocaleSwitcher
|
8
8
|
include NeedsAuthorization
|
9
9
|
include PayloadInfo
|
10
10
|
|
@@ -16,6 +16,7 @@ module Decidim
|
|
16
16
|
helper Decidim::CookiesHelper
|
17
17
|
helper Decidim::AriaSelectedLinkToHelper
|
18
18
|
helper Decidim::MenuHelper
|
19
|
+
helper Decidim::FeaturePathHelper
|
19
20
|
|
20
21
|
# Saves the location before loading each page so we can return to the
|
21
22
|
# right page. If we're on a devise page, we don't want to store that as the
|
@@ -28,8 +29,6 @@ module Decidim
|
|
28
29
|
|
29
30
|
layout "layouts/decidim/application"
|
30
31
|
|
31
|
-
rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
|
32
|
-
|
33
32
|
private
|
34
33
|
|
35
34
|
def store_current_location
|
@@ -46,9 +45,5 @@ module Decidim
|
|
46
45
|
def add_vary_header
|
47
46
|
response.headers["Vary"] = "Accept"
|
48
47
|
end
|
49
|
-
|
50
|
-
def redirect_to_404
|
51
|
-
raise ActionController::RoutingError, "Not Found"
|
52
|
-
end
|
53
48
|
end
|
54
49
|
end
|
@@ -5,7 +5,6 @@ module Decidim
|
|
5
5
|
# Custom Devise SessionsController to avoid namespace problems.
|
6
6
|
class SessionsController < ::Devise::SessionsController
|
7
7
|
include Decidim::DeviseControllers
|
8
|
-
helper Decidim::OmniauthHelper
|
9
8
|
|
10
9
|
def after_sign_in_path_for(user)
|
11
10
|
return first_login_authorizations_path if first_login_and_not_authorized?(user) &&
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ErrorsController < ApplicationController
|
5
|
+
skip_authorization_check
|
6
|
+
|
7
|
+
def not_found
|
8
|
+
render status: :not_found
|
9
|
+
end
|
10
|
+
|
11
|
+
def internal_server_error
|
12
|
+
render status: :internal_server_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -16,6 +16,7 @@ module Decidim
|
|
16
16
|
helper Decidim::FeatureReferenceHelper
|
17
17
|
helper Decidim::TranslationsHelper
|
18
18
|
helper Decidim::ParticipatoryProcessHelper
|
19
|
+
helper Decidim::IconHelper
|
19
20
|
helper Decidim::ResourceHelper
|
20
21
|
helper Decidim::OrganizationScopesHelper
|
21
22
|
helper Decidim::ActionAuthorizationHelper
|
@@ -6,6 +6,8 @@ module Decidim
|
|
6
6
|
class ParticipatoryProcessGroupsController < ApplicationController
|
7
7
|
helper_method :participatory_processes, :group, :collection
|
8
8
|
|
9
|
+
before_action :set_group
|
10
|
+
|
9
11
|
def show
|
10
12
|
authorize! :read, ParticipatoryProcessGroup
|
11
13
|
end
|
@@ -17,8 +19,10 @@ module Decidim
|
|
17
19
|
end
|
18
20
|
alias collection participatory_processes
|
19
21
|
|
20
|
-
def
|
21
|
-
Decidim::ParticipatoryProcessGroup.find(params[:id])
|
22
|
+
def set_group
|
23
|
+
@group = Decidim::ParticipatoryProcessGroup.find(params[:id])
|
22
24
|
end
|
25
|
+
|
26
|
+
attr_reader :group
|
23
27
|
end
|
24
28
|
end
|
@@ -6,15 +6,15 @@ module Decidim
|
|
6
6
|
# A controller that holds the logic to show ParticipatoryProcesses in a
|
7
7
|
# public layout.
|
8
8
|
class ParticipatoryProcessesController < ApplicationController
|
9
|
-
include NeedsParticipatoryProcess
|
10
|
-
|
11
9
|
layout "layouts/decidim/participatory_process", only: [:show]
|
12
10
|
|
13
|
-
|
11
|
+
before_action -> { extend(NeedsParticipatoryProcess) }, only: [:show]
|
14
12
|
|
15
13
|
helper Decidim::AttachmentsHelper
|
16
14
|
helper Decidim::ParticipatoryProcessHelper
|
15
|
+
helper Decidim::IconHelper
|
17
16
|
helper Decidim::WidgetUrlsHelper
|
17
|
+
|
18
18
|
helper_method :collection, :promoted_participatory_processes, :participatory_processes
|
19
19
|
|
20
20
|
def index
|