enju_biblio 0.3.8 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/content_types_controller.rb +1 -1
- data/app/controllers/item_custom_properties_controller.rb +69 -0
- data/app/controllers/items_controller.rb +2 -3
- data/app/controllers/manifestation_custom_properties_controller.rb +69 -0
- data/app/controllers/manifestations_controller.rb +12 -15
- data/app/controllers/resource_import_results_controller.rb +6 -2
- data/app/models/agent.rb +6 -6
- data/app/models/agent_import_file.rb +7 -7
- data/app/models/agent_type.rb +0 -1
- data/app/models/carrier_type.rb +0 -1
- data/app/models/content_type.rb +0 -1
- data/app/models/form_of_work.rb +1 -2
- data/app/models/frequency.rb +0 -1
- data/app/models/identifier_type.rb +0 -1
- data/app/models/item.rb +15 -16
- data/app/models/item_custom_property.rb +18 -0
- data/app/models/item_custom_value.rb +17 -0
- data/app/models/license.rb +0 -1
- data/app/models/manifestation.rb +54 -22
- data/app/models/manifestation_custom_property.rb +18 -0
- data/app/models/manifestation_custom_value.rb +17 -0
- data/app/models/medium_of_performance.rb +1 -2
- data/app/models/picture_file.rb +0 -2
- data/app/models/resource_export_file.rb +4 -2
- data/app/models/resource_import_file.rb +157 -67
- data/app/policies/item_custom_property_policy.rb +21 -0
- data/app/policies/manifestation_custom_property_policy.rb +21 -0
- data/app/views/agent_import_results/index.txt.ruby +5 -0
- data/app/views/agent_relationship_types/_form.html.erb +1 -1
- data/app/views/agent_types/_form.html.erb +1 -1
- data/app/views/carrier_types/_form.html.erb +1 -1
- data/app/views/create_types/_form.html.erb +1 -1
- data/app/views/form_of_works/_form.html.erb +1 -1
- data/app/views/frequencies/_form.html.erb +1 -1
- data/app/views/item_custom_properties/_form.html.erb +32 -0
- data/app/views/item_custom_properties/edit.html.erb +13 -0
- data/app/views/item_custom_properties/index.html.erb +43 -0
- data/app/views/item_custom_properties/new.html.erb +12 -0
- data/app/views/item_custom_properties/show.html.erb +28 -0
- data/app/views/items/_form.html.erb +13 -10
- data/app/views/items/show.html.erb +3 -4
- data/app/views/licenses/_form.html.erb +1 -1
- data/app/views/manifestation_custom_properties/_form.html.erb +32 -0
- data/app/views/manifestation_custom_properties/edit.html.erb +13 -0
- data/app/views/manifestation_custom_properties/index.html.erb +43 -0
- data/app/views/manifestation_custom_properties/new.html.erb +12 -0
- data/app/views/manifestation_custom_properties/show.html.erb +28 -0
- data/app/views/manifestation_relationship_types/_form.html.erb +1 -1
- data/app/views/manifestations/_export_detail.html.erb +1 -0
- data/app/views/manifestations/_export_list.html.erb +1 -0
- data/app/views/manifestations/_form.html.erb +18 -10
- data/app/views/manifestations/_show_detail_librarian.html.erb +9 -3
- data/app/views/manifestations/_show_detail_user.html.erb +8 -0
- data/app/views/manifestations/show.json.jbuilder +2 -0
- data/app/views/medium_of_performances/_form.html.erb +1 -1
- data/app/views/picture_files/edit.html.erb +4 -0
- data/app/views/produce_types/_form.html.erb +1 -1
- data/app/views/realize_types/_form.html.erb +1 -1
- data/app/views/resource_import_results/index.txt.ruby +5 -0
- data/app/views/series_statement_merges/_form.html.erb +1 -1
- data/config/locales/translation_en.yml +22 -8
- data/config/locales/translation_ja.yml +22 -8
- data/config/routes.rb +2 -0
- data/db/migrate/20081027150907_create_picture_files.rb +0 -2
- data/db/migrate/20200425072340_create_manifestation_custom_properties.rb +12 -0
- data/db/migrate/20200425072349_create_item_custom_properties.rb +12 -0
- data/db/migrate/20200425074758_create_manifestation_custom_values.rb +12 -0
- data/db/migrate/20200425074822_create_item_custom_values.rb +12 -0
- data/lib/enju_biblio/version.rb +1 -1
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_import_custom_values.yml +121 -0
- data/spec/cassette_library/resource_import_results/index_txt_ruby/renders_a_list_of_resource_import_results.yml +121 -0
- data/spec/controllers/content_types_controller_spec.rb +1 -1
- data/spec/controllers/item_custom_properties_controller_spec.rb +449 -0
- data/spec/controllers/items_controller_spec.rb +22 -25
- data/spec/controllers/manifestation_custom_properties_controller_spec.rb +449 -0
- data/spec/controllers/manifestations_controller_spec.rb +20 -23
- data/spec/dummy/db/schema.rb +43 -12
- data/spec/factories/item_custom_property.rb +6 -0
- data/spec/factories/item_custom_value.rb +6 -0
- data/spec/factories/manifestation_custom_property.rb +6 -0
- data/spec/factories/manifestation_custom_value.rb +6 -0
- data/spec/fixtures/creates.yml +2 -0
- data/spec/fixtures/item_custom_properties.yml +24 -0
- data/spec/fixtures/library_groups.yml +29 -15
- data/spec/fixtures/manifestation_custom_properties.yml +24 -0
- data/spec/fixtures/picture_files.yml +0 -2
- data/spec/fixtures/produces.yml +2 -0
- data/spec/fixtures/realizes.yml +2 -0
- data/spec/fixtures/resource_import_results.yml +2 -2
- data/spec/models/item_custom_property_spec.rb +18 -0
- data/spec/models/item_custom_value_spec.rb +17 -0
- data/spec/models/manifestation_custom_property_spec.rb +18 -0
- data/spec/models/manifestation_custom_value_spec.rb +17 -0
- data/spec/models/manifestation_spec.rb +11 -21
- data/spec/models/picture_file_spec.rb +0 -2
- data/spec/models/resource_export_file_spec.rb +61 -8
- data/spec/models/resource_import_file_spec.rb +43 -13
- data/spec/requests/item_custom_properties_spec.rb +129 -0
- data/spec/requests/manifestation_custom_properties_spec.rb +129 -0
- data/spec/routing/item_custom_properties_routing_spec.rb +38 -0
- data/spec/routing/manifestation_custom_properties_routing_spec.rb +38 -0
- data/spec/system/items_spec.rb +12 -0
- data/spec/system/manifestations_spec.rb +12 -0
- data/spec/views/agent_import_results/index.html.erb_spec.rb +29 -0
- data/spec/views/agent_import_results/index.txt.ruby_spec.rb +20 -0
- data/spec/views/agent_import_results/show.html.erb_spec.rb +24 -0
- data/spec/views/item_custom_properties/edit.html.erb_spec.rb +21 -0
- data/spec/views/item_custom_properties/index.html.erb_spec.rb +25 -0
- data/spec/views/item_custom_properties/new.html.erb_spec.rb +21 -0
- data/spec/views/item_custom_properties/show.html.erb_spec.rb +16 -0
- data/spec/views/manifestation_custom_properties/edit.html.erb_spec.rb +21 -0
- data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +25 -0
- data/spec/views/manifestation_custom_properties/new.html.erb_spec.rb +21 -0
- data/spec/views/manifestation_custom_properties/show.html.erb_spec.rb +16 -0
- data/spec/views/manifestations/show.json.jbuilder_spec.rb +16 -0
- data/spec/views/manifestations/show.txt.ruby_spec.rb +1 -1
- data/spec/views/resource_import_results/index.txt.ruby_spec.rb +22 -0
- data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
- metadata +118 -37
- data/app/models/custom_property.rb +0 -17
- data/app/views/agent_import_results/index.txt.erb +0 -3
- data/app/views/items/_custom_property_fields.html.erb +0 -7
- data/app/views/manifestations/_custom_property_fields.html.erb +0 -7
- data/app/views/resource_import_results/index.txt.erb +0 -3
- data/db/migrate/20191219122214_create_custom_properties.rb +0 -12
- data/spec/factories/custom_property.rb +0 -18
- data/spec/models/custom_property_spec.rb +0 -18
- data/spec/system/custom_properties_spec.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d531d406b5fda2fe6871aacfff5e40ee50b4b9e705011b48194043636435d4f
|
4
|
+
data.tar.gz: 254254c68a6ad93a6e05ca9db4bcc38dcb5abd6ba100cdb26dd9f1d6cc8a3ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab53272b3a84a1970be279892113c5296ca7eb3ee5fa8058d807b716737597dabe1d4a087e1abfed6763853920a922096ba0d932de6e2645bb3dfb96040e3f50
|
7
|
+
data.tar.gz: 9967b069e6d50dd77c0ed2f1d42c06d574d1138164e569043fb00861bd4b6246105288f052fb0351993a60531e87f9c79266def019ac45e749f548caf1162e02
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class ItemCustomPropertiesController < ApplicationController
|
2
|
+
before_action :set_item_custom_property, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :check_policy, only: [:index, :new, :create ]
|
4
|
+
|
5
|
+
# GET /item_custom_properties
|
6
|
+
def index
|
7
|
+
@item_custom_properties = ItemCustomProperty.order(:position)
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /item_custom_properties/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /item_custom_properties/new
|
15
|
+
def new
|
16
|
+
@item_custom_property = ItemCustomProperty.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /item_custom_properties/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /item_custom_properties
|
24
|
+
def create
|
25
|
+
@item_custom_property = ItemCustomProperty.new(item_custom_property_params)
|
26
|
+
|
27
|
+
if @item_custom_property.save
|
28
|
+
redirect_to @item_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.item_custom_property'))
|
29
|
+
else
|
30
|
+
render :new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /item_custom_properties/1
|
35
|
+
def update
|
36
|
+
if params[:move]
|
37
|
+
move_position(@item_custom_property, params[:move])
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
if @item_custom_property.update(item_custom_property_params)
|
42
|
+
redirect_to @item_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.item_custom_property'))
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /item_custom_properties/1
|
49
|
+
def destroy
|
50
|
+
@item_custom_property.destroy
|
51
|
+
redirect_to item_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.item_custom_property'))
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
# Use callbacks to share common setup or constraints between actions.
|
56
|
+
def set_item_custom_property
|
57
|
+
@item_custom_property = ItemCustomProperty.find(params[:id])
|
58
|
+
authorize @item_custom_property
|
59
|
+
end
|
60
|
+
|
61
|
+
def check_policy
|
62
|
+
authorize ItemCustomProperty
|
63
|
+
end
|
64
|
+
|
65
|
+
# Only allow a trusted parameter "white list" through.
|
66
|
+
def item_custom_property_params
|
67
|
+
params.require(:item_custom_property).permit(:name, :display_name, :note)
|
68
|
+
end
|
69
|
+
end
|
@@ -274,9 +274,8 @@ class ItemsController < ApplicationController
|
|
274
274
|
:binding_item_identifier, :binding_call_number, :binded_at,
|
275
275
|
:use_restriction_id, :memo,
|
276
276
|
{item_has_use_restriction_attributes: :use_restriction_id}, # EnjuCirculation
|
277
|
-
{
|
278
|
-
:id, :
|
279
|
-
:_destroy
|
277
|
+
{item_custom_values_attributes: [
|
278
|
+
:id, :item_custom_property_id, :item_id, :value,:_destroy
|
280
279
|
]}
|
281
280
|
)
|
282
281
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class ManifestationCustomPropertiesController < ApplicationController
|
2
|
+
before_action :set_manifestation_custom_property, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :check_policy, only: [:index, :new, :create ]
|
4
|
+
|
5
|
+
# GET /manifestation_custom_properties
|
6
|
+
def index
|
7
|
+
@manifestation_custom_properties = ManifestationCustomProperty.order(:position)
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /manifestation_custom_properties/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /manifestation_custom_properties/new
|
15
|
+
def new
|
16
|
+
@manifestation_custom_property = ManifestationCustomProperty.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /manifestation_custom_properties/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /manifestation_custom_properties
|
24
|
+
def create
|
25
|
+
@manifestation_custom_property = ManifestationCustomProperty.new(manifestation_custom_property_params)
|
26
|
+
|
27
|
+
if @manifestation_custom_property.save
|
28
|
+
redirect_to @manifestation_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_custom_property'))
|
29
|
+
else
|
30
|
+
render :new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /manifestation_custom_properties/1
|
35
|
+
def update
|
36
|
+
if params[:move]
|
37
|
+
move_position(@manifestation_custom_property, params[:move])
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
if @manifestation_custom_property.update(manifestation_custom_property_params)
|
42
|
+
redirect_to @manifestation_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_custom_property'))
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /manifestation_custom_properties/1
|
49
|
+
def destroy
|
50
|
+
@manifestation_custom_property.destroy
|
51
|
+
redirect_to manifestation_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.manifestation_custom_property'))
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
# Use callbacks to share common setup or constraints between actions.
|
56
|
+
def set_manifestation_custom_property
|
57
|
+
@manifestation_custom_property = ManifestationCustomProperty.find(params[:id])
|
58
|
+
authorize @manifestation_custom_property
|
59
|
+
end
|
60
|
+
|
61
|
+
def check_policy
|
62
|
+
authorize ManifestationCustomProperty
|
63
|
+
end
|
64
|
+
|
65
|
+
# Only allow a trusted parameter "white list" through.
|
66
|
+
def manifestation_custom_property_params
|
67
|
+
params.require(:manifestation_custom_property).permit(:name, :display_name, :note)
|
68
|
+
end
|
69
|
+
end
|
@@ -332,7 +332,7 @@ class ManifestationsController < ApplicationController
|
|
332
332
|
}
|
333
333
|
format.rdf
|
334
334
|
format.mods
|
335
|
-
format.json
|
335
|
+
format.json
|
336
336
|
format.txt
|
337
337
|
format.js
|
338
338
|
format.download {
|
@@ -355,8 +355,8 @@ class ManifestationsController < ApplicationController
|
|
355
355
|
# GET /manifestations/new.json
|
356
356
|
def new
|
357
357
|
@manifestation = Manifestation.new
|
358
|
-
@manifestation.language = Language.
|
359
|
-
@parent = Manifestation.
|
358
|
+
@manifestation.language = Language.find_by(iso_639_1: @locale)
|
359
|
+
@parent = Manifestation.find_by(id: params[:parent_id]) if params[:parent_id].present?
|
360
360
|
if @parent
|
361
361
|
@manifestation.parent_id = @parent.id
|
362
362
|
[ :original_title, :title_transcription,
|
@@ -550,9 +550,8 @@ class ManifestationsController < ApplicationController
|
|
550
550
|
:id, :body, :identifier_type_id,
|
551
551
|
:_destroy
|
552
552
|
]},
|
553
|
-
{
|
554
|
-
:id, :
|
555
|
-
:_destroy
|
553
|
+
{manifestation_custom_values_attributes: [
|
554
|
+
:id, :manifestation_custom_property_id, :manifestation_id, :value,:_destroy
|
556
555
|
]}
|
557
556
|
)
|
558
557
|
end
|
@@ -738,12 +737,12 @@ class ManifestationsController < ApplicationController
|
|
738
737
|
end
|
739
738
|
|
740
739
|
def prepare_options
|
741
|
-
@carrier_types = CarrierType.select([:id, :display_name, :position])
|
742
|
-
@content_types = ContentType.select([:id, :display_name, :position])
|
740
|
+
@carrier_types = CarrierType.order(:position).select([:id, :display_name, :position])
|
741
|
+
@content_types = ContentType.order(:position).select([:id, :display_name, :position])
|
743
742
|
@roles = Role.select([:id, :display_name, :position])
|
744
|
-
@languages = Language.select([:id, :display_name, :position])
|
745
|
-
@frequencies = Frequency.select([:id, :display_name, :position])
|
746
|
-
@identifier_types = IdentifierType.select([:id, :display_name, :position])
|
743
|
+
@languages = Language.order(:position).select([:id, :display_name, :position])
|
744
|
+
@frequencies = Frequency.order(:position).select([:id, :display_name, :position])
|
745
|
+
@identifier_types = IdentifierType.order(:position).select([:id, :display_name, :position])
|
747
746
|
@nii_types = NiiType.select([:id, :display_name, :position]) if defined?(EnjuNii)
|
748
747
|
if defined?(EnjuSubject)
|
749
748
|
@subject_types = SubjectType.select([:id, :display_name, :position])
|
@@ -783,7 +782,7 @@ class ManifestationsController < ApplicationController
|
|
783
782
|
if options[:pub_date_from].blank?
|
784
783
|
pub_date[:from] = "*"
|
785
784
|
else
|
786
|
-
year = options[:pub_date_from].rjust(4, "0")
|
785
|
+
year = options[:pub_date_from].to_s.gsub(/\D/, '').rjust(4, "0")
|
787
786
|
if year.length == 4
|
788
787
|
pub_date[:from] = Time.zone.parse(Time.utc(year).to_s).beginning_of_year.utc.iso8601
|
789
788
|
else
|
@@ -797,7 +796,7 @@ class ManifestationsController < ApplicationController
|
|
797
796
|
if options[:pub_date_until].blank?
|
798
797
|
pub_date[:until] = "*"
|
799
798
|
else
|
800
|
-
year = options[:pub_date_until].rjust(4, "0")
|
799
|
+
year = options[:pub_date_until].to_s.gsub(/\D/, '').rjust(4, "0")
|
801
800
|
if year.length == 4
|
802
801
|
pub_date[:until] = Time.zone.parse(Time.utc(year).to_s).end_of_year.utc.iso8601
|
803
802
|
else
|
@@ -812,8 +811,6 @@ class ManifestationsController < ApplicationController
|
|
812
811
|
|
813
812
|
def set_pub_date(query, options)
|
814
813
|
unless options[:pub_date_from].blank? && options[:pub_date_until].blank?
|
815
|
-
options[:pub_date_from].to_s.gsub!(/\D/, '')
|
816
|
-
options[:pub_date_until].to_s.gsub!(/\D/, '')
|
817
814
|
pub_date = parse_pub_date(options)
|
818
815
|
query = "#{query} date_of_publication_d:[#{pub_date[:from]} TO #{pub_date[:until]}]"
|
819
816
|
end
|
@@ -5,9 +5,13 @@ class ResourceImportResultsController < ApplicationController
|
|
5
5
|
# GET /resource_import_results
|
6
6
|
# GET /resource_import_results.json
|
7
7
|
def index
|
8
|
-
@resource_import_file = ResourceImportFile.
|
8
|
+
@resource_import_file = ResourceImportFile.find_by(id: params[:resource_import_file_id])
|
9
9
|
if @resource_import_file
|
10
|
-
|
10
|
+
if params[:format].to_s.downcase == 'txt'
|
11
|
+
@resource_import_results = @resource_import_file.resource_import_results
|
12
|
+
else
|
13
|
+
@resource_import_results = @resource_import_file.resource_import_results.page(params[:page])
|
14
|
+
end
|
11
15
|
else
|
12
16
|
@resource_import_results = ResourceImportResult.page(params[:page])
|
13
17
|
end
|
data/app/models/agent.rb
CHANGED
@@ -76,7 +76,7 @@ class Agent < ApplicationRecord
|
|
76
76
|
paginates_per 10
|
77
77
|
|
78
78
|
def set_role_and_name
|
79
|
-
self.required_role = Role.
|
79
|
+
self.required_role = Role.find_by(name: 'Librarian') if required_role_id.nil?
|
80
80
|
set_full_name
|
81
81
|
end
|
82
82
|
|
@@ -202,15 +202,15 @@ class Agent < ApplicationRecord
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def created(work)
|
205
|
-
creates.
|
205
|
+
creates.find_by(work_id: work.id)
|
206
206
|
end
|
207
207
|
|
208
208
|
def realized(expression)
|
209
|
-
realizes.
|
209
|
+
realizes.find_by(expression_id: expression.id)
|
210
210
|
end
|
211
211
|
|
212
212
|
def produced(manifestation)
|
213
|
-
produces.
|
213
|
+
produces.find_by(manifestation_id: manifestation.id)
|
214
214
|
end
|
215
215
|
|
216
216
|
def owned(item)
|
@@ -222,7 +222,7 @@ class Agent < ApplicationRecord
|
|
222
222
|
agent_lists.each do |agent_list|
|
223
223
|
name_and_role = agent_list[:full_name].split('||')
|
224
224
|
if agent_list[:agent_identifier].present?
|
225
|
-
agent = Agent.
|
225
|
+
agent = Agent.find_by(agent_identifier: agent_list[:agent_identifier])
|
226
226
|
else
|
227
227
|
agents_matched = Agent.where(full_name: name_and_role[0])
|
228
228
|
agents_matched = agents_matched.where(place: agent_list[:place]) if agent_list[:place]
|
@@ -237,7 +237,7 @@ class Agent < ApplicationRecord
|
|
237
237
|
place: agent_list[:place],
|
238
238
|
language_id: 1,
|
239
239
|
)
|
240
|
-
agent.required_role = Role.
|
240
|
+
agent.required_role = Role.find_by(name: 'Guest')
|
241
241
|
agent.save
|
242
242
|
end
|
243
243
|
agents << agent
|
@@ -116,7 +116,7 @@ class AgentImportFile < ApplicationRecord
|
|
116
116
|
rows.each do |row|
|
117
117
|
row_num += 1
|
118
118
|
next if row['dummy'].to_s.strip.present?
|
119
|
-
agent = Agent.
|
119
|
+
agent = Agent.find_by(id: row['id'])
|
120
120
|
if agent
|
121
121
|
agent.full_name = row['full_name'] if row['full_name'].to_s.strip.present?
|
122
122
|
agent.full_name_transcription = row['full_name_transcription'] if row['full_name_transcription'].to_s.strip.present?
|
@@ -151,7 +151,7 @@ class AgentImportFile < ApplicationRecord
|
|
151
151
|
rows.each do |row|
|
152
152
|
row_num += 1
|
153
153
|
next if row['dummy'].to_s.strip.present?
|
154
|
-
agent = Agent.
|
154
|
+
agent = Agent.find_by(id: row['id'].to_s.strip)
|
155
155
|
if agent
|
156
156
|
agent.picture_files.destroy_all
|
157
157
|
agent.reload
|
@@ -225,15 +225,15 @@ class AgentImportFile < ApplicationRecord
|
|
225
225
|
|
226
226
|
#if row['username'].to_s.strip.blank?
|
227
227
|
agent.email = row['email'].to_s.strip
|
228
|
-
agent.required_role = Role.
|
228
|
+
agent.required_role = Role.find_by(name: row['required_role'].to_s.strip.camelize) || Role.find_by(name: 'Guest')
|
229
229
|
#else
|
230
230
|
# agent.required_role = Role.where(name: row['required_role'].to_s.strip.camelize).first || Role.where('Librarian').first
|
231
231
|
#end
|
232
|
-
language = Language.
|
233
|
-
language = Language.
|
234
|
-
language = Language.
|
232
|
+
language = Language.find_by(name: row['language'].to_s.strip.camelize)
|
233
|
+
language = Language.find_by(iso_639_2: row['language'].to_s.strip.downcase) unless language
|
234
|
+
language = Language.find_by(iso_639_1: row['language'].to_s.strip.downcase) unless language
|
235
235
|
agent.language = language if language
|
236
|
-
country = Country.
|
236
|
+
country = Country.find_by(name: row['country'].to_s.strip)
|
237
237
|
agent.country = country if country
|
238
238
|
agent
|
239
239
|
end
|
data/app/models/agent_type.rb
CHANGED
data/app/models/carrier_type.rb
CHANGED
data/app/models/content_type.rb
CHANGED
data/app/models/form_of_work.rb
CHANGED
data/app/models/frequency.rb
CHANGED
data/app/models/item.rb
CHANGED
@@ -19,12 +19,12 @@ class Item < ApplicationRecord
|
|
19
19
|
belongs_to :budget_type, optional: true
|
20
20
|
has_one :accept, dependent: :destroy
|
21
21
|
has_one :withdraw, dependent: :destroy
|
22
|
-
has_many :
|
23
|
-
accepts_nested_attributes_for :custom_properties, allow_destroy: true, reject_if: :all_blank
|
24
|
-
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)}
|
22
|
+
has_many :item_custom_values, -> { joins(:item_custom_property).order(:position) }
|
25
23
|
|
26
24
|
belongs_to :shelf, counter_cache: true
|
25
|
+
accepts_nested_attributes_for :item_custom_values, reject_if: :all_blank
|
27
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
28
|
validates_associated :bookstore
|
29
29
|
validates :manifestation_id, presence: true
|
30
30
|
validates :item_identifier, allow_blank: true, uniqueness: true,
|
@@ -107,10 +107,11 @@ class Item < ApplicationRecord
|
|
107
107
|
record = {
|
108
108
|
item_id: id,
|
109
109
|
item_identifier: item_identifier,
|
110
|
+
binding_item_identifier: binding_item_identifier,
|
110
111
|
call_number: call_number,
|
111
|
-
shelf: shelf
|
112
|
+
shelf: shelf&.name,
|
112
113
|
item_note: note,
|
113
|
-
accepted_at: accept
|
114
|
+
accepted_at: accept&.created_at,
|
114
115
|
acquired_at: acquired_at,
|
115
116
|
item_created_at: created_at,
|
116
117
|
item_updated_at: updated_at
|
@@ -118,25 +119,23 @@ class Item < ApplicationRecord
|
|
118
119
|
|
119
120
|
if ['Administrator', 'Librarian'].include?(role)
|
120
121
|
record.merge!({
|
121
|
-
bookstore: bookstore
|
122
|
-
budget_type: budget_type
|
122
|
+
bookstore: bookstore&.name,
|
123
|
+
budget_type: budget_type&.name,
|
124
|
+
item_required_role: required_role.name,
|
123
125
|
item_price: price,
|
124
126
|
memo: memo
|
125
127
|
})
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
if property
|
131
|
-
record[:"item_custom_property_#{i + 1}"] = "#{property.label}: #{property.value}"
|
132
|
-
else
|
133
|
-
record[:"item_custom_property_#{i + 1}"] = nil
|
134
|
-
end
|
129
|
+
ItemCustomProperty.order(:position).each do |custom_property|
|
130
|
+
custom_value = item_custom_values.find_by(item_custom_property: custom_property)
|
131
|
+
record[:"item:#{custom_property.name}"] = custom_value.try(:value)
|
135
132
|
end
|
136
133
|
|
137
134
|
if defined?(EnjuCirculation)
|
138
135
|
record.merge!({
|
139
|
-
use_restriction: use_restriction
|
136
|
+
use_restriction: use_restriction&.name,
|
137
|
+
circulation_status: circulation_status&.name,
|
138
|
+
checkout_type: checkout_type&.name,
|
140
139
|
total_checkouts: checkouts.count
|
141
140
|
})
|
142
141
|
end
|