enju_biblio 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/manifestations_controller.rb +1 -1
  3. data/app/jobs/agent_import_file_job.rb +1 -1
  4. data/app/jobs/resource_export_file_job.rb +1 -1
  5. data/app/jobs/resource_import_file_job.rb +1 -1
  6. data/app/mailers/agent_import_mailer.rb +17 -0
  7. data/app/mailers/resource_export_mailer.rb +17 -0
  8. data/app/mailers/resource_import_mailer.rb +17 -0
  9. data/app/models/agent.rb +4 -4
  10. data/app/models/agent_import_file.rb +13 -1
  11. data/app/models/agent_import_file_transition.rb +1 -1
  12. data/app/models/agent_import_result.rb +1 -1
  13. data/app/models/agent_merge.rb +1 -1
  14. data/app/models/agent_merge_list.rb +1 -1
  15. data/app/models/agent_relationship.rb +1 -1
  16. data/app/models/agent_relationship_type.rb +1 -1
  17. data/app/models/agent_type.rb +1 -1
  18. data/app/models/carrier_type.rb +1 -1
  19. data/app/models/content_type.rb +1 -1
  20. data/app/models/country.rb +1 -1
  21. data/app/models/create.rb +1 -1
  22. data/app/models/create_type.rb +1 -1
  23. data/app/models/donate.rb +1 -1
  24. data/app/models/form_of_work.rb +1 -1
  25. data/app/models/frequency.rb +1 -1
  26. data/app/models/identifier.rb +1 -1
  27. data/app/models/identifier_type.rb +1 -1
  28. data/app/models/import_request.rb +1 -1
  29. data/app/models/import_request_transition.rb +1 -1
  30. data/app/models/item.rb +3 -3
  31. data/app/models/language.rb +2 -18
  32. data/app/models/license.rb +1 -1
  33. data/app/models/manifestation.rb +16 -4
  34. data/app/models/manifestation_relationship.rb +1 -1
  35. data/app/models/manifestation_relationship_type.rb +1 -1
  36. data/app/models/medium_of_performance.rb +1 -1
  37. data/app/models/own.rb +1 -1
  38. data/app/models/picture_file.rb +1 -1
  39. data/app/models/produce.rb +1 -1
  40. data/app/models/produce_type.rb +1 -1
  41. data/app/models/realize.rb +1 -1
  42. data/app/models/realize_type.rb +1 -1
  43. data/app/models/resource_export_file.rb +6 -4
  44. data/app/models/resource_export_file_transition.rb +1 -1
  45. data/app/models/resource_import_file.rb +30 -6
  46. data/app/models/resource_import_file_transition.rb +1 -1
  47. data/app/models/resource_import_result.rb +1 -1
  48. data/app/models/series_statement.rb +1 -1
  49. data/app/models/series_statement_merge.rb +1 -1
  50. data/app/models/series_statement_merge_list.rb +1 -1
  51. data/app/views/agent_import_mailer/completed.en.text.erb +9 -0
  52. data/app/views/agent_import_mailer/completed.ja.text.erb +9 -0
  53. data/app/views/agent_import_mailer/failed.en.text +9 -0
  54. data/app/views/agent_import_mailer/failed.ja.text.erb +9 -0
  55. data/app/views/items/show.html+phone.erb +0 -9
  56. data/app/views/items/show.html.erb +0 -12
  57. data/app/views/manifestations/_manifestation.json.jbuilder +53 -0
  58. data/app/views/manifestations/index.json.jbuilder +6 -0
  59. data/app/views/picture_files/edit.html.erb +2 -22
  60. data/app/views/resource_export_mailer/completed.en.text.erb +9 -0
  61. data/app/views/resource_export_mailer/completed.ja.text.erb +9 -0
  62. data/app/views/resource_export_mailer/failed.en.text.erb +9 -0
  63. data/app/views/resource_export_mailer/failed.ja.text.erb +9 -0
  64. data/app/views/resource_import_mailer/completed.en.text.erb +9 -0
  65. data/app/views/resource_import_mailer/completed.ja.text.erb +9 -0
  66. data/app/views/resource_import_mailer/failed.en.text.erb +9 -0
  67. data/app/views/resource_import_mailer/failed.ja.text.erb +9 -0
  68. data/config/locales/translation_en.yml +11 -0
  69. data/config/locales/translation_ja.yml +11 -0
  70. data/lib/enju_biblio/version.rb +1 -1
  71. data/spec/controllers/items_controller_spec.rb +0 -37
  72. data/spec/dummy/app/jobs/application_job.rb +7 -0
  73. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  74. data/spec/dummy/app/models/application_record.rb +3 -0
  75. data/spec/dummy/app/models/user.rb +1 -7
  76. data/spec/dummy/config/application.rb +2 -1
  77. data/spec/dummy/db/migrate/029_create_subjects.rb +3 -6
  78. data/spec/dummy/db/migrate/032_create_checkins.rb +3 -6
  79. data/spec/dummy/db/migrate/033_create_checkouts.rb +6 -11
  80. data/spec/dummy/db/migrate/035_create_reserves.rb +4 -9
  81. data/spec/dummy/db/migrate/121_create_checked_items.rb +3 -4
  82. data/spec/dummy/db/migrate/129_create_item_has_use_restrictions.rb +2 -4
  83. data/spec/dummy/db/migrate/20081030023518_create_user_group_has_checkout_types.rb +2 -4
  84. data/spec/dummy/db/migrate/20081030023615_create_carrier_type_has_checkout_types.rb +2 -3
  85. data/spec/dummy/db/migrate/20081212075554_create_checkout_stat_has_manifestations.rb +2 -2
  86. data/spec/dummy/db/migrate/20081215094955_create_checkout_stat_has_users.rb +2 -4
  87. data/spec/dummy/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb +2 -2
  88. data/spec/dummy/db/migrate/20081220034117_create_reserve_stat_has_users.rb +2 -4
  89. data/spec/dummy/db/migrate/20090831220301_create_lending_policies.rb +3 -3
  90. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
  91. data/spec/dummy/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +2 -2
  92. data/spec/dummy/db/migrate/20111129044509_add_pickup_location_to_reserve.rb +6 -0
  93. data/spec/dummy/db/migrate/20120424103932_add_librarian_id_to_checked_item.rb +1 -1
  94. data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +1 -1
  95. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
  96. data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +1 -1
  97. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +1 -1
  98. data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +1 -1
  99. data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +1 -1
  100. data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +1 -1
  101. data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +1 -1
  102. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +1 -1
  103. data/spec/dummy/db/migrate/20140810061942_add_user_id_to_user_checkout_stat.rb +4 -8
  104. data/spec/dummy/db/migrate/20141014065831_add_shelf_id_to_checkout.rb +1 -2
  105. data/spec/dummy/db/migrate/20141020120523_add_library_id_to_checkout.rb +5 -0
  106. data/spec/dummy/db/migrate/20150106001709_create_demands.rb +11 -0
  107. data/spec/dummy/db/migrate/20150421023923_create_identities.rb +14 -0
  108. data/spec/dummy/db/migrate/20150923173139_add_url_to_classification.rb +5 -0
  109. data/spec/dummy/db/migrate/20150925092505_add_label_to_classification.rb +5 -0
  110. data/spec/dummy/db/migrate/20151126005552_add_provider_to_identity.rb +5 -0
  111. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +4 -11
  112. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  113. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  114. data/spec/dummy/db/migrate/20180107161035_add_constraints_to_most_recent_for_reserve_transitions.rb +13 -0
  115. data/spec/dummy/db/migrate/20180107161951_add_constraints_to_most_recent_for_user_checkout_stat_transitions.rb +13 -0
  116. data/spec/dummy/db/migrate/20180107162009_add_constraints_to_most_recent_for_user_reserve_stat_transitions.rb +13 -0
  117. data/spec/dummy/db/migrate/20180107162029_add_constraints_to_most_recent_for_manifestation_checkout_stat_transitions.rb +13 -0
  118. data/spec/dummy/db/migrate/20180107162048_add_constraints_to_most_recent_for_manifestation_reserve_stat_transitions.rb +13 -0
  119. data/spec/dummy/db/schema.rb +51 -12
  120. data/spec/factories/agent.rb +1 -1
  121. data/spec/factories/identifier.rb +1 -0
  122. data/spec/factories/item.rb +0 -1
  123. data/spec/fixtures/reserve_transitions.yml +23 -7
  124. data/spec/mailers/agent_import_spec.rb +5 -0
  125. data/spec/mailers/previews/agent_import_preview.rb +4 -0
  126. data/spec/mailers/previews/resource_export_preview.rb +4 -0
  127. data/spec/mailers/previews/resource_import_preview.rb +4 -0
  128. data/spec/mailers/resource_export_spec.rb +5 -0
  129. data/spec/mailers/resource_import_spec.rb +5 -0
  130. data/spec/models/agent_spec.rb +1 -1
  131. data/spec/models/item_spec.rb +0 -41
  132. data/spec/models/manifestation_spec.rb +0 -32
  133. data/spec/models/resource_export_file_spec.rb +2 -26
  134. data/spec/models/resource_import_file_spec.rb +2 -2
  135. data/spec/policies/manifestation_policy_spec.rb +2 -5
  136. data/spec/views/items/index.html.erb_spec.rb +3 -10
  137. data/spec/views/manifestations/show.html.erb_spec.rb +1 -5
  138. metadata +121 -26
  139. data/spec/factories/checkout.rb +0 -9
  140. data/spec/fixtures/checked_items.yml +0 -35
  141. data/spec/fixtures/checkins.yml +0 -48
  142. data/spec/fixtures/checkouts.yml +0 -162
  143. data/spec/fixtures/item_has_use_restrictions.yml +0 -61
  144. data/spec/fixtures/lending_policies.yml +0 -92
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a23d1ef687793d665f0bc4af86c00a09d1979e0d70292120bdbf9ec0e4c1b7af
4
- data.tar.gz: 2e37b0bf8d14c64eacc7fd4027ec6df757b3d8e05cdd9b24378636af6801c38b
3
+ metadata.gz: 2888d4c10b1fd92841241ecba36a6d2f7ea687d4c9f667db6460ae1231503c76
4
+ data.tar.gz: 528744242fa80482bb5c08328619d916ee481b9a6fd5209d705cbfd0b6079d1a
5
5
  SHA512:
6
- metadata.gz: 53a8ec2efd849064fd1ec1f9d22b2f7c8c9b38c253c99940a63a6cefe691944f4a6b0f2273ab4ba3935d6b7ff889430fe78bea168b998eede3fc4904704b18ec
7
- data.tar.gz: e608f4dd26a8d8be692205d4b0ec757e2d1eb77b5e5c3c1fb2bf582f2063219c8c626c9c534f19a5f7614e43bc45140f069b45b5739832d8aa58aade6bc68396
6
+ metadata.gz: 4dfd6f2cc2000df1e14f289c191e11f7124b1587547fa4df7fc03876472f7797773cd15fd399ae8481b2dfc2a1394bf2345403f509b7555e13ccec4a19e7d452
7
+ data.tar.gz: a2f56218856579f419fa8759b4cf57c9b75aee8b43f4524b53fd0daab0b4289e9aac6ab76adf85ee98bce277c5b928f020b03e656ec100c3b3938e557d6f0875
@@ -267,7 +267,7 @@ class ManifestationsController < ApplicationController
267
267
  format.rdf { render layout: false }
268
268
  format.atom
269
269
  format.mods
270
- format.json { render json: @manifestations }
270
+ format.json
271
271
  format.js
272
272
  end
273
273
  end
@@ -1,4 +1,4 @@
1
- class AgentImportFileJob < ActiveJob::Base
1
+ class AgentImportFileJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(agent_import_file)
@@ -1,4 +1,4 @@
1
- class ResourceExportFileJob < ActiveJob::Base
1
+ class ResourceExportFileJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(resource_export_file)
@@ -1,4 +1,4 @@
1
- class ResourceImportFileJob < ActiveJob::Base
1
+ class ResourceImportFileJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(resource_import_file)
@@ -0,0 +1,17 @@
1
+ class AgentImportMailer < ApplicationMailer
2
+ def completed(agent_import_file)
3
+ @agent_import_file = agent_import_file
4
+ @library_group = LibraryGroup.site_config
5
+ from = "#{LibraryGroup.system_name(agent_import_file.user.profile.locale)} <#{@library_group.user.email}>"
6
+ subject = "#{I18n.t('agent_import_mailer.completed.subject')}: #{@agent_import_file.id}"
7
+ mail(from: from, to: agent_import_file.user.email, subject: subject)
8
+ end
9
+
10
+ def failed(agent_import_file)
11
+ @agent_import_file = agent_import_file
12
+ @library_group = LibraryGroup.site_config
13
+ from = "#{LibraryGroup.system_name(agent_import_file.user.profile.locale)} <#{@library_group.user.email}>"
14
+ subject = "#{I18n.t('agent_import_mailer.failed.subject')}: #{@agent_import_file.id}"
15
+ mail(from: from, to: agent_import_file.user.email, subject: subject)
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class ResourceExportMailer < ApplicationMailer
2
+ def completed(resource_export_file)
3
+ @resource_export_file = resource_export_file
4
+ @library_group = LibraryGroup.site_config
5
+ from = "#{LibraryGroup.system_name(resource_export_file.user.profile.locale)} <#{@library_group.user.email}>"
6
+ subject = "#{I18n.t('resource_export_mailer.completed.subject')}: #{@resource_export_file.id}"
7
+ mail(from: from, to: resource_export_file.user.email, subject: subject)
8
+ end
9
+
10
+ def failed(resource_export_file)
11
+ @resource_export_file = resource_export_file
12
+ @library_group = LibraryGroup.site_config
13
+ from = "#{LibraryGroup.system_name(resource_export_file.user.profile.locale)} <#{@library_group.user.email}>"
14
+ subject = "#{I18n.t('resource_export_mailer.failed.subject')}: #{@resource_export_file.id}"
15
+ mail(from: from, to: resource_export_file.user.email, subject: subject)
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class ResourceImportMailer < ApplicationMailer
2
+ def completed(resource_import_file)
3
+ @resource_import_file = resource_import_file
4
+ @library_group = LibraryGroup.site_config
5
+ from = "#{LibraryGroup.system_name(resource_import_file.user.profile.locale)} <#{@library_group.user.email}>"
6
+ subject = "#{I18n.t('resource_import_mailer.completed.subject')}: #{@resource_import_file.id}"
7
+ mail(from: from, to: resource_import_file.user.email, subject: subject)
8
+ end
9
+
10
+ def failed(resource_import_file)
11
+ @resource_import_file = resource_import_file
12
+ @library_group = LibraryGroup.site_config
13
+ from = "#{LibraryGroup.system_name(resource_import_file.user.profile.locale)} <#{@library_group.user.email}>"
14
+ subject = "#{I18n.t('resource_import_mailer.failed.subject')}: #{@resource_import_file.id}"
15
+ mail(from: from, to: resource_import_file.user.email, subject: subject)
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- class Agent < ActiveRecord::Base
1
+ class Agent < ApplicationRecord
2
2
  scope :readable_by, lambda{ |user|
3
3
  if user
4
4
  where('required_role_id <= ?', user.try(:user_has_role).try(:role_id))
@@ -17,7 +17,7 @@ class Agent < ActiveRecord::Base
17
17
  has_many :derived_agents, through: :children, source: :child
18
18
  has_many :original_agents, through: :parents, source: :parent
19
19
  has_many :picture_files, as: :picture_attachable, dependent: :destroy
20
- has_many :donates
20
+ has_many :donates, dependent: :destroy
21
21
  has_many :donated_items, through: :donates, source: :item
22
22
  has_many :owns, dependent: :destroy
23
23
  has_many :items, through: :owns
@@ -97,7 +97,7 @@ class Agent < ActiveRecord::Base
97
97
  def set_date_of_birth
98
98
  return if birth_date.blank?
99
99
  begin
100
- date = Time.zone.parse("#{birth_date}")
100
+ date = Time.zone.parse(birth_date.to_s)
101
101
  rescue ArgumentError
102
102
  begin
103
103
  date = Time.zone.parse("#{birth_date}-01")
@@ -115,7 +115,7 @@ class Agent < ActiveRecord::Base
115
115
  def set_date_of_death
116
116
  return if death_date.blank?
117
117
  begin
118
- date = Time.zone.parse("#{death_date}")
118
+ date = Time.zone.parse(death_date.to_s)
119
119
  rescue ArgumentError
120
120
  begin
121
121
  date = Time.zone.parse("#{death_date}-01")
@@ -1,4 +1,4 @@
1
- class AgentImportFile < ActiveRecord::Base
1
+ class AgentImportFile < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include ImportFile
4
4
  default_scope { order('agent_import_files.id DESC') }
@@ -88,10 +88,14 @@ class AgentImportFile < ActiveRecord::Base
88
88
  Sunspot.commit
89
89
  rows.close
90
90
  transition_to!(:completed)
91
+ mailer = AgentImportMailer.completed(self)
92
+ send_message(mailer)
91
93
  return num
92
94
  rescue => e
93
95
  self.error_message = "line #{row_num}: #{e.message}"
94
96
  transition_to!(:failed)
97
+ mailer = AgentImportMailer.failed(self)
98
+ send_message(mailer)
95
99
  raise e
96
100
  end
97
101
 
@@ -128,9 +132,13 @@ class AgentImportFile < ActiveRecord::Base
128
132
  end
129
133
  end
130
134
  transition_to!(:completed)
135
+ mailer = AgentImportMailer.completed(self)
136
+ send_message(mailer)
131
137
  rescue => e
132
138
  self.error_message = "line #{row_num}: #{e.message}"
133
139
  transition_to!(:failed)
140
+ mailer = AgentImportMailer.failed(self)
141
+ send_message(mailer)
134
142
  raise e
135
143
  end
136
144
 
@@ -151,9 +159,13 @@ class AgentImportFile < ActiveRecord::Base
151
159
  end
152
160
  end
153
161
  transition_to!(:completed)
162
+ mailer = AgentImportMailer.completed(self)
163
+ send_message(mailer)
154
164
  rescue => e
155
165
  self.error_message = "line #{row_num}: #{e.message}"
156
166
  transition_to!(:failed)
167
+ mailer = AgentImportMailer.failed(self)
168
+ send_message(mailer)
157
169
  raise e
158
170
  end
159
171
 
@@ -1,4 +1,4 @@
1
- class AgentImportFileTransition < ActiveRecord::Base
1
+ class AgentImportFileTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- class AgentImportResult < ActiveRecord::Base
1
+ class AgentImportResult < ApplicationRecord
2
2
  default_scope { order('agent_import_results.id') }
3
3
  scope :file_id, proc{|file_id| where(agent_import_file_id: file_id)}
4
4
  scope :failed, -> { where(agent_id: nil) }
@@ -1,4 +1,4 @@
1
- class AgentMerge < ActiveRecord::Base
1
+ class AgentMerge < ApplicationRecord
2
2
  belongs_to :agent
3
3
  belongs_to :agent_merge_list
4
4
  validates_presence_of :agent, :agent_merge_list
@@ -1,4 +1,4 @@
1
- class AgentMergeList < ActiveRecord::Base
1
+ class AgentMergeList < ApplicationRecord
2
2
  has_many :agent_merges, dependent: :destroy
3
3
  has_many :agents, through: :agent_merges
4
4
  validates_presence_of :title
@@ -1,4 +1,4 @@
1
- class AgentRelationship < ActiveRecord::Base
1
+ class AgentRelationship < ApplicationRecord
2
2
  belongs_to :parent, foreign_key: 'parent_id', class_name: 'Agent'
3
3
  belongs_to :child, foreign_key: 'child_id', class_name: 'Agent'
4
4
  belongs_to :agent_relationship_type, optional: true
@@ -1,4 +1,4 @@
1
- class AgentRelationshipType < ActiveRecord::Base
1
+ class AgentRelationshipType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('agent_relationship_types.position') }
4
4
  has_many :agent_relationships
@@ -1,4 +1,4 @@
1
- class AgentType < ActiveRecord::Base
1
+ class AgentType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('agent_types.position') }
4
4
  has_many :agents
@@ -1,4 +1,4 @@
1
- class CarrierType < ActiveRecord::Base
1
+ class CarrierType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order("carrier_types.position") }
4
4
  has_many :manifestations
@@ -1,4 +1,4 @@
1
- class ContentType < ActiveRecord::Base
1
+ class ContentType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('content_types.position') }
4
4
  has_many :manifestations
@@ -1,4 +1,4 @@
1
- class Country < ActiveRecord::Base
1
+ class Country < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('countries.position') }
4
4
  has_many :agents
@@ -1,4 +1,4 @@
1
- class Create < ActiveRecord::Base
1
+ class Create < ApplicationRecord
2
2
  belongs_to :agent
3
3
  belongs_to :work, class_name: 'Manifestation', foreign_key: 'work_id', touch: true
4
4
  belongs_to :create_type, optional: true
@@ -1,4 +1,4 @@
1
- class CreateType < ActiveRecord::Base
1
+ class CreateType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('create_types.position') }
4
4
  end
@@ -1,4 +1,4 @@
1
- class Donate < ActiveRecord::Base
1
+ class Donate < ApplicationRecord
2
2
  belongs_to :agent
3
3
  belongs_to :item
4
4
  validates_associated :agent, :item
@@ -1,4 +1,4 @@
1
- class FormOfWork < ActiveRecord::Base
1
+ class FormOfWork < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('form_of_works.position') }
4
4
  has_many :works
@@ -1,4 +1,4 @@
1
- class Frequency < ActiveRecord::Base
1
+ class Frequency < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('frequencies.position') }
4
4
  has_many :manifestations
@@ -1,4 +1,4 @@
1
- class Identifier < ActiveRecord::Base
1
+ class Identifier < ApplicationRecord
2
2
  belongs_to :identifier_type
3
3
  belongs_to :manifestation, touch: true, optional: true
4
4
 
@@ -1,4 +1,4 @@
1
- class IdentifierType < ActiveRecord::Base
1
+ class IdentifierType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('identifier_types.position') }
4
4
  has_many :identifiers
@@ -1,4 +1,4 @@
1
- class ImportRequest < ActiveRecord::Base
1
+ class ImportRequest < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  default_scope { order('import_requests.id DESC') }
4
4
  belongs_to :manifestation, optional: true
@@ -1,4 +1,4 @@
1
- class ImportRequestTransition < ActiveRecord::Base
1
+ class ImportRequestTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- class Item < ActiveRecord::Base
1
+ class Item < ApplicationRecord
2
2
  scope :on_shelf, -> { includes(:shelf).references(:shelf).where('shelves.name != ?', 'web') }
3
3
  scope :on_web, -> { includes(:shelf).references(:shelf).where('shelves.name = ?', 'web') }
4
4
  scope :available, -> {}
@@ -10,7 +10,7 @@ class Item < ActiveRecord::Base
10
10
  delegate :display_name, to: :shelf, prefix: true
11
11
  has_many :owns
12
12
  has_many :agents, through: :owns
13
- has_many :donates
13
+ has_many :donates, dependent: :destroy
14
14
  has_many :donors, through: :donates, source: :agent
15
15
  has_one :resource_import_result
16
16
  belongs_to :manifestation, touch: true
@@ -90,7 +90,7 @@ class Item < ActiveRecord::Base
90
90
  def removable?
91
91
  if defined?(EnjuCirculation)
92
92
  return false if circulation_status.name == 'Removed'
93
- return false if checkouts.not_returned.exists?
93
+ return false if checkouts.exists?
94
94
  true
95
95
  else
96
96
  true
@@ -1,29 +1,13 @@
1
- class Language < ActiveRecord::Base
1
+ class Language < ApplicationRecord
2
2
  include MasterModel
3
- default_scope { order('languages.position') }
4
3
  # If you wish to change the field names for brevity, feel free to enable/modify these.
5
4
  # alias_attribute :iso1, :iso_639_1
6
5
  # alias_attribute :iso2, :iso_639_2
7
6
  # alias_attribute :iso3, :iso_639_3
8
7
 
9
8
  # Validations
10
- validates_presence_of :iso_639_1, :iso_639_2, :iso_639_3
9
+ validates :iso_639_1, :iso_639_2, :iso_639_3, presence: true
11
10
  validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
12
- after_save :clear_available_languages_cache
13
- after_destroy :clear_available_languages_cache
14
-
15
- def self.all_cache
16
- if Rails.env == 'production'
17
- Rails.cache.fetch('language_all'){Language.all.to_a}
18
- else
19
- Language.all
20
- end
21
- end
22
-
23
- def clear_available_languages_cache
24
- Rails.cache.delete('language_all')
25
- Rails.cache.delete('available_languages')
26
- end
27
11
 
28
12
  def self.available_languages
29
13
  Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s}).order(:position)
@@ -1,4 +1,4 @@
1
- class License < ActiveRecord::Base
1
+ class License < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('licenses.position') }
4
4
  end
@@ -1,4 +1,4 @@
1
- class Manifestation < ActiveRecord::Base
1
+ class Manifestation < ApplicationRecord
2
2
  enju_manifestation_viewer if defined?(EnjuManifestationViewer)
3
3
  enju_ndl_ndl_search if defined?(EnjuNdl)
4
4
  enju_loc_search if defined?(EnjuLoc)
@@ -678,16 +678,28 @@ class Manifestation < ActiveRecord::Base
678
678
  when :Administrator, :Librarian
679
679
  item_lines << i.bookstore.try(:name)
680
680
  item_lines << i.budget_type.try(:name)
681
- item_lines << Checkout.where(item_id: i.id).size
681
+ if defined?(EnjuCirtulation)
682
+ item_lines << Checkout.where(item_id: i.id).count
683
+ else
684
+ item_lines << ''
685
+ end
686
+ end
687
+ if defined?(EnjuCirtulation)
688
+ item_lines << i.circulation_status.try(:name)
689
+ else
690
+ item_lines << ''
682
691
  end
683
- item_lines << i.circulation_status.try(:name)
684
692
  item_lines << i.shelf.name
685
693
  item_lines << i.shelf.library.name
686
694
  item_lines << i.created_at
687
695
  item_lines << i.updated_at
688
696
  case options[:role].to_sym
689
697
  when :Administrator, :Librarian
690
- item_lines << i.use_restriction.try(:name)
698
+ if defined?(EnjuCirtulation)
699
+ item_lines << i.use_restriction.try(:name)
700
+ else
701
+ item_lines << ''
702
+ end
691
703
  end
692
704
  lines << item_lines
693
705
  end
@@ -1,4 +1,4 @@
1
- class ManifestationRelationship < ActiveRecord::Base
1
+ class ManifestationRelationship < ApplicationRecord
2
2
  belongs_to :parent, foreign_key: 'parent_id', class_name: 'Manifestation'
3
3
  belongs_to :child, foreign_key: 'child_id', class_name: 'Manifestation'
4
4
  belongs_to :manifestation_relationship_type, optional: true
@@ -1,4 +1,4 @@
1
- class ManifestationRelationshipType < ActiveRecord::Base
1
+ class ManifestationRelationshipType < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('manifestation_relationship_types.position') }
4
4
  has_many :manifestation_relationships
@@ -1,4 +1,4 @@
1
- class MediumOfPerformance < ActiveRecord::Base
1
+ class MediumOfPerformance < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('medium_of_performances.position') }
4
4
  has_many :works
@@ -1,4 +1,4 @@
1
- class Own < ActiveRecord::Base
1
+ class Own < ApplicationRecord
2
2
  belongs_to :agent
3
3
  belongs_to :item
4
4
 
@@ -1,4 +1,4 @@
1
- class PictureFile < ActiveRecord::Base
1
+ class PictureFile < ApplicationRecord
2
2
  scope :attached, -> { where('picture_attachable_id IS NOT NULL') }
3
3
  belongs_to :picture_attachable, polymorphic: true
4
4
  before_save :extract_dimensions