enju_circulation 0.0.56 → 0.0.57

Sign up to get free protection for your applications and to get access to all the features.
@@ -110,9 +110,11 @@ class CheckoutsController < ApplicationController
110
110
  end
111
111
  @checkout.reload
112
112
  @checkout.checkout_renewal_count += 1
113
+ @checkout.assign_attributes(params[:checkout])
114
+ @checkout.due_date = @checkout.due_date.end_of_day
113
115
 
114
116
  respond_to do |format|
115
- if @checkout.update_attributes(params[:checkout])
117
+ if @checkout.save
116
118
  format.html { redirect_to @checkout, :notice => t('controller.successfully_updated', :model => t('activerecord.models.checkout')) }
117
119
  format.json { head :no_content }
118
120
  else
@@ -1,5 +1,5 @@
1
1
  class Checkout < ActiveRecord::Base
2
- attr_accessible
2
+ attr_accessible :due_date
3
3
  default_scope :order => 'checkouts.id DESC'
4
4
  scope :not_returned, where(:checkin_id => nil)
5
5
  scope :overdue, lambda {|date| {:conditions => ['checkin_id IS NULL AND due_date < ?', date]}}
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.56"
2
+ VERSION = "0.0.57"
3
3
  end
@@ -243,9 +243,11 @@ describe CheckoutsController do
243
243
  end
244
244
 
245
245
  it "assigns the requested checkout as @checkout" do
246
+ old_due_date = @checkout.due_date
246
247
  put :update, :id => @checkout.id, :checkout => @attrs
247
248
  assigns(:checkout).should eq(@checkout)
248
249
  response.should redirect_to(assigns(:checkout))
250
+ assigns(:checkout).due_date.should eq 1.day.from_now.end_of_day
249
251
  end
250
252
  end
251
253
 
@@ -1,4 +1,22 @@
1
1
  class UserHasRole < ActiveRecord::Base
2
+ attr_accessible :user_id, :role_id
3
+ attr_accessible :user_id, :role_id, :as => :admin
2
4
  belongs_to :user
3
5
  belongs_to :role
6
+ accepts_nested_attributes_for :role
7
+
8
+ # validates_uniqueness_of :role_id, :scope => :user_id
9
+ # validates_presence_of :role_id, :user_id
4
10
  end
11
+
12
+ # == Schema Information
13
+ #
14
+ # Table name: user_has_roles
15
+ #
16
+ # id :integer not null, primary key
17
+ # user_id :integer
18
+ # role_id :integer
19
+ # created_at :datetime
20
+ # updated_at :datetime
21
+ #
22
+
@@ -35,6 +35,17 @@ module Dummy
35
35
  # Configure sensitive parameters which will be filtered from the log file.
36
36
  config.filter_parameters += [:password]
37
37
 
38
+ # Use SQL instead of Active Record's schema dumper when creating the database.
39
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
40
+ # like if you have constraints or database-specific column types
41
+ # config.active_record.schema_format = :sql
42
+
43
+ # Enforce whitelist mode for mass assignment.
44
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
45
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
46
+ # parameters by using an attr_accessible or attr_protected declaration.
47
+ config.active_record.whitelist_attributes = true
48
+
38
49
  # Enable the asset pipeline
39
50
  config.assets.enabled = true
40
51
 
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.56
4
+ version: 0.0.57
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-11 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -563,7 +563,6 @@ files:
563
563
  - spec/dummy/app/helpers/application_helper.rb
564
564
  - spec/dummy/app/mailers/notifier.rb
565
565
  - spec/dummy/app/models/ability.rb
566
- - spec/dummy/app/models/basket.rb
567
566
  - spec/dummy/app/models/role.rb
568
567
  - spec/dummy/app/models/user.rb
569
568
  - spec/dummy/app/models/user_group.rb
@@ -842,7 +841,6 @@ test_files:
842
841
  - spec/dummy/app/helpers/application_helper.rb
843
842
  - spec/dummy/app/mailers/notifier.rb
844
843
  - spec/dummy/app/models/ability.rb
845
- - spec/dummy/app/models/basket.rb
846
844
  - spec/dummy/app/models/role.rb
847
845
  - spec/dummy/app/models/user.rb
848
846
  - spec/dummy/app/models/user_group.rb
@@ -1,63 +0,0 @@
1
- class Basket < ActiveRecord::Base
2
- attr_accessible :note, :user_number
3
- default_scope :order => 'baskets.id DESC'
4
- scope :will_expire, lambda {|date| {:conditions => ['created_at < ?', date]}}
5
- belongs_to :user, :validate => true
6
- has_many :accepts
7
-
8
- validates_associated :user, :on => :create
9
- # 貸出完了後にかごのユーザidは破棄する
10
- validates_presence_of :user, :on => :create
11
- validate :check_suspended
12
-
13
- attr_accessor :user_number
14
-
15
- def check_suspended
16
- if self.user
17
- errors[:base] << I18n.t('basket.this_account_is_suspended') if self.user.locked_at?
18
- else
19
- errors[:base] << I18n.t('user.not_found')
20
- end
21
- end
22
-
23
- def self.expire
24
- Basket.will_expire(Time.zone.now.beginning_of_day).destroy_all
25
- logger.info "#{Time.zone.now} baskets expired!"
26
- end
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 checked_items.size == 0
36
- Item.transaction do
37
- self.checked_items.each do |checked_item|
38
- checkout = self.user.checkouts.new
39
- checkout.librarian = librarian
40
- checkout.item = checked_item.item
41
- checkout.basket = self
42
- checkout.due_date = checked_item.due_date
43
- checked_item.item.checkout!(user)
44
- checkout.save!
45
- end
46
- CheckedItem.destroy_all(:basket_id => id)
47
- end
48
- end
49
- end
50
- end
51
-
52
- # == Schema Information
53
- #
54
- # Table name: baskets
55
- #
56
- # id :integer not null, primary key
57
- # user_id :integer
58
- # note :text
59
- # lock_version :integer default(0), not null
60
- # created_at :datetime not null
61
- # updated_at :datetime not null
62
- #
63
-