qcms 1.3.5 → 1.3.6

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/app/models/document.rb +8 -0
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.5
1
+ 1.3.6
@@ -38,6 +38,7 @@ class Document < ActiveRecord::Base
38
38
  named_scope :roots, { :conditions => { :parent_id => nil }, :include => [:meta_definition, :parent] }
39
39
  named_scope :public, { :conditions => { :state => 'published' }}
40
40
  named_scope :offset, lambda { |offset| { :offset => offset } }
41
+ named_scope :siblings, lambda { |document| { :conditions => { :parent_id => document.parent.id } } }
41
42
 
42
43
  # Callbacks
43
44
  before_validation_on_create :pull_meta_definition
@@ -104,6 +105,13 @@ class Document < ActiveRecord::Base
104
105
  find_by_path(path)
105
106
  end
106
107
 
108
+ # ordered_siblings_for returns siblings as a named_scope in the correct order
109
+ # It is a class method so does not trample on the instance method, siblings, which returns an Array
110
+ def self.ordered_siblings_for(document)
111
+ raise 'Can not get siblings for root documents' if document.root?
112
+ siblings(document).order_by(document.parent.meta_definition.children.by_label(document.label).first.sort_by)
113
+ end
114
+
107
115
  # All children grouped by year and month
108
116
  def archive
109
117
  result = ActiveSupport::OrderedHash.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qcms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 5
10
- version: 1.3.5
9
+ - 6
10
+ version: 1.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kris Leech
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-07 00:00:00 +01:00
18
+ date: 2010-10-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21