enju_bookmark 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/bookmark_sweeper.rb +1 -0
- data/app/views/bookmark_stat_has_manifestations/index.html.erb +1 -1
- data/app/views/bookmark_stats/index.html.erb +1 -1
- data/app/views/bookmarks/_index.html.erb +1 -1
- data/app/views/bookmarks/_index_user.html.erb +1 -1
- data/app/views/bookmarks/show.html.erb +1 -1
- data/lib/enju_bookmark.rb +2 -2
- data/lib/enju_bookmark/calculate_stat.rb +30 -0
- data/lib/enju_bookmark/expire_tag_cloud.rb +10 -0
- data/lib/enju_bookmark/version.rb +1 -1
- data/spec/dummy/app/models/user_has_role.rb +18 -0
- data/spec/dummy/config/application.rb +3 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/db/migrate/001_create_patrons.rb +1 -10
- data/spec/dummy/db/migrate/005_create_manifestations.rb +4 -16
- data/spec/dummy/db/migrate/006_create_items.rb +1 -9
- 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/059_create_libraries.rb +1 -7
- data/spec/dummy/db/migrate/069_create_shelves.rb +1 -5
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +1 -5
- data/spec/dummy/db/migrate/{20111201163342_create_user_groups.rb → 077_create_user_groups.rb} +2 -2
- data/spec/dummy/db/migrate/080_create_library_groups.rb +1 -6
- data/spec/dummy/db/migrate/112_create_frequencies.rb +12 -0
- data/spec/dummy/db/migrate/117_create_form_of_works.rb +12 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
- data/spec/dummy/db/migrate/125_create_donates.rb +12 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +12 -0
- data/spec/dummy/db/migrate/131_create_request_types.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/20081006090811_create_subscriptions.rb +17 -0
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
- 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/20081027150907_create_picture_files.rb +15 -0
- data/spec/dummy/db/migrate/20081028083142_create_patron_import_files.rb +22 -0
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +22 -0
- data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +15 -0
- data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +15 -0
- data/spec/dummy/db/migrate/20090719201843_create_extents.rb +12 -0
- data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +12 -0
- data/spec/dummy/db/migrate/20090720091429_create_content_types.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/20091025080447_create_licenses.rb +12 -0
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +2 -8
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +15 -0
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +13 -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/20100925043847_create_resource_import_results.rb +15 -0
- data/spec/dummy/db/migrate/20100925074559_create_patron_import_results.rb +12 -0
- data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.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/20110603184217_add_edit_mode_to_resource_import_file.rb +9 -0
- data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +11 -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 +1 -5
- data/spec/dummy/db/migrate/20111009183423_add_ndc_to_manifestation.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/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +6 -0
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +12 -0
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +6 -0
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +6 -0
- data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_patron_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413170720_add_error_message_to_patron_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +9 -0
- data/spec/dummy/db/migrate/20120415060323_rename_patron_import_file_imported_at_to_executed_at.rb +9 -0
- data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_patron_import_file.rb +5 -0
- data/spec/dummy/db/schema.rb +520 -106
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/fixtures/libraries.yml +0 -5
- metadata +141 -139
- data/lib/enju_bookmark/master_model.rb +0 -41
- data/lib/enju_bookmark/url_validator.rb +0 -10
- data/spec/dummy/app/models/bookstore.rb +0 -31
- data/spec/dummy/app/models/carrier_type.rb +0 -33
- data/spec/dummy/app/models/exemplify.rb +0 -45
- data/spec/dummy/app/models/item.rb +0 -121
- 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 -396
- data/spec/dummy/app/models/patron.rb +0 -168
- data/spec/dummy/app/models/patron_type.rb +0 -19
- data/spec/dummy/app/models/series_has_manifestation.rb +0 -35
- data/spec/dummy/app/models/series_statement.rb +0 -88
- data/spec/dummy/app/models/shelf.rb +0 -54
@@ -1,41 +0,0 @@
|
|
1
|
-
module MasterModel
|
2
|
-
def self.included(base)
|
3
|
-
#base.extend ClassMethods
|
4
|
-
base.send :include, InstanceMethods
|
5
|
-
base.class_eval do
|
6
|
-
acts_as_list
|
7
|
-
validates_uniqueness_of :name, :case_sensitive => false
|
8
|
-
validates_presence_of :name, :display_name
|
9
|
-
before_validation :set_display_name, :on => :create
|
10
|
-
normalize_attributes :name
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module InstanceMethods
|
15
|
-
def set_display_name
|
16
|
-
self.display_name = self.name if self.display_name.blank?
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_creatable
|
20
|
-
if creatable?
|
21
|
-
raise NotModifiableError
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def check_deletable
|
26
|
-
if deletable?
|
27
|
-
raise NotModifiableError
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def creatable?
|
32
|
-
false
|
33
|
-
end
|
34
|
-
|
35
|
-
def deletable?
|
36
|
-
false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class NotModifiableError < StandardError; end
|
41
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Bookstore < ActiveRecord::Base
|
2
|
-
default_scope :order => "position"
|
3
|
-
has_many :items
|
4
|
-
|
5
|
-
acts_as_list
|
6
|
-
validates_presence_of :name
|
7
|
-
validates :url, :url => true, :allow_blank => true, :length => {:maximum => 255}
|
8
|
-
|
9
|
-
def self.per_page
|
10
|
-
10
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# == Schema Information
|
15
|
-
#
|
16
|
-
# Table name: bookstores
|
17
|
-
#
|
18
|
-
# id :integer not null, primary key
|
19
|
-
# name :text not null
|
20
|
-
# zip_code :string(255)
|
21
|
-
# address :text
|
22
|
-
# note :text
|
23
|
-
# telephone_number :string(255)
|
24
|
-
# fax_number :string(255)
|
25
|
-
# url :string(255)
|
26
|
-
# position :integer
|
27
|
-
# deleted_at :datetime
|
28
|
-
# created_at :datetime
|
29
|
-
# updated_at :datetime
|
30
|
-
#
|
31
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
class CarrierType < ActiveRecord::Base
|
2
|
-
include MasterModel
|
3
|
-
default_scope :order => "position"
|
4
|
-
has_many :manifestations
|
5
|
-
if defined?(EnjuCirculation)
|
6
|
-
has_many :carrier_type_has_checkout_types, :dependent => :destroy
|
7
|
-
has_many :checkout_types, :through => :carrier_type_has_checkout_types
|
8
|
-
end
|
9
|
-
|
10
|
-
def mods_type
|
11
|
-
case name
|
12
|
-
when 'print'
|
13
|
-
'text'
|
14
|
-
else
|
15
|
-
# TODO: その他のタイプ
|
16
|
-
'software, multimedia'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# == Schema Information
|
22
|
-
#
|
23
|
-
# Table name: carrier_types
|
24
|
-
#
|
25
|
-
# id :integer not null, primary key
|
26
|
-
# name :string(255) not null
|
27
|
-
# display_name :text
|
28
|
-
# note :text
|
29
|
-
# position :integer
|
30
|
-
# created_at :datetime
|
31
|
-
# updated_at :datetime
|
32
|
-
#
|
33
|
-
|
@@ -1,45 +0,0 @@
|
|
1
|
-
class Exemplify < ActiveRecord::Base
|
2
|
-
belongs_to :manifestation
|
3
|
-
belongs_to :item
|
4
|
-
|
5
|
-
validates_associated :manifestation, :item
|
6
|
-
validates_presence_of :manifestation_id, :item_id
|
7
|
-
validates_uniqueness_of :item_id
|
8
|
-
after_save :reindex
|
9
|
-
after_destroy :reindex
|
10
|
-
|
11
|
-
acts_as_list :scope => :manifestation_id
|
12
|
-
|
13
|
-
def self.per_page
|
14
|
-
10
|
15
|
-
end
|
16
|
-
|
17
|
-
def reindex
|
18
|
-
manifestation.try(:index)
|
19
|
-
item.try(:index)
|
20
|
-
end
|
21
|
-
|
22
|
-
if defined?(EnjuCirculation)
|
23
|
-
after_create :create_lending_policy
|
24
|
-
|
25
|
-
def create_lending_policy
|
26
|
-
UserGroupHasCheckoutType.available_for_item(item).each do |rule|
|
27
|
-
LendingPolicy.create!(:item_id => item.id, :user_group_id => rule.user_group_id, :fixed_due_date => rule.fixed_due_date, :loan_period => rule.checkout_period, :renewal => rule.checkout_renewal_limit)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# == Schema Information
|
34
|
-
#
|
35
|
-
# Table name: exemplifies
|
36
|
-
#
|
37
|
-
# id :integer not null, primary key
|
38
|
-
# manifestation_id :integer not null
|
39
|
-
# item_id :integer not null
|
40
|
-
# type :string(255)
|
41
|
-
# position :integer
|
42
|
-
# created_at :datetime
|
43
|
-
# updated_at :datetime
|
44
|
-
#
|
45
|
-
|
@@ -1,121 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
class Item < ActiveRecord::Base
|
3
|
-
attr_accessible :call_number, :item_identifier, :circulation_status_id,
|
4
|
-
:checkout_type_id, :shelf_id, :include_supplements, :note, :url, :price,
|
5
|
-
:acquired_at, :bookstore_id, :missing_since, :budget_type_id,
|
6
|
-
:manifestation_id #,:exemplify_attributes
|
7
|
-
scope :on_shelf, where('shelf_id != 1')
|
8
|
-
scope :on_web, where(:shelf_id => 1)
|
9
|
-
|
10
|
-
scope :for_checkout, where('item_identifier IS NOT NULL')
|
11
|
-
scope :not_for_checkout, where(:item_identifier => nil)
|
12
|
-
has_one :exemplify
|
13
|
-
has_one :manifestation, :through => :exemplify
|
14
|
-
has_many :checkouts
|
15
|
-
has_many :reserves
|
16
|
-
has_many :reserved_patrons, :through => :reserves, :class_name => 'Patron'
|
17
|
-
has_many :checked_items, :dependent => :destroy
|
18
|
-
has_many :baskets, :through => :checked_items
|
19
|
-
belongs_to :circulation_status, :validate => true
|
20
|
-
belongs_to :checkout_type
|
21
|
-
has_many :lending_policies, :dependent => :destroy
|
22
|
-
has_one :item_has_use_restriction, :dependent => :destroy
|
23
|
-
has_one :use_restriction, :through => :item_has_use_restriction
|
24
|
-
belongs_to :shelf, :counter_cache => true, :validate => true
|
25
|
-
|
26
|
-
validates_associated :shelf
|
27
|
-
validates :manifestation_id, :presence => true, :on => :create
|
28
|
-
validates_associated :circulation_status, :checkout_type
|
29
|
-
validates_presence_of :circulation_status, :checkout_type
|
30
|
-
searchable do
|
31
|
-
integer :circulation_status_id
|
32
|
-
end
|
33
|
-
accepts_nested_attributes_for :item_has_use_restriction
|
34
|
-
attr_accessor :library_id, :manifestation_id
|
35
|
-
|
36
|
-
def set_circulation_status
|
37
|
-
self.circulation_status = CirculationStatus.where(:name => 'In Process').first if self.circulation_status.nil?
|
38
|
-
end
|
39
|
-
|
40
|
-
def checkout_status(user)
|
41
|
-
user.user_group.user_group_has_checkout_types.where(:checkout_type_id => self.checkout_type.id).first
|
42
|
-
end
|
43
|
-
|
44
|
-
def next_reservation
|
45
|
-
Reserve.waiting.where(:manifestation_id => self.manifestation.id).first
|
46
|
-
end
|
47
|
-
|
48
|
-
def reserved?
|
49
|
-
return true if self.next_reservation
|
50
|
-
false
|
51
|
-
end
|
52
|
-
|
53
|
-
def reservable_by?(user)
|
54
|
-
if manifestation.is_reservable_by?(user)
|
55
|
-
return false if ['Lost', 'Missing', 'Claimed Returned Or Never Borrowed'].include?(self.circulation_status.name)
|
56
|
-
return false if self.item_identifier.blank?
|
57
|
-
true
|
58
|
-
else
|
59
|
-
false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def rent?
|
64
|
-
return true if self.checkouts.not_returned.select(:item_id).detect{|checkout| checkout.item_id == self.id}
|
65
|
-
false
|
66
|
-
end
|
67
|
-
|
68
|
-
def reserved_by_user?(user)
|
69
|
-
if self.next_reservation
|
70
|
-
return true if self.next_reservation.user == user
|
71
|
-
end
|
72
|
-
false
|
73
|
-
end
|
74
|
-
|
75
|
-
def available_for_checkout?
|
76
|
-
circulation_statuses = CirculationStatus.available_for_checkout.select(:id)
|
77
|
-
return true if circulation_statuses.include?(self.circulation_status)
|
78
|
-
false
|
79
|
-
end
|
80
|
-
|
81
|
-
def checkout!(user)
|
82
|
-
self.circulation_status = CirculationStatus.where(:name => 'On Loan').first
|
83
|
-
if self.reserved_by_user?(user)
|
84
|
-
self.next_reservation.update_attributes(:checked_out_at => Time.zone.now)
|
85
|
-
self.next_reservation.sm_complete!
|
86
|
-
end
|
87
|
-
save!
|
88
|
-
end
|
89
|
-
|
90
|
-
def checkin!
|
91
|
-
self.circulation_status = CirculationStatus.where(:name => 'Available On Shelf').first
|
92
|
-
save(:validate => false)
|
93
|
-
end
|
94
|
-
|
95
|
-
def retain(librarian)
|
96
|
-
Item.transaction do
|
97
|
-
reservation = self.manifestation.next_reservation
|
98
|
-
unless reservation.nil?
|
99
|
-
reservation.item = self
|
100
|
-
reservation.sm_retain!
|
101
|
-
reservation.update_attributes({:request_status_type => RequestStatusType.where(:name => 'In Process').first})
|
102
|
-
request = MessageRequest.new(:sender_id => librarian.id, :receiver_id => reservation.user_id)
|
103
|
-
message_template = MessageTemplate.localized_template('item_received', reservation.user.locale)
|
104
|
-
request.message_template = message_template
|
105
|
-
request.save!
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def lending_rule(user)
|
111
|
-
lending_policies.where(:user_group_id => user.user_group.id).first
|
112
|
-
end
|
113
|
-
|
114
|
-
def not_for_loan?
|
115
|
-
if use_restriction.try(:name) == 'Not For Loan'
|
116
|
-
true
|
117
|
-
else
|
118
|
-
false
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
class Library < ActiveRecord::Base
|
3
|
-
include MasterModel
|
4
|
-
default_scope :order => 'libraries.position'
|
5
|
-
scope :real, where('id != 1')
|
6
|
-
has_many :shelves, :order => 'shelves.position'
|
7
|
-
belongs_to :library_group, :validate => true
|
8
|
-
has_many :events, :include => :event_category
|
9
|
-
#belongs_to :holding_patron, :polymorphic => true, :validate => true
|
10
|
-
belongs_to :patron #, :validate => true
|
11
|
-
has_many :inter_library_loans, :foreign_key => 'borrowing_library_id'
|
12
|
-
has_many :users
|
13
|
-
belongs_to :country
|
14
|
-
|
15
|
-
extend FriendlyId
|
16
|
-
friendly_id :name
|
17
|
-
#geocoded_by :address
|
18
|
-
|
19
|
-
searchable do
|
20
|
-
text :name, :display_name, :note, :address
|
21
|
-
time :created_at
|
22
|
-
time :updated_at
|
23
|
-
integer :position
|
24
|
-
end
|
25
|
-
|
26
|
-
#validates_associated :library_group, :holding_patron
|
27
|
-
validates_associated :library_group, :patron
|
28
|
-
validates_presence_of :short_display_name, :library_group, :patron
|
29
|
-
validates_uniqueness_of :short_display_name, :case_sensitive => false
|
30
|
-
validates :display_name, :uniqueness => true
|
31
|
-
validates :name, :format => {:with => /^[a-z][0-9a-z]{2,254}$/}
|
32
|
-
before_validation :set_patron, :on => :create
|
33
|
-
#before_save :set_calil_neighborhood_library
|
34
|
-
after_validation :geocode, :if => :address_changed?
|
35
|
-
after_create :create_shelf
|
36
|
-
after_save :clear_all_cache
|
37
|
-
after_destroy :clear_all_cache
|
38
|
-
|
39
|
-
def self.per_page
|
40
|
-
10
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.all_cache
|
44
|
-
if Rails.env == 'production'
|
45
|
-
Rails.cache.fetch('library_all'){Library.all}
|
46
|
-
else
|
47
|
-
Library.all
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def clear_all_cache
|
52
|
-
Rails.cache.delete('library_all')
|
53
|
-
end
|
54
|
-
|
55
|
-
def set_patron
|
56
|
-
self.patron = Patron.new(
|
57
|
-
:full_name => self.name
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
def create_shelf
|
62
|
-
Shelf.create!(:name => "#{self.name}_default", :library => self)
|
63
|
-
end
|
64
|
-
|
65
|
-
def closed?(date)
|
66
|
-
events.closing_days.collect{|c| c.start_at.beginning_of_day}.include?(date.beginning_of_day)
|
67
|
-
end
|
68
|
-
|
69
|
-
def web?
|
70
|
-
return true if self.id == 1
|
71
|
-
false
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.web
|
75
|
-
Library.find(1)
|
76
|
-
end
|
77
|
-
|
78
|
-
def address(locale = I18n.locale)
|
79
|
-
case locale.to_sym
|
80
|
-
when :ja
|
81
|
-
"#{self.region.to_s.localize(locale)}#{self.locality.to_s.localize(locale)}#{self.street.to_s.localize(locale)}"
|
82
|
-
else
|
83
|
-
"#{self.street.to_s.localize(locale)} #{self.locality.to_s.localize(locale)} #{self.region.to_s.localize(locale)}"
|
84
|
-
end
|
85
|
-
rescue
|
86
|
-
nil
|
87
|
-
end
|
88
|
-
|
89
|
-
def address_changed?
|
90
|
-
return true if region_changed? or locality_changed? or street_changed?
|
91
|
-
false
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# == Schema Information
|
96
|
-
#
|
97
|
-
# Table name: libraries
|
98
|
-
#
|
99
|
-
# id :integer not null, primary key
|
100
|
-
# patron_id :integer
|
101
|
-
# patron_type :string(255)
|
102
|
-
# name :string(255) not null
|
103
|
-
# display_name :text
|
104
|
-
# short_display_name :string(255) not null
|
105
|
-
# zip_code :string(255)
|
106
|
-
# street :text
|
107
|
-
# locality :text
|
108
|
-
# region :text
|
109
|
-
# telephone_number_1 :string(255)
|
110
|
-
# telephone_number_2 :string(255)
|
111
|
-
# fax_number :string(255)
|
112
|
-
# note :text
|
113
|
-
# call_number_rows :integer default(1), not null
|
114
|
-
# call_number_delimiter :string(255) default("|"), not null
|
115
|
-
# library_group_id :integer default(1), not null
|
116
|
-
# users_count :integer default(0), not null
|
117
|
-
# position :integer
|
118
|
-
# country_id :integer
|
119
|
-
# created_at :datetime
|
120
|
-
# updated_at :datetime
|
121
|
-
# deleted_at :datetime
|
122
|
-
# opening_hour :text
|
123
|
-
# latitude :float
|
124
|
-
# longitude :float
|
125
|
-
# calil_systemid :string(255)
|
126
|
-
# calil_neighborhood_systemid :text
|
127
|
-
#
|
128
|
-
|
@@ -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
|
-
|