enju_circulation 0.0.43 → 0.0.45

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 (63) hide show
  1. data/app/controllers/checked_items_controller.rb +2 -4
  2. data/app/controllers/checkout_stat_has_manifestations_controller.rb +6 -6
  3. data/app/controllers/checkout_stat_has_users_controller.rb +6 -6
  4. data/app/controllers/checkout_types_controller.rb +2 -4
  5. data/app/controllers/item_has_use_restrictions_controller.rb +5 -5
  6. data/app/controllers/manifestation_checkout_stats_controller.rb +2 -4
  7. data/app/controllers/manifestation_reserve_stats_controller.rb +2 -4
  8. data/app/controllers/reserve_stat_has_manifestations_controller.rb +4 -2
  9. data/app/controllers/reserve_stat_has_users_controller.rb +6 -6
  10. data/app/controllers/user_group_has_checkout_types_controller.rb +2 -4
  11. data/app/models/carrier_type_has_checkout_type.rb +1 -0
  12. data/app/models/checked_item.rb +1 -0
  13. data/app/models/checkin.rb +1 -1
  14. data/app/models/checkout.rb +2 -3
  15. data/app/models/checkout_stat_has_manifestation.rb +3 -0
  16. data/app/models/checkout_stat_has_user.rb +3 -0
  17. data/app/models/checkout_type.rb +1 -0
  18. data/app/models/circulation_status.rb +2 -2
  19. data/app/models/item_has_use_restriction.rb +2 -0
  20. data/app/models/lending_policy.rb +2 -0
  21. data/app/models/manifestation_checkout_stat.rb +2 -0
  22. data/app/models/manifestation_reserve_stat.rb +2 -0
  23. data/app/models/reserve.rb +35 -16
  24. data/app/models/reserve_stat_has_manifestation.rb +3 -0
  25. data/app/models/reserve_stat_has_user.rb +3 -0
  26. data/app/models/use_restriction.rb +1 -1
  27. data/app/models/user_checkout_stat.rb +2 -1
  28. data/app/models/user_group_has_checkout_type.rb +4 -0
  29. data/app/models/user_reserve_stat.rb +2 -1
  30. data/lib/enju_circulation/version.rb +1 -1
  31. data/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb +7 -7
  32. data/spec/controllers/checkout_stat_has_manifestations_controller_spec.rb +10 -10
  33. data/spec/controllers/checkout_stat_has_users_controller_spec.rb +3 -3
  34. data/spec/controllers/checkouts_controller_spec.rb +9 -7
  35. data/spec/controllers/circulation_statuses_controller_spec.rb +445 -0
  36. data/spec/controllers/item_has_use_restrictions_controller_spec.rb +10 -10
  37. data/spec/controllers/reserve_stat_has_manifestations_controller_spec.rb +10 -10
  38. data/spec/controllers/reserve_stat_has_users_controller_spec.rb +3 -3
  39. data/spec/controllers/reserves_controller_spec.rb +1 -1
  40. data/spec/controllers/use_restrictions_controller_spec.rb +4 -4
  41. data/spec/dummy/app/models/basket.rb +5 -2
  42. data/spec/dummy/db/development.sqlite3 +0 -0
  43. data/spec/dummy/db/test.sqlite3 +0 -0
  44. data/spec/dummy/solr/conf/admin-extra.html +31 -0
  45. data/spec/dummy/solr/conf/elevate.xml +36 -0
  46. data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  47. data/spec/dummy/solr/conf/protwords.txt +21 -0
  48. data/spec/dummy/solr/conf/schema.xml +238 -0
  49. data/spec/dummy/solr/conf/scripts.conf +24 -0
  50. data/spec/dummy/solr/conf/solrconfig.xml +934 -0
  51. data/spec/dummy/solr/conf/spellings.txt +2 -0
  52. data/spec/dummy/solr/conf/stopwords.txt +58 -0
  53. data/spec/dummy/solr/conf/synonyms.txt +31 -0
  54. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  55. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  56. data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
  57. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  58. data/spec/factories/circulation_status.rb +5 -0
  59. data/spec/models/basket_spec.rb +43 -0
  60. data/spec/models/checkin_spec.rb +13 -4
  61. data/spec/models/circulation_status_spec.rb +21 -0
  62. data/spec/spec_helper.rb +13 -0
  63. metadata +56 -18
@@ -68,8 +68,7 @@ class CheckedItemsController < ApplicationController
68
68
  if @checked_item.item.include_supplements
69
69
  flash[:message] << t('item.this_item_include_supplement')
70
70
  end
71
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.checked_item'))
72
- format.html { redirect_to(basket_checked_items_url(@basket)) }
71
+ format.html { redirect_to(basket_checked_items_url(@basket), :notice => t('controller.successfully_created', :model => t('activerecord.models.checked_item'))) }
73
72
  format.json { render :json => @checked_item, :status => :created, :location => @checked_item }
74
73
  format.js { redirect_to(basket_checked_items_url(@basket, :format => :js)) }
75
74
  else
@@ -93,8 +92,7 @@ class CheckedItemsController < ApplicationController
93
92
 
94
93
  respond_to do |format|
95
94
  if @checked_item.update_attributes(params[:checked_item])
96
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.checked_item'))
97
- format.html { redirect_to @checked_item }
95
+ format.html { redirect_to @checked_item, :notice => t('controller.successfully_updated', :model => t('activerecord.models.checked_item')) }
98
96
  format.json { head :no_content }
99
97
  else
100
98
  format.html { render :action => "edit" }
@@ -39,12 +39,12 @@ class CheckoutStatHasManifestationsController < ApplicationController
39
39
  # POST /checkout_stat_has_manifestations
40
40
  # POST /checkout_stat_has_manifestations.json
41
41
  def create
42
- @checkout_stat_has_manifestation = CheckoutStatHasManifestation.new(params[:checkout_stat_has_manifestation])
42
+ @checkout_stat_has_manifestation = CheckoutStatHasManifestation.new
43
+ @checkout_stat_has_manifestation.assign_attributes(params[:checkout_stat_has_manifestation], :as => :admin)
43
44
 
44
45
  respond_to do |format|
45
46
  if @checkout_stat_has_manifestation.save
46
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.checkout_stat_has_manifestation'))
47
- format.html { redirect_to @checkout_stat_has_manifestation }
47
+ format.html { redirect_to @checkout_stat_has_manifestation, :notice => t('controller.successfully_created', :model => t('activerecord.models.checkout_stat_has_manifestation')) }
48
48
  format.json { render :json => @checkout_stat_has_manifestation, :status => :created, :location => @checkout_stat_has_manifestation }
49
49
  else
50
50
  format.html { render :action => "new" }
@@ -56,10 +56,10 @@ class CheckoutStatHasManifestationsController < ApplicationController
56
56
  # PUT /checkout_stat_has_manifestations/1
57
57
  # PUT /checkout_stat_has_manifestations/1.json
58
58
  def update
59
+ @checkout_stat_has_manifestation.assign_attributes(params[:checkout_stat_has_manifestation], :as => :admin)
59
60
  respond_to do |format|
60
- if @checkout_stat_has_manifestation.update_attributes(params[:checkout_stat_has_manifestation])
61
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.checkout_stat_has_manifestation'))
62
- format.html { redirect_to @checkout_stat_has_manifestation }
61
+ if @checkout_stat_has_manifestation.save
62
+ format.html { redirect_to @checkout_stat_has_manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.checkout_stat_has_manifestation')) }
63
63
  format.json { head :no_content }
64
64
  else
65
65
  format.html { render :action => "edit" }
@@ -39,12 +39,12 @@ class CheckoutStatHasUsersController < ApplicationController
39
39
  # POST /checkout_stat_has_users
40
40
  # POST /checkout_stat_has_users.json
41
41
  def create
42
- @checkout_stat_has_user = CheckoutStatHasUser.new(params[:checkout_stat_has_user])
42
+ @checkout_stat_has_user = CheckoutStatHasUser.new
43
+ @checkout_stat_has_user.assign_attributes(params[:checkout_stat_has_user], :as => :admin)
43
44
 
44
45
  respond_to do |format|
45
46
  if @checkout_stat_has_user.save
46
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.checkout_stat_has_user'))
47
- format.html { redirect_to @checkout_stat_has_user }
47
+ format.html { redirect_to @checkout_stat_has_user, :notice => t('controller.successfully_created', :model => t('activerecord.models.checkout_stat_has_user')) }
48
48
  format.json { render :json => @checkout_stat_has_user, :status => :created, :location => @checkout_stat_has_user }
49
49
  else
50
50
  format.html { render :action => "new" }
@@ -56,10 +56,10 @@ class CheckoutStatHasUsersController < ApplicationController
56
56
  # PUT /checkout_stat_has_users/1
57
57
  # PUT /checkout_stat_has_users/1.json
58
58
  def update
59
+ @checkout_stat_has_user.assign_attributes(params[:checkout_stat_has_user], :as => :admin)
59
60
  respond_to do |format|
60
- if @checkout_stat_has_user.update_attributes(params[:checkout_stat_has_user])
61
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.checkout_stat_has_user'))
62
- format.html { redirect_to @checkout_stat_has_user }
61
+ if @checkout_stat_has_user.save
62
+ format.html { redirect_to @checkout_stat_has_user, :notice => t('controller.successfully_updated', :model => t('activerecord.models.checkout_stat_has_user')) }
63
63
  format.json { head :no_content }
64
64
  else
65
65
  format.html { render :action => "edit" }
@@ -63,8 +63,7 @@ class CheckoutTypesController < ApplicationController
63
63
 
64
64
  respond_to do |format|
65
65
  if @checkout_type.save
66
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.checkout_type'))
67
- format.html { redirect_to @checkout_type }
66
+ format.html { redirect_to @checkout_type, :notice => t('controller.successfully_created', :model => t('activerecord.models.checkout_type')) }
68
67
  format.json { render :json => @checkout_type, :status => :created, :location => @checkout_type }
69
68
  else
70
69
  format.html { render :action => "new" }
@@ -87,8 +86,7 @@ class CheckoutTypesController < ApplicationController
87
86
 
88
87
  respond_to do |format|
89
88
  if @checkout_type.update_attributes(params[:checkout_type])
90
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.checkout_type'))
91
- format.html { redirect_to @checkout_type }
89
+ format.html { redirect_to @checkout_type, :notice => t('controller.successfully_updated', :model => t('activerecord.models.checkout_type')) }
92
90
  format.json { head :no_content }
93
91
  else
94
92
  format.html { render :action => "edit" }
@@ -46,11 +46,11 @@ class ItemHasUseRestrictionsController < ApplicationController
46
46
  # POST /item_has_use_restrictions.json
47
47
  def create
48
48
  @item_has_use_restriction = ItemHasUseRestriction.new(params[:item_has_use_restriction])
49
+ @item_has_use_restriction.assign_attributes(params[:item_has_use_restriction], :as => :admin)
49
50
 
50
51
  respond_to do |format|
51
52
  if @item_has_use_restriction.save
52
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.item_has_use_restriction'))
53
- format.html { redirect_to @item_has_use_restriction }
53
+ format.html { redirect_to @item_has_use_restriction, :notice => t('controller.successfully_created', :model => t('activerecord.models.item_has_use_restriction')) }
54
54
  format.json { render :json => @item_has_use_restriction, :status => :created, :location => @item_has_use_restriction }
55
55
  else
56
56
  @use_restrictions = UseRestriction.all
@@ -63,10 +63,10 @@ class ItemHasUseRestrictionsController < ApplicationController
63
63
  # PUT /item_has_use_restrictions/1
64
64
  # PUT /item_has_use_restrictions/1.json
65
65
  def update
66
+ @item_has_use_restriction.assign_attributes(params[:item_has_use_restriction], :as => :admin)
66
67
  respond_to do |format|
67
- if @item_has_use_restriction.update_attributes(params[:item_has_use_restriction])
68
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.item_has_use_restriction'))
69
- format.html { redirect_to @item_has_use_restriction }
68
+ if @item_has_use_restriction.save
69
+ format.html { redirect_to @item_has_use_restriction, :notice => t('controller.successfully_updated', :model => t('activerecord.models.item_has_use_restriction')) }
70
70
  format.json { head :no_content }
71
71
  else
72
72
  @use_restrictions = UseRestriction.all
@@ -52,8 +52,7 @@ class ManifestationCheckoutStatsController < ApplicationController
52
52
 
53
53
  respond_to do |format|
54
54
  if @manifestation_checkout_stat.save
55
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.manifestation_checkout_stat'))
56
- format.html { redirect_to @manifestation_checkout_stat }
55
+ format.html { redirect_to @manifestation_checkout_stat, :notice => t('controller.successfully_created', :model => t('activerecord.models.manifestation_checkout_stat')) }
57
56
  format.json { render :json => @manifestation_checkout_stat, :status => :created, :location => @manifestation_checkout_stat }
58
57
  else
59
58
  format.html { render :action => "new" }
@@ -67,8 +66,7 @@ class ManifestationCheckoutStatsController < ApplicationController
67
66
  def update
68
67
  respond_to do |format|
69
68
  if @manifestation_checkout_stat.update_attributes(params[:manifestation_checkout_stat])
70
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.manifestation_checkout_stat'))
71
- format.html { redirect_to @manifestation_checkout_stat }
69
+ format.html { redirect_to @manifestation_checkout_stat, :notice => t('controller.successfully_updated', :model => t('activerecord.models.manifestation_checkout_stat')) }
72
70
  format.json { head :no_content }
73
71
  else
74
72
  format.html { render :action => "edit" }
@@ -52,8 +52,7 @@ class ManifestationReserveStatsController < ApplicationController
52
52
 
53
53
  respond_to do |format|
54
54
  if @manifestation_reserve_stat.save
55
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.manifestation_reserve_stat'))
56
- format.html { redirect_to @manifestation_reserve_stat }
55
+ format.html { redirect_to @manifestation_reserve_stat, :notice => t('controller.successfully_created', :model => t('activerecord.models.manifestation_reserve_stat')) }
57
56
  format.json { render :json => @manifestation_reserve_stat, :status => :created, :location => @manifestation_reserve_stat }
58
57
  else
59
58
  format.html { render :action => "new" }
@@ -67,8 +66,7 @@ class ManifestationReserveStatsController < ApplicationController
67
66
  def update
68
67
  respond_to do |format|
69
68
  if @manifestation_reserve_stat.update_attributes(params[:manifestation_reserve_stat])
70
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.manifestation_reserve_stat'))
71
- format.html { redirect_to @manifestation_reserve_stat }
69
+ format.html { redirect_to @manifestation_reserve_stat, :notice => t('controller.successfully_created', :model => t('activerecord.models.manifestation_reserve_stat')) }
72
70
  format.json { head :no_content }
73
71
  else
74
72
  format.html { render :action => "edit" }
@@ -39,7 +39,8 @@ class ReserveStatHasManifestationsController < ApplicationController
39
39
  # POST /reserve_stat_has_manifestations
40
40
  # POST /reserve_stat_has_manifestations.json
41
41
  def create
42
- @reserve_stat_has_manifestation = ReserveStatHasManifestation.new(params[:reserve_stat_has_manifestation])
42
+ @reserve_stat_has_manifestation = ReserveStatHasManifestation.new
43
+ @reserve_stat_has_manifestation.assign_attributes(params[:reserve_stat_has_manifestation], :as => :admin)
43
44
 
44
45
  respond_to do |format|
45
46
  if @reserve_stat_has_manifestation.save
@@ -55,8 +56,9 @@ class ReserveStatHasManifestationsController < ApplicationController
55
56
  # PUT /reserve_stat_has_manifestations/1
56
57
  # PUT /reserve_stat_has_manifestations/1.json
57
58
  def update
59
+ @reserve_stat_has_manifestation.assign_attributes(params[:reserve_stat_has_manifestation], :as => :admin)
58
60
  respond_to do |format|
59
- if @reserve_stat_has_manifestation.update_attributes(params[:reserve_stat_has_manifestation])
61
+ if @reserve_stat_has_manifestation.save
60
62
  format.html { redirect_to @reserve_stat_has_manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.reserve_stat_has_manifestation')) }
61
63
  format.json { head :no_content }
62
64
  else
@@ -39,12 +39,12 @@ class ReserveStatHasUsersController < ApplicationController
39
39
  # POST /reserve_stat_has_users
40
40
  # POST /reserve_stat_has_users.json
41
41
  def create
42
- @reserve_stat_has_user = ReserveStatHasUser.new(params[:reserve_stat_has_user])
42
+ @reserve_stat_has_user = ReserveStatHasUser.new
43
+ @reserve_stat_has_user.assign_attributes(params[:reserve_stat_has_user], :as => :admin)
43
44
 
44
45
  respond_to do |format|
45
46
  if @reserve_stat_has_user.save
46
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.reserve_stat_has_user'))
47
- format.html { redirect_to @reserve_stat_has_user }
47
+ format.html { redirect_to @reserve_stat_has_user, :notice => t('controller.successfully_created', :model => t('activerecord.models.reserve_stat_has_user')) }
48
48
  format.json { render :json => @reserve_stat_has_user, :status => :created, :location => @reserve_stat_has_user }
49
49
  else
50
50
  format.html { render :action => "new" }
@@ -56,10 +56,10 @@ class ReserveStatHasUsersController < ApplicationController
56
56
  # PUT /reserve_stat_has_users/1
57
57
  # PUT /reserve_stat_has_users/1.json
58
58
  def update
59
+ @reserve_stat_has_user.assign_attributes(params[:reserve_stat_has_user], :as => :admin)
59
60
  respond_to do |format|
60
- if @reserve_stat_has_user.update_attributes(params[:reserve_stat_has_user])
61
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.reserve_stat_has_user'))
62
- format.html { redirect_to @reserve_stat_has_user }
61
+ if @reserve_stat_has_user.save
62
+ format.html { redirect_to @reserve_stat_has_user, :notice => t('controller.successfully_updated', :model => t('activerecord.models.reserve_stat_has_user')) }
63
63
  format.json { head :no_content }
64
64
  else
65
65
  format.html { render :action => "edit" }
@@ -48,8 +48,7 @@ class UserGroupHasCheckoutTypesController < ApplicationController
48
48
 
49
49
  respond_to do |format|
50
50
  if @user_group_has_checkout_type.save
51
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.user_group_has_checkout_type'))
52
- format.html { redirect_to(@user_group_has_checkout_type) }
51
+ format.html { redirect_to(@user_group_has_checkout_type, :notice => t('controller.successfully_created', :model => t('activerecord.models.user_group_has_checkout_type'))) }
53
52
  format.json { render :json => @user_group_has_checkout_type, :status => :created, :location => @user_group_has_checkout_type }
54
53
  else
55
54
  prepare_options
@@ -64,8 +63,7 @@ class UserGroupHasCheckoutTypesController < ApplicationController
64
63
  def update
65
64
  respond_to do |format|
66
65
  if @user_group_has_checkout_type.update_attributes(params[:user_group_has_checkout_type])
67
- flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.user_group_has_checkout_type'))
68
- format.html { redirect_to @user_group_has_checkout_type }
66
+ format.html { redirect_to @user_group_has_checkout_type, :notice => t('controller.successfully_updated', :model => t('activerecord.models.user_group_has_checkout_type')) }
69
67
  format.json { head :no_content }
70
68
  else
71
69
  prepare_options
@@ -1,4 +1,5 @@
1
1
  class CarrierTypeHasCheckoutType < ActiveRecord::Base
2
+ attr_accessible :carrier_type_id, :checkout_type_id, :note
2
3
  scope :available_for_carrier_type, lambda {|carrier_type| {:include => :carrier_type, :conditions => ['carrier_types.name = ?', carrier_type.name]}}
3
4
  scope :available_for_user_group, lambda {|user_group| {:include => {:checkout_type => :user_groups}, :conditions => ['user_groups.name = ?', user_group.name]}}
4
5
 
@@ -1,4 +1,5 @@
1
1
  class CheckedItem < ActiveRecord::Base
2
+ attr_accessible
2
3
  belongs_to :item #, :validate => true
3
4
  belongs_to :basket #, :validate => true
4
5
  belongs_to :librarian, :class_name => 'User' #, :validate => true
@@ -1,4 +1,5 @@
1
1
  class Checkin < ActiveRecord::Base
2
+ attr_accessible :item_identifier
2
3
  default_scope :order => 'checkins.id DESC'
3
4
  scope :on, lambda {|date| {:conditions => ['created_at >= ? AND created_at < ?', date.beginning_of_day, date.tomorrow.beginning_of_day]}}
4
5
  has_one :checkout
@@ -10,7 +11,6 @@ class Checkin < ActiveRecord::Base
10
11
  validates_presence_of :item_id, :message => I18n.t('checkin.item_not_found')
11
12
  validates_presence_of :basket_id
12
13
 
13
- attr_protected :user_id
14
14
  attr_accessor :item_identifier
15
15
 
16
16
  def self.per_page
@@ -1,5 +1,6 @@
1
1
  class Checkout < ActiveRecord::Base
2
- default_scope :order => 'id DESC'
2
+ attr_accessible
3
+ default_scope :order => 'checkouts.id DESC'
3
4
  scope :not_returned, where(:checkin_id => nil)
4
5
  scope :overdue, lambda {|date| {:conditions => ['checkin_id IS NULL AND due_date < ?', date]}}
5
6
  scope :due_date_on, lambda {|date| where(:checkin_id => nil, :due_date => date.beginning_of_day .. date.end_of_day)}
@@ -21,8 +22,6 @@ class Checkout < ActiveRecord::Base
21
22
  validate :is_not_checked?, :on => :create
22
23
  validates_date :due_date
23
24
 
24
- attr_protected :user_id
25
-
26
25
  def self.per_page
27
26
  10
28
27
  end
@@ -1,4 +1,7 @@
1
1
  class CheckoutStatHasManifestation < ActiveRecord::Base
2
+ attr_accessible
3
+ attr_accessible :manifestation_checkout_stat_id, :manifestation_id,
4
+ :as => :admin
2
5
  belongs_to :manifestation_checkout_stat
3
6
  belongs_to :manifestation
4
7
 
@@ -1,4 +1,7 @@
1
1
  class CheckoutStatHasUser < ActiveRecord::Base
2
+ attr_accessible
3
+ attr_accessible :user_checkout_stat_id, :user_id,
4
+ :as => :admin
2
5
  belongs_to :user_checkout_stat
3
6
  belongs_to :user
4
7
 
@@ -1,4 +1,5 @@
1
1
  class CheckoutType < ActiveRecord::Base
2
+ attr_accessible :name, :display_name, :note
2
3
  include MasterModel
3
4
  default_scope :order => "checkout_types.position"
4
5
  scope :available_for_carrier_type, lambda {|carrier_type| {:include => :carrier_types, :conditions => ['carrier_types.name = ?', carrier_type.name], :order => 'carrier_types.position'}}
@@ -1,9 +1,9 @@
1
1
  class CirculationStatus < ActiveRecord::Base
2
+ attr_accessible :name, :display_name, :note
2
3
  include MasterModel
3
- default_scope :order => "position"
4
+ default_scope :order => "circulation_statuses.position"
4
5
  scope :available_for_checkout, where(:name => 'Available On Shelf')
5
6
  has_many :items
6
- attr_protected :name
7
7
  end
8
8
 
9
9
  # == Schema Information
@@ -1,4 +1,6 @@
1
1
  class ItemHasUseRestriction < ActiveRecord::Base
2
+ attr_accessible
3
+ attr_accessible :item_id, :use_restriction_id, :as => :admin
2
4
  belongs_to :item, :validate => true
3
5
  belongs_to :use_restriction, :validate => true
4
6
  accepts_nested_attributes_for :use_restriction
@@ -1,4 +1,6 @@
1
1
  class LendingPolicy < ActiveRecord::Base
2
+ attr_accessible :item_id, :user_group_id, :loan_period, :fixed_due_date,
3
+ :renewal, :fine, :note
2
4
  default_scope :order => 'position'
3
5
  belongs_to :item
4
6
  belongs_to :user_group
@@ -1,5 +1,7 @@
1
1
  class ManifestationCheckoutStat < ActiveRecord::Base
2
+ attr_accessible :start_date, :end_date, :note
2
3
  include CalculateStat
4
+ default_scope :order => 'manifestation_checkout_stats.id DESC'
3
5
  scope :not_calculated, where(:state => 'pending')
4
6
  has_many :checkout_stat_has_manifestations
5
7
  has_many :manifestations, :through => :checkout_stat_has_manifestations
@@ -1,5 +1,7 @@
1
1
  class ManifestationReserveStat < ActiveRecord::Base
2
+ attr_accessible :start_date, :end_date, :note
2
3
  include CalculateStat
4
+ default_scope :order => 'manifestation_reserve_stats.id DESC'
3
5
  scope :not_calculated, where(:state => 'pending')
4
6
  has_many :reserve_stat_has_manifestations
5
7
  has_many :manifestations, :through => :reserve_stat_has_manifestations
@@ -1,5 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class Reserve < ActiveRecord::Base
3
+ attr_accessible :manifestation_id, :item_identifier, :user_number, :expired_at
4
+ attr_accessible :manifestation_id, :item_identifier, :user_number,
5
+ :expired_at, :request_status_type, :canceled_at, :checked_out_at,
6
+ :expiration_notice_to_patron, :expiration_notice_to_library,
7
+ :as => :admin
3
8
  scope :hold, where('item_id IS NOT NULL')
4
9
  scope :not_hold, where(:item_id => nil)
5
10
  scope :waiting, where('canceled_at IS NULL AND expired_at > ? AND state != ?', Time.zone.now, 'completed').order('reserves.id DESC')
@@ -31,7 +36,6 @@ class Reserve < ActiveRecord::Base
31
36
  before_validation :set_expired_at
32
37
  before_validation :set_request_status, :on => :create
33
38
 
34
- attr_protected :user_id
35
39
  attr_accessor :user_number, :item_identifier
36
40
 
37
41
  state_machine :initial => :pending do
@@ -94,7 +98,8 @@ class Reserve < ActiveRecord::Base
94
98
  end
95
99
 
96
100
  def do_request
97
- self.update_attributes({:request_status_type => RequestStatusType.where(:name => 'In Process').first})
101
+ self.assign_attributes({:request_status_type => RequestStatusType.where(:name => 'In Process').first}, :as => :admin)
102
+ self.save!
98
103
  end
99
104
 
100
105
  def manifestation_must_include_item
@@ -116,39 +121,47 @@ class Reserve < ActiveRecord::Base
116
121
  case state
117
122
  when 'requested'
118
123
  message_template_to_patron = MessageTemplate.localized_template('reservation_accepted_for_patron', user.locale)
119
- request = MessageRequest.create!(:sender => sender, :receiver => user, :message_template => message_template_to_patron)
124
+ request = MessageRequest.new
125
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template_to_patron}, :as => :admin)
120
126
  request.save_message_body(:manifestations => Array[manifestation], :user => user)
121
127
  request.sm_send_message! # 受付時は即時送信
122
128
  message_template_to_library = MessageTemplate.localized_template('reservation_accepted_for_library', user.locale)
123
- request = MessageRequest.create!(:sender => sender, :receiver => sender, :message_template => message_template_to_library)
129
+ request = MessageRequest.new
130
+ request.assign_attributes({:sender => sender, :receiver => sender, :message_template => message_template_to_library}, :as => :admin)
124
131
  request.save_message_body(:manifestations => Array[manifestation], :user => user)
125
132
  request.sm_send_message! # 受付時は即時送信
126
133
  when 'canceled'
127
134
  message_template_to_patron = MessageTemplate.localized_template('reservation_canceled_for_patron', user.locale)
128
- request = MessageRequest.create!(:sender => sender, :receiver => user, :message_template => message_template_to_patron)
135
+ request = MessageRequest.new
136
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template_to_patron}, :as => :admin)
129
137
  request.save_message_body(:manifestations => Array[manifestation], :user => user)
130
138
  request.sm_send_message! # キャンセル時は即時送信
131
139
  message_template_to_library = MessageTemplate.localized_template('reservation_canceled_for_library', user.locale)
132
- request = MessageRequest.create!(:sender => sender, :receiver => sender, :message_template => message_template_to_library)
140
+ request = MessageRequest.new
141
+ request.assign_attributes({:sender => sender, :receiver => sender, :message_template => message_template_to_library}, :as => :admin)
133
142
  request.save_message_body(:manifestations => Array[manifestation], :user => user)
134
143
  request.sm_send_message! # キャンセル時は即時送信
135
144
  when 'expired'
136
145
  message_template_to_patron = MessageTemplate.localized_template('reservation_expired_for_patron', user.locale)
137
- request = MessageRequest.create!(:sender => sender, :receiver => user, :message_template => message_template_to_patron)
146
+ request = MessageRequest.new
147
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template_to_patron}, :as => :admin)
138
148
  request.save_message_body(:manifestations => Array[manifestation], :user => user)
139
149
  request.sm_send_message!
140
150
  self.update_attribute(:expiration_notice_to_patron, true)
141
151
  message_template_to_library = MessageTemplate.localized_template('reservation_expired_for_library', sender.locale)
142
- request = MessageRequest.create!(:sender => sender, :receiver => sender, :message_template => message_template_to_library)
152
+ request = MessageRequest.new
153
+ request.assign_attributes({:sender => sender, :receiver => sender, :message_template => message_template_to_library}, :as => :admin)
143
154
  request.save_message_body(:manifestations => Array[manifestation], :user => sender)
144
155
  request.sm_send_message!
145
156
  when 'retained'
146
157
  message_template_for_patron = MessageTemplate.localized_template('item_received_for_patron', user.locale)
147
- request = MessageRequest.create!(:sender => sender, :receiver => user, :message_template => message_template_for_patron)
158
+ request = MessageRequest.new
159
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template_for_patron}, :as => :admin)
148
160
  request.save_message_body(:manifestations => Array[item.manifestation], :user => user)
149
161
  request.sm_send_message!
150
162
  message_template_for_library = MessageTemplate.localized_template('item_received_for_library', user.locale)
151
- request = MessageRequest.create!(:sender => sender, :receiver => sender, :message_template => message_template_for_library)
163
+ request = MessageRequest.new
164
+ request.assign_attributes({:sender => sender, :receiver => sender, :message_template => message_template_for_library}, :as => :admin)
152
165
  request.save_message_body(:manifestations => Array[item.manifestation], :user => user)
153
166
  request.sm_send_message!
154
167
  else
@@ -162,14 +175,16 @@ class Reserve < ActiveRecord::Base
162
175
  case status
163
176
  when 'expired'
164
177
  message_template_to_library = MessageTemplate.localized_template('reservation_expired_for_library', sender.locale)
165
- request = MessageRequest.create!(:sender => sender, :receiver => sender, :message_template => message_template_to_library)
178
+ request = MessageRequest.new
179
+ request.assign_attributes({:sender => sender, :receiver => sender, :message_template => message_template_to_library}, :as => :admin)
166
180
  request.save_message_body(:manifestations => options[:manifestations])
167
181
  self.not_sent_expiration_notice_to_library.each do |reserve|
168
182
  reserve.update_attribute(:expiration_notice_to_library, true)
169
183
  end
170
184
  #when 'canceled'
171
185
  # message_template_to_library = MessageTemplate.localized_template('reservation_canceled_for_library', sender.locale)
172
- # request = MessageRequest.create!(:sender => sender, :receiver => sender, :message_template => message_template_to_library)
186
+ # request = MessageRequest.new
187
+ # request.assign_attributes({:sender => sender, :receiver => sender, :message_template => message_template_to_library}, :as => :admin)
173
188
  # request.save_message_body(:manifestations => self.not_sent_expiration_notice_to_library.collect(&:manifestation))
174
189
  # self.not_sent_cancel_notice_to_library.each do |reserve|
175
190
  # reserve.update_attribute(:expiration_notice_to_library, true)
@@ -219,11 +234,13 @@ class Reserve < ActiveRecord::Base
219
234
  private
220
235
  def retain
221
236
  # TODO: 「取り置き中」の状態を正しく表す
222
- self.update_attributes!({:request_status_type => RequestStatusType.where(:name => 'In Process').first, :checked_out_at => Time.zone.now})
237
+ self.assign_attributes({:request_status_type => RequestStatusType.where(:name => 'In Process').first, :checked_out_at => Time.zone.now}, :as => :admin)
238
+ self.save!
223
239
  end
224
240
 
225
241
  def expire
226
- self.update_attributes!({:request_status_type => RequestStatusType.where(:name => 'Expired').first, :canceled_at => Time.zone.now})
242
+ self.assign_attributes({:request_status_type => RequestStatusType.where(:name => 'Expired').first, :canceled_at => Time.zone.now}, :as => :admin)
243
+ self.save!
227
244
  logger.info "#{Time.zone.now} reserve_id #{self.id} expired!"
228
245
  reserve = next_reservation
229
246
  if reserve
@@ -234,7 +251,8 @@ class Reserve < ActiveRecord::Base
234
251
  end
235
252
 
236
253
  def cancel
237
- self.update_attributes!({:request_status_type => RequestStatusType.where(:name => 'Cannot Fulfill Request').first, :canceled_at => Time.zone.now})
254
+ self.assign_attributes({:request_status_type => RequestStatusType.where(:name => 'Cannot Fulfill Request').first, :canceled_at => Time.zone.now}, :as => :admin)
255
+ self.save!
238
256
  reserve = next_reservation
239
257
  if reserve
240
258
  reserve.item = item
@@ -244,7 +262,8 @@ class Reserve < ActiveRecord::Base
244
262
  end
245
263
 
246
264
  def checkout
247
- self.update_attributes!({:request_status_type => RequestStatusType.where(:name => 'Available For Pickup').first, :checked_out_at => Time.zone.now})
265
+ self.assign_attributes({:request_status_type => RequestStatusType.where(:name => 'Available For Pickup').first, :checked_out_at => Time.zone.now}, :as => :admin)
266
+ self.save!
248
267
  end
249
268
 
250
269
  if defined?(EnjuInterLibraryLoan)