enju_event 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/app/views/event_categories/index.html.erb +1 -1
  2. data/app/views/event_import_files/index.html.erb +1 -1
  3. data/app/views/event_import_results/index.html.erb +1 -1
  4. data/app/views/events/index.html.erb +1 -1
  5. data/app/views/participates/index.html.erb +1 -1
  6. data/config/routes.rb +3 -0
  7. data/lib/enju_event/engine.rb +1 -8
  8. data/lib/enju_event/version.rb +1 -1
  9. data/spec/dummy/app/models/role.rb +39 -1
  10. data/spec/dummy/app/models/user.rb +61 -10
  11. data/spec/dummy/app/models/user_group.rb +38 -0
  12. data/spec/dummy/app/models/user_has_role.rb +1 -0
  13. data/spec/dummy/config/application.rb +3 -1
  14. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  15. data/spec/dummy/db/migrate/001_create_patrons.rb +1 -10
  16. data/spec/dummy/db/migrate/005_create_manifestations.rb +56 -0
  17. data/spec/dummy/db/migrate/006_create_items.rb +28 -0
  18. data/spec/dummy/db/migrate/012_create_owns.rb +12 -0
  19. data/spec/dummy/db/migrate/015_create_creates.rb +12 -0
  20. data/spec/dummy/db/migrate/047_create_produces.rb +12 -0
  21. data/spec/dummy/db/migrate/073_create_carrier_types.rb +11 -0
  22. data/spec/dummy/db/migrate/112_create_frequencies.rb +12 -0
  23. data/spec/dummy/db/migrate/117_create_form_of_works.rb +12 -0
  24. data/spec/dummy/db/migrate/125_create_donates.rb +12 -0
  25. data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +13 -0
  26. data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +13 -0
  27. data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +1 -5
  28. data/spec/dummy/db/migrate/20081025083905_create_languages.rb +1 -5
  29. data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +15 -0
  30. data/spec/dummy/db/migrate/20081028083142_create_patron_import_files.rb +22 -0
  31. data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +22 -0
  32. data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +15 -0
  33. data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +15 -0
  34. data/spec/dummy/db/migrate/20090719201843_create_extents.rb +12 -0
  35. data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +12 -0
  36. data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +12 -0
  37. data/spec/dummy/db/migrate/20090812151902_create_patron_relationship_types.rb +12 -0
  38. data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +27 -0
  39. data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +12 -0
  40. data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
  41. data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +13 -0
  42. data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +15 -0
  43. data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +13 -0
  44. data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -0
  45. data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +13 -0
  46. data/spec/dummy/db/migrate/20100606073747_create_patron_relationships.rb +13 -0
  47. data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +12 -0
  48. data/spec/dummy/db/migrate/20100814091104_add_position_to_patron_relationship.rb +11 -0
  49. data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +15 -0
  50. data/spec/dummy/db/migrate/20100925074559_create_patron_import_results.rb +12 -0
  51. data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +9 -0
  52. data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +9 -0
  53. data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_patron.rb +11 -0
  54. data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +9 -0
  55. data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +9 -0
  56. data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +9 -0
  57. data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +11 -0
  58. data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +9 -0
  59. data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +12 -0
  60. data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +13 -0
  61. data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +13 -0
  62. data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +13 -0
  63. data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +10 -0
  64. data/spec/dummy/db/migrate/20110918161853_rename_series_statement_manifestation_id_to_root_manifestation_id.rb +13 -0
  65. data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +9 -0
  66. data/spec/dummy/db/migrate/20111009183423_add_ndc_to_manifestation.rb +9 -0
  67. data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +12 -0
  68. data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +12 -0
  69. data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +12 -0
  70. data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +7 -0
  71. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -10
  72. data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +6 -0
  73. data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +6 -0
  74. data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +6 -0
  75. data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +5 -0
  76. data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +5 -0
  77. data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +5 -0
  78. data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +5 -0
  79. data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_patron_import_file.rb +5 -0
  80. data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +5 -0
  81. data/spec/dummy/db/migrate/20120413170720_add_error_message_to_patron_import_file.rb +5 -0
  82. data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +9 -0
  83. data/spec/dummy/db/migrate/20120415060323_rename_patron_import_file_imported_at_to_executed_at.rb +9 -0
  84. data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +5 -0
  85. data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +5 -0
  86. data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_patron_import_file.rb +5 -0
  87. data/spec/dummy/db/schema.rb +490 -18
  88. data/spec/dummy/db/test.sqlite3 +0 -0
  89. data/spec/dummy/solr/data/test/index/_a.fdt +0 -0
  90. data/spec/dummy/solr/data/test/index/_a.fdx +0 -0
  91. data/spec/dummy/solr/data/test/index/{_2s.fnm → _a.fnm} +2 -2
  92. data/spec/dummy/solr/data/test/index/_a.frq +1 -0
  93. data/spec/dummy/solr/data/test/index/_a.nrm +1 -0
  94. data/spec/dummy/solr/data/test/index/_a.prx +0 -0
  95. data/spec/dummy/solr/data/test/index/{_2s.tii → _a.tii} +0 -0
  96. data/spec/dummy/solr/data/test/index/_a.tis +0 -0
  97. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  98. data/spec/dummy/solr/data/test/index/{segments_2k → segments_b} +0 -0
  99. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  100. metadata +178 -153
  101. data/db/migrate/20120602122753_add_edit_mode_to_event_import_file.rb +0 -5
  102. data/spec/dummy/app/models/country.rb +0 -44
  103. data/spec/dummy/app/models/language.rb +0 -4
  104. data/spec/dummy/app/models/library.rb +0 -128
  105. data/spec/dummy/app/models/library_group.rb +0 -86
  106. data/spec/dummy/app/models/patron.rb +0 -163
  107. data/spec/dummy/app/models/patron_type.rb +0 -19
  108. data/spec/dummy/app/models/shelf.rb +0 -54
  109. data/spec/dummy/db/development.sqlite3 +0 -0
  110. data/spec/dummy/lib/enju_leaf/import_file.rb +0 -13
  111. data/spec/dummy/lib/enju_leaf/localized_name.rb +0 -13
  112. data/spec/dummy/lib/enju_leaf/master_model.rb +0 -41
  113. data/spec/dummy/lib/enju_leaf/url_validator.rb +0 -10
  114. data/spec/dummy/lib/enju_leaf.rb +0 -4
  115. data/spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample1.tsv +0 -5
  116. data/spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample2.tsv +0 -3
  117. data/spec/dummy/solr/data/test/index/_2s.fdt +0 -0
  118. data/spec/dummy/solr/data/test/index/_2s.fdx +0 -0
  119. data/spec/dummy/solr/data/test/index/_2s.frq +0 -0
  120. data/spec/dummy/solr/data/test/index/_2s.nrm +0 -1
  121. data/spec/dummy/solr/data/test/index/_2s.prx +0 -0
  122. data/spec/dummy/solr/data/test/index/_2s.tis +0 -0
@@ -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
-
@@ -1,163 +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 :required_role_id
35
- integer :patron_type_id
36
- end
37
-
38
- def self.per_page
39
- 10
40
- end
41
-
42
- def full_name_without_space
43
- full_name.gsub(/\s/, "")
44
- end
45
-
46
- def set_role_and_name
47
- self.required_role = Role.where(:name => 'Librarian').first if self.required_role_id.nil?
48
- set_full_name
49
- end
50
-
51
- def set_full_name
52
- if self.full_name.blank?
53
- if self.last_name.to_s.strip and self.first_name.to_s.strip and configatron.family_name_first == true
54
- self.full_name = [last_name, middle_name, first_name].compact.join(" ").to_s.strip
55
- else
56
- self.full_name = [first_name, last_name, middle_name].compact.join(" ").to_s.strip
57
- end
58
- end
59
- if self.full_name_transcription.blank?
60
- self.full_name_transcription = [last_name_transcription, middle_name_transcription, first_name_transcription].join(" ").to_s.strip
61
- end
62
- [self.full_name, self.full_name_transcription]
63
- end
64
-
65
- def full_name_without_space
66
- full_name.gsub(/\s/, "")
67
- # # TODO: 日本人以外は?
68
- # name = []
69
- # name << self.last_name.to_s.strip
70
- # name << self.middle_name.to_s.strip
71
- # name << self.first_name.to_s.strip
72
- # name << self.corporate_name.to_s.strip
73
- # name.join("").strip
74
- end
75
-
76
- def full_name_transcription_without_space
77
- full_name_transcription.to_s.gsub(/\s/, "")
78
- end
79
-
80
- def full_name_alternative_without_space
81
- full_name_alternative.to_s.gsub(/\s/, "")
82
- end
83
-
84
- def name
85
- name = []
86
- name << full_name.to_s.strip
87
- name << full_name_transcription.to_s.strip
88
- name << full_name_alternative.to_s.strip
89
- #name << full_name_without_space
90
- #name << full_name_transcription_without_space
91
- #name << full_name_alternative_without_space
92
- #name << full_name.wakati rescue nil
93
- #name << full_name_transcription.wakati rescue nil
94
- #name << full_name_alternative.wakati rescue nil
95
- name
96
- end
97
-
98
- def date
99
- if date_of_birth
100
- if date_of_death
101
- "#{date_of_birth} - #{date_of_death}"
102
- else
103
- "#{date_of_birth} -"
104
- end
105
- end
106
- end
107
-
108
- def creator?(resource)
109
- resource.creators.include?(self)
110
- end
111
-
112
- def publisher?(resource)
113
- resource.publishers.include?(self)
114
- end
115
-
116
- def check_required_role(user)
117
- return true if self.user.blank?
118
- return true if self.user.required_role.name == 'Guest'
119
- return true if user == self.user
120
- return true if user.has_role?(self.user.required_role.name)
121
- false
122
- rescue NoMethodError
123
- false
124
- end
125
-
126
- def created(work)
127
- creates.where(:work_id => work.id).first
128
- end
129
-
130
- def realized(expression)
131
- realizes.where(:expression_id => expression.id).first
132
- end
133
-
134
- def produced(manifestation)
135
- produces.where(:manifestation_id => manifestation.id).first
136
- end
137
-
138
- def owned(item)
139
- owns.where(:item_id => item.id)
140
- end
141
-
142
- def self.import_patrons(patron_lists)
143
- list = []
144
- patron_lists.each do |patron_list|
145
- patron = Patron.where(:full_name => patron_list[:full_name]).first
146
- unless patron
147
- patron = Patron.new(
148
- :full_name => patron_list[:full_name],
149
- :full_name_transcription => patron_list[:full_name_transcription],
150
- :language_id => 1
151
- )
152
- patron.required_role = Role.where(:name => 'Guest').first
153
- patron.save
154
- end
155
- list << patron
156
- end
157
- list
158
- end
159
-
160
- def patrons
161
- self.original_patrons + self.derived_patrons
162
- end
163
- 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,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
-
Binary file
@@ -1,13 +0,0 @@
1
- module ImportFile
2
- def self.included(base)
3
- base.extend ClassMethods
4
- end
5
-
6
- module ClassMethods
7
- def expire
8
- self.stucked.find_each do |file|
9
- file.destroy
10
- end
11
- end
12
- end
13
- 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,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,10 +0,0 @@
1
- class UrlValidator < ActiveModel::EachValidator
2
- def validate_each(record, attribute, value)
3
- url = ::Addressable::URI.parse(value)
4
- if url
5
- unless ['http', 'https'].include?(url.scheme)
6
- record.errors.add(attribute.to_sym)
7
- end
8
- end
9
- end
10
- end
@@ -1,4 +0,0 @@
1
- require 'enju_leaf/import_file'
2
- require 'enju_leaf/localized_name'
3
- require 'enju_leaf/master_model'
4
- require 'enju_leaf/url_validator'
@@ -1,5 +0,0 @@
1
- "name" "category" "library_shortname" "start_at" "end_at" "dummy"
2
- "イベント名" "カテゴリ。休館日の場合はclosed" "図書館名" "開始日" "終了日" "インポート省略"
3
- "hogehoge" "おはなし会" "kamata" "2009-04-01" "2009-04-03"
4
- "hogehoge" "hachioji"
5
- "休館日" "closed" "kamata" "2011-04-01" "2011-04-03"
@@ -1,3 +0,0 @@
1
- "name" "library_shortname" "start_at" "end_at"
2
- "���{��̍Â���" "kamata" "2011-03-26" "2011-03-27"
3
- "���{��̍Â���2" "kamata" "2011-03-26" "2011-03-27"
@@ -1 +0,0 @@
1
- NRM�xxvx|u|||||||||||||||||||||||||�|ut�u��|||||