pulitzer 0.15.11 → 0.15.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/pulitzer/partials_controller.rb +5 -0
- data/app/interactions/pulitzer/partials_controller/upgrade_partial_version.rb +24 -0
- data/app/models/pulitzer/partial.rb +6 -3
- data/app/models/pulitzer/post_type.rb +4 -0
- data/app/models/pulitzer/post_type_version.rb +2 -0
- data/app/models/pulitzer/version.rb +4 -0
- data/app/views/pulitzer/partials/_show.html.erb +6 -1
- data/app/views/pulitzer/versions/_edit.html.erb +6 -3
- data/config/routes.rb +3 -0
- data/lib/pulitzer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6101c5c502e2b5c671157957f4906705092e3d1e
|
4
|
+
data.tar.gz: 1d8763814827c1df4b8325146e0f122a64e84e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35f815967cbf623a1aee11a07becc482fad54bdcd5b847fdca6fb204375737818734e5f38cda2ecb160b62daa69632367d6836a8d49239b5998a49f39c5ecbf8
|
7
|
+
data.tar.gz: e5fe46974a637f3833c5c8aa5d1156a750d246a7bb83cb8b2ac5267a1a325dc88d829b54dca418b8643dd806346e1bcb0446f8db11c299a2c2d33b7081e334f2
|
@@ -45,6 +45,11 @@ class Pulitzer::PartialsController < Pulitzer::ApplicationController
|
|
45
45
|
head :ok
|
46
46
|
end
|
47
47
|
|
48
|
+
def upgrade
|
49
|
+
@partial = UpgradePartialVersion.new(@partial).call
|
50
|
+
render partial: 'show', locals: { partial: @partial }
|
51
|
+
end
|
52
|
+
|
48
53
|
protected
|
49
54
|
|
50
55
|
def partial_params
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Pulitzer::PartialsController::UpgradePartialVersion
|
2
|
+
|
3
|
+
def initialize(partial)
|
4
|
+
@partial = partial
|
5
|
+
@free_form_section = partial.free_form_section
|
6
|
+
end
|
7
|
+
|
8
|
+
def call
|
9
|
+
most_recent_partial_version = @partial.post_type_version.post_type.most_recent_published_post_type_version
|
10
|
+
new_partial = @free_form_section.partials.create(label: @partial.label, post_type_version_id: most_recent_partial_version.id)
|
11
|
+
Pulitzer::CreatePartialContentElements.new(new_partial).call
|
12
|
+
content_elements = new_partial.content_elements.to_a
|
13
|
+
content_elements.each do |ce|
|
14
|
+
old_ce = @partial.content_elements.find_by(label: ce.label)
|
15
|
+
if old_ce
|
16
|
+
cloned = old_ce.clone_me
|
17
|
+
cloned.update(post_type_content_element_type_id: ce.post_type_content_element_type_id, partial_id: ce.partial_id)
|
18
|
+
ce.destroy
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@partial.destroy
|
22
|
+
new_partial
|
23
|
+
end
|
24
|
+
end
|
@@ -7,7 +7,7 @@ module Pulitzer
|
|
7
7
|
belongs_to :sequence_flow_style
|
8
8
|
belongs_to :arrangement_style
|
9
9
|
has_one :post_type, through: :post_type_version
|
10
|
-
|
10
|
+
|
11
11
|
has_many :content_elements, dependent: :destroy
|
12
12
|
|
13
13
|
delegate :name, :post_type_content_element_types, :has_display?, :post_type_id, :version_number, to: :post_type_version
|
@@ -54,7 +54,7 @@ module Pulitzer
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def folder_path
|
57
|
-
name.downcase.gsub(/ /,'_').gsub(/\W/,'')
|
57
|
+
name.downcase.gsub(/ /,'_').gsub(/\W/,'')
|
58
58
|
end
|
59
59
|
|
60
60
|
def version_folder
|
@@ -86,5 +86,8 @@ module Pulitzer
|
|
86
86
|
my_clone
|
87
87
|
end
|
88
88
|
|
89
|
+
def upgradable?
|
90
|
+
version_number < (post_type_version&.post_type&.post_type_versions&.published&.maximum(:version_number) || 0)
|
91
|
+
end
|
89
92
|
end
|
90
|
-
end
|
93
|
+
end
|
@@ -17,6 +17,8 @@ class Pulitzer::PostTypeVersion < ActiveRecord::Base
|
|
17
17
|
|
18
18
|
delegate :name, :kind, :partial?, :template?, :plural, :plural?, to: :post_type
|
19
19
|
|
20
|
+
scope :published, -> { where(status: 'published') }
|
21
|
+
|
20
22
|
register_transitions({
|
21
23
|
previewing_service: Preview,
|
22
24
|
publishing_service: Publish,
|
@@ -52,6 +52,10 @@ module Pulitzer
|
|
52
52
|
processed_element_count: self.processed_element_count
|
53
53
|
end
|
54
54
|
|
55
|
+
def publishable?
|
56
|
+
!empty_required_content_elements? && required_partials?
|
57
|
+
end
|
58
|
+
|
55
59
|
def empty_required_content_elements?
|
56
60
|
content_elements.required.select{|ce| ce.empty_body?}.any? || free_form_sections.includes(partials: :content_elements).map(&:partials).flatten.map(&:content_elements).flatten.select{|ce| ce.empty_body? && ce.required?}.any?
|
57
61
|
end
|
@@ -13,6 +13,11 @@
|
|
13
13
|
<%= render partial: '/pulitzer/shared/drag_handle' %>
|
14
14
|
</div>
|
15
15
|
</div>
|
16
|
+
<div class="pulitzer-row margin-bottom">
|
17
|
+
<% if partial.upgradable? %>
|
18
|
+
<%= ajax_link "Upgrade #{partial.label} to the last partial version", upgrade_partial_path(partial), {class: 'button'}, dom_target(partial), http_method: 'PATCH' %>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
16
21
|
<div <%= collapsed(dom_id(partial)) %>>
|
17
22
|
<%= render partial: '/pulitzer/content_elements/partial_index', locals: {partial: partial} %>
|
18
|
-
</div>
|
23
|
+
</div>
|
@@ -39,7 +39,6 @@
|
|
39
39
|
<% end %>
|
40
40
|
</div>
|
41
41
|
</div>
|
42
|
-
|
43
42
|
<% version.all_elements.each do |element| %>
|
44
43
|
<%= render partial: "/pulitzer/#{element.class.table_name.gsub(/pulitzer_/,'')}/show_wrapper", locals: { element: element } %>
|
45
44
|
<% end %>
|
@@ -47,10 +46,14 @@
|
|
47
46
|
<%= render partial: 'pulitzer/versions/form', locals: { version: version } %>
|
48
47
|
</div>
|
49
48
|
<div class="preview-link">
|
50
|
-
<% if @preview_path %>
|
49
|
+
<% if @preview_path && version.publishable? %>
|
51
50
|
<%= link_to "Preview", @preview_path, target: '_blank' %>
|
52
51
|
<% else %>
|
53
|
-
<small>Preview not available
|
52
|
+
<small>Preview not available.
|
53
|
+
<% if !version.publishable? %>
|
54
|
+
Missing required content
|
55
|
+
<% end %>
|
56
|
+
</small>
|
54
57
|
<% end %>
|
55
58
|
</div>
|
56
59
|
<% end %>
|
data/config/routes.rb
CHANGED
data/lib/pulitzer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulitzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-07-
|
12
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -545,6 +545,7 @@ files:
|
|
545
545
|
- app/interactions/pulitzer/create_singleton_post.rb
|
546
546
|
- app/interactions/pulitzer/destroy_post_type_content_elements.rb
|
547
547
|
- app/interactions/pulitzer/destroy_post_type_free_form_sections.rb
|
548
|
+
- app/interactions/pulitzer/partials_controller/upgrade_partial_version.rb
|
548
549
|
- app/interactions/pulitzer/post_type_versions_controller/change_state.rb
|
549
550
|
- app/interactions/pulitzer/post_type_versions_controller/clone.rb
|
550
551
|
- app/interactions/pulitzer/post_type_versions_controller/clone_post_with_version_elements.rb
|