enju_circulation 0.1.0.pre13 → 0.1.0.pre14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5845944eef1f0c2d1777fe6ba7df3fd6f2e377f9
4
- data.tar.gz: f5c62000d43b8ed38a57bbd1ecc09ef11248300b
3
+ metadata.gz: 0557b6769b99cbba61295d93b895895b29816c85
4
+ data.tar.gz: 5f3c123b482ec3fc8916e350740687383068831a
5
5
  SHA512:
6
- metadata.gz: 770526489dcf4b8292fe358f400edb66528c31851ece78572c00a05045bf8ca0d2b80eec80973f54898075aed3e19d8a074f752458a08361103ba67d27d68e14
7
- data.tar.gz: fd05f0a45c2b765b1c387dce82a4c6286ec4ba45beb0311da096e1c48d19b6cb7abbe13a6e68c11334e9a1342dce68a7a897506dbda8a26d90a23a565429c68f
6
+ metadata.gz: 797b70b0c4c3607f43d850121eaa7461da9a1a9b127142ee6807a152cf6bfdb1424b1a3fb3c68b1808532c3f7978c7561d01b7353ec0b4f26b14232efd5edce1
7
+ data.tar.gz: 77c12777e53cbb3505f4a16b58efdd2dc0bc9d30ea8bac8293dd622d3a9bd4b754f8712085380d72af7086d7603e06dbdfc469efa44a6a5d93bd79bfabba5bfd
@@ -0,0 +1,113 @@
1
+ module EnjuCirculation
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ def initialize(user, ip_address = nil)
6
+ case user.try(:role).try(:name)
7
+ when 'Administrator'
8
+ can :destroy, Manifestation do |manifestation|
9
+ manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
10
+ end
11
+ can :destroy, User do |u|
12
+ u.deletable? and u != user
13
+ end
14
+ can :manage, [
15
+ Basket,
16
+ CarrierTypeHasCheckoutType,
17
+ CheckedItem,
18
+ Checkin,
19
+ CheckoutStatHasManifestation,
20
+ CheckoutStatHasUser,
21
+ CheckoutType,
22
+ ItemHasUseRestriction,
23
+ ManifestationCheckoutStat,
24
+ ManifestationReserveStat,
25
+ Reserve,
26
+ ReserveStatHasManifestation,
27
+ ReserveStatHasUser,
28
+ UserCheckoutStat,
29
+ UserGroupHasCheckoutType,
30
+ UserReserveStat
31
+ ]
32
+ can [:read, :create, :update, :remove_all], Checkout
33
+ can :destroy, Checkout do |checkout|
34
+ checkout.checkin
35
+ end
36
+ can [:read, :update], [
37
+ CirculationStatus,
38
+ LendingPolicy,
39
+ UseRestriction
40
+ ]
41
+ can :destroy, LendingPolicy
42
+ when 'Librarian'
43
+ can :destroy, Item do |item|
44
+ item.checkouts.not_returned.empty?
45
+ end
46
+ can :destroy, Manifestation do |manifestation|
47
+ manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
48
+ end
49
+ can :destroy, User do |u|
50
+ u.deletable? and u.role.name == 'User' and u != user
51
+ end
52
+ can :manage, [
53
+ Basket,
54
+ CheckedItem,
55
+ Checkin,
56
+ ManifestationCheckoutStat,
57
+ ManifestationReserveStat,
58
+ Reserve
59
+ ]
60
+ can [:read, :create, :update, :remove_all], Checkout
61
+ can :destroy, Checkout do |checkout|
62
+ checkout.checkin
63
+ end
64
+ can [:read, :create, :update], UserCheckoutStat
65
+ can [:read, :create, :update], UserReserveStat
66
+ can :read, [
67
+ CarrierTypeHasCheckoutType,
68
+ CheckoutType,
69
+ CheckoutStatHasManifestation,
70
+ CheckoutStatHasUser,
71
+ CirculationStatus,
72
+ ItemHasUseRestriction,
73
+ LendingPolicy,
74
+ ReserveStatHasManifestation,
75
+ ReserveStatHasUser,
76
+ UseRestriction,
77
+ UserGroupHasCheckoutType
78
+ ]
79
+ when 'User'
80
+ can [:index, :create, :remove_all], Checkout
81
+ can [:show, :update], Checkout do |checkout|
82
+ checkout.user == user
83
+ end
84
+ can :destroy, Checkout do |checkout|
85
+ checkout.user == user && checkout.checkin
86
+ end
87
+ can :index, Reserve
88
+ can :create, Reserve do |reserve|
89
+ user.user_number.present?
90
+ end
91
+ can [:show, :update, :destroy], Reserve do |reserve|
92
+ reserve.user == user
93
+ end
94
+ can :read, [
95
+ CirculationStatus,
96
+ ManifestationCheckoutStat,
97
+ ManifestationReserveStat,
98
+ UserCheckoutStat,
99
+ UserReserveStat,
100
+ ]
101
+ else
102
+ can :index, Checkout
103
+ can :read, [
104
+ CirculationStatus,
105
+ ManifestationCheckoutStat,
106
+ ManifestationReserveStat,
107
+ UserCheckoutStat,
108
+ UserReserveStat
109
+ ]
110
+ end
111
+ end
112
+ end
113
+ end
@@ -9,8 +9,8 @@
9
9
  <%= t('page.search_term') -%>: <%= search_field_tag 'query', h(@query), {:id => 'search_form_top', :class => 'search_form', :placeholder => t('page.search_term')} -%>
10
10
  <br />
11
11
  <%= t('activerecord.attributes.reserve.created_at') %>:
12
- <%= t('reserve.reserved_from') %>: <%= text_field_tag 'reserved_from', @reserved_from, {:class => 'date_field', :placeholder => "#{t('page.example')}: 2012-04-12"} -%>
13
- <%= t('reserve.reserved_to') %>: <%= text_field_tag 'reserved_to', @reserved_to, {:class => 'date_field', :placeholder => "#{t('page.example')}: 2012-05-11"} -%>
12
+ <%= t('reserve.reserved_from') %> <%= text_field_tag 'reserved_from', @reserved_from, {:class => 'date_field', :placeholder => "#{t('page.example')}: 2012-04-12"} -%>
13
+ <%= t('reserve.reserved_to') %> <%= text_field_tag 'reserved_to', @reserved_to, {:class => 'date_field', :placeholder => "#{t('page.example')}: 2012-05-11"} -%>
14
14
  <%= submit_tag t('page.search') -%>
15
15
  </p>
16
16
  <%- end -%>
@@ -174,8 +174,8 @@ ja:
174
174
  expired: "期限切れ"
175
175
  postponed: "取置延期"
176
176
  completed: "貸出済み"
177
- reserved_from: "この日から"
178
- reserved_to: "この日まで"
177
+ reserved_from: ""
178
+ reserved_to: "から"
179
179
  attempt_to_update_retained_reservation: "取り置き済みの予約を変更しようとしています。"
180
180
  bibliographic_detail: "書誌詳細"
181
181
  page:
@@ -0,0 +1,25 @@
1
+ module EnjuCirculation
2
+ module ManifestationsHelper
3
+ def link_to_reservation(manifestation, reserve)
4
+ unless current_user
5
+ unless manifestation.items.for_checkout.empty?
6
+ link_to t('manifestation.reserve_this'), new_reserve_path(:manifestation_id => manifestation.id)
7
+ end
8
+ else
9
+ if current_user.has_role?('Librarian')
10
+ link_to t('manifestation.reserve_this'), new_reserve_path(:manifestation_id => manifestation.id)
11
+ else
12
+ if manifestation.is_checked_out_by?(current_user)
13
+ I18n.t('manifestation.currently_checked_out')
14
+ else
15
+ if manifestation.is_reserved_by?(current_user)
16
+ link_to t('manifestation.cancel_reservation'), reserve, :confirm => t('page.are_you_sure'), :method => :delete
17
+ else
18
+ link_to t('manifestation.reserve_this'), new_reserve_path(:manifestation_id => manifestation.id)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.1.0.pre13"
2
+ VERSION = "0.1.0.pre14"
3
3
  end
@@ -3,6 +3,7 @@ require "enju_circulation/manifestation"
3
3
  require "enju_circulation/item"
4
4
  require "enju_circulation/user"
5
5
  require "enju_circulation/controller"
6
+ require "enju_circulation/helper"
6
7
 
7
8
  module EnjuCirculation
8
9
  end
@@ -11,3 +12,4 @@ ActionController::Base.send :include, EnjuCirculation::Controller
11
12
  ActiveRecord::Base.send :include, EnjuCirculation::Manifestation
12
13
  ActiveRecord::Base.send :include, EnjuCirculation::Item
13
14
  ActiveRecord::Base.send :include, EnjuCirculation::User
15
+ ActionView::Base.send :include, EnjuCirculation::ManifestationsHelper
@@ -1,122 +1,116 @@
1
- class Ability
2
- include CanCan::Ability
3
-
4
- def initialize(user)
5
- case user.try(:role).try(:name)
6
- when 'Administrator'
7
- can :manage, [
8
- Basket,
9
- CarrierTypeHasCheckoutType,
10
- CheckedItem,
11
- Checkin,
12
- CheckoutStatHasManifestation,
13
- CheckoutStatHasUser,
14
- CheckoutType,
15
- ItemHasUseRestriction,
16
- ManifestationCheckoutStat,
17
- ManifestationReserveStat,
18
- Reserve,
19
- ReserveStatHasManifestation,
20
- ReserveStatHasUser,
21
- UserCheckoutStat,
22
- UserGroupHasCheckoutType,
23
- UserReserveStat
24
- ]
25
- can [:read, :create, :update, :remove_all], Checkout
26
- can :destroy, Checkout do |checkout|
27
- checkout.checkin
1
+ #module EnjuCirculation
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ def initialize(user, ip_address = nil)
6
+ case user.try(:role).try(:name)
7
+ when 'Administrator'
8
+ can :destroy, Manifestation do |manifestation|
9
+ manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
10
+ end
11
+ can :destroy, User do |u|
12
+ u.deletable? and u != user
13
+ end
14
+ can :manage, [
15
+ Basket,
16
+ CarrierTypeHasCheckoutType,
17
+ CheckedItem,
18
+ Checkin,
19
+ CheckoutStatHasManifestation,
20
+ CheckoutStatHasUser,
21
+ CheckoutType,
22
+ ItemHasUseRestriction,
23
+ ManifestationCheckoutStat,
24
+ ManifestationReserveStat,
25
+ Reserve,
26
+ ReserveStatHasManifestation,
27
+ ReserveStatHasUser,
28
+ UserCheckoutStat,
29
+ UserGroupHasCheckoutType,
30
+ UserReserveStat
31
+ ]
32
+ can [:read, :create, :update, :remove_all], Checkout
33
+ can :destroy, Checkout do |checkout|
34
+ checkout.checkin
35
+ end
36
+ can [:read, :update], [
37
+ CirculationStatus,
38
+ LendingPolicy,
39
+ UseRestriction
40
+ ]
41
+ can :destroy, LendingPolicy
42
+ can :read, [Item, Manifestation]
43
+ when 'Librarian'
44
+ can :destroy, Item do |item|
45
+ item.checkouts.not_returned.empty?
46
+ end
47
+ can :destroy, Manifestation do |manifestation|
48
+ manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
49
+ end
50
+ can :destroy, User do |u|
51
+ u.deletable? and u.role.name == 'User' and u != user
52
+ end
53
+ can :manage, [
54
+ Basket,
55
+ CheckedItem,
56
+ Checkin,
57
+ ManifestationCheckoutStat,
58
+ ManifestationReserveStat,
59
+ Reserve
60
+ ]
61
+ can [:read, :create, :update, :remove_all], Checkout
62
+ can :destroy, Checkout do |checkout|
63
+ checkout.checkin
64
+ end
65
+ can [:read, :create, :update], UserCheckoutStat
66
+ can [:read, :create, :update], UserReserveStat
67
+ can :read, [
68
+ CarrierTypeHasCheckoutType,
69
+ CheckoutType,
70
+ CheckoutStatHasManifestation,
71
+ CheckoutStatHasUser,
72
+ CirculationStatus,
73
+ ItemHasUseRestriction,
74
+ LendingPolicy,
75
+ ReserveStatHasManifestation,
76
+ ReserveStatHasUser,
77
+ UseRestriction,
78
+ UserGroupHasCheckoutType
79
+ ]
80
+ can :read, [Item, Manifestation]
81
+ when 'User'
82
+ can [:index, :create, :remove_all], Checkout
83
+ can [:show, :update], Checkout do |checkout|
84
+ checkout.user == user
85
+ end
86
+ can :destroy, Checkout do |checkout|
87
+ checkout.user == user && checkout.checkin
88
+ end
89
+ can :index, Reserve
90
+ can :create, Reserve do |reserve|
91
+ user.user_number.present?
92
+ end
93
+ can [:show, :update, :destroy], Reserve do |reserve|
94
+ reserve.user == user
95
+ end
96
+ can :read, [
97
+ CirculationStatus,
98
+ ManifestationCheckoutStat,
99
+ ManifestationReserveStat,
100
+ UserCheckoutStat,
101
+ UserReserveStat,
102
+ ]
103
+ can :read, [Item, Manifestation]
104
+ else
105
+ can :index, Checkout
106
+ can :read, [
107
+ CirculationStatus,
108
+ ManifestationCheckoutStat,
109
+ ManifestationReserveStat,
110
+ UserCheckoutStat,
111
+ UserReserveStat
112
+ ]
28
113
  end
29
- can [:read, :update], [
30
- CirculationStatus,
31
- LendingPolicy,
32
- UseRestriction
33
- ]
34
- can :destroy, LendingPolicy
35
- can [:read, :create, :update], Item
36
- can :destroy, Item do |item|
37
- item.deletable?
38
- end
39
- can [:read, :create, :update], Manifestation
40
- can :destroy, Manifestation do |manifestation|
41
- manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
42
- end
43
- when 'Librarian'
44
- can :manage, [
45
- Basket,
46
- CheckedItem,
47
- Checkin,
48
- ManifestationCheckoutStat,
49
- ManifestationReserveStat,
50
- Reserve
51
- ]
52
- can [:read, :create, :update, :remove_all], Checkout
53
- can :destroy, Checkout do |checkout|
54
- checkout.checkin
55
- end
56
- can [:read, :create, :update], UserCheckoutStat
57
- can [:read, :create, :update], UserReserveStat
58
- can :read, [
59
- CarrierTypeHasCheckoutType,
60
- CheckoutType,
61
- CheckoutStatHasManifestation,
62
- CheckoutStatHasUser,
63
- CirculationStatus,
64
- ItemHasUseRestriction,
65
- LendingPolicy,
66
- ReserveStatHasManifestation,
67
- ReserveStatHasUser,
68
- UseRestriction,
69
- UserGroupHasCheckoutType
70
- ]
71
- can [:read, :create, :update], Item
72
- can :destroy, Item do |item|
73
- item.checkouts.not_returned.empty?
74
- end
75
- can [:read, :create, :update], Manifestation
76
- can :destroy, Manifestation do |manifestation|
77
- manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
78
- end
79
- when 'User'
80
- can [:index, :create, :remove_all], Checkout
81
- can [:show, :update], Checkout do |checkout|
82
- checkout.user == user
83
- end
84
- can :destroy, Checkout do |checkout|
85
- checkout.user == user && checkout.checkin
86
- end
87
- can :index, Reserve
88
- can :create, Reserve do |reserve|
89
- user.user_number.present?
90
- end
91
- can [:show, :update, :destroy], Reserve do |reserve|
92
- reserve.user == user
93
- end
94
- can :read, [
95
- CirculationStatus,
96
- ManifestationCheckoutStat,
97
- ManifestationReserveStat,
98
- UserCheckoutStat,
99
- UserReserveStat,
100
- ]
101
- can :index, Item
102
- can :show, Item do |item|
103
- item.required_role_id <= 2
104
- end
105
- can :read, Manifestation do |manifestation|
106
- manifestation.required_role_id <= 2
107
- end
108
- can :edit, Manifestation
109
- else
110
- can :index, Checkout
111
- can :read, [
112
- CirculationStatus,
113
- ManifestationCheckoutStat,
114
- ManifestationReserveStat,
115
- UserCheckoutStat,
116
- UserReserveStat
117
- ]
118
- can :read, Item
119
- can :read, Manifestation
120
114
  end
121
115
  end
122
- end
116
+ #end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_circulation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre13
4
+ version: 0.1.0.pre14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kosuke Tanabe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-06 00:00:00.000000000 Z
11
+ date: 2013-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -271,6 +271,7 @@ files:
271
271
  - app/models/checkout_type.rb
272
272
  - app/models/circulation_status.rb
273
273
  - app/models/circulation_sweeper.rb
274
+ - app/models/enju_circulation/ability.rb
274
275
  - app/models/item_has_use_restriction.rb
275
276
  - app/models/lending_policy.rb
276
277
  - app/models/manifestation_checkout_stat.rb
@@ -451,6 +452,7 @@ files:
451
452
  - db/migrate/20130304015019_add_postponed_at_to_reserve.rb
452
453
  - lib/enju_circulation/controller.rb
453
454
  - lib/enju_circulation/engine.rb
455
+ - lib/enju_circulation/helper.rb
454
456
  - lib/enju_circulation/item.rb
455
457
  - lib/enju_circulation/manifestation.rb
456
458
  - lib/enju_circulation/user.rb
@@ -610,16 +612,16 @@ files:
610
612
  - spec/dummy/solr/conf/spellings.txt
611
613
  - spec/dummy/solr/conf/stopwords.txt
612
614
  - spec/dummy/solr/conf/synonyms.txt
613
- - spec/dummy/solr/data/test/index/_lj.fdt
614
- - spec/dummy/solr/data/test/index/_lj.fdx
615
- - spec/dummy/solr/data/test/index/_lj.fnm
616
- - spec/dummy/solr/data/test/index/_lj.frq
617
- - spec/dummy/solr/data/test/index/_lj.nrm
618
- - spec/dummy/solr/data/test/index/_lj.prx
619
- - spec/dummy/solr/data/test/index/_lj.tii
620
- - spec/dummy/solr/data/test/index/_lj.tis
615
+ - spec/dummy/solr/data/test/index/_ub.fdt
616
+ - spec/dummy/solr/data/test/index/_ub.fdx
617
+ - spec/dummy/solr/data/test/index/_ub.fnm
618
+ - spec/dummy/solr/data/test/index/_ub.frq
619
+ - spec/dummy/solr/data/test/index/_ub.nrm
620
+ - spec/dummy/solr/data/test/index/_ub.prx
621
+ - spec/dummy/solr/data/test/index/_ub.tii
622
+ - spec/dummy/solr/data/test/index/_ub.tis
621
623
  - spec/dummy/solr/data/test/index/segments.gen
622
- - spec/dummy/solr/data/test/index/segments_175
624
+ - spec/dummy/solr/data/test/index/segments_1op
623
625
  - spec/dummy/solr/data/test/spellchecker/segments.gen
624
626
  - spec/dummy/solr/data/test/spellchecker/segments_1
625
627
  - spec/factories/basket.rb
@@ -883,16 +885,16 @@ test_files:
883
885
  - spec/dummy/solr/conf/spellings.txt
884
886
  - spec/dummy/solr/conf/stopwords.txt
885
887
  - spec/dummy/solr/conf/synonyms.txt
886
- - spec/dummy/solr/data/test/index/_lj.fdt
887
- - spec/dummy/solr/data/test/index/_lj.fdx
888
- - spec/dummy/solr/data/test/index/_lj.fnm
889
- - spec/dummy/solr/data/test/index/_lj.frq
890
- - spec/dummy/solr/data/test/index/_lj.nrm
891
- - spec/dummy/solr/data/test/index/_lj.prx
892
- - spec/dummy/solr/data/test/index/_lj.tii
893
- - spec/dummy/solr/data/test/index/_lj.tis
888
+ - spec/dummy/solr/data/test/index/_ub.fdt
889
+ - spec/dummy/solr/data/test/index/_ub.fdx
890
+ - spec/dummy/solr/data/test/index/_ub.fnm
891
+ - spec/dummy/solr/data/test/index/_ub.frq
892
+ - spec/dummy/solr/data/test/index/_ub.nrm
893
+ - spec/dummy/solr/data/test/index/_ub.prx
894
+ - spec/dummy/solr/data/test/index/_ub.tii
895
+ - spec/dummy/solr/data/test/index/_ub.tis
894
896
  - spec/dummy/solr/data/test/index/segments.gen
895
- - spec/dummy/solr/data/test/index/segments_175
897
+ - spec/dummy/solr/data/test/index/segments_1op
896
898
  - spec/dummy/solr/data/test/spellchecker/segments.gen
897
899
  - spec/dummy/solr/data/test/spellchecker/segments_1
898
900
  - spec/factories/basket.rb