enju_message 0.1.14.pre9 → 0.1.14.pre10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/message_request.rb +4 -4
- data/lib/enju_message/version.rb +1 -1
- data/spec/dummy/app/models/user.rb +4 -37
- data/spec/dummy/db/migrate/001_create_patrons.rb +1 -10
- data/spec/dummy/db/migrate/059_create_libraries.rb +28 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
- 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 +2 -9
- data/spec/dummy/db/migrate/120_create_baskets.rb +12 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -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/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/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.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/20110318183304_add_valid_period_for_new_user_to_user_group.rb +11 -0
- data/spec/dummy/db/migrate/20111201155456_devise_create_users.rb +46 -0
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +12 -0
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +26 -0
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
- data/spec/dummy/db/schema.rb +202 -27
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.fdt → _93.fdt} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.fdx → _93.fdx} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.fnm → _93.fnm} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.frq → _93.frq} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.nrm → _93.nrm} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.prx → _93.prx} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.tii → _93.tii} +0 -0
- data/spec/dummy/solr/data/test/index/{_6n.tis → _93.tis} +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_i1 +0 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/user.rb +34 -9
- data/spec/fixtures/libraries.yml +102 -0
- data/spec/fixtures/library_groups.yml +20 -20
- metadata +71 -47
- data/spec/dummy/app/models/library_group.rb +0 -86
- data/spec/dummy/app/models/patron.rb +0 -167
- data/spec/dummy/app/models/patron_type.rb +0 -19
- data/spec/dummy/app/models/role.rb +0 -8
- data/spec/dummy/app/models/user_group.rb +0 -2
- data/spec/dummy/app/models/user_has_role.rb +0 -4
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +0 -9
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +0 -14
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +0 -52
- data/spec/dummy/db/migrate/20120213092115_add_queue_to_delayed_jobs.rb +0 -9
- data/spec/dummy/solr/data/test/index/segments_dd +0 -0
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.14.
|
4
|
+
version: 0.1.14.pre10
|
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-06-
|
11
|
+
date: 2013-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: enju_core
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.1.0.
|
131
|
+
version: 1.1.0.rc3
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.1.0.
|
138
|
+
version: 1.1.0.rc3
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rspec-rails
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,14 +255,8 @@ files:
|
|
255
255
|
- spec/dummy/app/helpers/application_helper.rb
|
256
256
|
- spec/dummy/app/mailers/notifier.rb
|
257
257
|
- spec/dummy/app/models/ability.rb
|
258
|
-
- spec/dummy/app/models/library_group.rb
|
259
|
-
- spec/dummy/app/models/patron.rb
|
260
|
-
- spec/dummy/app/models/patron_type.rb
|
261
|
-
- spec/dummy/app/models/role.rb
|
262
258
|
- spec/dummy/app/models/setting.rb
|
263
259
|
- spec/dummy/app/models/user.rb
|
264
|
-
- spec/dummy/app/models/user_group.rb
|
265
|
-
- spec/dummy/app/models/user_has_role.rb
|
266
260
|
- spec/dummy/app/views/layouts/application.html.erb
|
267
261
|
- spec/dummy/app/views/page/403.html.erb
|
268
262
|
- spec/dummy/app/views/page/403.mobile.erb
|
@@ -289,23 +283,39 @@ files:
|
|
289
283
|
- spec/dummy/config/locales/en.yml
|
290
284
|
- spec/dummy/config/routes.rb
|
291
285
|
- spec/dummy/config.ru
|
292
|
-
- spec/dummy/db/development.sqlite3
|
293
286
|
- spec/dummy/db/migrate/001_create_patrons.rb
|
287
|
+
- spec/dummy/db/migrate/059_create_libraries.rb
|
288
|
+
- spec/dummy/db/migrate/069_create_shelves.rb
|
289
|
+
- spec/dummy/db/migrate/077_create_user_groups.rb
|
294
290
|
- spec/dummy/db/migrate/080_create_library_groups.rb
|
291
|
+
- spec/dummy/db/migrate/120_create_baskets.rb
|
292
|
+
- spec/dummy/db/migrate/124_create_bookstores.rb
|
293
|
+
- spec/dummy/db/migrate/130_create_request_status_types.rb
|
294
|
+
- spec/dummy/db/migrate/131_create_request_types.rb
|
295
295
|
- spec/dummy/db/migrate/20080905191442_create_patron_types.rb
|
296
|
+
- spec/dummy/db/migrate/20081006090811_create_subscriptions.rb
|
297
|
+
- spec/dummy/db/migrate/20081006093246_create_subscribes.rb
|
298
|
+
- spec/dummy/db/migrate/20081023092436_create_search_engines.rb
|
299
|
+
- spec/dummy/db/migrate/20081025083323_create_countries.rb
|
300
|
+
- spec/dummy/db/migrate/20091202124834_create_versions.rb
|
296
301
|
- spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb
|
297
302
|
- spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb
|
303
|
+
- spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb
|
298
304
|
- spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb
|
299
|
-
- spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb
|
300
305
|
- spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb
|
306
|
+
- spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_patron.rb
|
307
|
+
- spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb
|
301
308
|
- spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb
|
302
309
|
- spec/dummy/db/migrate/20111201121636_create_languages.rb
|
303
310
|
- spec/dummy/db/migrate/20111201121844_create_roles.rb
|
304
|
-
- spec/dummy/db/migrate/
|
305
|
-
- spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb
|
306
|
-
- spec/dummy/db/migrate/20111201163342_create_user_groups.rb
|
311
|
+
- spec/dummy/db/migrate/20111201155456_devise_create_users.rb
|
307
312
|
- spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb
|
308
|
-
- spec/dummy/db/migrate/
|
313
|
+
- spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb
|
314
|
+
- spec/dummy/db/migrate/20120129014038_create_budget_types.rb
|
315
|
+
- spec/dummy/db/migrate/20120319173203_create_accepts.rb
|
316
|
+
- spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb
|
317
|
+
- spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb
|
318
|
+
- spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb
|
309
319
|
- spec/dummy/db/schema.rb
|
310
320
|
- spec/dummy/db/test.sqlite3
|
311
321
|
- spec/dummy/public/404.html
|
@@ -325,22 +335,24 @@ files:
|
|
325
335
|
- spec/dummy/solr/conf/spellings.txt
|
326
336
|
- spec/dummy/solr/conf/stopwords.txt
|
327
337
|
- spec/dummy/solr/conf/synonyms.txt
|
328
|
-
- spec/dummy/solr/data/test/index/
|
329
|
-
- spec/dummy/solr/data/test/index/
|
330
|
-
- spec/dummy/solr/data/test/index/
|
331
|
-
- spec/dummy/solr/data/test/index/
|
332
|
-
- spec/dummy/solr/data/test/index/
|
333
|
-
- spec/dummy/solr/data/test/index/
|
334
|
-
- spec/dummy/solr/data/test/index/
|
335
|
-
- spec/dummy/solr/data/test/index/
|
338
|
+
- spec/dummy/solr/data/test/index/_93.fdt
|
339
|
+
- spec/dummy/solr/data/test/index/_93.fdx
|
340
|
+
- spec/dummy/solr/data/test/index/_93.fnm
|
341
|
+
- spec/dummy/solr/data/test/index/_93.frq
|
342
|
+
- spec/dummy/solr/data/test/index/_93.nrm
|
343
|
+
- spec/dummy/solr/data/test/index/_93.prx
|
344
|
+
- spec/dummy/solr/data/test/index/_93.tii
|
345
|
+
- spec/dummy/solr/data/test/index/_93.tis
|
336
346
|
- spec/dummy/solr/data/test/index/segments.gen
|
337
|
-
- spec/dummy/solr/data/test/index/
|
347
|
+
- spec/dummy/solr/data/test/index/segments_i1
|
338
348
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
339
349
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
350
|
+
- spec/factories/library.rb
|
340
351
|
- spec/factories/message.rb
|
341
352
|
- spec/factories/message_request.rb
|
342
353
|
- spec/factories/message_template.rb
|
343
354
|
- spec/factories/user.rb
|
355
|
+
- spec/fixtures/libraries.yml
|
344
356
|
- spec/fixtures/library_groups.yml
|
345
357
|
- spec/fixtures/message_requests.yml
|
346
358
|
- spec/fixtures/message_templates.yml
|
@@ -375,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
375
387
|
version: 1.3.1
|
376
388
|
requirements: []
|
377
389
|
rubyforge_project:
|
378
|
-
rubygems_version: 2.0.
|
390
|
+
rubygems_version: 2.0.3
|
379
391
|
signing_key:
|
380
392
|
specification_version: 4
|
381
393
|
summary: enju_message plugin
|
@@ -389,14 +401,8 @@ test_files:
|
|
389
401
|
- spec/dummy/app/helpers/application_helper.rb
|
390
402
|
- spec/dummy/app/mailers/notifier.rb
|
391
403
|
- spec/dummy/app/models/ability.rb
|
392
|
-
- spec/dummy/app/models/library_group.rb
|
393
|
-
- spec/dummy/app/models/patron.rb
|
394
|
-
- spec/dummy/app/models/patron_type.rb
|
395
|
-
- spec/dummy/app/models/role.rb
|
396
404
|
- spec/dummy/app/models/setting.rb
|
397
405
|
- spec/dummy/app/models/user.rb
|
398
|
-
- spec/dummy/app/models/user_group.rb
|
399
|
-
- spec/dummy/app/models/user_has_role.rb
|
400
406
|
- spec/dummy/app/views/layouts/application.html.erb
|
401
407
|
- spec/dummy/app/views/page/403.html.erb
|
402
408
|
- spec/dummy/app/views/page/403.mobile.erb
|
@@ -423,23 +429,39 @@ test_files:
|
|
423
429
|
- spec/dummy/config/locales/en.yml
|
424
430
|
- spec/dummy/config/routes.rb
|
425
431
|
- spec/dummy/config.ru
|
426
|
-
- spec/dummy/db/development.sqlite3
|
427
432
|
- spec/dummy/db/migrate/001_create_patrons.rb
|
433
|
+
- spec/dummy/db/migrate/059_create_libraries.rb
|
434
|
+
- spec/dummy/db/migrate/069_create_shelves.rb
|
435
|
+
- spec/dummy/db/migrate/077_create_user_groups.rb
|
428
436
|
- spec/dummy/db/migrate/080_create_library_groups.rb
|
437
|
+
- spec/dummy/db/migrate/120_create_baskets.rb
|
438
|
+
- spec/dummy/db/migrate/124_create_bookstores.rb
|
439
|
+
- spec/dummy/db/migrate/130_create_request_status_types.rb
|
440
|
+
- spec/dummy/db/migrate/131_create_request_types.rb
|
429
441
|
- spec/dummy/db/migrate/20080905191442_create_patron_types.rb
|
442
|
+
- spec/dummy/db/migrate/20081006090811_create_subscriptions.rb
|
443
|
+
- spec/dummy/db/migrate/20081006093246_create_subscribes.rb
|
444
|
+
- spec/dummy/db/migrate/20081023092436_create_search_engines.rb
|
445
|
+
- spec/dummy/db/migrate/20081025083323_create_countries.rb
|
446
|
+
- spec/dummy/db/migrate/20091202124834_create_versions.rb
|
430
447
|
- spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb
|
431
448
|
- spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb
|
449
|
+
- spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb
|
432
450
|
- spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb
|
433
|
-
- spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb
|
434
451
|
- spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb
|
452
|
+
- spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_patron.rb
|
453
|
+
- spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb
|
435
454
|
- spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb
|
436
455
|
- spec/dummy/db/migrate/20111201121636_create_languages.rb
|
437
456
|
- spec/dummy/db/migrate/20111201121844_create_roles.rb
|
438
|
-
- spec/dummy/db/migrate/
|
439
|
-
- spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb
|
440
|
-
- spec/dummy/db/migrate/20111201163342_create_user_groups.rb
|
457
|
+
- spec/dummy/db/migrate/20111201155456_devise_create_users.rb
|
441
458
|
- spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb
|
442
|
-
- spec/dummy/db/migrate/
|
459
|
+
- spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb
|
460
|
+
- spec/dummy/db/migrate/20120129014038_create_budget_types.rb
|
461
|
+
- spec/dummy/db/migrate/20120319173203_create_accepts.rb
|
462
|
+
- spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb
|
463
|
+
- spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb
|
464
|
+
- spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb
|
443
465
|
- spec/dummy/db/schema.rb
|
444
466
|
- spec/dummy/db/test.sqlite3
|
445
467
|
- spec/dummy/public/404.html
|
@@ -459,22 +481,24 @@ test_files:
|
|
459
481
|
- spec/dummy/solr/conf/spellings.txt
|
460
482
|
- spec/dummy/solr/conf/stopwords.txt
|
461
483
|
- spec/dummy/solr/conf/synonyms.txt
|
462
|
-
- spec/dummy/solr/data/test/index/
|
463
|
-
- spec/dummy/solr/data/test/index/
|
464
|
-
- spec/dummy/solr/data/test/index/
|
465
|
-
- spec/dummy/solr/data/test/index/
|
466
|
-
- spec/dummy/solr/data/test/index/
|
467
|
-
- spec/dummy/solr/data/test/index/
|
468
|
-
- spec/dummy/solr/data/test/index/
|
469
|
-
- spec/dummy/solr/data/test/index/
|
484
|
+
- spec/dummy/solr/data/test/index/_93.fdt
|
485
|
+
- spec/dummy/solr/data/test/index/_93.fdx
|
486
|
+
- spec/dummy/solr/data/test/index/_93.fnm
|
487
|
+
- spec/dummy/solr/data/test/index/_93.frq
|
488
|
+
- spec/dummy/solr/data/test/index/_93.nrm
|
489
|
+
- spec/dummy/solr/data/test/index/_93.prx
|
490
|
+
- spec/dummy/solr/data/test/index/_93.tii
|
491
|
+
- spec/dummy/solr/data/test/index/_93.tis
|
470
492
|
- spec/dummy/solr/data/test/index/segments.gen
|
471
|
-
- spec/dummy/solr/data/test/index/
|
493
|
+
- spec/dummy/solr/data/test/index/segments_i1
|
472
494
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
473
495
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
496
|
+
- spec/factories/library.rb
|
474
497
|
- spec/factories/message.rb
|
475
498
|
- spec/factories/message_request.rb
|
476
499
|
- spec/factories/message_template.rb
|
477
500
|
- spec/factories/user.rb
|
501
|
+
- spec/fixtures/libraries.yml
|
478
502
|
- spec/fixtures/library_groups.yml
|
479
503
|
- spec/fixtures/message_requests.yml
|
480
504
|
- spec/fixtures/message_templates.yml
|
@@ -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,167 +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
|
-
|
8
|
-
validates_presence_of :patron_type
|
9
|
-
validates_associated :patron_type
|
10
|
-
validates :full_name, :presence => true, :length => {:maximum => 255}
|
11
|
-
validates :user_id, :uniqueness => true, :allow_nil => true
|
12
|
-
validates :email, :format => {:with => /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i}, :allow_blank => true
|
13
|
-
before_validation :set_role_and_name, :on => :create
|
14
|
-
|
15
|
-
#has_paper_trail
|
16
|
-
attr_accessor :user_username
|
17
|
-
#[:address_1, :address_2].each do |column|
|
18
|
-
# encrypt_with_public_key column,
|
19
|
-
# :key_pair => File.join(Rails.root.to_s,'config','keypair.pem'),
|
20
|
-
# :base64 => true
|
21
|
-
#end
|
22
|
-
|
23
|
-
searchable do
|
24
|
-
text :name, :place, :address_1, :address_2, :other_designation, :note
|
25
|
-
string :zip_code_1
|
26
|
-
string :zip_code_2
|
27
|
-
string :username do
|
28
|
-
user.username if user
|
29
|
-
end
|
30
|
-
time :created_at
|
31
|
-
time :updated_at
|
32
|
-
string :user
|
33
|
-
integer :work_ids, :multiple => true
|
34
|
-
integer :expression_ids, :multiple => true
|
35
|
-
integer :manifestation_ids, :multiple => true
|
36
|
-
integer :patron_merge_list_ids, :multiple => true if defined?(EnjuResourceMerge)
|
37
|
-
integer :original_patron_ids, :multiple => true
|
38
|
-
integer :required_role_id
|
39
|
-
integer :patron_type_id
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.per_page
|
43
|
-
10
|
44
|
-
end
|
45
|
-
|
46
|
-
def full_name_without_space
|
47
|
-
full_name.gsub(/\s/, "")
|
48
|
-
end
|
49
|
-
|
50
|
-
def set_role_and_name
|
51
|
-
self.required_role = Role.where(:name => 'Librarian').first if self.required_role_id.nil?
|
52
|
-
set_full_name
|
53
|
-
end
|
54
|
-
|
55
|
-
def set_full_name
|
56
|
-
if self.full_name.blank?
|
57
|
-
if self.last_name.to_s.strip and self.first_name.to_s.strip and Setting.family_name_first == true
|
58
|
-
self.full_name = [last_name, middle_name, first_name].compact.join(" ").to_s.strip
|
59
|
-
else
|
60
|
-
self.full_name = [first_name, last_name, middle_name].compact.join(" ").to_s.strip
|
61
|
-
end
|
62
|
-
end
|
63
|
-
if self.full_name_transcription.blank?
|
64
|
-
self.full_name_transcription = [last_name_transcription, middle_name_transcription, first_name_transcription].join(" ").to_s.strip
|
65
|
-
end
|
66
|
-
[self.full_name, self.full_name_transcription]
|
67
|
-
end
|
68
|
-
|
69
|
-
def full_name_without_space
|
70
|
-
full_name.gsub(/\s/, "")
|
71
|
-
# # TODO: 日本人以外は?
|
72
|
-
# name = []
|
73
|
-
# name << self.last_name.to_s.strip
|
74
|
-
# name << self.middle_name.to_s.strip
|
75
|
-
# name << self.first_name.to_s.strip
|
76
|
-
# name << self.corporate_name.to_s.strip
|
77
|
-
# name.join("").strip
|
78
|
-
end
|
79
|
-
|
80
|
-
def full_name_transcription_without_space
|
81
|
-
full_name_transcription.to_s.gsub(/\s/, "")
|
82
|
-
end
|
83
|
-
|
84
|
-
def full_name_alternative_without_space
|
85
|
-
full_name_alternative.to_s.gsub(/\s/, "")
|
86
|
-
end
|
87
|
-
|
88
|
-
def name
|
89
|
-
name = []
|
90
|
-
name << full_name.to_s.strip
|
91
|
-
name << full_name_transcription.to_s.strip
|
92
|
-
name << full_name_alternative.to_s.strip
|
93
|
-
#name << full_name_without_space
|
94
|
-
#name << full_name_transcription_without_space
|
95
|
-
#name << full_name_alternative_without_space
|
96
|
-
#name << full_name.wakati rescue nil
|
97
|
-
#name << full_name_transcription.wakati rescue nil
|
98
|
-
#name << full_name_alternative.wakati rescue nil
|
99
|
-
name
|
100
|
-
end
|
101
|
-
|
102
|
-
def date
|
103
|
-
if date_of_birth
|
104
|
-
if date_of_death
|
105
|
-
"#{date_of_birth} - #{date_of_death}"
|
106
|
-
else
|
107
|
-
"#{date_of_birth} -"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def creator?(resource)
|
113
|
-
resource.creators.include?(self)
|
114
|
-
end
|
115
|
-
|
116
|
-
def publisher?(resource)
|
117
|
-
resource.publishers.include?(self)
|
118
|
-
end
|
119
|
-
|
120
|
-
def check_required_role(user)
|
121
|
-
return true if self.user.blank?
|
122
|
-
return true if self.user.required_role.name == 'Guest'
|
123
|
-
return true if user == self.user
|
124
|
-
return true if user.has_role?(self.user.required_role.name)
|
125
|
-
false
|
126
|
-
rescue NoMethodError
|
127
|
-
false
|
128
|
-
end
|
129
|
-
|
130
|
-
def created(work)
|
131
|
-
creates.where(:work_id => work.id).first
|
132
|
-
end
|
133
|
-
|
134
|
-
def realized(expression)
|
135
|
-
realizes.where(:expression_id => expression.id).first
|
136
|
-
end
|
137
|
-
|
138
|
-
def produced(manifestation)
|
139
|
-
produces.where(:manifestation_id => manifestation.id).first
|
140
|
-
end
|
141
|
-
|
142
|
-
def owned(item)
|
143
|
-
owns.where(:item_id => item.id)
|
144
|
-
end
|
145
|
-
|
146
|
-
def self.import_patrons(patron_lists)
|
147
|
-
list = []
|
148
|
-
patron_lists.each do |patron_list|
|
149
|
-
patron = Patron.where(:full_name => patron_list[:full_name]).first
|
150
|
-
unless patron
|
151
|
-
patron = Patron.new(
|
152
|
-
:full_name => patron_list[:full_name],
|
153
|
-
:full_name_transcription => patron_list[:full_name_transcription],
|
154
|
-
:language_id => 1
|
155
|
-
)
|
156
|
-
patron.required_role = Role.where(:name => 'Guest').first
|
157
|
-
patron.save
|
158
|
-
end
|
159
|
-
list << patron
|
160
|
-
end
|
161
|
-
list
|
162
|
-
end
|
163
|
-
|
164
|
-
def patrons
|
165
|
-
self.original_patrons + self.derived_patrons
|
166
|
-
end
|
167
|
-
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
|
-
|
Binary file
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class CreateUsers < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :users do |t|
|
4
|
-
t.integer :user_group_id
|
5
|
-
t.integer :required_role_id
|
6
|
-
t.string :username
|
7
|
-
t.text :note
|
8
|
-
t.string :locale
|
9
|
-
t.string :user_number
|
10
|
-
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class AddDeviseToUsers < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
change_table(:users) do |t|
|
4
|
-
## Database authenticatable
|
5
|
-
t.string :email, :null => false, :default => ""
|
6
|
-
t.string :encrypted_password, :null => false, :default => ""
|
7
|
-
|
8
|
-
## Recoverable
|
9
|
-
t.string :reset_password_token
|
10
|
-
t.datetime :reset_password_sent_at
|
11
|
-
|
12
|
-
## Rememberable
|
13
|
-
t.datetime :remember_created_at
|
14
|
-
|
15
|
-
## Trackable
|
16
|
-
t.integer :sign_in_count, :default => 0
|
17
|
-
t.datetime :current_sign_in_at
|
18
|
-
t.datetime :last_sign_in_at
|
19
|
-
t.string :current_sign_in_ip
|
20
|
-
t.string :last_sign_in_ip
|
21
|
-
|
22
|
-
## Encryptable
|
23
|
-
t.string :password_salt
|
24
|
-
|
25
|
-
## Confirmable
|
26
|
-
t.string :confirmation_token
|
27
|
-
t.datetime :confirmed_at
|
28
|
-
t.datetime :confirmation_sent_at
|
29
|
-
t.string :unconfirmed_email # Only if using reconfirmable
|
30
|
-
|
31
|
-
## Lockable
|
32
|
-
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
33
|
-
t.string :unlock_token # Only if unlock strategy is :email or :both
|
34
|
-
t.datetime :locked_at
|
35
|
-
|
36
|
-
# Token authenticatable
|
37
|
-
t.string :authentication_token
|
38
|
-
end
|
39
|
-
|
40
|
-
add_index :users, :email #, :unique => true
|
41
|
-
add_index :users, :reset_password_token, :unique => true
|
42
|
-
# add_index :users, :confirmation_token, :unique => true
|
43
|
-
# add_index :users, :unlock_token, :unique => true
|
44
|
-
# add_index :users, :authentication_token, :unique => true
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.down
|
48
|
-
# By default, we don't want to make any assumption about how to roll back a migration when your
|
49
|
-
# model already existed. Please edit below which fields you would like to remove in this migration.
|
50
|
-
raise ActiveRecord::IrreversibleMigration
|
51
|
-
end
|
52
|
-
end
|
Binary file
|