enju_biblio 0.1.0.pre22 → 0.1.0.pre23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/items_controller.rb +1 -1
  3. data/app/controllers/manifestations_controller.rb +3 -0
  4. data/app/helpers/manifestations_helper.rb +2 -24
  5. data/app/models/enju_biblio/ability.rb +203 -0
  6. data/app/models/item.rb +5 -62
  7. data/app/models/manifestation.rb +2 -47
  8. data/lib/enju_biblio/version.rb +1 -1
  9. data/spec/dummy/app/controllers/application_controller.rb +0 -4
  10. data/spec/dummy/app/models/ability.rb +192 -176
  11. data/spec/dummy/app/models/user.rb +2 -15
  12. data/spec/dummy/db/test.sqlite3 +0 -0
  13. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  14. data/spec/dummy/solr/data/test/index/segments_36o +0 -0
  15. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  16. data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
  17. metadata +15 -64
  18. data/spec/dummy/solr/data/test/index/_tu.fdt +0 -0
  19. data/spec/dummy/solr/data/test/index/_tu.fdx +0 -0
  20. data/spec/dummy/solr/data/test/index/_tu.fnm +0 -7
  21. data/spec/dummy/solr/data/test/index/_tu.frq +0 -0
  22. data/spec/dummy/solr/data/test/index/_tu.nrm +0 -1
  23. data/spec/dummy/solr/data/test/index/_tu.prx +0 -0
  24. data/spec/dummy/solr/data/test/index/_tu.tii +0 -0
  25. data/spec/dummy/solr/data/test/index/_tu.tis +0 -0
  26. data/spec/dummy/solr/data/test/index/_tv.fdt +0 -0
  27. data/spec/dummy/solr/data/test/index/_tv.fdx +0 -0
  28. data/spec/dummy/solr/data/test/index/_tv.fnm +0 -7
  29. data/spec/dummy/solr/data/test/index/_tv.frq +0 -0
  30. data/spec/dummy/solr/data/test/index/_tv.nrm +0 -1
  31. data/spec/dummy/solr/data/test/index/_tv.prx +0 -0
  32. data/spec/dummy/solr/data/test/index/_tv.tii +0 -0
  33. data/spec/dummy/solr/data/test/index/_tv.tis +0 -0
  34. data/spec/dummy/solr/data/test/index/_tw.fdt +0 -0
  35. data/spec/dummy/solr/data/test/index/_tw.fdx +0 -0
  36. data/spec/dummy/solr/data/test/index/_tw.fnm +0 -8
  37. data/spec/dummy/solr/data/test/index/_tw.frq +0 -0
  38. data/spec/dummy/solr/data/test/index/_tw.nrm +0 -1
  39. data/spec/dummy/solr/data/test/index/_tw.prx +0 -0
  40. data/spec/dummy/solr/data/test/index/_tw.tii +0 -0
  41. data/spec/dummy/solr/data/test/index/_tw.tis +0 -0
  42. data/spec/dummy/solr/data/test/index/segments_16t +0 -0
  43. data/spec/dummy/tmp/cache/ACB/B20/manifestation_search_total +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 110e82e3513e0759085b4be6f4fc13103261b7b1
4
- data.tar.gz: 0985130ae8accad84425cc3c6fdf8ba0d9963132
3
+ metadata.gz: 851b384f2c1744c595dfcbb4fd82bb8cd4d00576
4
+ data.tar.gz: 6bb9b6d4286ebff9e25fcd3afde173539ee3f713
5
5
  SHA512:
6
- metadata.gz: ad635f15df3b55e5d794a04bdcf0fa8be3850342b4ef2a2ef6f066d07d5701563ae400af212468c0c574d7eefa968bff8345c357c8da3926cb217c6d82c4a47f
7
- data.tar.gz: c83a06a6418f21538a2626e354ff6a3da19fa4173e3172371db74cdeaa50f779f2cec9c82e1ec4ef88129b75917fbe57f71228cece0dd7034e0591b4c8c55c83
6
+ metadata.gz: 4b6158f5e071dae93770850c337a636a6afdd32bcdc1104ce3fefc1c99cc98824ba6947e98ae6b4c3dc754dbf57b8073caa6b7f735a59bf2faab61f2fde29162
7
+ data.tar.gz: 52d1c943f40c811ad864a93981066d737e325f2cdd5576210aefa8e33102a2ed13f057451fba42f177ed0752119275909e038becbc436be01578dab1419a5567
@@ -133,7 +133,7 @@ class ItemsController < ApplicationController
133
133
  end
134
134
  @item = Item.new
135
135
  @item.shelf = @library.shelves.first
136
- @item.manifestation_id = @manifestation.id if @manifestation
136
+ @item.manifestation_id = @manifestation.id
137
137
  if defined?(EnjuCirculation)
138
138
  @circulation_statuses = CirculationStatus.where(
139
139
  :name => [
@@ -454,6 +454,9 @@ class ManifestationsController < ApplicationController
454
454
  end
455
455
  @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
456
456
  @series_statement = @manifestation.series_statement unless @series_statement
457
+ if defined?(EnjuSubject)
458
+ @classification_types = ClassificationType.select(:display_name)
459
+ end
457
460
  if defined?(EnjuBookmark)
458
461
  if params[:mode] == 'tag_edit'
459
462
  @bookmark = current_user.bookmarks.where(:manifestation_id => @manifestation.id).first if @manifestation rescue nil
@@ -1,4 +1,6 @@
1
1
  module ManifestationsHelper
2
+ include EnjuCirculation::ManifestationsHelper if defined?(EnjuCirculation)
3
+
2
4
  def resource_title(manifestation, action)
3
5
  string = LibraryGroup.site_config.display_name.localize.dup
4
6
  unless action == ('index' or 'new')
@@ -145,28 +147,4 @@ module ManifestationsHelper
145
147
  end
146
148
  end
147
149
  end
148
-
149
- if defined?(EnjuCirculation)
150
- def link_to_reservation(manifestation, reserve)
151
- unless current_user
152
- unless manifestation.items.for_checkout.empty?
153
- link_to t('manifestation.reserve_this'), new_reserve_path(:manifestation_id => manifestation.id)
154
- end
155
- else
156
- if current_user.has_role?('Librarian')
157
- link_to t('manifestation.reserve_this'), new_reserve_path(:manifestation_id => manifestation.id)
158
- else
159
- if manifestation.is_checked_out_by?(current_user)
160
- I18n.t('manifestation.currently_checked_out')
161
- else
162
- if manifestation.is_reserved_by?(current_user)
163
- link_to t('manifestation.cancel_reservation'), reserve, :confirm => t('page.are_you_sure'), :method => :delete
164
- else
165
- link_to t('manifestation.reserve_this'), new_reserve_path(:manifestation_id => manifestation.id)
166
- end
167
- end
168
- end
169
- end
170
- end
171
- end
172
150
  end
@@ -0,0 +1,203 @@
1
+ module EnjuBiblio
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 [:read, :create, :update], CarrierType
9
+ can :destroy, CarrierType do |carrier_type|
10
+ true unless carrier_type.manifestations.exists?
11
+ end if LibraryGroup.site_config.network_access_allowed?(ip_address)
12
+ can [:read, :create, :update], Item
13
+ can :destroy, Item do |item|
14
+ item.deletable?
15
+ end
16
+ can [:read, :create, :update], Manifestation
17
+ can :destroy, Manifestation do |manifestation|
18
+ manifestation.items.empty? and !manifestation.periodical_master?
19
+ end
20
+ can :manage, [
21
+ Create,
22
+ CreateType,
23
+ Donate,
24
+ Exemplify,
25
+ ImportRequest,
26
+ ManifestationRelationship,
27
+ ManifestationRelationshipType,
28
+ Own,
29
+ Patron,
30
+ PatronImportFile,
31
+ PatronRelationship,
32
+ PatronRelationshipType,
33
+ PictureFile,
34
+ Produce,
35
+ ProduceType,
36
+ Realize,
37
+ RealizeType,
38
+ ResourceImportFile,
39
+ SeriesStatement,
40
+ SeriesStatementRelationship,
41
+ SeriesHasManifestation
42
+ ]
43
+ can :update, [
44
+ CarrierType,
45
+ ContentType,
46
+ Country,
47
+ Extent,
48
+ Frequency,
49
+ FormOfWork,
50
+ Language,
51
+ License,
52
+ MediumOfPerformance,
53
+ PatronType,
54
+ RequestStatusType,
55
+ RequestType
56
+ ] if LibraryGroup.site_config.network_access_allowed?(ip_address)
57
+ can :read, [
58
+ CarrierType,
59
+ ContentType,
60
+ Country,
61
+ Extent,
62
+ Frequency,
63
+ FormOfWork,
64
+ Language,
65
+ License,
66
+ MediumOfPerformance,
67
+ PatronImportResult,
68
+ PatronType,
69
+ RequestStatusType,
70
+ RequestType,
71
+ ResourceImportResult
72
+ ]
73
+ when 'Librarian'
74
+ can :manage, Item
75
+ can [:read, :create, :update], Manifestation
76
+ can :destroy, Manifestation do |manifestation|
77
+ manifestation.items.empty? and !manifestation.periodical_master?
78
+ end
79
+ can [:index, :create], Patron
80
+ can :show, Patron do |patron|
81
+ patron.required_role_id <= 3
82
+ end
83
+ can [:update, :destroy], Patron do |patron|
84
+ !patron.user.try(:has_role?, 'Librarian') and patron.required_role_id <= 3
85
+ end
86
+ can :manage, [
87
+ Create,
88
+ Donate,
89
+ Exemplify,
90
+ ImportRequest,
91
+ ManifestationRelationship,
92
+ Own,
93
+ PatronImportFile,
94
+ PatronRelationship,
95
+ PictureFile,
96
+ Produce,
97
+ Realize,
98
+ ResourceImportFile,
99
+ SeriesStatement,
100
+ SeriesStatementRelationship,
101
+ SeriesHasManifestation
102
+ ]
103
+ can :read, [
104
+ CarrierType,
105
+ ContentType,
106
+ Country,
107
+ Extent,
108
+ Frequency,
109
+ FormOfWork,
110
+ Language,
111
+ License,
112
+ ManifestationRelationshipType,
113
+ PatronImportResult,
114
+ PatronRelationshipType,
115
+ PatronType,
116
+ RequestStatusType,
117
+ RequestType,
118
+ ResourceImportResult,
119
+ MediumOfPerformance
120
+ ]
121
+ when 'User'
122
+ can :index, Item
123
+ can :show, Item do |item|
124
+ item.required_role_id <= 2
125
+ end
126
+ can [:read, :edit], Manifestation do |manifestation|
127
+ manifestation.required_role_id <= 2
128
+ end
129
+ can :index, Patron
130
+ can :update, Patron do |patron|
131
+ patron.user == user
132
+ end
133
+ can :show, Patron do |patron|
134
+ #if patron.user == user
135
+ # true
136
+ #elsif patron.user != user
137
+ true if patron.required_role_id <= 2 #name == 'Administrator'
138
+ #end
139
+ end
140
+ can :index, PictureFile
141
+ can :show, PictureFile do |picture_file|
142
+ begin
143
+ true if picture_file.picture_attachable.required_role_id <= 2
144
+ rescue NoMethodError
145
+ true
146
+ end
147
+ end
148
+ can :read, [
149
+ CarrierType,
150
+ ContentType,
151
+ Country,
152
+ Create,
153
+ Exemplify,
154
+ Extent,
155
+ Frequency,
156
+ FormOfWork,
157
+ Language,
158
+ License,
159
+ ManifestationRelationship,
160
+ ManifestationRelationshipType,
161
+ MediumOfPerformance,
162
+ Own,
163
+ PatronRelationship,
164
+ PatronRelationshipType,
165
+ Produce,
166
+ Realize,
167
+ SeriesStatement,
168
+ SeriesHasManifestation
169
+ ]
170
+ else
171
+ can :index, Patron
172
+ can :show, Patron do |patron|
173
+ patron.required_role_id == 1 #name == 'Guest'
174
+ end
175
+ can :read, [
176
+ CarrierType,
177
+ ContentType,
178
+ Country,
179
+ Create,
180
+ Exemplify,
181
+ Extent,
182
+ Frequency,
183
+ FormOfWork,
184
+ Item,
185
+ Language,
186
+ License,
187
+ Manifestation,
188
+ ManifestationRelationship,
189
+ ManifestationRelationshipType,
190
+ MediumOfPerformance,
191
+ Own,
192
+ PatronRelationship,
193
+ PatronRelationshipType,
194
+ PictureFile,
195
+ Produce,
196
+ Realize,
197
+ SeriesStatement,
198
+ SeriesHasManifestation
199
+ ]
200
+ end
201
+ end
202
+ end
203
+ end
data/app/models/item.rb CHANGED
@@ -30,8 +30,6 @@ class Item < ActiveRecord::Base
30
30
  has_paper_trail
31
31
  normalize_attributes :item_identifier
32
32
 
33
- #enju_export
34
-
35
33
  searchable do
36
34
  text :item_identifier, :note, :title, :creator, :contributor, :publisher
37
35
  string :item_identifier
@@ -46,42 +44,14 @@ class Item < ActiveRecord::Base
46
44
  end
47
45
 
48
46
  enju_circulation_item_model if defined?(EnjuCirculation)
47
+ enju_library_item_model if defined?(EnjuLibrary)
48
+ enju_question_item_model if defined?(EnjuQuestion)
49
+ enju_inventory_item_model if defined?(EnjuInventory)
50
+ enju_inter_library_loan_item_model if defined?(EnjuInterLibraryLoan)
51
+ #enju_export
49
52
 
50
53
  attr_accessor :library_id, :manifestation_id
51
54
 
52
- if defined?(EnjuInventory)
53
- has_many :inventories, :dependent => :destroy
54
- has_many :inventory_files, :through => :inventories
55
- searchable do
56
- integer :inventory_file_ids, :multiple => true
57
- end
58
-
59
- def self.inventory_items(inventory_file, mode = 'not_on_shelf')
60
- item_ids = Item.pluck(:id)
61
- inventory_item_ids = inventory_file.items.pluck('items.id')
62
- case mode
63
- when 'not_on_shelf'
64
- Item.where(:id => (item_ids - inventory_item_ids))
65
- when 'not_in_catalog'
66
- Item.where(:id => (inventory_item_ids - item_ids))
67
- end
68
- rescue
69
- nil
70
- end
71
- end
72
-
73
- if defined?(EnjuQuestion)
74
- has_many :answer_has_items, :dependent => :destroy
75
- has_many :answers, :through => :answer_has_items
76
- end
77
-
78
- if defined?(EnjuInterLibraryLoan)
79
- has_many :inter_library_loans, :dependent => :destroy
80
- def inter_library_loaned?
81
- true if self.inter_library_loans.size > 0
82
- end
83
- end
84
-
85
55
  paginates_per 10
86
56
 
87
57
  def title
@@ -125,33 +95,6 @@ class Item < ActiveRecord::Base
125
95
  self.manifestation = Manifestation.find(manifestation_id)
126
96
  end
127
97
  end
128
-
129
- if defined?(EnjuLibrary)
130
- has_one :accept
131
- scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)}
132
-
133
- belongs_to :shelf, :counter_cache => true, :validate => true
134
- validates_associated :shelf
135
-
136
- searchable do
137
- string :library do
138
- shelf.library.name if shelf
139
- end
140
- end
141
-
142
- def shelf_name
143
- shelf.name
144
- end
145
-
146
- def hold?(library)
147
- return true if self.shelf.library == library
148
- false
149
- end
150
-
151
- def library_url
152
- "#{LibraryGroup.site_config.url}libraries/#{self.shelf.library.name}"
153
- end
154
- end
155
98
  end
156
99
 
157
100
  # == Schema Information
@@ -193,6 +193,8 @@ class Manifestation < ActiveRecord::Base
193
193
  #enju_amazon
194
194
  enju_oai if defined?(EnjuOai)
195
195
  enju_nii_cinii_books if defined?(EnjuNii)
196
+ enju_question_manifestation_model if defined?(EnjuQuestion)
197
+ enju_bookmark_manifestation_model if defined?(EnjuBookmark)
196
198
  #enju_export
197
199
 
198
200
  has_paper_trail
@@ -467,53 +469,6 @@ class Manifestation < ActiveRecord::Base
467
469
  items.where(:shelf_id => Shelf.web.id).first
468
470
  end
469
471
 
470
- if defined?(EnjuBookmark)
471
- has_many :bookmarks, :include => :tags, :dependent => :destroy, :foreign_key => :manifestation_id
472
- has_many :users, :through => :bookmarks
473
-
474
- searchable do
475
- string :tag, :multiple => true do
476
- tags.collect(&:name)
477
- end
478
- text :tag do
479
- tags.collect(&:name)
480
- end
481
- end
482
-
483
- def bookmarked?(user)
484
- return true if user.bookmarks.where(:url => url).first
485
- false
486
- end
487
-
488
- def tags
489
- if self.bookmarks.first
490
- self.bookmarks.tag_counts
491
- else
492
- []
493
- end
494
- end
495
- end
496
-
497
- if defined?(EnjuQuestion)
498
- def questions(options = {})
499
- id = self.id
500
- options = {:page => 1, :per_page => Question.default_per_page}.merge(options)
501
- page = options[:page]
502
- per_page = options[:per_page]
503
- user = options[:user]
504
- Question.search do
505
- with(:manifestation_id).equal_to id
506
- any_of do
507
- unless user.try(:has_role?, 'Librarian')
508
- with(:shared).equal_to true
509
- # with(:username).equal_to user.try(:username)
510
- end
511
- end
512
- paginate :page => page, :per_page => per_page
513
- end.results
514
- end
515
- end
516
-
517
472
  def set_patron_role_type(patron_lists, options = {:scope => :creator})
518
473
  patron_lists.each do |patron_list|
519
474
  name_and_role = patron_list[:full_name].split('||')
@@ -1,3 +1,3 @@
1
1
  module EnjuBiblio
2
- VERSION = "0.1.0.pre22"
2
+ VERSION = "0.1.0.pre23"
3
3
  end
@@ -53,10 +53,6 @@ class ApplicationController < ActionController::Base
53
53
  Sunspot.commit
54
54
  end
55
55
 
56
- def current_ability
57
- @current_ability ||= Ability.new(current_user, request.remote_ip)
58
- end
59
-
60
56
  def move_position(resource, direction, redirect = true)
61
57
  if ['higher', 'lower'].include?(direction)
62
58
  resource.send("move_#{direction}")
@@ -1,186 +1,202 @@
1
- class Ability
2
- include CanCan::Ability
1
+ #module EnjuBiblio
2
+ class Ability
3
+ include CanCan::Ability
3
4
 
4
- def initialize(user, ip_addess = nil)
5
- case user.try(:role).try(:name)
6
- when 'Administrator'
7
- can [:read, :update], ContentType
8
- can [:read, :update], Country
9
- can :manage, Create
10
- can :manage, CreateType
11
- can :manage, Donate
12
- can :manage, Exemplify
13
- can [:read, :update], Extent
14
- can [:read, :update], Frequency
15
- can [:read, :update], FormOfWork
16
- can [:read, :create, :update], Item
17
- can :destroy, Item do |item|
18
- item.deletable?
19
- end
20
- can :manage, ImportRequest
21
- can [:read, :update], Language
22
- can [:read, :update], License
23
- can [:read, :create, :update], Manifestation
24
- can :destroy, Manifestation do |manifestation|
25
- if defined?(EnjuCirculation)
26
- manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
27
- else
28
- manifestation.items.empty? and !manifestation.periodical_master?
5
+ def initialize(user, ip_address = '0.0.0.0')
6
+ case user.try(:role).try(:name)
7
+ when 'Administrator'
8
+ can [:read, :create, :update], CarrierType
9
+ can :destroy, CarrierType do |carrier_type|
10
+ true unless carrier_type.manifestations.exists?
11
+ end if LibraryGroup.site_config.network_access_allowed?(ip_address)
12
+ can [:read, :create, :update], Item
13
+ can :destroy, Item do |item|
14
+ item.deletable?
29
15
  end
30
- end
31
- can [:read, :update], MediumOfPerformance
32
- can :manage, Own
33
- can [:read, :create, :update], Patron
34
- can :destroy, Patron do |patron|
35
- true
36
- end
37
- can :manage, CarrierType
38
- can :manage, PatronImportFile
39
- can :read, PatronImportResult
40
- can :manage, PatronRelationship
41
- can :manage, PatronRelationshipType
42
- can [:read, :update], PatronType
43
- can :manage, PictureFile
44
- can :manage, Produce
45
- can :manage, ProduceType
46
- can :manage, ManifestationRelationship
47
- can :manage, ManifestationRelationshipType
48
- can :manage, Realize
49
- can :manage, RealizeType
50
- can :manage, ResourceImportFile
51
- can :read, ResourceImportResult
52
- can :manage, SeriesHasManifestation
53
- can :manage, SeriesStatement
54
- can :manage, SeriesStatementRelationship
55
- when 'Librarian'
56
- can [:read, :update], CarrierType
57
- can :read, ContentType
58
- can :read, Country
59
- can :manage, Create
60
- can :manage, Donate
61
- can :manage, Exemplify
62
- can :read, Extent
63
- can :read, Frequency
64
- can :read, FormOfWork
65
- can :manage, ImportRequest
66
- can [:read, :create, :update], Item
67
- can :destroy, Item do |item|
68
- if defined?(EnjuCirculation)
69
- item.checkouts.not_returned.empty?
70
- else
71
- true
16
+ can [:read, :create, :update], Manifestation
17
+ can :destroy, Manifestation do |manifestation|
18
+ manifestation.items.empty? and !manifestation.periodical_master?
72
19
  end
73
- end
74
- can :read, Language
75
- can :read, License
76
- can [:read, :create, :update], Manifestation
77
- can :destroy, Manifestation do |manifestation|
78
- if defined?(EnjuCirculation)
79
- manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
80
- else
20
+ can :manage, [
21
+ Create,
22
+ CreateType,
23
+ Donate,
24
+ Exemplify,
25
+ ImportRequest,
26
+ ManifestationRelationship,
27
+ ManifestationRelationshipType,
28
+ Own,
29
+ Patron,
30
+ PatronImportFile,
31
+ PatronRelationship,
32
+ PatronRelationshipType,
33
+ PictureFile,
34
+ Produce,
35
+ ProduceType,
36
+ Realize,
37
+ RealizeType,
38
+ ResourceImportFile,
39
+ SeriesStatement,
40
+ SeriesStatementRelationship,
41
+ SeriesHasManifestation
42
+ ]
43
+ can :update, [
44
+ ContentType,
45
+ Country,
46
+ Extent,
47
+ Frequency,
48
+ FormOfWork,
49
+ Language,
50
+ License,
51
+ MediumOfPerformance,
52
+ PatronType,
53
+ RequestStatusType,
54
+ RequestType
55
+ ] if LibraryGroup.site_config.network_access_allowed?(ip_address)
56
+ can :read, [
57
+ CarrierType,
58
+ ContentType,
59
+ Country,
60
+ Extent,
61
+ Frequency,
62
+ FormOfWork,
63
+ Language,
64
+ License,
65
+ MediumOfPerformance,
66
+ PatronImportResult,
67
+ PatronType,
68
+ RequestStatusType,
69
+ RequestType,
70
+ ResourceImportResult
71
+ ]
72
+ when 'Librarian'
73
+ can :manage, Item
74
+ can [:read, :create, :update], Manifestation
75
+ can :destroy, Manifestation do |manifestation|
81
76
  manifestation.items.empty? and !manifestation.periodical_master?
82
77
  end
83
- end
84
- can :read, MediumOfPerformance
85
- can :manage, Own
86
- can [:index, :create], Patron
87
- can [:show, :update, :destroy], Patron do |patron|
88
- patron.required_role_id <= 3
89
- end
90
- can :manage, PatronImportFile
91
- can :read, PatronImportResult
92
- can :manage, PatronRelationship
93
- can :read, PatronRelationshipType
94
- can :read, PatronType
95
- can :manage, PictureFile
96
- can :manage, Produce
97
- can :manage, ManifestationRelationship
98
- can :read, ManifestationRelationshipType
99
- can :manage, Realize
100
- can :manage, ResourceImportFile
101
- can :read, ResourceImportResult
102
- can :manage, SeriesHasManifestation
103
- can :manage, SeriesStatement
104
- can :manage, SeriesStatementRelationship
105
- when 'User'
106
- can :read, CarrierType
107
- can :read, ContentType
108
- can :read, Country
109
- can :read, Create
110
- can :read, Exemplify
111
- can :read, Extent
112
- can :read, Frequency
113
- can :read, FormOfWork
114
- can :index, Item
115
- can :show, Item do |item|
116
- item.required_role_id <= 2
117
- end
118
- can :read, Language
119
- can :read, License
120
- can [:read, :edit], Manifestation do |manifestation|
121
- manifestation.required_role_id <= 2
122
- end
123
- can :read, ManifestationRelationship
124
- can :read, ManifestationRelationshipType
125
- can :read, MediumOfPerformance
126
- can :read, Own
127
- can :index, Patron
128
- can :show, Patron do |patron|
129
- true if patron.required_role_id <= 2
130
- end
131
- can :read, PatronRelationship
132
- can :read, PatronRelationshipType
133
- can :index, PictureFile
134
- can :show, PictureFile do |picture_file|
135
- begin
136
- true if picture_file.picture_attachable.required_role_id <= 2
137
- rescue NoMethodError
138
- true
78
+ can [:index, :create], Patron
79
+ can :show, Patron do |patron|
80
+ patron.required_role_id <= 3
139
81
  end
140
- end
141
- can :show, User
142
- can :read, Produce
143
- can :read, Realize
144
- can :read, SeriesHasManifestation
145
- can :read, SeriesStatement
146
- else
147
- can :read, CarrierType
148
- can :read, ContentType
149
- can :read, Country
150
- can :read, Create
151
- can :read, Exemplify
152
- can :read, Extent
153
- can :read, Frequency
154
- can :read, FormOfWork
155
- can :read, Item
156
- can :read, Language
157
- can :read, License
158
- can :read, Manifestation do |manifestation|
159
- manifestation.required_role_id <= 1
160
- end
161
- can :read, ManifestationRelationship
162
- can :read, ManifestationRelationshipType
163
- can :read, MediumOfPerformance
164
- can :read, Own
165
- can :index, Patron
166
- can :show, Patron do |patron|
167
- true if patron.required_role_id <= 1
168
- end
169
- can :read, PatronRelationship
170
- can :read, PatronRelationshipType
171
- can :index, PictureFile
172
- can :show, PictureFile do |picture_file|
173
- begin
174
- true if picture_file.picture_attachable.required_role_id <= 2
175
- rescue NoMethodError
176
- true
82
+ can [:update, :destroy], Patron do |patron|
83
+ !patron.user.try(:has_role?, 'Librarian') and patron.required_role_id <= 3
84
+ end
85
+ can :manage, [
86
+ Create,
87
+ Donate,
88
+ Exemplify,
89
+ ImportRequest,
90
+ ManifestationRelationship,
91
+ Own,
92
+ PatronImportFile,
93
+ PatronRelationship,
94
+ PictureFile,
95
+ Produce,
96
+ Realize,
97
+ ResourceImportFile,
98
+ SeriesStatement,
99
+ SeriesStatementRelationship,
100
+ SeriesHasManifestation
101
+ ]
102
+ can :read, [
103
+ CarrierType,
104
+ ContentType,
105
+ Country,
106
+ Extent,
107
+ Frequency,
108
+ FormOfWork,
109
+ Language,
110
+ License,
111
+ ManifestationRelationshipType,
112
+ PatronImportResult,
113
+ PatronRelationshipType,
114
+ PatronType,
115
+ RequestStatusType,
116
+ RequestType,
117
+ ResourceImportResult,
118
+ MediumOfPerformance
119
+ ]
120
+ when 'User'
121
+ can :index, Item
122
+ can :show, Item do |item|
123
+ item.required_role_id <= 2
124
+ end
125
+ can [:read, :edit], Manifestation do |manifestation|
126
+ manifestation.required_role_id <= 2
127
+ end
128
+ can :index, Patron
129
+ can :update, Patron do |patron|
130
+ patron.user == user
131
+ end
132
+ can :show, Patron do |patron|
133
+ #if patron.user == user
134
+ # true
135
+ #elsif patron.user != user
136
+ true if patron.required_role_id <= 2 #name == 'Administrator'
137
+ #end
138
+ end
139
+ can :index, PictureFile
140
+ can :show, PictureFile do |picture_file|
141
+ begin
142
+ true if picture_file.picture_attachable.required_role_id <= 2
143
+ rescue NoMethodError
144
+ true
145
+ end
146
+ end
147
+ can :read, [
148
+ CarrierType,
149
+ ContentType,
150
+ Country,
151
+ Create,
152
+ Exemplify,
153
+ Extent,
154
+ Frequency,
155
+ FormOfWork,
156
+ Language,
157
+ License,
158
+ ManifestationRelationship,
159
+ ManifestationRelationshipType,
160
+ MediumOfPerformance,
161
+ Own,
162
+ PatronRelationship,
163
+ PatronRelationshipType,
164
+ Produce,
165
+ Realize,
166
+ SeriesStatement,
167
+ SeriesHasManifestation
168
+ ]
169
+ else
170
+ can :index, Patron
171
+ can :show, Patron do |patron|
172
+ patron.required_role_id == 1 #name == 'Guest'
177
173
  end
174
+ can :read, [
175
+ CarrierType,
176
+ ContentType,
177
+ Country,
178
+ Create,
179
+ Exemplify,
180
+ Extent,
181
+ Frequency,
182
+ FormOfWork,
183
+ Item,
184
+ Language,
185
+ License,
186
+ Manifestation,
187
+ ManifestationRelationship,
188
+ ManifestationRelationshipType,
189
+ MediumOfPerformance,
190
+ Own,
191
+ PatronRelationship,
192
+ PatronRelationshipType,
193
+ PictureFile,
194
+ Produce,
195
+ Realize,
196
+ SeriesStatement,
197
+ SeriesHasManifestation
198
+ ]
178
199
  end
179
- can :show, User
180
- can :read, Produce
181
- can :read, Realize
182
- can :read, SeriesHasManifestation
183
- can :read, SeriesStatement
184
200
  end
185
201
  end
186
- end
202
+ #end
@@ -76,21 +76,8 @@ class User < ActiveRecord::Base
76
76
  end
77
77
  end
78
78
 
79
- if defined?(EnjuMessage)
80
- has_many :sent_messages, :foreign_key => 'sender_id', :class_name => 'Message'
81
- has_many :received_messages, :foreign_key => 'receiver_id', :class_name => 'Message'
82
-
83
- def send_message(status, options = {})
84
- MessageRequest.transaction do
85
- request = MessageRequest.new
86
- request.sender = User.find(1)
87
- request.receiver = self
88
- request.message_template = MessageTemplate.localized_template(status, self.locale)
89
- request.save_message_body(options)
90
- request.sm_send_message!
91
- end
92
- end
93
- end
79
+ enju_bookmark_user_model if defined?(EnjuBookmark)
80
+ enju_message_user_model if defined?(EnjuBookmark)
94
81
 
95
82
  def patron
96
83
  LocalPatron.new(self)
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_biblio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre22
4
+ version: 0.1.0.pre23
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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.13.rc1
19
+ version: 3.2.13.rc2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.13.rc1
26
+ version: 3.2.13.rc2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: paperclip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -324,42 +324,42 @@ dependencies:
324
324
  requirements:
325
325
  - - ~>
326
326
  - !ruby/object:Gem::Version
327
- version: 0.1.0.pre11
327
+ version: 0.1.0.pre12
328
328
  type: :development
329
329
  prerelease: false
330
330
  version_requirements: !ruby/object:Gem::Requirement
331
331
  requirements:
332
332
  - - ~>
333
333
  - !ruby/object:Gem::Version
334
- version: 0.1.0.pre11
334
+ version: 0.1.0.pre12
335
335
  - !ruby/object:Gem::Dependency
336
336
  name: enju_inventory
337
337
  requirement: !ruby/object:Gem::Requirement
338
338
  requirements:
339
339
  - - ~>
340
340
  - !ruby/object:Gem::Version
341
- version: 0.1.11.pre5
341
+ version: 0.1.11.pre6
342
342
  type: :development
343
343
  prerelease: false
344
344
  version_requirements: !ruby/object:Gem::Requirement
345
345
  requirements:
346
346
  - - ~>
347
347
  - !ruby/object:Gem::Version
348
- version: 0.1.11.pre5
348
+ version: 0.1.11.pre6
349
349
  - !ruby/object:Gem::Dependency
350
350
  name: enju_bookmark
351
351
  requirement: !ruby/object:Gem::Requirement
352
352
  requirements:
353
353
  - - ~>
354
354
  - !ruby/object:Gem::Version
355
- version: 0.1.2.pre7
355
+ version: 0.1.2.pre8
356
356
  type: :development
357
357
  prerelease: false
358
358
  version_requirements: !ruby/object:Gem::Requirement
359
359
  requirements:
360
360
  - - ~>
361
361
  - !ruby/object:Gem::Version
362
- version: 0.1.2.pre7
362
+ version: 0.1.2.pre8
363
363
  - !ruby/object:Gem::Dependency
364
364
  name: enju_event
365
365
  requirement: !ruby/object:Gem::Requirement
@@ -422,14 +422,14 @@ dependencies:
422
422
  requirements:
423
423
  - - ~>
424
424
  - !ruby/object:Gem::Version
425
- version: 0.1.0.pre12
425
+ version: 0.1.0.pre14
426
426
  type: :development
427
427
  prerelease: false
428
428
  version_requirements: !ruby/object:Gem::Requirement
429
429
  requirements:
430
430
  - - ~>
431
431
  - !ruby/object:Gem::Version
432
- version: 0.1.0.pre12
432
+ version: 0.1.0.pre14
433
433
  - !ruby/object:Gem::Dependency
434
434
  name: enju_oai
435
435
  requirement: !ruby/object:Gem::Requirement
@@ -539,6 +539,7 @@ files:
539
539
  - app/models/create.rb
540
540
  - app/models/create_type.rb
541
541
  - app/models/donate.rb
542
+ - app/models/enju_biblio/ability.rb
542
543
  - app/models/exemplify.rb
543
544
  - app/models/extent.rb
544
545
  - app/models/form_of_work.rb
@@ -1141,37 +1142,12 @@ files:
1141
1142
  - spec/dummy/solr/conf/spellings.txt
1142
1143
  - spec/dummy/solr/conf/stopwords.txt
1143
1144
  - spec/dummy/solr/conf/synonyms.txt
1144
- - spec/dummy/solr/data/test/index/_tu.fdt
1145
- - spec/dummy/solr/data/test/index/_tu.fdx
1146
- - spec/dummy/solr/data/test/index/_tu.fnm
1147
- - spec/dummy/solr/data/test/index/_tu.frq
1148
- - spec/dummy/solr/data/test/index/_tu.nrm
1149
- - spec/dummy/solr/data/test/index/_tu.prx
1150
- - spec/dummy/solr/data/test/index/_tu.tii
1151
- - spec/dummy/solr/data/test/index/_tu.tis
1152
- - spec/dummy/solr/data/test/index/_tv.fdt
1153
- - spec/dummy/solr/data/test/index/_tv.fdx
1154
- - spec/dummy/solr/data/test/index/_tv.fnm
1155
- - spec/dummy/solr/data/test/index/_tv.frq
1156
- - spec/dummy/solr/data/test/index/_tv.nrm
1157
- - spec/dummy/solr/data/test/index/_tv.prx
1158
- - spec/dummy/solr/data/test/index/_tv.tii
1159
- - spec/dummy/solr/data/test/index/_tv.tis
1160
- - spec/dummy/solr/data/test/index/_tw.fdt
1161
- - spec/dummy/solr/data/test/index/_tw.fdx
1162
- - spec/dummy/solr/data/test/index/_tw.fnm
1163
- - spec/dummy/solr/data/test/index/_tw.frq
1164
- - spec/dummy/solr/data/test/index/_tw.nrm
1165
- - spec/dummy/solr/data/test/index/_tw.prx
1166
- - spec/dummy/solr/data/test/index/_tw.tii
1167
- - spec/dummy/solr/data/test/index/_tw.tis
1168
1145
  - spec/dummy/solr/data/test/index/segments.gen
1169
- - spec/dummy/solr/data/test/index/segments_16t
1146
+ - spec/dummy/solr/data/test/index/segments_36o
1170
1147
  - spec/dummy/solr/data/test/spellchecker/segments.gen
1171
1148
  - spec/dummy/solr/data/test/spellchecker/segments_1
1172
1149
  - spec/dummy/tmp/cache/4F7/F90/default_role
1173
1150
  - spec/dummy/tmp/cache/6E4/420/search_engine_all
1174
- - spec/dummy/tmp/cache/ACB/B20/manifestation_search_total
1175
1151
  - spec/factories/basket.rb
1176
1152
  - spec/factories/carrier_type.rb
1177
1153
  - spec/factories/content_type.rb
@@ -1599,37 +1575,12 @@ test_files:
1599
1575
  - spec/dummy/solr/conf/spellings.txt
1600
1576
  - spec/dummy/solr/conf/stopwords.txt
1601
1577
  - spec/dummy/solr/conf/synonyms.txt
1602
- - spec/dummy/solr/data/test/index/_tu.fdt
1603
- - spec/dummy/solr/data/test/index/_tu.fdx
1604
- - spec/dummy/solr/data/test/index/_tu.fnm
1605
- - spec/dummy/solr/data/test/index/_tu.frq
1606
- - spec/dummy/solr/data/test/index/_tu.nrm
1607
- - spec/dummy/solr/data/test/index/_tu.prx
1608
- - spec/dummy/solr/data/test/index/_tu.tii
1609
- - spec/dummy/solr/data/test/index/_tu.tis
1610
- - spec/dummy/solr/data/test/index/_tv.fdt
1611
- - spec/dummy/solr/data/test/index/_tv.fdx
1612
- - spec/dummy/solr/data/test/index/_tv.fnm
1613
- - spec/dummy/solr/data/test/index/_tv.frq
1614
- - spec/dummy/solr/data/test/index/_tv.nrm
1615
- - spec/dummy/solr/data/test/index/_tv.prx
1616
- - spec/dummy/solr/data/test/index/_tv.tii
1617
- - spec/dummy/solr/data/test/index/_tv.tis
1618
- - spec/dummy/solr/data/test/index/_tw.fdt
1619
- - spec/dummy/solr/data/test/index/_tw.fdx
1620
- - spec/dummy/solr/data/test/index/_tw.fnm
1621
- - spec/dummy/solr/data/test/index/_tw.frq
1622
- - spec/dummy/solr/data/test/index/_tw.nrm
1623
- - spec/dummy/solr/data/test/index/_tw.prx
1624
- - spec/dummy/solr/data/test/index/_tw.tii
1625
- - spec/dummy/solr/data/test/index/_tw.tis
1626
1578
  - spec/dummy/solr/data/test/index/segments.gen
1627
- - spec/dummy/solr/data/test/index/segments_16t
1579
+ - spec/dummy/solr/data/test/index/segments_36o
1628
1580
  - spec/dummy/solr/data/test/spellchecker/segments.gen
1629
1581
  - spec/dummy/solr/data/test/spellchecker/segments_1
1630
1582
  - spec/dummy/tmp/cache/4F7/F90/default_role
1631
1583
  - spec/dummy/tmp/cache/6E4/420/search_engine_all
1632
- - spec/dummy/tmp/cache/ACB/B20/manifestation_search_total
1633
1584
  - spec/factories/basket.rb
1634
1585
  - spec/factories/carrier_type.rb
1635
1586
  - spec/factories/content_type.rb
@@ -1,7 +0,0 @@
1
- ����+idtype
2
- class_nametitle_smconnect_title_sconnect_creator_sconnect_publisher_sisbn_smcarrier_type_s
3
- library_sm
4
- language_sitem_identifier_smshelf_sm created_at_d updated_at_dcreator_ids_imcontributor_ids_impublisher_ids_im item_ids_imrequired_role_id_i start_page_i
5
- end_page_inumber_of_pages_iseries_statement_id_irepository_content_b
6
- creator_sm sort_title_s periodical_bperiodical_master_b reservable_b
7
- title_text creator_textcontributor_textpublisher_textitem_identifier_text aulast_text aufirst_textau_text btitle_text isbn_textoriginal_manifestation_ids_im jtitle_text pub_date_dm
@@ -1 +0,0 @@
1
- NRM�turxtuxutrtwsssuuvyrttrvrrtxtxswuywtrtyvywtuwwttptxy|||||||||||tuuu|||||||||||||||||||||||||||||||||wxwwx|||||||||||||||||||||||||||||||||||||||||||||wxwwx|||||||||||||||||||||||||||u|||||||||||||||||uvw|||||||x|||||||||||||||||||||||||||||||||||||||y||||||||||||w���|||||||||||||||||||||||||||||||||��|||||||||||w���|||||||||||||||||||||||||||||||||xy|||||||||||tuuu|||||||||||||||||||||||||||||||||turxtuxutrtwsssuuvyrttrvrrtxtxswuywtrtyvywtuwwttpt||||��|||||��||||||||||||||||||||||||||||||||||||||tu|||||||||||||||||||||||||||||||||||||||||||||||
@@ -1,7 +0,0 @@
1
- ����+idtype
2
- class_nametitle_smconnect_title_sconnect_creator_sconnect_publisher_sisbn_smcarrier_type_s
3
- library_sm
4
- language_sitem_identifier_smshelf_sm created_at_d updated_at_dcreator_ids_imcontributor_ids_impublisher_ids_im item_ids_imrequired_role_id_i start_page_i
5
- end_page_inumber_of_pages_iseries_statement_id_irepository_content_b
6
- creator_sm sort_title_s periodical_bperiodical_master_b reservable_b
7
- title_text creator_textcontributor_textpublisher_textitem_identifier_text aulast_text aufirst_textau_text btitle_text isbn_textoriginal_manifestation_ids_im jtitle_text pub_date_dm
@@ -1 +0,0 @@
1
- NRM�xuuwuyutxxvxvxwtyvxwxxxvvtwwxvytwxwrwvxxyxuyxyuysx||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||xuuwuyutxxvxvxwtyvxwxxxvvtwwxvytwxwrwvxxyxuyxyuysx||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@@ -1,8 +0,0 @@
1
- ����3idtype
2
- class_nametitle_smconnect_title_sconnect_creator_sconnect_publisher_sisbn_smcarrier_type_s
3
- library_sm
4
- language_sitem_identifier_smshelf_sm created_at_d updated_at_dcreator_ids_imcontributor_ids_impublisher_ids_im item_ids_imrequired_role_id_i start_page_i
5
- end_page_inumber_of_pages_iseries_statement_id_irepository_content_b
6
- creator_sm sort_title_s periodical_bperiodical_master_b reservable_b
7
- title_text creator_textcontributor_textpublisher_textitem_identifier_text aulast_text aufirst_textau_text btitle_text isbn_textoriginal_manifestation_ids_im jtitle_text pub_date_dmissn_sm issn_textvolume_number_iissue_number_iserial_number_i atitle_textdate_of_publication_d
8
- pub_year_i
@@ -1 +0,0 @@
1
- NRM�vruwvvuur|xutttttwwuuuuuuxx||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||xtt|uuutt||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||vruwvvuur|xu||tttwwuuuuuuxx|||||y|||��|||||||���������||||||||||||xw|||||||||||||||||||||||||y||||||||||||||||||||||||||tt|||||||||||||
@@ -1,2 +0,0 @@
1
- o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1362472376.395749: @value"
2
- i