enju_circulation 0.0.47 → 0.0.48
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/reserve.rb +9 -9
- data/lib/enju_circulation/controller.rb +25 -0
- data/lib/enju_circulation/manifestation.rb +61 -45
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/enju_circulation.rb +4 -1
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -13
- data/spec/dummy/app/models/user_group.rb +11 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/db/migrate/001_create_patrons.rb +1 -5
- data/spec/dummy/db/migrate/005_create_manifestations.rb +1 -8
- data/spec/dummy/db/migrate/006_create_items.rb +1 -6
- data/spec/dummy/db/migrate/012_create_owns.rb +12 -0
- data/spec/dummy/db/migrate/015_create_creates.rb +12 -0
- data/spec/dummy/db/migrate/047_create_produces.rb +12 -0
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +1 -5
- data/spec/dummy/db/migrate/125_create_donates.rb +12 -0
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +13 -0
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +1 -7
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +1 -5
- data/spec/dummy/db/migrate/20081025083323_create_countries.rb +28 -0
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +1 -5
- data/spec/dummy/db/migrate/20090812151902_create_patron_relationship_types.rb +12 -0
- data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +27 -0
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +13 -0
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +13 -0
- data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -0
- data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +13 -0
- data/spec/dummy/db/migrate/20100606073747_create_patron_relationships.rb +13 -0
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +12 -0
- data/spec/dummy/db/migrate/20100814091104_add_position_to_patron_relationship.rb +11 -0
- data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +9 -0
- data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_patron.rb +11 -0
- data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +9 -0
- data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +9 -0
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +12 -0
- data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +13 -0
- data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +13 -0
- data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +10 -0
- data/spec/dummy/db/migrate/20110918161853_rename_series_statement_manifestation_id_to_root_manifestation_id.rb +13 -0
- data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +7 -0
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +6 -0
- data/spec/dummy/db/schema.rb +246 -36
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/enju_leaf.rb +2 -0
- metadata +71 -33
- data/lib/enju_circulation/user_group.rb +0 -10
- data/spec/dummy/app/models/basket.rb +0 -64
- data/spec/dummy/app/models/carrier_type.rb +0 -33
- data/spec/dummy/app/models/event.rb +0 -85
- data/spec/dummy/app/models/event_category.rb +0 -23
- data/spec/dummy/app/models/exemplify.rb +0 -45
- data/spec/dummy/app/models/item.rb +0 -278
- data/spec/dummy/app/models/language.rb +0 -4
- data/spec/dummy/app/models/library.rb +0 -128
- data/spec/dummy/app/models/library_group.rb +0 -86
- data/spec/dummy/app/models/manifestation.rb +0 -13
- data/spec/dummy/app/models/patron.rb +0 -168
- data/spec/dummy/app/models/patron_type.rb +0 -19
- data/spec/dummy/app/models/request_status_type.rb +0 -19
- data/spec/dummy/app/models/request_type.rb +0 -18
- data/spec/dummy/app/models/shelf.rb +0 -54
@@ -1,86 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
class LibraryGroup < ActiveRecord::Base
|
3
|
-
#include Singleton
|
4
|
-
#include Configurator
|
5
|
-
include MasterModel
|
6
|
-
|
7
|
-
has_many :libraries
|
8
|
-
has_many :search_engines
|
9
|
-
#has_many :news_feeds
|
10
|
-
belongs_to :country
|
11
|
-
|
12
|
-
validates :email, :format => {:with => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i}, :presence => true
|
13
|
-
validates :url, :presence => true, :url => true
|
14
|
-
after_save :clear_site_config_cache
|
15
|
-
|
16
|
-
def clear_site_config_cache
|
17
|
-
Rails.cache.delete('library_site_config')
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.site_config
|
21
|
-
#if Rails.env == 'production'
|
22
|
-
# Rails.cache.fetch('library_site_config'){LibraryGroup.find(1)}
|
23
|
-
#else
|
24
|
-
LibraryGroup.find(1)
|
25
|
-
#end
|
26
|
-
rescue
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.system_name(locale = I18n.locale)
|
31
|
-
LibraryGroup.site_config.display_name.localize(locale)
|
32
|
-
end
|
33
|
-
|
34
|
-
def config?
|
35
|
-
true if self == LibraryGroup.site_config
|
36
|
-
end
|
37
|
-
|
38
|
-
def real_libraries
|
39
|
-
# 物理的な図書館 = IDが1以外
|
40
|
-
libraries.where('id != 1').all
|
41
|
-
end
|
42
|
-
|
43
|
-
def network_access_allowed?(ip_address, options = {})
|
44
|
-
options = {:network_type => :lan}.merge(options)
|
45
|
-
client_ip = IPAddr.new(ip_address)
|
46
|
-
case options[:network_type]
|
47
|
-
when :admin
|
48
|
-
allowed_networks = self.admin_networks.to_s.split
|
49
|
-
else
|
50
|
-
allowed_networks = self.my_networks.to_s.split
|
51
|
-
end
|
52
|
-
allowed_networks.each do |allowed_network|
|
53
|
-
begin
|
54
|
-
network = IPAddr.new(allowed_network)
|
55
|
-
return true if network.include?(client_ip)
|
56
|
-
rescue ArgumentError
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
return false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
# == Schema Information
|
66
|
-
#
|
67
|
-
# Table name: library_groups
|
68
|
-
#
|
69
|
-
# id :integer not null, primary key
|
70
|
-
# name :string(255) not null
|
71
|
-
# display_name :text
|
72
|
-
# short_name :string(255) not null
|
73
|
-
# email :string(255)
|
74
|
-
# my_networks :text
|
75
|
-
# login_banner :text
|
76
|
-
# note :text
|
77
|
-
# post_to_union_catalog :boolean default(FALSE), not null
|
78
|
-
# country_id :integer
|
79
|
-
# created_at :datetime
|
80
|
-
# updated_at :datetime
|
81
|
-
# admin_networks :text
|
82
|
-
# allow_bookmark_external_url :boolean default(FALSE), not null
|
83
|
-
# position :integer
|
84
|
-
# url :string(255) default("http://localhost:3000/")
|
85
|
-
#
|
86
|
-
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class Manifestation < ActiveRecord::Base
|
2
|
-
include EnjuCirculation::Manifestation
|
3
|
-
belongs_to :carrier_type
|
4
|
-
has_many :exemplifies, :foreign_key => 'manifestation_id'
|
5
|
-
has_many :items, :through => :exemplifies
|
6
|
-
has_many :reserves, :foreign_key => :manifestation_id
|
7
|
-
|
8
|
-
searchable do
|
9
|
-
boolean :reservable do
|
10
|
-
items.for_checkout.exists?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
class Patron < ActiveRecord::Base
|
3
|
-
scope :readable_by, lambda{|user| {:conditions => ['required_role_id <= ?', user.try(:user_has_role).try(:role_id) || Role.where(:name => 'Guest').select(:id).first.id]}}
|
4
|
-
belongs_to :user
|
5
|
-
belongs_to :patron_type
|
6
|
-
belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id', :validate => true
|
7
|
-
belongs_to :language
|
8
|
-
|
9
|
-
validates_presence_of :language, :patron_type
|
10
|
-
validates_associated :language, :patron_type
|
11
|
-
validates :full_name, :presence => true, :length => {:maximum => 255}
|
12
|
-
validates :user_id, :uniqueness => true, :allow_nil => true
|
13
|
-
validates :email, :format => {:with => /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i}, :allow_blank => true
|
14
|
-
before_validation :set_role_and_name, :on => :create
|
15
|
-
|
16
|
-
#has_paper_trail
|
17
|
-
attr_accessor :user_username
|
18
|
-
#[:address_1, :address_2].each do |column|
|
19
|
-
# encrypt_with_public_key column,
|
20
|
-
# :key_pair => File.join(Rails.root.to_s,'config','keypair.pem'),
|
21
|
-
# :base64 => true
|
22
|
-
#end
|
23
|
-
|
24
|
-
searchable do
|
25
|
-
text :name, :place, :address_1, :address_2, :other_designation, :note
|
26
|
-
string :zip_code_1
|
27
|
-
string :zip_code_2
|
28
|
-
string :username do
|
29
|
-
user.username if user
|
30
|
-
end
|
31
|
-
time :created_at
|
32
|
-
time :updated_at
|
33
|
-
string :user
|
34
|
-
integer :work_ids, :multiple => true
|
35
|
-
integer :expression_ids, :multiple => true
|
36
|
-
integer :manifestation_ids, :multiple => true
|
37
|
-
integer :patron_merge_list_ids, :multiple => true if defined?(EnjuResourceMerge)
|
38
|
-
integer :original_patron_ids, :multiple => true
|
39
|
-
integer :required_role_id
|
40
|
-
integer :patron_type_id
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.per_page
|
44
|
-
10
|
45
|
-
end
|
46
|
-
|
47
|
-
def full_name_without_space
|
48
|
-
full_name.gsub(/\s/, "")
|
49
|
-
end
|
50
|
-
|
51
|
-
def set_role_and_name
|
52
|
-
self.required_role = Role.where(:name => 'Librarian').first if self.required_role_id.nil?
|
53
|
-
set_full_name
|
54
|
-
end
|
55
|
-
|
56
|
-
def set_full_name
|
57
|
-
if self.full_name.blank?
|
58
|
-
if self.last_name.to_s.strip and self.first_name.to_s.strip and configatron.family_name_first == true
|
59
|
-
self.full_name = [last_name, middle_name, first_name].compact.join(" ").to_s.strip
|
60
|
-
else
|
61
|
-
self.full_name = [first_name, last_name, middle_name].compact.join(" ").to_s.strip
|
62
|
-
end
|
63
|
-
end
|
64
|
-
if self.full_name_transcription.blank?
|
65
|
-
self.full_name_transcription = [last_name_transcription, middle_name_transcription, first_name_transcription].join(" ").to_s.strip
|
66
|
-
end
|
67
|
-
[self.full_name, self.full_name_transcription]
|
68
|
-
end
|
69
|
-
|
70
|
-
def full_name_without_space
|
71
|
-
full_name.gsub(/\s/, "")
|
72
|
-
# # TODO: 日本人以外は?
|
73
|
-
# name = []
|
74
|
-
# name << self.last_name.to_s.strip
|
75
|
-
# name << self.middle_name.to_s.strip
|
76
|
-
# name << self.first_name.to_s.strip
|
77
|
-
# name << self.corporate_name.to_s.strip
|
78
|
-
# name.join("").strip
|
79
|
-
end
|
80
|
-
|
81
|
-
def full_name_transcription_without_space
|
82
|
-
full_name_transcription.to_s.gsub(/\s/, "")
|
83
|
-
end
|
84
|
-
|
85
|
-
def full_name_alternative_without_space
|
86
|
-
full_name_alternative.to_s.gsub(/\s/, "")
|
87
|
-
end
|
88
|
-
|
89
|
-
def name
|
90
|
-
name = []
|
91
|
-
name << full_name.to_s.strip
|
92
|
-
name << full_name_transcription.to_s.strip
|
93
|
-
name << full_name_alternative.to_s.strip
|
94
|
-
#name << full_name_without_space
|
95
|
-
#name << full_name_transcription_without_space
|
96
|
-
#name << full_name_alternative_without_space
|
97
|
-
#name << full_name.wakati rescue nil
|
98
|
-
#name << full_name_transcription.wakati rescue nil
|
99
|
-
#name << full_name_alternative.wakati rescue nil
|
100
|
-
name
|
101
|
-
end
|
102
|
-
|
103
|
-
def date
|
104
|
-
if date_of_birth
|
105
|
-
if date_of_death
|
106
|
-
"#{date_of_birth} - #{date_of_death}"
|
107
|
-
else
|
108
|
-
"#{date_of_birth} -"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def creator?(resource)
|
114
|
-
resource.creators.include?(self)
|
115
|
-
end
|
116
|
-
|
117
|
-
def publisher?(resource)
|
118
|
-
resource.publishers.include?(self)
|
119
|
-
end
|
120
|
-
|
121
|
-
def check_required_role(user)
|
122
|
-
return true if self.user.blank?
|
123
|
-
return true if self.user.required_role.name == 'Guest'
|
124
|
-
return true if user == self.user
|
125
|
-
return true if user.has_role?(self.user.required_role.name)
|
126
|
-
false
|
127
|
-
rescue NoMethodError
|
128
|
-
false
|
129
|
-
end
|
130
|
-
|
131
|
-
def created(work)
|
132
|
-
creates.where(:work_id => work.id).first
|
133
|
-
end
|
134
|
-
|
135
|
-
def realized(expression)
|
136
|
-
realizes.where(:expression_id => expression.id).first
|
137
|
-
end
|
138
|
-
|
139
|
-
def produced(manifestation)
|
140
|
-
produces.where(:manifestation_id => manifestation.id).first
|
141
|
-
end
|
142
|
-
|
143
|
-
def owned(item)
|
144
|
-
owns.where(:item_id => item.id)
|
145
|
-
end
|
146
|
-
|
147
|
-
def self.import_patrons(patron_lists)
|
148
|
-
list = []
|
149
|
-
patron_lists.each do |patron_list|
|
150
|
-
patron = Patron.where(:full_name => patron_list[:full_name]).first
|
151
|
-
unless patron
|
152
|
-
patron = Patron.new(
|
153
|
-
:full_name => patron_list[:full_name],
|
154
|
-
:full_name_transcription => patron_list[:full_name_transcription],
|
155
|
-
:language_id => 1
|
156
|
-
)
|
157
|
-
patron.required_role = Role.where(:name => 'Guest').first
|
158
|
-
patron.save
|
159
|
-
end
|
160
|
-
list << patron
|
161
|
-
end
|
162
|
-
list
|
163
|
-
end
|
164
|
-
|
165
|
-
def patrons
|
166
|
-
self.original_patrons + self.derived_patrons
|
167
|
-
end
|
168
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class PatronType < ActiveRecord::Base
|
2
|
-
include MasterModel
|
3
|
-
default_scope :order => "patron_types.position"
|
4
|
-
has_many :patrons
|
5
|
-
end
|
6
|
-
|
7
|
-
# == Schema Information
|
8
|
-
#
|
9
|
-
# Table name: patron_types
|
10
|
-
#
|
11
|
-
# id :integer not null, primary key
|
12
|
-
# name :string(255) not null
|
13
|
-
# display_name :text
|
14
|
-
# note :text
|
15
|
-
# position :integer
|
16
|
-
# created_at :datetime
|
17
|
-
# updated_at :datetime
|
18
|
-
#
|
19
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class RequestStatusType < ActiveRecord::Base
|
2
|
-
include MasterModel
|
3
|
-
default_scope :order => 'position'
|
4
|
-
has_many :reserves
|
5
|
-
end
|
6
|
-
|
7
|
-
# == Schema Information
|
8
|
-
#
|
9
|
-
# Table name: request_status_types
|
10
|
-
#
|
11
|
-
# id :integer not null, primary key
|
12
|
-
# name :string(255) not null
|
13
|
-
# display_name :text
|
14
|
-
# note :text
|
15
|
-
# position :integer
|
16
|
-
# created_at :datetime
|
17
|
-
# updated_at :datetime
|
18
|
-
#
|
19
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class RequestType < ActiveRecord::Base
|
2
|
-
include MasterModel
|
3
|
-
default_scope :order => 'position'
|
4
|
-
end
|
5
|
-
|
6
|
-
# == Schema Information
|
7
|
-
#
|
8
|
-
# Table name: request_types
|
9
|
-
#
|
10
|
-
# id :integer not null, primary key
|
11
|
-
# name :string(255) not null
|
12
|
-
# display_name :text
|
13
|
-
# note :text
|
14
|
-
# position :integer
|
15
|
-
# created_at :datetime
|
16
|
-
# updated_at :datetime
|
17
|
-
#
|
18
|
-
|
@@ -1,54 +0,0 @@
|
|
1
|
-
class Shelf < ActiveRecord::Base
|
2
|
-
include MasterModel
|
3
|
-
default_scope :order => "position"
|
4
|
-
scope :real, where('library_id != 1')
|
5
|
-
belongs_to :library, :validate => true
|
6
|
-
has_many :items, :include => [:circulation_status]
|
7
|
-
has_many :picture_files, :as => :picture_attachable, :dependent => :destroy
|
8
|
-
|
9
|
-
validates_associated :library
|
10
|
-
validates_presence_of :library
|
11
|
-
validates_uniqueness_of :display_name, :scope => :library_id
|
12
|
-
|
13
|
-
acts_as_list :scope => :library
|
14
|
-
|
15
|
-
def self.per_page
|
16
|
-
10
|
17
|
-
end
|
18
|
-
|
19
|
-
def web_shelf?
|
20
|
-
return true if self.id == 1
|
21
|
-
false
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.web
|
25
|
-
Shelf.find(1)
|
26
|
-
end
|
27
|
-
|
28
|
-
def first?
|
29
|
-
# 必ずposition順に並んでいる
|
30
|
-
return true if library.shelves.first.position == position
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
def localized_display_name
|
35
|
-
display_name.localize
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# == Schema Information
|
40
|
-
#
|
41
|
-
# Table name: shelves
|
42
|
-
#
|
43
|
-
# id :integer not null, primary key
|
44
|
-
# name :string(255) not null
|
45
|
-
# display_name :text
|
46
|
-
# note :text
|
47
|
-
# library_id :integer default(1), not null
|
48
|
-
# items_count :integer default(0), not null
|
49
|
-
# position :integer
|
50
|
-
# created_at :datetime
|
51
|
-
# updated_at :datetime
|
52
|
-
# deleted_at :datetime
|
53
|
-
#
|
54
|
-
|