enju_oai 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/enju_oai/engine.rb +1 -8
- data/lib/enju_oai/version.rb +1 -1
- data/spec/controllers/manifestations_controller_spec.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/initializers/devise.rb +0 -4
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +0 -1
- data/spec/dummy/db/migrate/005_create_manifestations.rb +0 -3
- data/spec/dummy/db/migrate/012_create_owns.rb +0 -2
- data/spec/dummy/db/migrate/015_create_creates.rb +0 -2
- data/spec/dummy/db/migrate/047_create_produces.rb +0 -2
- data/spec/dummy/db/migrate/059_create_libraries.rb +1 -3
- data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +0 -1
- 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 +0 -2
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +0 -2
- 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/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/20091012101112_add_dcndl_schema.rb +27 -0
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +13 -0
- 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/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -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/20110425133109_add_issn_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.rb +9 -0
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.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 +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/20111009183423_add_ndc_to_manifestation.rb +9 -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/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/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20120511072422_add_patron_identifier_to_patron.rb +6 -0
- data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_patron_import_file.rb +5 -0
- data/spec/dummy/db/schema.rb +288 -43
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +250 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/test/index/_c.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_c.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_c.fnm +7 -0
- data/spec/dummy/solr/data/test/index/_c.frq +0 -0
- data/spec/dummy/solr/data/test/index/_c.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_c.prx +0 -0
- data/spec/dummy/solr/data/test/index/_c.tii +0 -0
- data/spec/dummy/solr/data/test/index/_c.tis +0 -0
- data/spec/dummy/solr/data/test/index/_d.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_d.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_d.fnm +7 -0
- data/spec/dummy/solr/data/test/index/_d.frq +0 -0
- data/spec/dummy/solr/data/test/index/_d.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_d.prx +0 -0
- data/spec/dummy/solr/data/test/index/_d.tii +0 -0
- data/spec/dummy/solr/data/test/index/_d.tis +0 -0
- data/spec/dummy/solr/data/test/index/_e.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_e.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_e.fnm +7 -0
- data/spec/dummy/solr/data/test/index/_e.frq +0 -0
- data/spec/dummy/solr/data/test/index/_e.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_e.prx +0 -0
- data/spec/dummy/solr/data/test/index/_e.tii +0 -0
- data/spec/dummy/solr/data/test/index/_e.tis +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1p +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/factories/user.rb +6 -3
- data/spec/fixtures/bookstores.yml +107 -0
- data/spec/fixtures/budget_types.yml +29 -0
- data/spec/fixtures/content_types.yml +36 -0
- data/spec/fixtures/countries.yml +2059 -0
- data/spec/fixtures/create_types.yml +47 -0
- data/spec/fixtures/creates.yml +2 -3
- data/spec/fixtures/donates.yml +31 -0
- data/spec/fixtures/exemplifies.yml +8 -3
- data/spec/fixtures/extents.yml +29 -0
- data/spec/fixtures/form_of_works.yml +39 -0
- data/spec/fixtures/frequencies.yml +85 -0
- data/spec/fixtures/import_requests.yml +27 -0
- data/spec/fixtures/items.yml +0 -5
- data/spec/fixtures/languages.yml +1901 -0
- data/spec/fixtures/libraries.yml +25 -32
- data/spec/fixtures/library_groups.yml +2 -5
- data/spec/fixtures/licenses.yml +29 -0
- data/spec/fixtures/manifestation_relationship_types.yml +29 -0
- data/spec/fixtures/manifestation_relationships.yml +30 -0
- data/spec/fixtures/manifestations.yml +9 -13
- data/spec/fixtures/medium_of_performances.yml +29 -0
- data/spec/fixtures/owns.yml +26 -0
- data/spec/fixtures/patron_import_files.yml +47 -0
- data/spec/fixtures/patron_import_results.yml +29 -0
- data/spec/fixtures/patron_relationship_types.yml +34 -0
- data/spec/fixtures/patron_relationships.yml +25 -0
- data/spec/fixtures/patron_types.yml +0 -6
- data/spec/fixtures/patrons.yml +3 -3
- data/spec/fixtures/picture_files.yml +63 -0
- data/spec/fixtures/produce_types.yml +31 -0
- data/spec/fixtures/produces.yml +2 -3
- data/spec/fixtures/realize_types.yml +39 -0
- data/spec/fixtures/realizes.yml +2 -3
- data/spec/fixtures/request_status_types.yml +63 -0
- data/spec/fixtures/request_types.yml +55 -0
- data/spec/fixtures/resource_import_files.yml +47 -0
- data/spec/fixtures/resource_import_results.yml +29 -0
- data/spec/fixtures/series_has_manifestations.yml +35 -0
- data/spec/fixtures/series_statements.yml +45 -0
- data/spec/fixtures/shelves.yml +47 -0
- data/spec/fixtures/user_groups.yml +51 -0
- data/spec/spec_helper.rb +13 -0
- metadata +244 -116
- data/spec/dummy/app/models/carrier_type.rb +0 -33
- data/spec/dummy/app/models/create.rb +0 -38
- data/spec/dummy/app/models/exemplify.rb +0 -45
- data/spec/dummy/app/models/item.rb +0 -276
- data/spec/dummy/app/models/manifestation.rb +0 -631
- data/spec/dummy/app/models/patron.rb +0 -290
- data/spec/dummy/app/models/produce.rb +0 -39
- data/spec/dummy/app/models/realize.rb +0 -38
- data/spec/dummy/app/models/search_engine.rb +0 -51
- data/spec/dummy/db/migrate/20101228081401_rename_postal_code_to_zip_code.rb +0 -11
- data/spec/dummy/lib/enju_leaf/calculate_stat.rb +0 -30
- data/spec/dummy/lib/enju_leaf/expire_editable_fragment.rb +0 -30
- data/spec/dummy/lib/enju_leaf/expire_fragment_cache.rb +0 -17
- data/spec/dummy/lib/enju_leaf/import_file.rb +0 -13
- data/spec/dummy/lib/enju_leaf/localized_name.rb +0 -13
- data/spec/dummy/lib/enju_leaf/master_model.rb +0 -19
- data/spec/dummy/lib/enju_leaf/url_validator.rb +0 -10
@@ -1,290 +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
|
-
has_many :creates, :dependent => :destroy
|
5
|
-
has_many :works, :through => :creates
|
6
|
-
has_many :realizes, :dependent => :destroy
|
7
|
-
has_many :expressions, :through => :realizes
|
8
|
-
has_many :produces, :dependent => :destroy
|
9
|
-
has_many :manifestations, :through => :produces
|
10
|
-
has_many :children, :foreign_key => 'parent_id', :class_name => 'PatronRelationship', :dependent => :destroy
|
11
|
-
has_many :parents, :foreign_key => 'child_id', :class_name => 'PatronRelationship', :dependent => :destroy
|
12
|
-
has_many :derived_patrons, :through => :children, :source => :child
|
13
|
-
has_many :original_patrons, :through => :parents, :source => :parent
|
14
|
-
has_many :picture_files, :as => :picture_attachable, :dependent => :destroy
|
15
|
-
has_many :donates
|
16
|
-
has_many :donated_items, :through => :donates, :source => :item
|
17
|
-
has_many :owns, :dependent => :destroy
|
18
|
-
has_many :items, :through => :owns
|
19
|
-
if defined?(EnjuResourceMerge)
|
20
|
-
has_many :patron_merges, :dependent => :destroy
|
21
|
-
has_many :patron_merge_lists, :through => :patron_merges
|
22
|
-
end
|
23
|
-
#belongs_to :user
|
24
|
-
belongs_to :patron_type
|
25
|
-
belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id', :validate => true
|
26
|
-
belongs_to :language
|
27
|
-
belongs_to :country
|
28
|
-
has_one :patron_import_result
|
29
|
-
|
30
|
-
validates_presence_of :language, :patron_type, :country
|
31
|
-
validates_associated :language, :patron_type, :country
|
32
|
-
validates :full_name, :presence => true, :length => {:maximum => 255}
|
33
|
-
#validates :user_id, :uniqueness => true, :allow_nil => true
|
34
|
-
validates :birth_date, :format => {:with => /^\d+(-\d{0,2}){0,2}$/}, :allow_blank => true
|
35
|
-
validates :death_date, :format => {:with => /^\d+(-\d{0,2}){0,2}$/}, :allow_blank => true
|
36
|
-
validates :email, :format => {:with => /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i}, :allow_blank => true
|
37
|
-
validate :check_birth_date
|
38
|
-
before_validation :set_role_and_name, :on => :create
|
39
|
-
before_save :set_date_of_birth, :set_date_of_death
|
40
|
-
|
41
|
-
searchable do
|
42
|
-
text :name, :place, :address_1, :address_2, :other_designation, :note
|
43
|
-
string :zip_code_1
|
44
|
-
string :zip_code_2
|
45
|
-
#string :username do
|
46
|
-
# user.username if user
|
47
|
-
#end
|
48
|
-
time :created_at
|
49
|
-
time :updated_at
|
50
|
-
time :date_of_birth
|
51
|
-
time :date_of_death
|
52
|
-
#string :user
|
53
|
-
integer :work_ids, :multiple => true
|
54
|
-
integer :expression_ids, :multiple => true
|
55
|
-
integer :manifestation_ids, :multiple => true
|
56
|
-
integer :patron_merge_list_ids, :multiple => true if defined?(EnjuResourceMerge)
|
57
|
-
integer :original_patron_ids, :multiple => true
|
58
|
-
integer :required_role_id
|
59
|
-
integer :patron_type_id
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.per_page
|
63
|
-
10
|
64
|
-
end
|
65
|
-
|
66
|
-
def set_role_and_name
|
67
|
-
self.required_role = Role.where(:name => 'Librarian').first if self.required_role_id.nil?
|
68
|
-
set_full_name
|
69
|
-
end
|
70
|
-
|
71
|
-
def set_full_name
|
72
|
-
if self.full_name.blank?
|
73
|
-
if self.last_name.to_s.strip and self.first_name.to_s.strip and configatron.family_name_first == true
|
74
|
-
self.full_name = [last_name, middle_name, first_name].compact.join(" ").to_s.strip
|
75
|
-
else
|
76
|
-
self.full_name = [first_name, last_name, middle_name].compact.join(" ").to_s.strip
|
77
|
-
end
|
78
|
-
end
|
79
|
-
if self.full_name_transcription.blank?
|
80
|
-
self.full_name_transcription = [last_name_transcription, middle_name_transcription, first_name_transcription].join(" ").to_s.strip
|
81
|
-
end
|
82
|
-
[self.full_name, self.full_name_transcription]
|
83
|
-
end
|
84
|
-
|
85
|
-
def set_date_of_birth
|
86
|
-
return if birth_date.blank?
|
87
|
-
begin
|
88
|
-
date = Time.zone.parse("#{birth_date}")
|
89
|
-
rescue ArgumentError
|
90
|
-
begin
|
91
|
-
date = Time.zone.parse("#{birth_date}-01")
|
92
|
-
rescue ArgumentError
|
93
|
-
begin
|
94
|
-
date = Time.zone.parse("#{birth_date}-01-01")
|
95
|
-
rescue
|
96
|
-
nil
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
self.date_of_birth = date
|
101
|
-
end
|
102
|
-
|
103
|
-
def set_date_of_death
|
104
|
-
return if death_date.blank?
|
105
|
-
begin
|
106
|
-
date = Time.zone.parse("#{death_date}")
|
107
|
-
rescue ArgumentError
|
108
|
-
begin
|
109
|
-
date = Time.zone.parse("#{death_date}-01")
|
110
|
-
rescue ArgumentError
|
111
|
-
begin
|
112
|
-
date = Time.zone.parse("#{death_date}-01-01")
|
113
|
-
rescue
|
114
|
-
nil
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
self.date_of_death = date
|
120
|
-
end
|
121
|
-
|
122
|
-
def check_birth_date
|
123
|
-
if date_of_birth.present? and date_of_death.present?
|
124
|
-
if date_of_birth > date_of_death
|
125
|
-
errors.add(:birth_date)
|
126
|
-
errors.add(:death_date)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
#def full_name_generate
|
132
|
-
# # TODO: 日本人以外は?
|
133
|
-
# name = []
|
134
|
-
# name << self.last_name.to_s.strip
|
135
|
-
# name << self.middle_name.to_s.strip unless self.middle_name.blank?
|
136
|
-
# name << self.first_name.to_s.strip
|
137
|
-
# name << self.corporate_name.to_s.strip
|
138
|
-
# name.join(" ").strip
|
139
|
-
#end
|
140
|
-
|
141
|
-
def full_name_without_space
|
142
|
-
full_name.gsub(/[\s,]/, "")
|
143
|
-
# # TODO: 日本人以外は?
|
144
|
-
# name = []
|
145
|
-
# name << self.last_name.to_s.strip
|
146
|
-
# name << self.middle_name.to_s.strip
|
147
|
-
# name << self.first_name.to_s.strip
|
148
|
-
# name << self.corporate_name.to_s.strip
|
149
|
-
# name.join("").strip
|
150
|
-
end
|
151
|
-
|
152
|
-
def full_name_transcription_without_space
|
153
|
-
full_name_transcription.to_s.gsub(/\s/, "")
|
154
|
-
end
|
155
|
-
|
156
|
-
def full_name_alternative_without_space
|
157
|
-
full_name_alternative.to_s.gsub(/\s/, "")
|
158
|
-
end
|
159
|
-
|
160
|
-
def name
|
161
|
-
name = []
|
162
|
-
name << full_name.to_s.strip
|
163
|
-
name << full_name_transcription.to_s.strip
|
164
|
-
name << full_name_alternative.to_s.strip
|
165
|
-
name << full_name_without_space
|
166
|
-
#name << full_name_transcription_without_space
|
167
|
-
#name << full_name_alternative_without_space
|
168
|
-
#name << full_name.wakati rescue nil
|
169
|
-
#name << full_name_transcription.wakati rescue nil
|
170
|
-
#name << full_name_alternative.wakati rescue nil
|
171
|
-
name
|
172
|
-
end
|
173
|
-
|
174
|
-
def date
|
175
|
-
if date_of_birth
|
176
|
-
if date_of_death
|
177
|
-
"#{date_of_birth} - #{date_of_death}"
|
178
|
-
else
|
179
|
-
"#{date_of_birth} -"
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def creator?(resource)
|
185
|
-
resource.creators.include?(self)
|
186
|
-
end
|
187
|
-
|
188
|
-
def publisher?(resource)
|
189
|
-
resource.publishers.include?(self)
|
190
|
-
end
|
191
|
-
|
192
|
-
def created(work)
|
193
|
-
creates.where(:work_id => work.id).first
|
194
|
-
end
|
195
|
-
|
196
|
-
def realized(expression)
|
197
|
-
realizes.where(:expression_id => expression.id).first
|
198
|
-
end
|
199
|
-
|
200
|
-
def produced(manifestation)
|
201
|
-
produces.where(:manifestation_id => manifestation.id).first
|
202
|
-
end
|
203
|
-
|
204
|
-
def owned(item)
|
205
|
-
owns.where(:item_id => item.id)
|
206
|
-
end
|
207
|
-
|
208
|
-
def self.import_patrons(patron_lists)
|
209
|
-
patrons = []
|
210
|
-
patron_lists.each do |patron_list|
|
211
|
-
name_and_role = patron_list[:full_name].split('||')
|
212
|
-
patron = Patron.where(:full_name => name_and_role[0]).first
|
213
|
-
role_type = name_and_role[1].to_s.strip
|
214
|
-
unless patron
|
215
|
-
patron = Patron.new(
|
216
|
-
:full_name => name_and_role[0],
|
217
|
-
:full_name_transcription => patron_list[:full_name_transcription],
|
218
|
-
:language_id => 1
|
219
|
-
)
|
220
|
-
patron.required_role = Role.where(:name => 'Guest').first
|
221
|
-
patron.save
|
222
|
-
end
|
223
|
-
patrons << patron
|
224
|
-
end
|
225
|
-
patrons
|
226
|
-
end
|
227
|
-
|
228
|
-
def patrons
|
229
|
-
self.original_patrons + self.derived_patrons
|
230
|
-
end
|
231
|
-
|
232
|
-
def user
|
233
|
-
# TODO: 外部サービスから取得する
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
|
238
|
-
# == Schema Information
|
239
|
-
#
|
240
|
-
# Table name: patrons
|
241
|
-
#
|
242
|
-
# id :integer not null, primary key
|
243
|
-
# user_id :integer
|
244
|
-
# last_name :string(255)
|
245
|
-
# middle_name :string(255)
|
246
|
-
# first_name :string(255)
|
247
|
-
# last_name_transcription :string(255)
|
248
|
-
# middle_name_transcription :string(255)
|
249
|
-
# first_name_transcription :string(255)
|
250
|
-
# corporate_name :string(255)
|
251
|
-
# corporate_name_transcription :string(255)
|
252
|
-
# full_name :string(255)
|
253
|
-
# full_name_transcription :text
|
254
|
-
# full_name_alternative :text
|
255
|
-
# created_at :datetime
|
256
|
-
# updated_at :datetime
|
257
|
-
# deleted_at :datetime
|
258
|
-
# zip_code_1 :string(255)
|
259
|
-
# zip_code_2 :string(255)
|
260
|
-
# address_1 :text
|
261
|
-
# address_2 :text
|
262
|
-
# address_1_note :text
|
263
|
-
# address_2_note :text
|
264
|
-
# telephone_number_1 :string(255)
|
265
|
-
# telephone_number_2 :string(255)
|
266
|
-
# fax_number_1 :string(255)
|
267
|
-
# fax_number_2 :string(255)
|
268
|
-
# other_designation :text
|
269
|
-
# place :text
|
270
|
-
# street :text
|
271
|
-
# locality :text
|
272
|
-
# region :text
|
273
|
-
# date_of_birth :datetime
|
274
|
-
# date_of_death :datetime
|
275
|
-
# language_id :integer default(1), not null
|
276
|
-
# country_id :integer default(1), not null
|
277
|
-
# patron_type_id :integer default(1), not null
|
278
|
-
# lock_version :integer default(0), not null
|
279
|
-
# note :text
|
280
|
-
# required_role_id :integer default(1), not null
|
281
|
-
# required_score :integer default(0), not null
|
282
|
-
# state :string(255)
|
283
|
-
# email :text
|
284
|
-
# url :text
|
285
|
-
# full_name_alternative_transcription :text
|
286
|
-
# title :string(255)
|
287
|
-
# birth_date :string(255)
|
288
|
-
# death_date :string(255)
|
289
|
-
#
|
290
|
-
|
@@ -1,39 +0,0 @@
|
|
1
|
-
class Produce < ActiveRecord::Base
|
2
|
-
belongs_to :patron
|
3
|
-
belongs_to :manifestation
|
4
|
-
belongs_to :produce_type
|
5
|
-
delegate :original_title, :to => :manifestation, :prefix => true
|
6
|
-
|
7
|
-
validates_associated :patron, :manifestation
|
8
|
-
validates_presence_of :patron, :manifestation
|
9
|
-
validates_uniqueness_of :manifestation_id, :scope => :patron_id
|
10
|
-
after_save :reindex
|
11
|
-
after_destroy :reindex
|
12
|
-
|
13
|
-
acts_as_list :scope => :manifestation
|
14
|
-
|
15
|
-
def self.per_page
|
16
|
-
10
|
17
|
-
end
|
18
|
-
|
19
|
-
def reindex
|
20
|
-
patron.try(:index)
|
21
|
-
manifestation.try(:index)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# == Schema Information
|
27
|
-
#
|
28
|
-
# Table name: produces
|
29
|
-
#
|
30
|
-
# id :integer not null, primary key
|
31
|
-
# patron_id :integer not null
|
32
|
-
# manifestation_id :integer not null
|
33
|
-
# position :integer
|
34
|
-
# type :string(255)
|
35
|
-
# created_at :datetime
|
36
|
-
# updated_at :datetime
|
37
|
-
# produce_type_id :integer
|
38
|
-
#
|
39
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
class Realize < ActiveRecord::Base
|
2
|
-
belongs_to :patron
|
3
|
-
belongs_to :expression, :class_name => 'Manifestation', :foreign_key => 'expression_id'
|
4
|
-
belongs_to :realize_type
|
5
|
-
|
6
|
-
validates_associated :patron, :expression
|
7
|
-
validates_presence_of :patron, :expression
|
8
|
-
validates_uniqueness_of :expression_id, :scope => :patron_id
|
9
|
-
after_save :reindex
|
10
|
-
after_destroy :reindex
|
11
|
-
|
12
|
-
acts_as_list :scope => :expression
|
13
|
-
|
14
|
-
def self.per_page
|
15
|
-
10
|
16
|
-
end
|
17
|
-
|
18
|
-
def reindex
|
19
|
-
patron.try(:index)
|
20
|
-
expression.try(:index)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
# == Schema Information
|
26
|
-
#
|
27
|
-
# Table name: realizes
|
28
|
-
#
|
29
|
-
# id :integer not null, primary key
|
30
|
-
# patron_id :integer not null
|
31
|
-
# expression_id :integer not null
|
32
|
-
# position :integer
|
33
|
-
# type :string(255)
|
34
|
-
# created_at :datetime
|
35
|
-
# updated_at :datetime
|
36
|
-
# realize_type_id :integer
|
37
|
-
#
|
38
|
-
|
@@ -1,51 +0,0 @@
|
|
1
|
-
class SearchEngine < ActiveRecord::Base
|
2
|
-
default_scope :order => "position"
|
3
|
-
belongs_to :library_group, :validate => true
|
4
|
-
acts_as_list
|
5
|
-
|
6
|
-
validates :name, :presence => true
|
7
|
-
validates :query_param, :presence => true
|
8
|
-
validates :http_method, :presence => true, :inclusion => %w(get post)
|
9
|
-
validates :url, :presence => true, :url => true, :length => {:maximum => 255}
|
10
|
-
validates :base_url, :presence => true, :url => true, :length => {:maximum => 255}
|
11
|
-
after_save :clear_all_cache
|
12
|
-
after_destroy :clear_all_cache
|
13
|
-
|
14
|
-
def self.per_page
|
15
|
-
10
|
16
|
-
end
|
17
|
-
|
18
|
-
def clear_all_cache
|
19
|
-
Rails.cache.delete('search_engine_all')
|
20
|
-
end
|
21
|
-
|
22
|
-
def search_params(query)
|
23
|
-
params = {}
|
24
|
-
if self.additional_param
|
25
|
-
self.additional_param.gsub('{query}', query).to_s.split.each do |param|
|
26
|
-
p = param.split("=")
|
27
|
-
params[p[0].to_sym] = p[1]
|
28
|
-
end
|
29
|
-
return params
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# == Schema Information
|
35
|
-
#
|
36
|
-
# Table name: search_engines
|
37
|
-
#
|
38
|
-
# id :integer not null, primary key
|
39
|
-
# name :string(255) not null
|
40
|
-
# display_name :text
|
41
|
-
# url :string(255) not null
|
42
|
-
# base_url :text not null
|
43
|
-
# http_method :text not null
|
44
|
-
# query_param :text not null
|
45
|
-
# additional_param :text
|
46
|
-
# note :text
|
47
|
-
# position :integer
|
48
|
-
# created_at :datetime
|
49
|
-
# updated_at :datetime
|
50
|
-
#
|
51
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class RenamePostalCodeToZipCode < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
remove_column :patrons, :postal_code
|
4
|
-
rename_column :libraries, :postal_code, :zip_code
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.down
|
8
|
-
add_column :patrons, :postal_code, :string
|
9
|
-
rename_column :libraries, :zip_code, :postal_code
|
10
|
-
end
|
11
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module CalculateStat
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
base.send :include, InstanceMethods
|
6
|
-
base.class_eval do
|
7
|
-
validates_presence_of :start_date, :end_date
|
8
|
-
validate :check_date
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module ClassMethods
|
13
|
-
def calculate_stat
|
14
|
-
self.not_calculated.each do |stat|
|
15
|
-
stat.aasm_calculate!
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module InstanceMethods
|
21
|
-
def check_date
|
22
|
-
if self.start_date and self.end_date
|
23
|
-
if self.start_date >= self.end_date
|
24
|
-
errors.add(:start_date)
|
25
|
-
errors.add(:end_date)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module ExpireEditableFragment
|
2
|
-
def expire_editable_fragment(record, fragments = [])
|
3
|
-
fragments.uniq!
|
4
|
-
if record.is_a?(Manifestation)
|
5
|
-
if fragments.empty?
|
6
|
-
fragments = %w[manifestation_html show_detail_user_html show_detail_librarian_html pickup_html title_html title_mobile index_sru]
|
7
|
-
end
|
8
|
-
expire_manifestation_cache(record, fragments)
|
9
|
-
else
|
10
|
-
I18n.available_locales.each do |locale|
|
11
|
-
Role.all_cache.each do |role|
|
12
|
-
fragments.each do |fragment|
|
13
|
-
expire_fragment(":#{record.class.to_s.downcase}" => record.id, :fragment => fragment, :role => role.name, :locale => locale)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def expire_manifestation_cache(manifestation, fragments = [])
|
22
|
-
I18n.available_locales.each do |locale|
|
23
|
-
Role.all_cache.each do |role|
|
24
|
-
fragments.uniq.each do |fragment|
|
25
|
-
expire_fragment([:manifestation => manifestation.id, :fragment => fragment, :role => role.name, :locale => locale])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class ExpireFragmentCache
|
2
|
-
def self.expire_fragment_cache(record, fragments = [])
|
3
|
-
if record.is_a?(Manifestation)
|
4
|
-
if fragments.empty?
|
5
|
-
fragments = %w[manifestation_html show_detail_user_html show_detail_librarian_html pickup_html title_html title_mobile index_sru]
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
I18n.available_locales.each do |locale|
|
10
|
-
Role.all_cache.each do |role|
|
11
|
-
fragments.each do |fragment|
|
12
|
-
Rails.cache.clear([":#{record.class.to_s.downcase}" => record.id, :fragment => fragment, :role => role.name, :locale => locale])
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module LocalizedName
|
2
|
-
def localize(locale = I18n.locale.to_s)
|
3
|
-
values = Hash[*self.strip.split("\n").map{|n| n.split(':', 2)}.flatten]
|
4
|
-
name = values[locale.to_s] || self
|
5
|
-
name.strip
|
6
|
-
rescue ArgumentError
|
7
|
-
self
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class String
|
12
|
-
include LocalizedName
|
13
|
-
end
|
@@ -1,19 +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 = "#{I18n.locale}: #{self.name}" if self.display_name.blank?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|