enju_circulation 0.1.0.pre6 → 0.1.0.pre7

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,6 +48,9 @@ module EnjuCirculation
48
48
  end
49
49
  attr_accessible :item_has_use_restriction_attributes
50
50
  accepts_nested_attributes_for :item_has_use_restriction
51
+
52
+ after_create :create_lending_policy
53
+ before_update :delete_lending_policy
51
54
  end
52
55
  end
53
56
 
@@ -118,6 +121,20 @@ module EnjuCirculation
118
121
  def not_for_loan?
119
122
  !manifestation.items.for_checkout.include?(self)
120
123
  end
124
+
125
+ def create_lending_policy
126
+ UserGroupHasCheckoutType.available_for_item(self).each do |rule|
127
+ LendingPolicy.create!(:item_id => id, :user_group_id => rule.user_group_id, :fixed_due_date => rule.fixed_due_date, :loan_period => rule.checkout_period, :renewal => rule.checkout_renewal_limit)
128
+ end
129
+ end
130
+
131
+ def delete_lending_policy
132
+ return nil unless changes[:circulation_status_id]
133
+ self.transaction do
134
+ lending_policies.delete_all
135
+ create_lending_policy
136
+ end
137
+ end
121
138
  end
122
139
  end
123
140
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.1.0.pre6"
2
+ VERSION = "0.1.0.pre7"
3
3
  end
@@ -28,7 +28,7 @@ describe LendingPoliciesController do
28
28
 
29
29
  it "assigns all lending_policies as @lending_policies" do
30
30
  get :index
31
- assigns(:lending_policies).should eq(LendingPolicy.all)
31
+ assigns(:lending_policies).should eq(LendingPolicy.page(1))
32
32
  end
33
33
  end
34
34
 
Binary file
@@ -84,14 +84,11 @@
84
84
  <fieldType name="tfloat" class="solr.TrieFloatField" omitNorms="true"/>
85
85
  <!-- *** This fieldType is used by Sunspot! *** -->
86
86
  <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true"/>
87
-
88
- <!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. -->
89
- <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
90
87
  </types>
91
88
  <fields>
92
89
  <!-- Valid attributes for fields:
93
90
  name: mandatory - the name for the field
94
- type: mandatory - the name of a previously defined type from the
91
+ type: mandatory - the name of a previously defined type from the
95
92
  <types> section
96
93
  indexed: true if this field should be indexed (searchable or sortable)
97
94
  stored: true if this field should be retrievable
@@ -226,17 +223,8 @@
226
223
  <dynamicField name="*_ets" stored="true" termVectors="true" type="tdouble" multiValued="false" indexed="true"/>
227
224
  <!-- *** This dynamicField is used by Sunspot! *** -->
228
225
  <dynamicField name="*_etms" stored="true" termVectors="true" type="tdouble" multiValued="true" indexed="true"/>
229
-
230
- <!-- Type used to index the lat and lon components for the "location" FieldType -->
231
- <dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" multiValued="false"/>
232
- <dynamicField name="*_p" type="location" indexed="true" stored="true" multiValued="false"/>
233
-
234
- <dynamicField name="*_ll" stored="false" type="location" multiValued="false" indexed="true"/>
235
- <dynamicField name="*_llm" stored="false" type="location" multiValued="true" indexed="true"/>
236
- <dynamicField name="*_lls" stored="true" type="location" multiValued="false" indexed="true"/>
237
- <dynamicField name="*_llms" stored="true" type="location" multiValued="true" indexed="true"/>
238
226
  </fields>
239
- <!-- Field to use to determine and enforce document uniqueness.
227
+ <!-- Field to use to determine and enforce document uniqueness.
240
228
  Unless this field is marked with required="false", it will be a required field
241
229
  -->
242
230
  <uniqueKey>id</uniqueKey>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_circulation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre6
4
+ version: 0.1.0.pre7
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-23 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -636,16 +636,16 @@ files:
636
636
  - spec/dummy/solr/conf/spellings.txt
637
637
  - spec/dummy/solr/conf/stopwords.txt
638
638
  - spec/dummy/solr/conf/synonyms.txt
639
- - spec/dummy/solr/data/test/index/_1w.fdt
640
- - spec/dummy/solr/data/test/index/_1w.fdx
641
- - spec/dummy/solr/data/test/index/_1w.fnm
642
- - spec/dummy/solr/data/test/index/_1w.frq
643
- - spec/dummy/solr/data/test/index/_1w.nrm
644
- - spec/dummy/solr/data/test/index/_1w.prx
645
- - spec/dummy/solr/data/test/index/_1w.tii
646
- - spec/dummy/solr/data/test/index/_1w.tis
639
+ - spec/dummy/solr/data/test/index/_cr.fdt
640
+ - spec/dummy/solr/data/test/index/_cr.fdx
641
+ - spec/dummy/solr/data/test/index/_cr.fnm
642
+ - spec/dummy/solr/data/test/index/_cr.frq
643
+ - spec/dummy/solr/data/test/index/_cr.nrm
644
+ - spec/dummy/solr/data/test/index/_cr.prx
645
+ - spec/dummy/solr/data/test/index/_cr.tii
646
+ - spec/dummy/solr/data/test/index/_cr.tis
647
647
  - spec/dummy/solr/data/test/index/segments.gen
648
- - spec/dummy/solr/data/test/index/segments_3z
648
+ - spec/dummy/solr/data/test/index/segments_qn
649
649
  - spec/dummy/solr/data/test/spellchecker/segments.gen
650
650
  - spec/dummy/solr/data/test/spellchecker/segments_1
651
651
  - spec/factories/basket.rb
@@ -908,16 +908,16 @@ test_files:
908
908
  - spec/dummy/solr/conf/spellings.txt
909
909
  - spec/dummy/solr/conf/stopwords.txt
910
910
  - spec/dummy/solr/conf/synonyms.txt
911
- - spec/dummy/solr/data/test/index/_1w.fdt
912
- - spec/dummy/solr/data/test/index/_1w.fdx
913
- - spec/dummy/solr/data/test/index/_1w.fnm
914
- - spec/dummy/solr/data/test/index/_1w.frq
915
- - spec/dummy/solr/data/test/index/_1w.nrm
916
- - spec/dummy/solr/data/test/index/_1w.prx
917
- - spec/dummy/solr/data/test/index/_1w.tii
918
- - spec/dummy/solr/data/test/index/_1w.tis
911
+ - spec/dummy/solr/data/test/index/_cr.fdt
912
+ - spec/dummy/solr/data/test/index/_cr.fdx
913
+ - spec/dummy/solr/data/test/index/_cr.fnm
914
+ - spec/dummy/solr/data/test/index/_cr.frq
915
+ - spec/dummy/solr/data/test/index/_cr.nrm
916
+ - spec/dummy/solr/data/test/index/_cr.prx
917
+ - spec/dummy/solr/data/test/index/_cr.tii
918
+ - spec/dummy/solr/data/test/index/_cr.tis
919
919
  - spec/dummy/solr/data/test/index/segments.gen
920
- - spec/dummy/solr/data/test/index/segments_3z
920
+ - spec/dummy/solr/data/test/index/segments_qn
921
921
  - spec/dummy/solr/data/test/spellchecker/segments.gen
922
922
  - spec/dummy/solr/data/test/spellchecker/segments_1
923
923
  - spec/factories/basket.rb