refinerycms-portfolio 0.9.3.6 → 0.9.3.7

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.
@@ -1,6 +1,7 @@
1
1
  class Admin::PortfolioEntriesController < Admin::BaseController
2
2
 
3
3
  crudify :portfolio_entry, :order => 'position ASC', :conditions => "parent_id IS NULL"
4
+ before_filter :find_portfolio_entries_for_parents_list, :only => [:new, :create, :edit, :update]
4
5
 
5
6
  def emancipate
6
7
  if (entry = PortfolioEntry.find(params[:id])).present?
@@ -10,4 +11,18 @@ class Admin::PortfolioEntriesController < Admin::BaseController
10
11
  redirect_to :action => "index"
11
12
  end
12
13
 
14
+ protected
15
+
16
+ # This finds all of the entries that could possibly be assigned as the current entry's parent.
17
+ def find_portfolio_entries_for_parents_list
18
+ @portfolio_entries_for_parents_list = PortfolioEntry.find(:all, :order => "parent_id, position ASC")
19
+
20
+ # We need to remove all references to the current entry or any of its decendants or we get a nightmare.
21
+ unless @portfolio_entry.nil? or @portfolio_entry.new_record?
22
+ @portfolio_entries_for_parents_list.reject! do |entry|
23
+ entry.id == @portfolio_entry.id or @portfolio_entry.descendants.include?(entry)
24
+ end
25
+ end
26
+ end
27
+
13
28
  end
@@ -1,28 +1,32 @@
1
1
  class PortfolioEntry < ActiveRecord::Base
2
-
2
+
3
3
  validates_presence_of :title
4
-
4
+
5
5
  # call to gems included in refinery.
6
6
  has_friendly_id :title, :use_slug => true, :strip_diacritics => true
7
7
  acts_as_tree :order => "position"
8
-
8
+
9
9
  has_and_belongs_to_many :images
10
10
 
11
11
  def content
12
12
  self.body
13
13
  end
14
-
14
+
15
15
  def content=(value)
16
16
  self.body = value
17
17
  end
18
-
18
+
19
19
  def image_ids=(ids)
20
20
  self.images.clear
21
-
21
+
22
22
  ids.reject{|id| id.blank? }.each do |image_id|
23
23
  image = Image.find(image_id.to_i) rescue nil
24
24
  self.images << image unless image.nil?
25
25
  end
26
26
  end
27
-
27
+
28
+ def indented_title
29
+ "#{"--" * self.ancestors.size} #{self.title}".chomp
30
+ end
31
+
28
32
  end
@@ -26,6 +26,12 @@
26
26
  <%= f.label :body, 'Content' %>
27
27
  <%= f.text_area :body, :class => "wymeditor", :rows => 7 %>
28
28
  </div>
29
+ <% if @portfolio_entries_for_parents_list.any? %>
30
+ <div class='field'>
31
+ <%= f.label :parent_id %>
32
+ <%= f.collection_select :parent_id, @portfolio_entries_for_parents_list, :id, :indented_title, :include_blank => true %>
33
+ </div>
34
+ <% end %>
29
35
  <div class='form-actions'>
30
36
  <%= f.submit 'Save', :class => "wymupdate" %>
31
37
  or
data/rails/init.rb CHANGED
@@ -3,7 +3,7 @@ Refinery::Plugin.register do |plugin|
3
3
  plugin.title = "Portfolio"
4
4
  plugin.description = "Manage a portfolio"
5
5
  plugin.url = "/admin/#{plugin.title.downcase}"
6
- plugin.version = '0.9.3.6'
6
+ plugin.version = '0.9.3.7'
7
7
  plugin.menu_match = /admin\/portfolio(_entries)?/
8
8
  plugin.activity = {
9
9
  :class => PortfolioEntry,
data/readme.md CHANGED
@@ -23,13 +23,13 @@ Then run:
23
23
  refinerycms-portfolio-install /path/to/your/refinery/application
24
24
 
25
25
  Then place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
26
- config.gem "refinerycms-portfolio", :version => ">= 0.9.3.6", :lib => "portfolio", :source => "http://gemcutter.org"
26
+ config.gem "refinerycms-portfolio", :version => ">= 0.9.3.7", :lib => "portfolio", :source => "http://gemcutter.org"
27
27
 
28
28
  ..and follow the instructions!
29
29
 
30
30
  ### Method Two
31
31
  Place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
32
- config.gem "refinerycms-portfolio", :version => ">= 0.9.3.6", :lib => "portfolio", :source => "http://gemcutter.org"
32
+ config.gem "refinerycms-portfolio", :version => ">= 0.9.3.7", :lib => "portfolio", :source => "http://gemcutter.org"
33
33
 
34
34
  Then run in your application's directory:
35
35
  rake gems:install
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-portfolio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3.6
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 9
8
+ - 3
9
+ - 7
10
+ version: 0.9.3.7
5
11
  platform: ruby
6
12
  authors:
7
13
  - Resolve Digital
@@ -10,7 +16,7 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2010-02-18 00:00:00 +13:00
19
+ date: 2010-02-27 00:00:00 +13:00
14
20
  default_executable: refinerycms-portfolio-install
15
21
  dependencies: []
16
22
 
@@ -61,18 +67,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
67
  requirements:
62
68
  - - ">="
63
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
64
72
  version: "0"
65
- version:
66
73
  required_rubygems_version: !ruby/object:Gem::Requirement
67
74
  requirements:
68
75
  - - ">="
69
76
  - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
70
79
  version: "0"
71
- version:
72
80
  requirements: []
73
81
 
74
82
  rubyforge_project:
75
- rubygems_version: 1.3.5
83
+ rubygems_version: 1.3.6
76
84
  signing_key:
77
85
  specification_version: 3
78
86
  summary: Ruby on Rails portfolio plugin for RefineryCMS.