enju_biblio 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/models2/agent.rb +331 -0
  3. data/app/models2/agent_import_file.rb +259 -0
  4. data/app/models2/agent_import_file_state_machine.rb +19 -0
  5. data/app/models2/agent_import_file_transition.rb +20 -0
  6. data/app/models2/agent_import_result.rb +20 -0
  7. data/app/models2/agent_merge.rb +17 -0
  8. data/app/models2/agent_merge_list.rb +27 -0
  9. data/app/models2/agent_relationship.rb +24 -0
  10. data/app/models2/agent_relationship_type.rb +20 -0
  11. data/app/models2/agent_type.rb +19 -0
  12. data/app/models2/carrier_type.rb +50 -0
  13. data/app/models2/content_type.rb +19 -0
  14. data/app/models2/country.rb +47 -0
  15. data/app/models2/create.rb +29 -0
  16. data/app/models2/create_type.rb +19 -0
  17. data/app/models2/doi_record.rb +36 -0
  18. data/app/models2/donate.rb +15 -0
  19. data/app/models2/form_of_work.rb +19 -0
  20. data/app/models2/frequency.rb +19 -0
  21. data/app/models2/identifier.rb +83 -0
  22. data/app/models2/identifier_type.rb +18 -0
  23. data/app/models2/import_request.rb +77 -0
  24. data/app/models2/import_request_state_machine.rb +9 -0
  25. data/app/models2/import_request_transition.rb +21 -0
  26. data/app/models2/isbn_record.rb +51 -0
  27. data/app/models2/isbn_record_and_manifestation.rb +18 -0
  28. data/app/models2/issn_record.rb +49 -0
  29. data/app/models2/issn_record_and_manifestation.rb +18 -0
  30. data/app/models2/item.rb +173 -0
  31. data/app/models2/item_custom_property.rb +18 -0
  32. data/app/models2/item_custom_value.rb +17 -0
  33. data/app/models2/language.rb +39 -0
  34. data/app/models2/license.rb +18 -0
  35. data/app/models2/manifestation.rb +764 -0
  36. data/app/models2/manifestation_custom_property.rb +18 -0
  37. data/app/models2/manifestation_custom_value.rb +17 -0
  38. data/app/models2/manifestation_relationship.rb +27 -0
  39. data/app/models2/manifestation_relationship_type.rb +20 -0
  40. data/app/models2/medium_of_performance.rb +19 -0
  41. data/app/models2/own.rb +29 -0
  42. data/app/models2/periodical.rb +33 -0
  43. data/app/models2/periodical_and_manifestation.rb +16 -0
  44. data/app/models2/picture_file.rb +60 -0
  45. data/app/models2/produce.rb +30 -0
  46. data/app/models2/produce_type.rb +19 -0
  47. data/app/models2/realize.rb +29 -0
  48. data/app/models2/realize_type.rb +19 -0
  49. data/app/models2/resource_export_file.rb +64 -0
  50. data/app/models2/resource_export_file_state_machine.rb +15 -0
  51. data/app/models2/resource_export_file_transition.rb +21 -0
  52. data/app/models2/resource_import_file.rb +909 -0
  53. data/app/models2/resource_import_file_state_machine.rb +19 -0
  54. data/app/models2/resource_import_file_transition.rb +21 -0
  55. data/app/models2/resource_import_result.rb +24 -0
  56. data/app/models2/series_statement.rb +72 -0
  57. data/app/models2/series_statement_merge.rb +17 -0
  58. data/app/models2/series_statement_merge_list.rb +17 -0
  59. data/app/views/manifestations/_book_jacket.html.erb +9 -5
  60. data/app/views/manifestations/_colorbox.html.erb +1 -1
  61. data/app/views/manifestations/_pickup.html.erb +1 -1
  62. data/lib/enju_biblio/version.rb +1 -1
  63. data/spec/dummy/yarn.lock +7560 -0
  64. metadata +61 -2
@@ -0,0 +1,18 @@
1
+ class IssnRecordAndManifestation < ApplicationRecord
2
+ belongs_to :issn_record
3
+ belongs_to :manifestation
4
+ acts_as_list
5
+ validates :issn_record_id, uniqueness: {scope: :manifestation_id}
6
+ end
7
+
8
+ # == Schema Information
9
+ #
10
+ # Table name: issn_record_and_manifestations
11
+ #
12
+ # id :bigint not null, primary key
13
+ # issn_record_id :bigint not null
14
+ # manifestation_id :bigint not null
15
+ # position :integer
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
+ #
@@ -0,0 +1,173 @@
1
+ class Item < ApplicationRecord
2
+ scope :on_shelf, -> { includes(:shelf).references(:shelf).where('shelves.name != ?', 'web') }
3
+ scope :on_web, -> { includes(:shelf).references(:shelf).where('shelves.name = ?', 'web') }
4
+ scope :available, -> {}
5
+ scope :available_for, -> user {
6
+ unless user.try(:has_role?, 'Librarian')
7
+ on_shelf
8
+ end
9
+ }
10
+ delegate :display_name, to: :shelf, prefix: true
11
+ has_many :owns
12
+ has_many :agents, through: :owns
13
+ has_many :donates, dependent: :destroy
14
+ has_many :donors, through: :donates, source: :agent
15
+ has_one :resource_import_result
16
+ belongs_to :manifestation, touch: true
17
+ belongs_to :bookstore, optional: true
18
+ belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
19
+ belongs_to :budget_type, optional: true
20
+ has_one :accept, dependent: :destroy
21
+ has_one :withdraw, dependent: :destroy
22
+ has_many :item_custom_values, -> { joins(:item_custom_property).order(:position) }
23
+
24
+ belongs_to :shelf, counter_cache: true
25
+ accepts_nested_attributes_for :item_custom_values, reject_if: :all_blank
26
+
27
+ scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)}
28
+ validates :item_identifier, allow_blank: true, uniqueness: true,
29
+ format: {with: /\A[0-9A-Za-z_]+\Z/}
30
+ validates :binding_item_identifier, allow_blank: true,
31
+ format: {with: /\A[0-9A-Za-z_]+\Z/}
32
+ validates :url, url: true, allow_blank: true, length: { maximum: 255 }
33
+ validates_date :acquired_at, allow_blank: true
34
+
35
+ strip_attributes only: [:item_identifier, :binding_item_identifier,
36
+ :call_number, :binding_call_number, :url]
37
+
38
+ searchable do
39
+ text :item_identifier, :note, :title, :creator, :contributor, :publisher,
40
+ :binding_item_identifier
41
+ string :item_identifier, multiple: true do
42
+ [item_identifier, binding_item_identifier]
43
+ end
44
+ integer :required_role_id
45
+ integer :manifestation_id
46
+ integer :shelf_id
47
+ integer :agent_ids, multiple: true
48
+ time :created_at
49
+ time :updated_at
50
+ time :acquired_at
51
+ end
52
+
53
+ after_save do
54
+ manifestation.index
55
+ Sunspot.commit
56
+ end
57
+ after_destroy do
58
+ manifestation.index
59
+ Sunspot.commit
60
+ end
61
+
62
+ attr_accessor :library_id
63
+
64
+ paginates_per 10
65
+
66
+ def title
67
+ manifestation&.original_title
68
+ end
69
+
70
+ def creator
71
+ manifestation&.creator
72
+ end
73
+
74
+ def contributor
75
+ manifestation&.contributor
76
+ end
77
+
78
+ def publisher
79
+ manifestation&.publisher
80
+ end
81
+
82
+ def owned(agent)
83
+ owns.find_by(agent_id: agent.id)
84
+ end
85
+
86
+ def manifestation_url
87
+ Addressable::URI.parse("#{LibraryGroup.site_config.url}manifestations/#{self.manifestation.id}").normalize.to_s if self.manifestation
88
+ end
89
+
90
+ def removable?
91
+ if defined?(EnjuCirculation)
92
+ return false if circulation_status.name == 'Removed'
93
+ return false if checkouts.exists?
94
+ true
95
+ else
96
+ true
97
+ end
98
+ end
99
+
100
+ def self.csv_header(role: 'Guest')
101
+ Item.new.to_hash(role: role).keys
102
+ end
103
+
104
+ def to_hash(role: 'Guest')
105
+ record = {
106
+ item_id: id,
107
+ item_identifier: item_identifier,
108
+ binding_item_identifier: binding_item_identifier,
109
+ call_number: call_number,
110
+ shelf: shelf&.name,
111
+ item_note: note,
112
+ accepted_at: accept&.created_at,
113
+ acquired_at: acquired_at,
114
+ item_created_at: created_at,
115
+ item_updated_at: updated_at
116
+ }
117
+
118
+ if ['Administrator', 'Librarian'].include?(role)
119
+ record.merge!({
120
+ bookstore: bookstore&.name,
121
+ budget_type: budget_type&.name,
122
+ item_required_role: required_role.name,
123
+ item_price: price,
124
+ memo: memo
125
+ })
126
+
127
+ ItemCustomProperty.order(:position).each do |custom_property|
128
+ custom_value = item_custom_values.find_by(item_custom_property: custom_property)
129
+ record[:"item:#{custom_property.name}"] = custom_value.try(:value)
130
+ end
131
+
132
+ if defined?(EnjuCirculation)
133
+ record.merge!({
134
+ use_restriction: use_restriction&.name,
135
+ circulation_status: circulation_status&.name,
136
+ checkout_type: checkout_type&.name,
137
+ total_checkouts: checkouts.count
138
+ })
139
+ end
140
+ end
141
+
142
+ record
143
+ end
144
+ end
145
+
146
+ # == Schema Information
147
+ #
148
+ # Table name: items
149
+ #
150
+ # id :integer not null, primary key
151
+ # call_number :string
152
+ # item_identifier :string
153
+ # created_at :datetime
154
+ # updated_at :datetime
155
+ # shelf_id :integer default(1), not null
156
+ # include_supplements :boolean default(FALSE), not null
157
+ # note :text
158
+ # url :string
159
+ # price :integer
160
+ # lock_version :integer default(0), not null
161
+ # required_role_id :integer default(1), not null
162
+ # required_score :integer default(0), not null
163
+ # acquired_at :datetime
164
+ # bookstore_id :integer
165
+ # budget_type_id :integer
166
+ # circulation_status_id :integer default(5), not null
167
+ # checkout_type_id :integer default(1), not null
168
+ # binding_item_identifier :string
169
+ # binding_call_number :string
170
+ # binded_at :datetime
171
+ # manifestation_id :integer not null
172
+ # memo :text
173
+ #
@@ -0,0 +1,18 @@
1
+ class ItemCustomProperty < ApplicationRecord
2
+ include MasterModel
3
+ validates :name, presence: true, uniqueness: true
4
+ acts_as_list
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: item_custom_properties
10
+ #
11
+ # id :bigint not null, primary key
12
+ # name :string not null
13
+ # display_name :text not null
14
+ # note :text
15
+ # position :integer default(1), not null
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
+ #
@@ -0,0 +1,17 @@
1
+ class ItemCustomValue < ApplicationRecord
2
+ belongs_to :item_custom_property
3
+ belongs_to :item, optional: true
4
+ validates :item_custom_property, uniqueness: {scope: :item_id}
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: item_custom_values
10
+ #
11
+ # id :bigint not null, primary key
12
+ # item_custom_property_id :bigint not null
13
+ # item_id :bigint not null
14
+ # value :text
15
+ # created_at :datetime not null
16
+ # updated_at :datetime not null
17
+ #
@@ -0,0 +1,39 @@
1
+ class Language < ApplicationRecord
2
+ include MasterModel
3
+ # If you wish to change the field names for brevity, feel free to enable/modify these.
4
+ # alias_attribute :iso1, :iso_639_1
5
+ # alias_attribute :iso2, :iso_639_2
6
+ # alias_attribute :iso3, :iso_639_3
7
+
8
+ # Validations
9
+ validates :iso_639_1, :iso_639_2, :iso_639_3, presence: true
10
+ validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
11
+
12
+ translates :display_name
13
+
14
+ def self.available_languages
15
+ Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s}).order(:position)
16
+ end
17
+
18
+ private
19
+
20
+ def valid_name?
21
+ true
22
+ end
23
+ end
24
+
25
+ # == Schema Information
26
+ #
27
+ # Table name: languages
28
+ #
29
+ # id :integer not null, primary key
30
+ # name :string not null
31
+ # native_name :string
32
+ # old_display_name :text
33
+ # iso_639_1 :string
34
+ # iso_639_2 :string
35
+ # iso_639_3 :string
36
+ # note :text
37
+ # position :integer
38
+ # display_name_translations :jsonb not null
39
+ #
@@ -0,0 +1,18 @@
1
+ class License < ApplicationRecord
2
+ include MasterModel
3
+ translates :display_name
4
+ end
5
+
6
+ # == Schema Information
7
+ #
8
+ # Table name: licenses
9
+ #
10
+ # id :integer not null, primary key
11
+ # name :string not null
12
+ # old_display_name :string
13
+ # note :text
14
+ # position :integer
15
+ # created_at :datetime
16
+ # updated_at :datetime
17
+ # display_name_translations :jsonb not null
18
+ #