enju_circulation 0.0.62 → 0.0.63

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,9 +100,11 @@ class CheckinsController < ApplicationController
100
100
  item = Item.where(:item_identifier => @checkin.item_identifier.to_s.strip).first
101
101
  end
102
102
  @checkin.item = item
103
+ @checkin.assign_attributes(params[:checkin])
104
+ @checkin.librarian = current_user
103
105
 
104
106
  respond_to do |format|
105
- if @checkin.update_attributes(params[:checkin])
107
+ if @checkin.save
106
108
  format.html { redirect_to @checkin, :notice => t('controller.successfully_updated', :model => t('activerecord.models.checkin')) }
107
109
  format.json { head :no_content }
108
110
  else
@@ -62,16 +62,16 @@ class ReservesController < ApplicationController
62
62
  # GET /reserves/new.json
63
63
  def new
64
64
  @reserve = Reserve.new(params[:reserve])
65
- if @user
65
+
66
+ if current_user.has_role?('Librarian')
66
67
  @reserve.user = @user
67
68
  else
68
- @reserve.user = User.where(:user_number => @reserve.user_number).first if @reserve.user_number.to_s.strip.present?
69
- end
70
-
71
- unless current_user.has_role?('Librarian')
72
- if @reserve.user and @reserve.user != current_user
73
- access_denied; return
69
+ if @user.present?
70
+ if @user != current_user
71
+ access_denied; return
72
+ end
74
73
  end
74
+ @reserve.user_number = current_user.user_number
75
75
  end
76
76
 
77
77
  get_manifestation
@@ -98,9 +98,15 @@ class ReservesController < ApplicationController
98
98
  @reserve = Reserve.new(params[:reserve])
99
99
  @reserve.user = User.where(:user_number => @reserve.user_number).first if @reserve.user_number.to_s.strip.present?
100
100
 
101
- unless current_user.has_role?('Librarian')
101
+ if current_user.has_role?('Librarian')
102
+ unless @reserve.user
103
+ @reserve.user = @user
104
+ end
105
+ else
102
106
  if @reserve.user != current_user
103
- access_denied; return
107
+ if @user != current_user
108
+ access_denied; return
109
+ end
104
110
  end
105
111
  end
106
112
 
@@ -121,6 +127,7 @@ class ReservesController < ApplicationController
121
127
  # PUT /reserves/1
122
128
  # PUT /reserves/1.json
123
129
  def update
130
+ @reserve.assign_attributes(params[:reserve])
124
131
  @reserve.user = User.where(:user_number => @reserve.user_number).first if @reserve.user_number.to_s.strip.present?
125
132
 
126
133
  unless current_user.has_role?('Librarian')
@@ -134,7 +141,7 @@ class ReservesController < ApplicationController
134
141
  end
135
142
 
136
143
  respond_to do |format|
137
- if @reserve.update_attributes(params[:reserve])
144
+ if @reserve.save
138
145
  if @reserve.state == 'canceled'
139
146
  flash[:notice] = t('reserve.reservation_was_canceled')
140
147
  @reserve.send_message
@@ -1,5 +1,5 @@
1
1
  class CheckedItem < ActiveRecord::Base
2
- attr_accessible
2
+ attr_accessible :item_identifier, :ignore_restriction
3
3
  belongs_to :item #, :validate => true
4
4
  belongs_to :basket #, :validate => true
5
5
  belongs_to :librarian, :class_name => 'User' #, :validate => true
@@ -20,7 +20,9 @@ class Checkin < ActiveRecord::Base
20
20
  def item_checkin(current_user)
21
21
  message = ''
22
22
  Checkin.transaction do
23
- checkouts = Checkout.not_returned.where(:item_id => item_id).select([:id, :item_id, :user_id, :basket_id, :lock_version])
23
+ checkouts = Checkout.not_returned.where(:item_id => item_id).select(
24
+ [:id, :item_id, :user_id, :basket_id, :due_date, :lock_version]
25
+ )
24
26
  item.checkin!
25
27
  checkouts.each do |checkout|
26
28
  # TODO: ILL時の処理
@@ -28,7 +30,7 @@ class Checkin < ActiveRecord::Base
28
30
  unless checkout.user.try(:save_checkout_history)
29
31
  checkout.user = nil
30
32
  end
31
- checkout.save(:validate => false)
33
+ checkout.save!
32
34
  unless checkout.item.shelf.library == current_user.library
33
35
  message << I18n.t('checkin.other_library_item')
34
36
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.62"
2
+ VERSION = "0.0.63"
3
3
  end
@@ -312,8 +312,8 @@ describe CheckinsController do
312
312
  describe "PUT update" do
313
313
  before(:each) do
314
314
  @checkin = checkins(:checkin_00001)
315
- @attrs = {:item_identifier => @checkin.item.item_identifier, :librarian_id => FactoryGirl.create(:librarian).id}
316
- @invalid_attrs = {:basket_id => ''}
315
+ @attrs = {:item_identifier => @checkin.item.item_identifier}
316
+ @invalid_attrs = {:item_identifier => 'invalid'}
317
317
  end
318
318
 
319
319
  describe "When logged in as Administrator" do
@@ -237,7 +237,7 @@ describe CheckoutsController do
237
237
  before(:each) do
238
238
  @checkout = checkouts(:checkout_00003)
239
239
  @attrs = {:due_date => 1.day.from_now}
240
- @invalid_attrs = {:item_id => ''}
240
+ @invalid_attrs = {:item_identifier => 'invalid'}
241
241
  end
242
242
 
243
243
  describe "When logged in as Administrator" do
Binary file
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.0.62
4
+ version: 0.0.63
5
5
  prerelease:
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-06-19 00:00:00.000000000 Z
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails