decidim-assemblies 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a5e19cd2b2c3452c6b347ceffb2f54efbfdd708
4
- data.tar.gz: 1a21d4162dc350d2644de0b8e64dca47a53d0dee
3
+ metadata.gz: 36bdde02af4051c46ec0dfe0fa5f01a80bb4c4ee
4
+ data.tar.gz: a761f3f9f2ec9a17707a5987559ba09ed766e6ad
5
5
  SHA512:
6
- metadata.gz: fff5da60a3aac6b67c0ec87a61b434445cc2f2ad8a90e82e3ce3f207a1717fb491f6d158aa355d4809e21653bc4be0f2bc375f0e359bab549a80588e95c15c1a
7
- data.tar.gz: b5b1cddaa99cc66ed9b81e711fe4db33687d85dd5f1bfefe1e36112300c4604f79bbd929dcc0ecadf8a2281972df4e5043047e7eda07544940f6f5ffd99e7bf4
6
+ metadata.gz: 67d0794a61829846d36a3d8fc3c3c5ce11f4acbf8c57f59ea78e90e0263c257eef2bd8c1b75df0e548b20e5b26c7b96535af9f4b053037a0fb597fcdf3fd0d00
7
+ data.tar.gz: e2c685cf545dd8890512dc11b9c699f9c1e741957844729e00c67cd82f71199e1694c7e121543786b6ae5f642eccd79fc4f080c55b9c1adcce5c489d427cad43
@@ -7,7 +7,6 @@ module Decidim
7
7
  #
8
8
  class AssembliesController < Decidim::Admin::ApplicationController
9
9
  helper_method :current_assembly
10
-
11
10
  layout "decidim/admin/assemblies"
12
11
 
13
12
  def index
@@ -84,12 +83,16 @@ module Decidim
84
83
  ).first
85
84
  end
86
85
 
86
+ def current_participatory_space
87
+ current_assembly
88
+ end
89
+
87
90
  def collection
88
91
  @collection ||= OrganizationAssemblies.new(current_user.organization).query
89
92
  end
90
93
 
91
94
  def ability_context
92
- super.merge(current_assembly: current_assembly)
95
+ super.merge(current_participatory_space: current_assembly)
93
96
  end
94
97
 
95
98
  def assembly_params
@@ -13,12 +13,22 @@ module Decidim
13
13
  extend ActiveSupport::Concern
14
14
 
15
15
  included do
16
- include NeedsAssembly
17
-
18
- layout "decidim/admin/assembly"
16
+ include Decidim::Admin::ParticipatorySpaceAdminContext
17
+ participatory_space_admin_layout
19
18
 
19
+ helper_method :current_assembly
20
20
  alias_method :current_participatory_space, :current_assembly
21
21
  end
22
+
23
+ def current_assembly
24
+ @current_assembly ||= organization_assemblies.find_by!(
25
+ slug: params[:assembly_slug] || params[:slug]
26
+ )
27
+ end
28
+
29
+ def organization_assemblies
30
+ @organization_assemblies ||= OrganizationAssemblies.new(current_organization).query
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -5,9 +5,8 @@ module Decidim
5
5
  # A controller that holds the logic to show Assemblies in a
6
6
  # public layout.
7
7
  class AssembliesController < Decidim::ApplicationController
8
- layout "layouts/decidim/assembly", only: [:show]
9
-
10
- before_action -> { extend NeedsAssembly }, only: [:show]
8
+ include ParticipatorySpaceContext
9
+ participatory_space_layout only: :show
11
10
 
12
11
  helper Decidim::AttachmentsHelper
13
12
  helper Decidim::IconHelper
@@ -22,12 +21,14 @@ module Decidim
22
21
  authorize! :read, Assembly
23
22
  end
24
23
 
25
- def show
26
- authorize! :read, current_assembly
27
- end
24
+ def show; end
28
25
 
29
26
  private
30
27
 
28
+ def current_participatory_space
29
+ @current_participatory_space ||= OrganizationAssemblies.new(current_organization).query.find_by(slug: params[:slug])
30
+ end
31
+
31
32
  def published_assemblies
32
33
  @published_assemblies ||= OrganizationPublishedAssemblies.new(current_organization)
33
34
  end
@@ -43,7 +44,7 @@ module Decidim
43
44
  end
44
45
 
45
46
  def stats
46
- @stats ||= AssemblyStatsPresenter.new(assembly: current_assembly)
47
+ @stats ||= AssemblyStatsPresenter.new(assembly: current_participatory_space)
47
48
  end
48
49
  end
49
50
  end
@@ -1,6 +1,6 @@
1
1
  <section class="extended" id="assembly-statistics" class="statistics">
2
2
  <div class="row column">
3
- <h4 class="section-heading"><%= t("statistics.headline", scope: "decidim.assemblies", assembly: translated_attribute(current_assembly.title)) %></h3>
3
+ <h4 class="section-heading"><%= t("statistics.headline", scope: "decidim.assemblies", assembly: translated_attribute(current_participatory_space.title)) %></h3>
4
4
  </div>
5
5
  <div class="row">
6
6
  <div class="columns small-centered mediumlarge-12 large-12 process_stats">
@@ -1,8 +1,8 @@
1
1
  <% add_decidim_meta_tags({
2
- image_url: current_assembly.hero_image.url,
3
- description: translated_attribute(current_assembly.short_description),
4
- title: translated_attribute(current_assembly.title),
5
- url: assembly_url(current_assembly),
2
+ image_url: current_participatory_space.hero_image.url,
3
+ description: translated_attribute(current_participatory_space.short_description),
4
+ title: translated_attribute(current_participatory_space.title),
5
+ url: assembly_url(current_participatory_space),
6
6
  twitter_handler: current_organization.twitter_handler
7
7
  }) %>
8
8
 
@@ -11,61 +11,61 @@
11
11
  <div class="columns medium-7 mediumlarge-8">
12
12
  <div class="section">
13
13
  <div class="lead">
14
- <%= decidim_sanitize translated_attribute(current_assembly.short_description) %>
14
+ <%= decidim_sanitize translated_attribute(current_participatory_space.short_description) %>
15
15
  </div>
16
- <%= decidim_sanitize translated_attribute(current_assembly.description) %>
16
+ <%= decidim_sanitize translated_attribute(current_participatory_space.description) %>
17
17
  </div>
18
- <%= attachments_for current_assembly %>
18
+ <%= attachments_for current_participatory_space %>
19
19
  </div>
20
20
  <div class="section columns medium-5 mediumlarge-4 large-3">
21
21
  <div class="card extra definition-data">
22
- <% if translated_attribute(current_assembly.meta_scope).present? %>
22
+ <% if translated_attribute(current_participatory_space.meta_scope).present? %>
23
23
  <div class="definition-data__item scope">
24
24
  <span class="definition-data__title"><%= t("assemblies.show.scope", scope: "decidim") %></span>
25
- <%= translated_attribute(current_assembly.meta_scope) %>
25
+ <%= translated_attribute(current_participatory_space.meta_scope) %>
26
26
  </div>
27
27
  <% end %>
28
28
 
29
- <% if translated_attribute(current_assembly.developer_group).present? %>
29
+ <% if translated_attribute(current_participatory_space.developer_group).present? %>
30
30
  <div class="definition-data__item developer-group">
31
31
  <span class="definition-data__title"><%= t("assemblies.show.developer_group", scope: "decidim") %></span>
32
- <%= translated_attribute(current_assembly.developer_group) %>
32
+ <%= translated_attribute(current_participatory_space.developer_group) %>
33
33
  </div>
34
34
  <% end %>
35
35
 
36
- <% if translated_attribute(current_assembly.local_area).present? %>
36
+ <% if translated_attribute(current_participatory_space.local_area).present? %>
37
37
  <div class="definition-data__item local_area">
38
38
  <span class="definition-data__title"><%= t("assemblies.show.local_area", scope: "decidim") %></span>
39
- <%= translated_attribute(current_assembly.local_area) %>
39
+ <%= translated_attribute(current_participatory_space.local_area) %>
40
40
  </div>
41
41
  <% end %>
42
42
 
43
- <% if translated_attribute(current_assembly.target).present? %>
43
+ <% if translated_attribute(current_participatory_space.target).present? %>
44
44
  <div class="definition-data__item target">
45
45
  <span class="definition-data__title"><%= t("assemblies.show.target", scope: "decidim") %></span>
46
- <%= translated_attribute(current_assembly.target) %>
46
+ <%= translated_attribute(current_participatory_space.target) %>
47
47
  </div>
48
48
  <% end %>
49
49
 
50
- <% if translated_attribute(current_assembly.participatory_scope).present? %>
50
+ <% if translated_attribute(current_participatory_space.participatory_scope).present? %>
51
51
  <div class="definition-data__item participatory_scope">
52
52
  <span class="definition-data__title"><%= t("assemblies.show.participatory_scope", scope: "decidim") %></span>
53
- <%= translated_attribute(current_assembly.participatory_scope) %>
53
+ <%= translated_attribute(current_participatory_space.participatory_scope) %>
54
54
  </div>
55
55
  <% end %>
56
56
 
57
- <% if translated_attribute(current_assembly.participatory_structure).present? %>
57
+ <% if translated_attribute(current_participatory_space.participatory_structure).present? %>
58
58
  <div class="definition-data__item participatory_structure">
59
59
  <span class="definition-data__title"><%= t("assemblies.show.participatory_structure", scope: "decidim") %></span>
60
- <%= translated_attribute(current_assembly.participatory_structure) %>
60
+ <%= translated_attribute(current_participatory_space.participatory_structure) %>
61
61
  </div>
62
62
  <% end %>
63
63
  </div>
64
64
  <%= render partial: "decidim/shared/share_modal" %>
65
- <%= embed_modal_for assembly_assembly_widget_url(current_assembly, format: :js) %>
65
+ <%= embed_modal_for assembly_assembly_widget_url(current_participatory_space, format: :js) %>
66
66
  </div>
67
67
  </div>
68
- <% if current_assembly.show_statistics? %>
68
+ <% if current_participatory_space.show_statistics? %>
69
69
  <%= render partial: 'statistics' %>
70
70
  <% end %>
71
71
  </div>
@@ -1,27 +1,27 @@
1
1
  <div class="process-header row column">
2
2
  <div class="row column process-header__main"
3
- style="background-image:url(<%= current_assembly.banner_image.url %>);">
3
+ style="background-image:url(<%= current_participatory_space.banner_image.url %>);">
4
4
  <div class="process-header__container row">
5
5
  <div class="columns mediumlarge-9 process-header__info">
6
6
  <div>
7
7
  <h1 class="text-highlight heading2">
8
- <%= translated_attribute(current_assembly.title) %>
8
+ <%= translated_attribute(current_participatory_space.title) %>
9
9
  </h1>
10
10
  </div>
11
11
  <div>
12
12
  <h2 class="text-highlight heading-small">
13
- <% if current_assembly.hashtag.present? %>
13
+ <% if current_participatory_space.hashtag.present? %>
14
14
  <span class="process-header__hashtag">
15
- <%= link_to "##{current_assembly.hashtag}", "https://twitter.com/hashtag/#{current_assembly.hashtag}" %>
15
+ <%= link_to "##{current_participatory_space.hashtag}", "https://twitter.com/hashtag/#{current_participatory_space.hashtag}" %>
16
16
  </span>
17
17
  <% end %>
18
- <%= translated_attribute(current_assembly.subtitle) %>
18
+ <%= translated_attribute(current_participatory_space.subtitle) %>
19
19
  </h2>
20
20
  </div>
21
21
  </div>
22
22
  </div>
23
23
  </div>
24
- <% if current_assembly.features.any? %>
24
+ <% if current_participatory_space.features.any? %>
25
25
  <div class="row column">
26
26
  <div class="process-nav">
27
27
  <button class="process-nav__trigger hide-for-medium" data-toggle="process-nav-content">
@@ -38,14 +38,14 @@
38
38
  </button>
39
39
  <div class="row column process-nav__content is-active" id="process-nav-content" data-toggler=".is-active">
40
40
  <ul>
41
- <li class="<%= "is-active" if is_active_link?(decidim_assemblies.assembly_path(current_assembly), :exclusive) %>">
42
- <%= active_link_to decidim_assemblies.assembly_path(current_assembly), active: :exclusive, class: "process-nav__link", class_active: "is-active" do %>
41
+ <li class="<%= "is-active" if is_active_link?(decidim_assemblies.assembly_path(current_participatory_space), :exclusive) %>">
42
+ <%= active_link_to decidim_assemblies.assembly_path(current_participatory_space), active: :exclusive, class: "process-nav__link", class_active: "is-active" do %>
43
43
  <%= external_icon "decidim/assemblies/assembly.svg" %>
44
44
  <%= t ".assembly_menu_item" %>
45
45
  <% end %>
46
46
  </li>
47
47
 
48
- <% current_assembly.features.each do |feature| %>
48
+ <% current_participatory_space.features.each do |feature| %>
49
49
  <% if feature.published? || feature == self.try(:current_feature) %>
50
50
  <li class="<%= "is-active" if is_active_link?(main_feature_path(feature), :inclusive) %>">
51
51
  <%= active_link_to main_feature_path(feature), class: "process-nav__link", active: :inclusive, class_active: "is-active" do %>
@@ -1,8 +1,8 @@
1
1
  <% add_decidim_page_title(translated_attribute(current_feature.name)) if try(:current_feature) %>
2
- <% add_decidim_page_title(translated_attribute(current_assembly.title)) %>
2
+ <% add_decidim_page_title(translated_attribute(current_participatory_space.title)) %>
3
3
  <% add_decidim_meta_tags(
4
- image_url: current_assembly.banner_image.url,
5
- description: translated_attribute(current_assembly.short_description),
4
+ image_url: current_participatory_space.banner_image.url,
5
+ description: translated_attribute(current_participatory_space.short_description),
6
6
  ) %>
7
7
 
8
8
  <%= render "layouts/decidim/application" do %>
@@ -23,4 +23,4 @@
23
23
  <%= render "layouts/decidim/feature_authorization_modals" %>
24
24
  <% end %>
25
25
 
26
- <% provide :meta_image_url, current_assembly.banner_image.url %>
26
+ <% provide :meta_image_url, current_participatory_space.banner_image.url %>
@@ -1,11 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Decidim.register_participatory_space(:assemblies) do |participatory_space|
4
- participatory_space.engine = Decidim::Assemblies::Engine
5
- participatory_space.admin_engine = Decidim::Assemblies::AdminEngine
6
4
  participatory_space.icon = "decidim/assemblies/icon.svg"
7
5
  participatory_space.model_class_name = "Decidim::Assembly"
8
6
 
7
+ participatory_space.context(:public) do |context|
8
+ context.engine = Decidim::Assemblies::Engine
9
+ context.layout = "layouts/decidim/assembly"
10
+ end
11
+
12
+ participatory_space.context(:admin) do |context|
13
+ context.engine = Decidim::Assemblies::AdminEngine
14
+ end
15
+
9
16
  participatory_space.seeds do
10
17
  organization = Decidim::Organization.first
11
18
  seeds_root = File.join(__dir__, "..", "..", "..", "db", "seeds")
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-assemblies version.
5
5
  module Assemblies
6
6
  def self.version
7
- "0.8.3"
7
+ "0.8.4"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-assemblies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
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: 2017-12-15 00:00:00.000000000 Z
13
+ date: 2018-01-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,42 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.8.3
21
+ version: 0.8.4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.8.3
28
+ version: 0.8.4
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-admin
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.8.3
35
+ version: 0.8.4
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.8.3
42
+ version: 0.8.4
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: decidim-dev
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.8.3
49
+ version: 0.8.4
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.8.3
56
+ version: 0.8.4
57
57
  description: Assemblies plugin for decidim
58
58
  email:
59
59
  - josepjaume@gmail.com
@@ -77,8 +77,6 @@ files:
77
77
  - app/constraints/decidim/assemblies/current_assembly.rb
78
78
  - app/constraints/decidim/assemblies/current_feature.rb
79
79
  - app/controllers/concerns/decidim/assemblies/admin/assembly_context.rb
80
- - app/controllers/concerns/decidim/assemblies/assembly_context.rb
81
- - app/controllers/concerns/decidim/assemblies/needs_assembly.rb
82
80
  - app/controllers/decidim/assemblies/admin/application_controller.rb
83
81
  - app/controllers/decidim/assemblies/admin/assemblies_controller.rb
84
82
  - app/controllers/decidim/assemblies/admin/assembly_attachments_controller.rb
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Assemblies
5
- # This module, when injected into a controller, ensures there's a
6
- # Assembly available and deducts it from the context.
7
- module AssemblyContext
8
- def self.extended(base)
9
- base.class_eval do
10
- include NeedsAssembly
11
-
12
- layout "layouts/decidim/assembly"
13
-
14
- before_action do
15
- authorize! :read, current_assembly
16
- end
17
- end
18
- end
19
-
20
- def ability_context
21
- super.merge(current_assembly: current_assembly)
22
- end
23
- end
24
- end
25
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Assemblies
5
- # This module, when injected into a controller, ensures there's a
6
- # Assembly available and deducts it from the context.
7
- module NeedsAssembly
8
- def self.enhance_controller(instance_or_module)
9
- instance_or_module.class_eval do
10
- helper_method :current_assembly
11
- end
12
- end
13
-
14
- def self.extended(base)
15
- base.extend Decidim::NeedsOrganization, InstanceMethods
16
-
17
- enhance_controller(base)
18
- end
19
-
20
- def self.included(base)
21
- base.include Decidim::NeedsOrganization, InstanceMethods
22
-
23
- enhance_controller(base)
24
- end
25
-
26
- module InstanceMethods
27
- # Public: Finds the current Assembly given this controller's
28
- # context.
29
- #
30
- # Returns the current Assembly.
31
- def current_assembly
32
- @current_assembly ||= detect_assembly
33
- end
34
-
35
- alias current_participatory_space current_assembly
36
-
37
- private
38
-
39
- def ability_context
40
- super.merge(current_assembly: current_assembly)
41
- end
42
-
43
- def detect_assembly
44
- request.env["current_assembly"] ||
45
- organization_assemblies.find_by!(slug: params[:assembly_slug] || params[:slug])
46
- end
47
-
48
- def organization_assemblies
49
- @organization_assemblies ||= OrganizationAssemblies.new(current_organization).query
50
- end
51
- end
52
- end
53
- end
54
- end