decidim-core 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/decidim/participatory_space_context.rb +60 -0
- data/app/controllers/decidim/features/base_controller.rb +7 -6
- data/app/helpers/decidim/participatory_space_helpers.rb +30 -0
- data/config/routes.rb +1 -1
- data/lib/decidim/abilities/participatory_process_role_ability.rb +1 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/participable.rb +0 -4
- data/lib/decidim/participatory_space_context_manifest.rb +14 -0
- data/lib/decidim/participatory_space_manifest.rb +27 -3
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ad061f43f8c514c854f0ea29035179e9f9010aa
|
4
|
+
data.tar.gz: 880adff366f398867619dd379122a0bb2704d153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80b4ae4bfee8d712fcbc8ec4aacbc630e3e294b887cebd70fe716b435cf51904f47c1179a56e4f1a92d50f1944f8bf6947259bb78a416e7651853e637f032a11
|
7
|
+
data.tar.gz: 607fdd0f547ee9b38348fc2d0a752fcb1be3fbd431931f4e04b22b3447ac07dd03825482d9bf1689a470c3fb51153d069ce6f795b61e833ef95d74006636cc76
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This module contains all the logic needed for a controller to render a participatory space
|
5
|
+
# public layout.
|
6
|
+
#
|
7
|
+
module ParticipatorySpaceContext
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
class_methods do
|
11
|
+
# Public: Called on a controller, it sets up all the surrounding methods to render a
|
12
|
+
# participatory space's template. It expects the method `current_participatory_space` to be
|
13
|
+
# defined, from which it will extract the participatory manifest.
|
14
|
+
#
|
15
|
+
# options - A hash used to modify the behavior of the layout. :only: - An array of actions on
|
16
|
+
# which the layout will be applied.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def participatory_space_layout(options = {})
|
20
|
+
layout :layout, options
|
21
|
+
before_action :authorize_participatory_space, options
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
included do
|
26
|
+
include Decidim::NeedsOrganization
|
27
|
+
|
28
|
+
helper ParticipatorySpaceHelpers, IconHelper
|
29
|
+
helper_method :current_participatory_space
|
30
|
+
helper_method :current_participatory_space_manifest
|
31
|
+
helper_method :current_participatory_space_context
|
32
|
+
|
33
|
+
delegate :manifest, to: :current_participatory_space, prefix: true
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def current_participatory_space_context
|
39
|
+
:public
|
40
|
+
end
|
41
|
+
|
42
|
+
def current_participatory_space
|
43
|
+
raise NotImplementedError
|
44
|
+
end
|
45
|
+
|
46
|
+
def authorize_participatory_space
|
47
|
+
authorize! :read, current_participatory_space
|
48
|
+
end
|
49
|
+
|
50
|
+
def ability_context
|
51
|
+
super.merge(
|
52
|
+
current_participatory_space: current_participatory_space,
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def layout
|
57
|
+
current_participatory_space_manifest.context(current_participatory_space_context).layout
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -9,6 +9,9 @@ module Decidim
|
|
9
9
|
include Settings
|
10
10
|
include ActionAuthorization
|
11
11
|
|
12
|
+
include ParticipatorySpaceContext
|
13
|
+
participatory_space_layout
|
14
|
+
|
12
15
|
helper Decidim::FiltersHelper
|
13
16
|
helper Decidim::OrdersHelper
|
14
17
|
helper Decidim::FeatureReferenceHelper
|
@@ -27,11 +30,13 @@ module Decidim
|
|
27
30
|
skip_authorize_resource
|
28
31
|
|
29
32
|
before_action do
|
30
|
-
extend current_participatory_space.extension_module
|
31
|
-
|
32
33
|
authorize! :read, current_feature
|
33
34
|
end
|
34
35
|
|
36
|
+
def current_participatory_space
|
37
|
+
request.env["decidim.current_participatory_space"]
|
38
|
+
end
|
39
|
+
|
35
40
|
def current_feature
|
36
41
|
request.env["decidim.current_feature"]
|
37
42
|
end
|
@@ -40,10 +45,6 @@ module Decidim
|
|
40
45
|
@current_manifest ||= current_feature.manifest
|
41
46
|
end
|
42
47
|
|
43
|
-
def current_participatory_space
|
44
|
-
current_feature.participatory_space
|
45
|
-
end
|
46
|
-
|
47
48
|
def ability_context
|
48
49
|
super.merge(
|
49
50
|
current_manifest: current_manifest,
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatorySpaceHelpers
|
5
|
+
# Public: This method gets exposed on all controllers that have `ParticipatorySpaceContext`
|
6
|
+
# included as a module.
|
7
|
+
#
|
8
|
+
# Through this method, you can access helpers that are unique to a particular participatory
|
9
|
+
# space. These helpers are defined in the participatory space manifest, via the `context`
|
10
|
+
# helper.
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# # If you had a `ParticipatoryProcessHelper` with a `participatory_process_header` method
|
15
|
+
# participatory_process_helpers.participatory_process_header(current_participatory_space)
|
16
|
+
#
|
17
|
+
# Returns an Object that includes the Helpers as public methods.
|
18
|
+
def participatory_space_helpers
|
19
|
+
return @participatory_space_helpers if defined?(@participatory_space_helpers)
|
20
|
+
|
21
|
+
helper = current_participatory_space_manifest.context(current_participatory_space_context).helper
|
22
|
+
|
23
|
+
klass = Class.new(SimpleDelegator) do
|
24
|
+
include helper.constantize if helper
|
25
|
+
end
|
26
|
+
|
27
|
+
@participatory_space_helpers = klass.new(self)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/config/routes.rb
CHANGED
@@ -23,7 +23,7 @@ Decidim::Core::Engine.routes.draw do
|
|
23
23
|
resource :locale, only: [:create]
|
24
24
|
|
25
25
|
Decidim.participatory_space_manifests.each do |manifest|
|
26
|
-
mount manifest.engine, at: "/", as: "decidim_#{manifest.name}"
|
26
|
+
mount manifest.context(:public).engine, at: "/", as: "decidim_#{manifest.name}"
|
27
27
|
end
|
28
28
|
|
29
29
|
mount Decidim::Verifications::Engine, at: "/", as: "decidim_verifications"
|
data/lib/decidim/core/version.rb
CHANGED
data/lib/decidim/participable.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This class holds the configuration for a participatory space's context. A context consists of an
|
5
|
+
# engine, a layout and a set of helpers (usually used by the layout itself).
|
6
|
+
class ParticipatorySpaceContextManifest
|
7
|
+
include ActiveModel::Model
|
8
|
+
include Virtus.model
|
9
|
+
|
10
|
+
attribute :engine, Rails::Engine
|
11
|
+
attribute :helper
|
12
|
+
attribute :layout
|
13
|
+
end
|
14
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "decidim/settings_manifest"
|
4
|
+
require "decidim/participatory_space_context_manifest"
|
4
5
|
|
5
6
|
module Decidim
|
6
7
|
# This class handles all the logic associated to configuring a participatory
|
@@ -12,9 +13,6 @@ module Decidim
|
|
12
13
|
include ActiveModel::Model
|
13
14
|
include Virtus.model
|
14
15
|
|
15
|
-
attribute :admin_engine, Rails::Engine
|
16
|
-
attribute :engine, Rails::Engine
|
17
|
-
|
18
16
|
attribute :name, Symbol
|
19
17
|
|
20
18
|
# The ActiveRecord class name of the model we're exposing
|
@@ -30,6 +28,32 @@ module Decidim
|
|
30
28
|
|
31
29
|
validates :name, presence: true
|
32
30
|
|
31
|
+
# A context used to set the layout and behavior of a participatory space. Full documentation can
|
32
|
+
# be found looking at the `ParticipatorySpaceContextManifest` class.
|
33
|
+
#
|
34
|
+
# Example:
|
35
|
+
#
|
36
|
+
# context(:public) do |context|
|
37
|
+
# context.layout "layouts/decidim/some_layout"
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# context(:public).layout
|
41
|
+
# # => "layouts/decidim/some_layout"
|
42
|
+
#
|
43
|
+
# Returns Nothing.
|
44
|
+
def context(name = :public, &block)
|
45
|
+
name = name.to_sym
|
46
|
+
@contexts ||= {}
|
47
|
+
|
48
|
+
if block
|
49
|
+
context = ParticipatorySpaceContextManifest.new
|
50
|
+
context.instance_eval(&block)
|
51
|
+
@contexts[name] = context
|
52
|
+
end
|
53
|
+
|
54
|
+
@contexts.fetch(name)
|
55
|
+
end
|
56
|
+
|
33
57
|
# Public: A block that gets called when seeding for this feature takes place.
|
34
58
|
#
|
35
59
|
# Returns nothing.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: active_link_to
|
@@ -508,28 +508,28 @@ dependencies:
|
|
508
508
|
requirements:
|
509
509
|
- - '='
|
510
510
|
- !ruby/object:Gem::Version
|
511
|
-
version: 0.8.
|
511
|
+
version: 0.8.4
|
512
512
|
type: :runtime
|
513
513
|
prerelease: false
|
514
514
|
version_requirements: !ruby/object:Gem::Requirement
|
515
515
|
requirements:
|
516
516
|
- - '='
|
517
517
|
- !ruby/object:Gem::Version
|
518
|
-
version: 0.8.
|
518
|
+
version: 0.8.4
|
519
519
|
- !ruby/object:Gem::Dependency
|
520
520
|
name: decidim-dev
|
521
521
|
requirement: !ruby/object:Gem::Requirement
|
522
522
|
requirements:
|
523
523
|
- - '='
|
524
524
|
- !ruby/object:Gem::Version
|
525
|
-
version: 0.8.
|
525
|
+
version: 0.8.4
|
526
526
|
type: :development
|
527
527
|
prerelease: false
|
528
528
|
version_requirements: !ruby/object:Gem::Requirement
|
529
529
|
requirements:
|
530
530
|
- - '='
|
531
531
|
- !ruby/object:Gem::Version
|
532
|
-
version: 0.8.
|
532
|
+
version: 0.8.4
|
533
533
|
description: Adds core features so other engines can hook into the framework.
|
534
534
|
email:
|
535
535
|
- josepjaume@gmail.com
|
@@ -679,6 +679,7 @@ files:
|
|
679
679
|
- app/controllers/concerns/decidim/needs_authorization.rb
|
680
680
|
- app/controllers/concerns/decidim/needs_organization.rb
|
681
681
|
- app/controllers/concerns/decidim/paginable.rb
|
682
|
+
- app/controllers/concerns/decidim/participatory_space_context.rb
|
682
683
|
- app/controllers/concerns/decidim/payload_info.rb
|
683
684
|
- app/controllers/concerns/decidim/settings.rb
|
684
685
|
- app/controllers/concerns/decidim/user_profile.rb
|
@@ -741,6 +742,7 @@ files:
|
|
741
742
|
- app/helpers/decidim/omniauth_helper.rb
|
742
743
|
- app/helpers/decidim/orders_helper.rb
|
743
744
|
- app/helpers/decidim/paginate_helper.rb
|
745
|
+
- app/helpers/decidim/participatory_space_helpers.rb
|
744
746
|
- app/helpers/decidim/replace_buttons_helper.rb
|
745
747
|
- app/helpers/decidim/resource_helper.rb
|
746
748
|
- app/helpers/decidim/sanitize_helper.rb
|
@@ -1100,6 +1102,7 @@ files:
|
|
1100
1102
|
- lib/decidim/messaging.rb
|
1101
1103
|
- lib/decidim/page_finder.rb
|
1102
1104
|
- lib/decidim/participable.rb
|
1105
|
+
- lib/decidim/participatory_space_context_manifest.rb
|
1103
1106
|
- lib/decidim/participatory_space_manifest.rb
|
1104
1107
|
- lib/decidim/publicable.rb
|
1105
1108
|
- lib/decidim/query_extensions.rb
|