decidim-pages 0.1.0 → 0.2.0

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: 5f7ec8af6f6777b79f43d8fd3a4f1b44e67d84a9
4
- data.tar.gz: 20c6394d7b6cfadd67a58e2e76c34d5b2e78a716
3
+ metadata.gz: de56df0dc3a9c281daa4100f5a40f4bd8a4ec91d
4
+ data.tar.gz: 4a20630f3b1eb1e9473155c6b4faa7fd99abde8c
5
5
  SHA512:
6
- metadata.gz: dc18d2bd41304a10c5eb7697a872301d1804aac787f6d9b84853774e47cab5d7a5bb40ad2fbf265824ef5cab4a73e1e1123cf4b3e77f27ea3ddf17e7aaa7657a
7
- data.tar.gz: 12d2923081c40e0d7f37c350acd4c3ee1107a67bf1774d9ca8a64e6ecb5636064db9b4748760dc4bc6f2cc958e765e926626d00b9bb81ba36aef38e7a8deff50
6
+ metadata.gz: 95d1b8bb66afafc374cd235b03414d6c6be6154a0b8567ef80b6fd1946446f56ebada3681ecfa2ed8ca7e2c1261b6360aac96cdb3dbb2ec40f210180f050e97f
7
+ data.tar.gz: 0e0bafee53b82edf8553886650b66de1163a8711400ef3f92737a13bba660003f4704dce5c43a7d912651f06a4e7042e13fe7dbf260de54e5f64af2ed0ea0ae5
data/Rakefile CHANGED
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "decidim/dev/common_rake"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  module Admin
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Pages
5
+ # Command that gets called whenever a feature's page has to be duplicated.
6
+ # It's need a context with the old feature that
7
+ # is going to be duplicated on the new one
8
+ class CopyPage < Rectify::Command
9
+ def initialize(context)
10
+ @context = context
11
+ end
12
+
13
+ def call
14
+ Decidim::Pages::Page.transaction do
15
+ pages = Decidim::Pages::Page.where(feature: @context[:old_feature])
16
+ pages.each do |page|
17
+ Decidim::Pages::Page.create!(feature: @context[:new_feature], body: page.body)
18
+ end
19
+ end
20
+ broadcast(:ok)
21
+ rescue ActiveRecord::RecordInvalid
22
+ broadcast(:invalid)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # Command that gets called whenever a feature's page has to be created. It
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # Command that gets called when the page of this feature needs to be
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  module Admin
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  module Admin
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # Custom helpers, scoped to the pages engine.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # Abstract class from which all models in this engine inherit.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # The data store for a Page in the Decidim::Pages component. It stores a
@@ -1,5 +1,6 @@
1
1
  base_locale: en
2
- locales: [en]
3
2
  ignore_unused:
4
3
  - "decidim.features.pages.name"
5
4
  - "decidim.features.pages.settings.*"
5
+ search:
6
+ strict: false
@@ -15,6 +15,7 @@ eu:
15
15
  body: Testu-gorputza
16
16
  pages:
17
17
  edit:
18
+ save: Eguneratu
18
19
  title: Editatu orria
19
20
  update:
20
21
  invalid: Erroreak gertatu dira orria gordetzean.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "decidim/pages/admin"
3
4
  require "decidim/pages/engine"
4
5
  require "decidim/pages/admin_engine"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # This module contains all the domain logic associated to Decidim's Pages
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # This is the admin interface for `decidim-pages`. It lets you edit and
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Decidim
3
4
  module Pages
4
5
  # This is the engine that runs on the public interface of `decidim-pages`.
@@ -19,6 +19,12 @@ Decidim.register_feature(:pages) do |feature|
19
19
  end
20
20
  end
21
21
 
22
+ feature.on(:copy) do |context|
23
+ Decidim::Pages::CopyPage.call(context) do
24
+ on(:invalid) { raise "Can't duplicate page" }
25
+ end
26
+ end
27
+
22
28
  feature.register_stat :comments_count, tag: :comments do |features, start_at, end_at|
23
29
  pages = Decidim::Pages::Page.where(feature: features)
24
30
  pages = pages.where("created_at >= ?", start_at) if start_at.present?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-05-18 00:00:00.000000000 Z
13
+ date: 2017-06-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.1.0
21
+ version: 0.2.0
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.1.0
28
+ version: 0.2.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-comments
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.1.0
35
+ version: 0.2.0
36
36
  type: :runtime
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.1.0
42
+ version: 0.2.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rectify
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.1.0
63
+ version: 0.2.0
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.1.0
70
+ version: 0.2.0
71
71
  description: A pages component for decidim's participatory processes.
72
72
  email:
73
73
  - josepjaume@gmail.com
@@ -81,6 +81,7 @@ files:
81
81
  - Rakefile
82
82
  - app/assets/images/decidim/pages/icon.svg
83
83
  - app/commands/decidim/pages/admin/update_page.rb
84
+ - app/commands/decidim/pages/copy_page.rb
84
85
  - app/commands/decidim/pages/create_page.rb
85
86
  - app/commands/decidim/pages/destroy_page.rb
86
87
  - app/controllers/decidim/pages/admin/application_controller.rb