enju_circulation 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,14 +2,13 @@ class CheckinsController < ApplicationController
2
2
  load_and_authorize_resource :except => :index
3
3
  authorize_resource :only => :index
4
4
  before_filter :get_user
5
- helper_method :get_basket
5
+ before_filter :get_basket, :only => [:index, :create]
6
6
  cache_sweeper :circulation_sweeper, :only => [:create, :update, :destroy]
7
7
 
8
8
  # GET /checkins
9
9
  # GET /checkins.json
10
10
  def index
11
11
  # かごがない場合、自動的に作成する
12
- get_basket
13
12
  unless @basket
14
13
  @basket = Basket.create!(:user => current_user)
15
14
  redirect_to basket_checkins_url(@basket)
@@ -51,12 +50,12 @@ class CheckinsController < ApplicationController
51
50
  # POST /checkins
52
51
  # POST /checkins.json
53
52
  def create
54
- get_basket
55
53
  unless @basket
56
54
  @basket = Basket.new(:user => current_user)
57
55
  @basket.save(:validate => false)
58
56
  end
59
57
  @checkin = @basket.checkins.new(params[:checkin])
58
+ @checkin.librarian = current_user
60
59
 
61
60
  flash[:message] = ''
62
61
  if @checkin.item_identifier.blank?
@@ -67,10 +66,10 @@ class CheckinsController < ApplicationController
67
66
 
68
67
  if item.blank?
69
68
  flash[:message] << t('checkin.item_not_found')
70
- end
71
-
72
- if @basket.checkins.collect(&:item).include?(item)
73
- flash[:message] << t('checkin.already_checked_in')
69
+ else
70
+ if @basket.checkins.collect(&:item).include?(item)
71
+ flash[:message] << t('checkin.already_checked_in')
72
+ end
74
73
  end
75
74
 
76
75
  respond_to do |format|
@@ -89,7 +88,7 @@ class CheckinsController < ApplicationController
89
88
  message = @checkin.item_checkin(current_user)
90
89
  flash[:message] << message if message
91
90
  format.html { redirect_to basket_checkins_url(@checkin.basket) }
92
- format.json { render :json => @checkin, :status => :created, :location => checkin_url(@checkin) }
91
+ format.json { render :json => @checkin, :status => :created, :location => @checkin }
93
92
  format.js {
94
93
  redirect_to basket_checkins_url(@checkin.basket, :mode => 'list', :format => :js)
95
94
  }
@@ -1,24 +1,15 @@
1
- <%= form_for(@checkin) do |f| %>
2
- <% if @checkin.errors.any? %>
3
- <div id="errorExplanation">
4
- <h2><%= pluralize(@checkin.errors.count, "error") %> prohibited this checkin from being saved:</h2>
5
- <ul>
6
- <% @checkin.errors.full_messages.each do |msg| %>
7
- <li><%= msg %></li>
8
- <% end %>
9
- </ul>
10
- </div>
11
- <% end %>
1
+ <%= simple_form_for(@checkin) do |f| %>
2
+ <%= f.error_notification %>
12
3
 
13
- <div class="field">
14
- <%= f.label :item_id %><br />
15
- <%= f.text_field :item_id %>
4
+ <div class="form-inputs">
5
+ <%= f.input :item_id %>
16
6
  </div>
17
- <div class="field">
18
- <%= f.label :librarian_id %><br />
19
- <%= f.text_field :librarian_id %>
7
+
8
+ <div class="form-inputs">
9
+ <%= f.input :librarian_id %>
20
10
  </div>
21
- <div class="actions">
22
- <%= f.submit %>
11
+
12
+ <div class="form-actions">
13
+ <%= f.button :submit %>
23
14
  </div>
24
15
  <% end %>
@@ -3,10 +3,11 @@
3
3
  <div class="search_form">
4
4
  <%= form_for @checkin, :html => {:method => :post}, :url => basket_checkins_path(@basket, :mode => 'list'), :remote => true do |f| -%>
5
5
 
6
- <p><%= t('activerecord.attributes.item.item_identifier') -%>:
6
+ <p>
7
+ <%= t('activerecord.attributes.item.item_identifier') -%>:
7
8
  <%= f.text_field :item_identifier, :class => 'resource_item_identifier' -%>
8
- <%= f.hidden_field :librarian_id, :value => current_user.id -%>
9
- <%= submit_tag t('checkin.checkin') -%></p>
9
+ <%= f.submit t('checkin.checkin') -%>
10
+ </p>
10
11
  <%- end -%>
11
12
  </div>
12
13
 
@@ -1,26 +1,13 @@
1
1
  <div id="content_detail" class="ui-corner-all">
2
2
  <h1 class="title"><%= t('page.editing', :model => t('activerecord.models.checkin')) -%></h1>
3
3
  <div id="content_list">
4
-
5
- <%= form_for(@checkin) do |f| -%>
6
- <%= f.error_messages -%>
7
-
8
- <div class="field">
9
- <%= f.label t('activerecord.models.item') -%><br />
10
- <%= f.text_field :item_identifier -%>
11
- </div>
12
-
13
- <div class="actions">
14
- <%= f.submit %>
15
- </div>
16
- <%- end -%>
17
-
4
+ <%= render 'form' %>
18
5
  </div>
19
6
  </div>
20
7
 
21
8
  <div id="submenu" class="ui-corner-all">
22
9
  <ul>
23
- <li><%= link_to t('page.show'), checkin_path(@checkin) -%></li>
10
+ <li><%= link_to t('page.show'), @checkin -%></li>
24
11
  <li><%= link_to t('page.back'), checkins_path -%></li>
25
12
  </ul>
26
13
  </div>
@@ -1,14 +1,12 @@
1
+ <div id="content_detail" class="ui-corner-all">
1
2
  <h1 class="title"><%= t('page.new', :model => t('activerecord.models.checkin')) -%></h1>
2
-
3
- <%= form_for(@checkin) do |f| -%>
4
- <%= f.error_messages -%>
5
-
6
- <div class="field">
7
- <%= f.label t('activerecord.models.item') -%><br />
8
- <%= f.text_field :item_id -%>
9
- </div>
10
-
11
- <%= f.submit %>
12
- <%- end -%>
13
-
14
- <%= link_to t('page.back'), checkins_path -%>
3
+ <div id="content_list">
4
+ <%= render 'form' %>
5
+ </div>
6
+ </div>
7
+
8
+ <div id="submenu" class="ui-corner-all">
9
+ <ul>
10
+ <li><%= link_to t('page.back'), checkins_path -%></li>
11
+ </ul>
12
+ </div>
@@ -4,12 +4,12 @@
4
4
  <p id="notice"><%= notice %></p>
5
5
 
6
6
  <p>
7
- <strong><%= t('activerecord.models.item') -%>:</strong>
7
+ <strong><%= t('activerecord.models.item') -%>:</strong>
8
8
  <%= link_to @checkin.item.manifestation.original_title, @checkin.item -%>
9
9
  </p>
10
10
 
11
11
  <p>
12
- <strong><%= ('Librarian') -%>:</strong>
12
+ <strong><%= t('activerecord.models.user') -%>:</strong>
13
13
  <%= link_to @checkin.librarian.username, @checkin.librarian -%>
14
14
  </p>
15
15
 
@@ -165,4 +165,3 @@ en:
165
165
  canceled: "Canceled"
166
166
  expired: "Expired"
167
167
  completed: "Completed"
168
-
@@ -163,4 +163,3 @@ ja:
163
163
  canceled: "取消済み"
164
164
  expired: "期限切れ"
165
165
  completed: "貸出済み"
166
-
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -2,10 +2,7 @@ class Basket < ActiveRecord::Base
2
2
  default_scope :order => 'id DESC'
3
3
  scope :will_expire, lambda {|date| {:conditions => ['created_at < ?', date]}}
4
4
  belongs_to :user, :validate => true
5
- has_many :checked_items, :dependent => :destroy
6
- has_many :items, :through => :checked_items
7
- has_many :checkouts
8
- has_many :checkins
5
+ has_many :accepts
9
6
 
10
7
  validates_associated :user, :on => :create
11
8
  # 貸出完了後にかごのユーザidは破棄する
@@ -23,24 +20,30 @@ class Basket < ActiveRecord::Base
23
20
  end
24
21
  end
25
22
 
26
- def basket_checkout(librarian)
27
- return nil if self.checked_items.size == 0
28
- Item.transaction do
29
- self.checked_items.each do |checked_item|
30
- checkout = self.user.checkouts.new(:librarian_id => librarian.id, :item_id => checked_item.item.id, :basket_id => self.id, :due_date => checked_item.due_date)
31
- if checked_item.item.checkout!(self.user)
32
- checkout.save!
33
- end
34
- end
35
- CheckedItem.destroy_all(:basket_id => self.id)
36
- end
37
- end
38
-
39
23
  def self.expire
40
24
  Basket.will_expire(Time.zone.now.beginning_of_day).destroy_all
41
25
  logger.info "#{Time.zone.now} baskets expired!"
42
26
  end
43
27
 
28
+ if defined?(EnjuCirculation)
29
+ has_many :checked_items, :dependent => :destroy
30
+ has_many :items, :through => :checked_items
31
+ has_many :checkouts
32
+ has_many :checkins
33
+
34
+ def basket_checkout(librarian)
35
+ return nil if self.checked_items.size == 0
36
+ Item.transaction do
37
+ self.checked_items.each do |checked_item|
38
+ checkout = self.user.checkouts.new(:librarian_id => librarian.id, :item_id => checked_item.item.id, :basket_id => self.id, :due_date => checked_item.due_date)
39
+ if checked_item.item.checkout!(self.user)
40
+ checkout.save!
41
+ end
42
+ end
43
+ CheckedItem.destroy_all(:basket_id => self.id)
44
+ end
45
+ end
46
+ end
44
47
  end
45
48
 
46
49
  # == Schema Information
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.16
4
+ version: 0.0.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70093669315100 !ruby/object:Gem::Requirement
16
+ requirement: &70307215747020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70093669315100
24
+ version_requirements: *70307215747020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simple_form
27
- requirement: &70093669314680 !ruby/object:Gem::Requirement
27
+ requirement: &70307215746420 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70093669314680
35
+ version_requirements: *70307215746420
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: devise
38
- requirement: &70093669314220 !ruby/object:Gem::Requirement
38
+ requirement: &70307215745760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70093669314220
46
+ version_requirements: *70307215745760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cancan
49
- requirement: &70093669313800 !ruby/object:Gem::Requirement
49
+ requirement: &70307215745160 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70093669313800
57
+ version_requirements: *70307215745160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: validates_timeliness
60
- requirement: &70093669313380 !ruby/object:Gem::Requirement
60
+ requirement: &70307215744480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70093669313380
68
+ version_requirements: *70307215744480
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: attribute_normalizer
71
- requirement: &70093669312880 !ruby/object:Gem::Requirement
71
+ requirement: &70307215743720 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '1.1'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70093669312880
79
+ version_requirements: *70307215743720
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: inherited_resources
82
- requirement: &70093669312460 !ruby/object:Gem::Requirement
82
+ requirement: &70307215743300 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70093669312460
90
+ version_requirements: *70307215743300
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: state_machine
93
- requirement: &70093669312000 !ruby/object:Gem::Requirement
93
+ requirement: &70307215742840 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70093669312000
101
+ version_requirements: *70307215742840
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: friendly_id
104
- requirement: &70093669311500 !ruby/object:Gem::Requirement
104
+ requirement: &70307215742300 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '4.0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70093669311500
112
+ version_requirements: *70307215742300
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: sunspot_rails
115
- requirement: &70093669311080 !ruby/object:Gem::Requirement
115
+ requirement: &70307215741880 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70093669311080
123
+ version_requirements: *70307215741880
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: sunspot_solr
126
- requirement: &70093669310620 !ruby/object:Gem::Requirement
126
+ requirement: &70307215741420 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *70093669310620
134
+ version_requirements: *70307215741420
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: will_paginate
137
- requirement: &70093669310120 !ruby/object:Gem::Requirement
137
+ requirement: &70307215740920 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '3.0'
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *70093669310120
145
+ version_requirements: *70307215740920
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: acts_as_list
148
- requirement: &70093669309620 !ruby/object:Gem::Requirement
148
+ requirement: &70307215740420 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: 0.1.5
154
154
  type: :runtime
155
155
  prerelease: false
156
- version_requirements: *70093669309620
156
+ version_requirements: *70307215740420
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: enju_message
159
- requirement: &70093669309160 !ruby/object:Gem::Requirement
159
+ requirement: &70307215739940 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ~>
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: 0.0.10
165
165
  type: :runtime
166
166
  prerelease: false
167
- version_requirements: *70093669309160
167
+ version_requirements: *70307215739940
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: enju_event
170
- requirement: &70093669308700 !ruby/object:Gem::Requirement
170
+ requirement: &70307215739480 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: 0.0.5
176
176
  type: :runtime
177
177
  prerelease: false
178
- version_requirements: *70093669308700
178
+ version_requirements: *70307215739480
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: sqlite3
181
- requirement: &70093669308320 !ruby/object:Gem::Requirement
181
+ requirement: &70307215739100 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ! '>='
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: '0'
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *70093669308320
189
+ version_requirements: *70307215739100
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: rspec-rails
192
- requirement: &70093669307860 !ruby/object:Gem::Requirement
192
+ requirement: &70307215738640 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ! '>='
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: '0'
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *70093669307860
200
+ version_requirements: *70307215738640
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: factory_girl_rails
203
- requirement: &70093669307360 !ruby/object:Gem::Requirement
203
+ requirement: &70307215738140 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ~>
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: '1.7'
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *70093669307360
211
+ version_requirements: *70307215738140
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: sunspot-rails-tester
214
- requirement: &70093669306940 !ruby/object:Gem::Requirement
214
+ requirement: &70307215737720 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ! '>='
@@ -219,7 +219,7 @@ dependencies:
219
219
  version: '0'
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *70093669306940
222
+ version_requirements: *70307215737720
223
223
  description: Circulation management for Next-L Enju
224
224
  email:
225
225
  - tanabe@mwr.mediacom.keio.ac.jp
@@ -248,7 +248,6 @@ files:
248
248
  - app/controllers/user_group_has_checkout_types_controller.rb
249
249
  - app/controllers/user_reserve_stats_controller.rb
250
250
  - app/helpers/reserves_helper.rb
251
- - app/models/basket.rb
252
251
  - app/models/carrier_type_has_checkout_type.rb
253
252
  - app/models/checked_item.rb
254
253
  - app/models/checkin.rb
@@ -398,7 +397,6 @@ files:
398
397
  - db/migrate/032_create_checkins.rb
399
398
  - db/migrate/033_create_checkouts.rb
400
399
  - db/migrate/035_create_reserves.rb
401
- - db/migrate/120_create_baskets.rb
402
400
  - db/migrate/121_create_checked_items.rb
403
401
  - db/migrate/127_create_use_restrictions.rb
404
402
  - db/migrate/129_create_item_has_use_restrictions.rb
@@ -455,6 +453,7 @@ files:
455
453
  - spec/dummy/app/helpers/application_helper.rb
456
454
  - spec/dummy/app/mailers/notifier.rb
457
455
  - spec/dummy/app/models/ability.rb
456
+ - spec/dummy/app/models/basket.rb
458
457
  - spec/dummy/app/models/carrier_type.rb
459
458
  - spec/dummy/app/models/event.rb
460
459
  - spec/dummy/app/models/event_category.rb
@@ -510,6 +509,7 @@ files:
510
509
  - spec/dummy/db/migrate/080_create_library_groups.rb
511
510
  - spec/dummy/db/migrate/113_create_events.rb
512
511
  - spec/dummy/db/migrate/114_create_event_categories.rb
512
+ - spec/dummy/db/migrate/120_create_baskets.rb
513
513
  - spec/dummy/db/migrate/130_create_request_status_types.rb
514
514
  - spec/dummy/db/migrate/131_create_request_types.rb
515
515
  - spec/dummy/db/migrate/149_create_message_templates.rb
@@ -681,6 +681,7 @@ test_files:
681
681
  - spec/dummy/app/helpers/application_helper.rb
682
682
  - spec/dummy/app/mailers/notifier.rb
683
683
  - spec/dummy/app/models/ability.rb
684
+ - spec/dummy/app/models/basket.rb
684
685
  - spec/dummy/app/models/carrier_type.rb
685
686
  - spec/dummy/app/models/event.rb
686
687
  - spec/dummy/app/models/event_category.rb
@@ -736,6 +737,7 @@ test_files:
736
737
  - spec/dummy/db/migrate/080_create_library_groups.rb
737
738
  - spec/dummy/db/migrate/113_create_events.rb
738
739
  - spec/dummy/db/migrate/114_create_event_categories.rb
740
+ - spec/dummy/db/migrate/120_create_baskets.rb
739
741
  - spec/dummy/db/migrate/130_create_request_status_types.rb
740
742
  - spec/dummy/db/migrate/131_create_request_types.rb
741
743
  - spec/dummy/db/migrate/149_create_message_templates.rb