enju_biblio 0.1.0.pre63 → 0.1.0.pre64

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/agent_import_files_controller.rb +9 -2
  3. data/app/controllers/agent_import_results_controller.rb +7 -0
  4. data/app/controllers/agent_merge_lists_controller.rb +7 -2
  5. data/app/controllers/agent_merges_controller.rb +7 -2
  6. data/app/controllers/agent_relationship_types_controller.rb +9 -4
  7. data/app/controllers/agent_relationships_controller.rb +8 -2
  8. data/app/controllers/agent_types_controller.rb +9 -4
  9. data/app/controllers/agents_controller.rb +15 -10
  10. data/app/controllers/carrier_types_controller.rb +14 -2
  11. data/app/controllers/content_types_controller.rb +9 -4
  12. data/app/controllers/countries_controller.rb +11 -4
  13. data/app/controllers/create_types_controller.rb +9 -4
  14. data/app/controllers/creates_controller.rb +8 -2
  15. data/app/controllers/donates_controller.rb +7 -2
  16. data/app/controllers/form_of_works_controller.rb +9 -4
  17. data/app/controllers/frequencies_controller.rb +9 -4
  18. data/app/controllers/identifier_types_controller.rb +11 -4
  19. data/app/controllers/import_requests_controller.rb +15 -2
  20. data/app/controllers/items_controller.rb +21 -3
  21. data/app/controllers/languages_controller.rb +12 -4
  22. data/app/controllers/licenses_controller.rb +9 -4
  23. data/app/controllers/manifestation_relationship_types_controller.rb +11 -4
  24. data/app/controllers/manifestation_relationships_controller.rb +8 -2
  25. data/app/controllers/manifestations_controller.rb +105 -10
  26. data/app/controllers/medium_of_performances_controller.rb +9 -4
  27. data/app/controllers/owns_controller.rb +7 -2
  28. data/app/controllers/picture_files_controller.rb +8 -2
  29. data/app/controllers/produce_types_controller.rb +9 -4
  30. data/app/controllers/produces_controller.rb +8 -2
  31. data/app/controllers/realize_types_controller.rb +11 -4
  32. data/app/controllers/realizes_controller.rb +8 -2
  33. data/app/controllers/resource_export_files_controller.rb +7 -2
  34. data/app/controllers/resource_import_files_controller.rb +9 -2
  35. data/app/controllers/resource_import_results_controller.rb +7 -0
  36. data/app/controllers/series_statement_merge_lists_controller.rb +7 -2
  37. data/app/controllers/series_statement_merges_controller.rb +9 -2
  38. data/app/controllers/series_statements_controller.rb +13 -2
  39. data/app/models/agent.rb +0 -9
  40. data/app/models/agent_import_file.rb +3 -3
  41. data/app/models/agent_import_file_transition.rb +1 -1
  42. data/app/models/agent_import_result.rb +0 -1
  43. data/app/models/agent_merge.rb +0 -1
  44. data/app/models/agent_merge_list.rb +0 -1
  45. data/app/models/agent_relationship.rb +0 -1
  46. data/app/models/agent_relationship_type.rb +0 -1
  47. data/app/models/agent_type.rb +0 -1
  48. data/app/models/carrier_type.rb +1 -7
  49. data/app/models/content_type.rb +0 -1
  50. data/app/models/country.rb +0 -1
  51. data/app/models/create.rb +0 -1
  52. data/app/models/create_type.rb +0 -1
  53. data/app/models/donate.rb +0 -1
  54. data/app/models/enju_biblio/ability.rb +25 -2
  55. data/app/models/exemplify.rb +1 -1
  56. data/app/models/form_of_work.rb +0 -1
  57. data/app/models/frequency.rb +0 -1
  58. data/app/models/identifier.rb +1 -1
  59. data/app/models/identifier_type.rb +0 -1
  60. data/app/models/import_request.rb +8 -7
  61. data/app/models/import_request_transition.rb +1 -1
  62. data/app/models/item.rb +0 -5
  63. data/app/models/language.rb +0 -2
  64. data/app/models/license.rb +0 -1
  65. data/app/models/manifestation.rb +29 -33
  66. data/app/models/manifestation_relationship.rb +0 -1
  67. data/app/models/manifestation_relationship_type.rb +0 -1
  68. data/app/models/medium_of_performance.rb +0 -1
  69. data/app/models/own.rb +0 -1
  70. data/app/models/picture_file.rb +1 -3
  71. data/app/models/produce.rb +0 -1
  72. data/app/models/produce_type.rb +0 -1
  73. data/app/models/realize.rb +0 -1
  74. data/app/models/realize_type.rb +0 -1
  75. data/app/models/resource_export_file.rb +9 -3
  76. data/app/models/resource_export_file_transition.rb +1 -1
  77. data/app/models/resource_import_file.rb +18 -10
  78. data/app/models/resource_import_file_transition.rb +1 -1
  79. data/app/models/resource_import_result.rb +0 -1
  80. data/app/models/series_statement.rb +0 -7
  81. data/app/models/series_statement_merge.rb +0 -1
  82. data/app/models/series_statement_merge_list.rb +0 -1
  83. data/app/views/items/index.html.erb +11 -0
  84. data/app/views/layouts/items.html.erb +29 -0
  85. data/app/views/manifestations/_form.html.erb +3 -3
  86. data/app/views/manifestations/_index_form_series_statement.html.erb +1 -1
  87. data/app/views/manifestations/_list.html.erb +15 -0
  88. data/app/views/manifestations/_manifestation.html.erb +59 -38
  89. data/app/views/manifestations/_pickup.html.erb +8 -0
  90. data/app/views/manifestations/_show_detail_librarian.html.erb +8 -0
  91. data/app/views/manifestations/_show_detail_user.html.erb +8 -0
  92. data/app/views/manifestations/_show_holding.html.erb +19 -0
  93. data/app/views/manifestations/_submenu_parent.html.erb +3 -0
  94. data/app/views/manifestations/index.atom.builder +3 -0
  95. data/app/views/manifestations/index.html.erb +31 -1
  96. data/app/views/manifestations/index.opds.builder +3 -0
  97. data/app/views/manifestations/show.html.erb +4 -1
  98. data/app/views/resource_export_files/index.html.erb +2 -2
  99. data/app/views/resource_export_files/show.html.erb +1 -1
  100. data/config/locales/translation_en.yml +1 -0
  101. data/config/locales/translation_ja.yml +1 -0
  102. data/db/migrate/20150117111136_add_foreign_key_to_items_referencing_manifestations.rb +5 -0
  103. data/lib/enju_biblio/biblio_helper.rb +2 -0
  104. data/lib/enju_biblio/engine.rb +0 -1
  105. data/lib/enju_biblio/version.rb +1 -1
  106. data/spec/controllers/agent_import_files_controller_spec.rb +3 -3
  107. data/spec/controllers/agent_merge_lists_controller_spec.rb +2 -2
  108. data/spec/controllers/agent_merges_controller_spec.rb +1 -1
  109. data/spec/controllers/agent_types_controller_spec.rb +8 -8
  110. data/spec/controllers/carrier_types_controller_spec.rb +8 -8
  111. data/spec/controllers/content_types_controller_spec.rb +8 -8
  112. data/spec/controllers/create_types_controller_spec.rb +6 -6
  113. data/spec/controllers/form_of_works_controller_spec.rb +6 -6
  114. data/spec/controllers/frequencies_controller_spec.rb +8 -8
  115. data/spec/controllers/identifier_types_controller_spec.rb +8 -8
  116. data/spec/controllers/licenses_controller_spec.rb +6 -6
  117. data/spec/controllers/manifestations_controller_spec.rb +22 -2
  118. data/spec/controllers/medium_of_performances_controller_spec.rb +6 -6
  119. data/spec/controllers/produce_types_controller_spec.rb +6 -6
  120. data/spec/controllers/realize_types_controller_spec.rb +6 -6
  121. data/spec/controllers/resource_export_files_controller_spec.rb +23 -23
  122. data/spec/controllers/resource_import_files_controller_spec.rb +4 -4
  123. data/spec/dummy/app/models/user.rb +0 -1
  124. data/spec/dummy/bin/bundle +3 -0
  125. data/spec/dummy/bin/rails +4 -0
  126. data/spec/dummy/bin/rake +4 -0
  127. data/spec/dummy/bin/setup +29 -0
  128. data/spec/dummy/config/application.rb +2 -2
  129. data/spec/dummy/config/boot.rb +4 -9
  130. data/spec/dummy/config/environment.rb +3 -3
  131. data/spec/dummy/db/schema.rb +118 -118
  132. data/spec/factories/manifestation.rb +8 -0
  133. data/spec/factories/series_statement.rb +5 -0
  134. data/spec/fixtures/events.yml +13 -39
  135. data/spec/fixtures/identifier_types.yml +7 -0
  136. data/spec/fixtures/identifiers.yml +7 -0
  137. data/spec/fixtures/manifestations.yml +9 -0
  138. data/spec/fixtures/use_restrictions.yml +1 -1
  139. data/spec/views/manifestations/show.html.erb_spec.rb +8 -0
  140. metadata +31 -43
  141. data/spec/dummy/db/test.sqlite3 +0 -0
  142. data/spec/dummy/script/rails +0 -6
  143. data/spec/dummy/tmp/cache/stdout +0 -25
  144. data/spec/dummy/tmp/pids/redis-test.pid +0 -1
@@ -38,11 +38,11 @@ class FormOfWorksController < ApplicationController
38
38
  # POST /form_of_works
39
39
  # POST /form_of_works.json
40
40
  def create
41
- @form_of_work = FormOfWork.new(params[:form_of_work])
41
+ @form_of_work = FormOfWork.new(form_of_work_params)
42
42
 
43
43
  respond_to do |format|
44
44
  if @form_of_work.save
45
- format.html { redirect_to @form_of_work, notice: t('controller.successfully_created', model: t('activerecord.models.form_of_work')) }
45
+ format.html { redirect_to @form_of_work, notice: t('controller.successfully_created', model: t('activerecord.models.form_of_work')) }
46
46
  format.json { render json: @form_of_work, status: :created, location: @form_of_work }
47
47
  else
48
48
  format.html { render action: "new" }
@@ -60,8 +60,8 @@ class FormOfWorksController < ApplicationController
60
60
  end
61
61
 
62
62
  respond_to do |format|
63
- if @form_of_work.update_attributes(params[:form_of_work])
64
- format.html { redirect_to @form_of_work, notice: t('controller.successfully_updated', model: t('activerecord.models.form_of_work')) }
63
+ if @form_of_work.update_attributes(form_of_work_params)
64
+ format.html { redirect_to @form_of_work, notice: t('controller.successfully_updated', model: t('activerecord.models.form_of_work')) }
65
65
  format.json { head :no_content }
66
66
  else
67
67
  format.html { render action: "edit" }
@@ -80,4 +80,9 @@ class FormOfWorksController < ApplicationController
80
80
  format.json { head :no_content }
81
81
  end
82
82
  end
83
+
84
+ private
85
+ def form_of_work_params
86
+ params.require(:form_of_work).permit(:name, :display_name, :note)
87
+ end
83
88
  end
@@ -38,11 +38,11 @@ class FrequenciesController < ApplicationController
38
38
  # POST /frequencies
39
39
  # POST /frequencies.json
40
40
  def create
41
- @frequency = Frequency.new(params[:frequency])
41
+ @frequency = Frequency.new(frequency_params)
42
42
 
43
43
  respond_to do |format|
44
44
  if @frequency.save
45
- format.html { redirect_to @frequency, notice: t('controller.successfully_created', model: t('activerecord.models.frequency')) }
45
+ format.html { redirect_to @frequency, notice: t('controller.successfully_created', model: t('activerecord.models.frequency')) }
46
46
  format.json { render json: @frequency, status: :created, location: @frequency }
47
47
  else
48
48
  format.html { render action: "new" }
@@ -60,8 +60,8 @@ class FrequenciesController < ApplicationController
60
60
  end
61
61
 
62
62
  respond_to do |format|
63
- if @frequency.update_attributes(params[:frequency])
64
- format.html { redirect_to @frequency, notice: t('controller.successfully_updated', model: t('activerecord.models.frequency')) }
63
+ if @frequency.update_attributes(frequency_params)
64
+ format.html { redirect_to @frequency, notice: t('controller.successfully_updated', model: t('activerecord.models.frequency')) }
65
65
  format.json { head :no_content }
66
66
  else
67
67
  format.html { render action: "edit" }
@@ -80,4 +80,9 @@ class FrequenciesController < ApplicationController
80
80
  format.json { head :no_content }
81
81
  end
82
82
  end
83
+
84
+ private
85
+ def frequency_params
86
+ params.require(:frequency).permit(:name, :display_name, :note)
87
+ end
83
88
  end
@@ -38,11 +38,11 @@ class IdentifierTypesController < ApplicationController
38
38
  # POST /identifier_types
39
39
  # POST /identifier_types.json
40
40
  def create
41
- @identifier_type = IdentifierType.new(params[:identifier_type])
41
+ @identifier_type = IdentifierType.new(identifier_type_params)
42
42
 
43
43
  respond_to do |format|
44
44
  if @identifier_type.save
45
- format.html { redirect_to @identifier_type, notice: t('controller.successfully_created', model: t('activerecord.models.identifier_type')) }
45
+ format.html { redirect_to @identifier_type, notice: t('controller.successfully_created', model: t('activerecord.models.identifier_type')) }
46
46
  format.json { render json: @identifier_type, status: :created, location: @identifier_type }
47
47
  else
48
48
  format.html { render action: "new" }
@@ -60,8 +60,8 @@ class IdentifierTypesController < ApplicationController
60
60
  end
61
61
 
62
62
  respond_to do |format|
63
- if @identifier_type.update_attributes(params[:identifier_type])
64
- format.html { redirect_to @identifier_type, notice: t('controller.successfully_updated', model: t('activerecord.models.identifier_type')) }
63
+ if @identifier_type.update_attributes(identifier_type_params)
64
+ format.html { redirect_to @identifier_type, notice: t('controller.successfully_updated', model: t('activerecord.models.identifier_type')) }
65
65
  format.json { head :no_content }
66
66
  else
67
67
  format.html { render action: "edit" }
@@ -80,4 +80,11 @@ class IdentifierTypesController < ApplicationController
80
80
  format.json { head :no_content }
81
81
  end
82
82
  end
83
+
84
+ private
85
+ def identifier_type_params
86
+ params.require(:identifier_type).permit(
87
+ :display_name, :name, :note, :position
88
+ )
89
+ end
83
90
  end
@@ -39,7 +39,7 @@ class ImportRequestsController < ApplicationController
39
39
  # POST /import_requests
40
40
  # POST /import_requests.json
41
41
  def create
42
- @import_request = ImportRequest.new(params[:import_request])
42
+ @import_request = ImportRequest.new(import_request_params)
43
43
  @import_request.user = current_user
44
44
 
45
45
  respond_to do |format|
@@ -52,9 +52,17 @@ class ImportRequestsController < ApplicationController
52
52
  redirect_to new_import_request_url, notice: t('import_request.record_not_found')
53
53
  end
54
54
  }
55
+ format.mobile {
56
+ if @import_request.manifestation
57
+ redirect_to @import_request.manifestation, notice: t('controller.successfully_created', model: t('activerecord.models.import_request'))
58
+ else
59
+ redirect_to new_import_request_url, notice: t('import_request.record_not_found')
60
+ end
61
+ }
55
62
  format.json { render json: @import_request, status: :created, location: @import_request }
56
63
  else
57
64
  format.html { render action: "new" }
65
+ format.mobile { render action: "new" }
58
66
  format.json { render json: @import_request.errors, status: :unprocessable_entity }
59
67
  end
60
68
  end
@@ -68,7 +76,7 @@ class ImportRequestsController < ApplicationController
68
76
  # PUT /import_requests/1.json
69
77
  def update
70
78
  respond_to do |format|
71
- if @import_request.update_attributes(params[:import_request])
79
+ if @import_request.update_attributes(import_request_params)
72
80
  @import_request.import!
73
81
  format.html { redirect_to @import_request, notice: t('controller.successfully_updated', model: t('activerecord.models.import_request')) }
74
82
  format.json { head :no_content }
@@ -89,4 +97,9 @@ class ImportRequestsController < ApplicationController
89
97
  format.json { head :no_content }
90
98
  end
91
99
  end
100
+
101
+ private
102
+ def import_request_params
103
+ params.require(:import_request).permit(:isbn, :manifestation_id, :user_id)
104
+ end
92
105
  end
@@ -70,6 +70,8 @@ class ItemsController < ApplicationController
70
70
  with(:agent_ids).equal_to agent.id if agent
71
71
  with(:manifestation_id).equal_to manifestation.id if manifestation
72
72
  with(:shelf_id).equal_to shelf.id if shelf
73
+ with(:circulation_status).equal_to params[:circulation_status] if params[:circulation_status].present?
74
+ facet :circulation_status if defined?(EnjuCirculation)
73
75
  end
74
76
  end
75
77
 
@@ -105,7 +107,9 @@ class ItemsController < ApplicationController
105
107
 
106
108
  page = params[:page] || 1
107
109
  search.query.paginate(page.to_i, per_page)
108
- @items = search.execute!.results
110
+ result = search.execute
111
+ @circulation_status_facet = result.facet(:circulation_status).rows if defined?(EnjuCirculation)
112
+ @items = result.results
109
113
  @count[:total] = @items.total_entries
110
114
  end
111
115
 
@@ -131,6 +135,7 @@ class ItemsController < ApplicationController
131
135
  def show
132
136
  #@item = Item.find(params[:id])
133
137
  @item = @item.versions.find(@version).item if @version
138
+ @manifestation = @item.manifestation unless @manifestation
134
139
 
135
140
  respond_to do |format|
136
141
  format.html # show.html.erb
@@ -178,6 +183,7 @@ class ItemsController < ApplicationController
178
183
  # GET /items/1/edit
179
184
  def edit
180
185
  @item.library_id = @item.shelf.library_id
186
+ @manifestation = @item.manifestation
181
187
  if defined?(EnjuCirculation)
182
188
  unless @item.use_restriction
183
189
  @item.build_item_has_use_restriction
@@ -189,7 +195,7 @@ class ItemsController < ApplicationController
189
195
  # POST /items
190
196
  # POST /items.json
191
197
  def create
192
- @item = Item.new(params[:item])
198
+ @item = Item.new(item_params)
193
199
  manifestation = Manifestation.find(@item.manifestation_id)
194
200
 
195
201
  respond_to do |format|
@@ -217,7 +223,7 @@ class ItemsController < ApplicationController
217
223
  # PUT /items/1.json
218
224
  def update
219
225
  respond_to do |format|
220
- if @item.update_attributes(params[:item])
226
+ if @item.update_attributes(item_params)
221
227
  format.html { redirect_to @item, notice: t('controller.successfully_updated', model: t('activerecord.models.item')) }
222
228
  format.json { head :no_content }
223
229
  else
@@ -247,6 +253,18 @@ class ItemsController < ApplicationController
247
253
  end
248
254
 
249
255
  private
256
+ def item_params
257
+ params.require(:item).permit(
258
+ :call_number, :item_identifier, :circulation_status_id,
259
+ :checkout_type_id, :shelf_id, :include_supplements, :note, :url, :price,
260
+ :acquired_at, :bookstore_id, :missing_since, :budget_type_id,
261
+ :lock_version, :manifestation_id, :library_id, :required_role_id,
262
+ :binding_item_identifier, :binding_call_number, :binded_at,
263
+ :use_restriction_id,
264
+ :item_has_use_restriction_attributes => :use_restriction_id # EnjuCirculation
265
+ )
266
+ end
267
+
250
268
  def prepare_options
251
269
  @libraries = Library.real << Library.web
252
270
  if @item.new_record?
@@ -38,11 +38,11 @@ class LanguagesController < ApplicationController
38
38
  # POST /languages
39
39
  # POST /languages.json
40
40
  def create
41
- @language = Language.new(params[:language])
41
+ @language = Language.new(language_params)
42
42
 
43
43
  respond_to do |format|
44
44
  if @language.save
45
- format.html { redirect_to @language, notice: t('controller.successfully_created', model: t('activerecord.models.language')) }
45
+ format.html { redirect_to @language, notice: t('controller.successfully_created', model: t('activerecord.models.language')) }
46
46
  format.json { render json: @language, status: :created, location: @language }
47
47
  else
48
48
  format.html { render action: "new" }
@@ -60,8 +60,8 @@ class LanguagesController < ApplicationController
60
60
  end
61
61
 
62
62
  respond_to do |format|
63
- if @language.update_attributes(params[:language])
64
- format.html { redirect_to @language, notice: t('controller.successfully_updated', model: t('activerecord.models.language')) }
63
+ if @language.update_attributes(language_params)
64
+ format.html { redirect_to @language, notice: t('controller.successfully_updated', model: t('activerecord.models.language')) }
65
65
  format.json { head :no_content }
66
66
  else
67
67
  format.html { render action: "edit" }
@@ -80,4 +80,12 @@ class LanguagesController < ApplicationController
80
80
  format.json { head :no_content }
81
81
  end
82
82
  end
83
+
84
+ private
85
+ def language_params
86
+ params.require(:language).permit(
87
+ :name, :native_name, :display_name, :iso_639_1, :iso_639_2, :iso_639_3,
88
+ :note
89
+ )
90
+ end
83
91
  end
@@ -38,11 +38,11 @@ class LicensesController < ApplicationController
38
38
  # POST /licenses
39
39
  # POST /licenses.json
40
40
  def create
41
- @license = License.new(params[:license])
41
+ @license = License.new(license_params)
42
42
 
43
43
  respond_to do |format|
44
44
  if @license.save
45
- format.html { redirect_to @license, notice: t('controller.successfully_created', model: t('activerecord.models.license')) }
45
+ format.html { redirect_to @license, notice: t('controller.successfully_created', model: t('activerecord.models.license')) }
46
46
  format.json { render json: @license, status: :created, location: @license }
47
47
  else
48
48
  format.html { render action: "new" }
@@ -60,8 +60,8 @@ class LicensesController < ApplicationController
60
60
  end
61
61
 
62
62
  respond_to do |format|
63
- if @license.update_attributes(params[:license])
64
- format.html { redirect_to @license, notice: t('controller.successfully_updated', model: t('activerecord.models.license')) }
63
+ if @license.update_attributes(license_params)
64
+ format.html { redirect_to @license, notice: t('controller.successfully_updated', model: t('activerecord.models.license')) }
65
65
  format.json { head :no_content }
66
66
  else
67
67
  format.html { render action: "edit" }
@@ -80,4 +80,9 @@ class LicensesController < ApplicationController
80
80
  format.json { head :no_content }
81
81
  end
82
82
  end
83
+
84
+ private
85
+ def license_params
86
+ params.require(:license).permit(:name, :display_name, :note)
87
+ end
83
88
  end
@@ -38,11 +38,11 @@ class ManifestationRelationshipTypesController < ApplicationController
38
38
  # POST /manifestation_relationship_types
39
39
  # POST /manifestation_relationship_types.json
40
40
  def create
41
- @manifestation_relationship_type = ManifestationRelationshipType.new(params[:manifestation_relationship_type])
41
+ @manifestation_relationship_type = ManifestationRelationshipType.new(manifestation_relationship_type_params)
42
42
 
43
43
  respond_to do |format|
44
44
  if @manifestation_relationship_type.save
45
- format.html { redirect_to @manifestation_relationship_type, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_relationship_type')) }
45
+ format.html { redirect_to @manifestation_relationship_type, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_relationship_type')) }
46
46
  format.json { render json: @manifestation_relationship_type, status: :created, location: @manifestation_relationship_type }
47
47
  else
48
48
  format.html { render action: "new" }
@@ -60,8 +60,8 @@ class ManifestationRelationshipTypesController < ApplicationController
60
60
  end
61
61
 
62
62
  respond_to do |format|
63
- if @manifestation_relationship_type.update_attributes(params[:manifestation_relationship_type])
64
- format.html { redirect_to @manifestation_relationship_type, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_relationship_type')) }
63
+ if @manifestation_relationship_type.update_attributes(manifestation_relationship_type_params)
64
+ format.html { redirect_to @manifestation_relationship_type, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_relationship_type')) }
65
65
  format.json { head :no_content }
66
66
  else
67
67
  format.html { render action: "edit" }
@@ -80,4 +80,11 @@ class ManifestationRelationshipTypesController < ApplicationController
80
80
  format.json { head :no_content }
81
81
  end
82
82
  end
83
+
84
+ private
85
+ def manifestation_relationship_type_params
86
+ params.require(:manifestation_relationship_type).permit(
87
+ :name, :display_name, :note
88
+ )
89
+ end
83
90
  end
@@ -47,7 +47,7 @@ class ManifestationRelationshipsController < ApplicationController
47
47
  # POST /manifestation_relationships
48
48
  # POST /manifestation_relationships.json
49
49
  def create
50
- @manifestation_relationship = ManifestationRelationship.new(params[:manifestation_relationship])
50
+ @manifestation_relationship = ManifestationRelationship.new(manifestation_relationship_params)
51
51
 
52
52
  respond_to do |format|
53
53
  if @manifestation_relationship.save
@@ -72,7 +72,7 @@ class ManifestationRelationshipsController < ApplicationController
72
72
  end
73
73
 
74
74
  respond_to do |format|
75
- if @manifestation_relationship.update_attributes(params[:manifestation_relationship])
75
+ if @manifestation_relationship.update_attributes(manifestation_relationship_params)
76
76
  format.html { redirect_to @manifestation_relationship, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_relationship')) }
77
77
  format.json { head :no_content }
78
78
  else
@@ -102,6 +102,12 @@ class ManifestationRelationshipsController < ApplicationController
102
102
  end
103
103
 
104
104
  private
105
+ def manifestation_relationship_params
106
+ params.require(:manifestation_relationship).permit(
107
+ :parent_id, :child_id, :manifestation_relationship_type_id
108
+ )
109
+ end
110
+
105
111
  def prepare_options
106
112
  @manifestation_relationship_types = ManifestationRelationshipType.all
107
113
  end
@@ -467,7 +467,7 @@ class ManifestationsController < ApplicationController
467
467
  # POST /manifestations
468
468
  # POST /manifestations.json
469
469
  def create
470
- @manifestation = Manifestation.new(params[:manifestation])
470
+ @manifestation = Manifestation.new(manifestation_params)
471
471
  parent = Manifestation.where(id: @manifestation.parent_id).first
472
472
  unless @manifestation.original_title?
473
473
  @manifestation.original_title = @manifestation.attachment_file_name
@@ -496,7 +496,7 @@ class ManifestationsController < ApplicationController
496
496
  # PUT /manifestations/1.json
497
497
  def update
498
498
  respond_to do |format|
499
- if @manifestation.update_attributes(params[:manifestation])
499
+ if @manifestation.update_attributes(manifestation_params)
500
500
  Sunspot.commit
501
501
  format.html { redirect_to @manifestation, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation')) }
502
502
  format.json { head :no_content }
@@ -526,6 +526,80 @@ class ManifestationsController < ApplicationController
526
526
  end
527
527
 
528
528
  private
529
+ def manifestation_params
530
+ params.require(:manifestation).permit(
531
+ :original_title, :title_alternative, :title_transcription,
532
+ :manifestation_identifier, :date_copyrighted,
533
+ :access_address, :language_id, :carrier_type_id, :extent, :start_page,
534
+ :end_page, :height, :width, :depth, :publication_place,
535
+ :price, :fulltext, :volume_number_string,
536
+ :issue_number_string, :serial_number_string, :edition, :note,
537
+ :repository_content, :required_role_id, :frequency_id,
538
+ :title_alternative_transcription, :description, :abstract, :available_at,
539
+ :valid_until, :date_submitted, :date_accepted, :date_captured,
540
+ :ndl_bib_id, :pub_date, :edition_string, :volume_number, :issue_number,
541
+ :serial_number, :content_type_id, :attachment, :lock_version,
542
+ :dimensions, :fulltext_content, :extent,
543
+ :number_of_page_string, :parent_id,
544
+ :serial, :statement_of_responsibility,
545
+ {:creators_attributes => [
546
+ :id, :last_name, :middle_name, :first_name,
547
+ :last_name_transcription, :middle_name_transcription,
548
+ :first_name_transcription, :corporate_name,
549
+ :corporate_name_transcription,
550
+ :full_name, :full_name_transcription, :full_name_alternative,
551
+ :other_designation, :language_id,
552
+ :country_id, :agent_type_id, :note, :required_role_id, :email, :url,
553
+ :full_name_alternative_transcription, :title,
554
+ :agent_identifier,
555
+ :_destroy
556
+ ]},
557
+ {:contributors_attributes => [
558
+ :id, :last_name, :middle_name, :first_name,
559
+ :last_name_transcription, :middle_name_transcription,
560
+ :first_name_transcription, :corporate_name,
561
+ :corporate_name_transcription,
562
+ :full_name, :full_name_transcription, :full_name_alternative,
563
+ :other_designation, :language_id,
564
+ :country_id, :agent_type_id, :note, :required_role_id, :email, :url,
565
+ :full_name_alternative_transcription, :title,
566
+ :agent_identifier,
567
+ :_destroy
568
+ ]},
569
+ {:publishers_attributes => [
570
+ :id, :last_name, :middle_name, :first_name,
571
+ :last_name_transcription, :middle_name_transcription,
572
+ :first_name_transcription, :corporate_name,
573
+ :corporate_name_transcription,
574
+ :full_name, :full_name_transcription, :full_name_alternative,
575
+ :other_designation, :language_id,
576
+ :country_id, :agent_type_id, :note, :required_role_id, :email, :url,
577
+ :full_name_alternative_transcription, :title,
578
+ :agent_identifier,
579
+ :_destroy
580
+ ]},
581
+ {:series_statements_attributes => [
582
+ :id, :original_title, :numbering, :title_subseries,
583
+ :numbering_subseries, :title_transcription, :title_alternative,
584
+ :title_subseries_transcription, :creator_string, :volume_number_string,
585
+ :volume_number_transcription_string, :series_master,
586
+ :_destroy
587
+ ]},
588
+ {:subjects_attributes => [
589
+ :id, :parent_id, :use_term_id, :term, :term_transcription,
590
+ :subject_type_id, :note, :required_role_id, :subject_heading_type_id,
591
+ :_destroy
592
+ ]},
593
+ {:classifications_attributes => [
594
+ :id, :parent_id, :category, :note, :classification_type_id,
595
+ :_destroy
596
+ ]},
597
+ {:identifiers_attributes => [
598
+ :id, :body, :identifier_type_id,
599
+ :_destroy
600
+ ]}
601
+ )
602
+ end
529
603
 
530
604
  def make_query(query, options = {})
531
605
  # TODO: integerやstringもqfに含める
@@ -726,18 +800,28 @@ class ManifestationsController < ApplicationController
726
800
  if options[:pub_date_from].blank?
727
801
  pub_date[:from] = "*"
728
802
  else
729
- pub_date[:from] = Time.zone.parse(options[:pub_date_from]).beginning_of_day.utc.iso8601 rescue nil
803
+ year = options[:pub_date_from].rjust(4, "0")
804
+ if year.length == 4
805
+ pub_date[:from] = Time.zone.parse(Time.utc(year).to_s).beginning_of_year.utc.iso8601
806
+ else
807
+ pub_date[:from] = Time.zone.parse(options[:pub_date_from]).beginning_of_day.utc.iso8601 rescue nil
808
+ end
730
809
  unless pub_date[:from]
731
- pub_date[:from] = Time.zone.parse(Time.mktime(options[:pub_date_from]).to_s).beginning_of_day.utc.iso8601
810
+ pub_date[:from] = Time.zone.parse(Time.utc(options[:pub_date_from]).to_s).beginning_of_day.utc.iso8601
732
811
  end
733
812
  end
734
813
 
735
814
  if options[:pub_date_to].blank?
736
815
  pub_date[:to] = "*"
737
816
  else
738
- pub_date[:to] = Time.zone.parse(options[:pub_date_to]).end_of_day.utc.iso8601 rescue nil
817
+ year = options[:pub_date_to].rjust(4, "0")
818
+ if year.length == 4
819
+ pub_date[:to] = Time.zone.parse(Time.utc(year).to_s).end_of_year.utc.iso8601
820
+ else
821
+ pub_date[:to] = Time.zone.parse(options[:pub_date_to]).end_of_day.utc.iso8601 rescue nil
822
+ end
739
823
  unless pub_date[:to]
740
- pub_date[:to] = Time.zone.parse(Time.mktime(options[:pub_date_to]).to_s).end_of_year.utc.iso8601
824
+ pub_date[:to] = Time.zone.parse(Time.utc(options[:pub_date_to]).to_s).end_of_year.utc.iso8601
741
825
  end
742
826
  end
743
827
  pub_date
@@ -762,20 +846,31 @@ class ManifestationsController < ApplicationController
762
846
  if options[:acquired_from].blank?
763
847
  acquisition_date[:from] = "*"
764
848
  else
765
- acquisition_date[:from] = Time.zone.parse(options[:acquired_from]).beginning_of_day.utc.iso8601 rescue nil
849
+ year = options[:acquired_from].rjust(4, "0")
850
+ if year.length == 4
851
+ acquisition_date[:from] = Time.zone.parse(Time.utc(year).to_s).beginning_of_year.utc.iso8601
852
+ else
853
+ acquisition_date[:from] = Time.zone.parse(options[:acquired_from]).beginning_of_day.utc.iso8601 rescue nil
854
+ end
766
855
  unless acquisition_date[:from]
767
- acquisition_date[:from] = Time.zone.parse(Time.mktime(options[:acquired_from]).to_s).beginning_of_day.utc.iso8601
856
+ acquisition_date[:from] = Time.zone.parse(Time.utc(options[:acquired_from]).to_s).beginning_of_day.utc.iso8601
768
857
  end
769
858
  end
770
859
 
771
860
  if options[:acquired_to].blank?
772
861
  acquisition_date[:to] = "*"
773
862
  else
774
- acquisition_date[:to] = Time.zone.parse(options[:acquired_to]).end_of_day.utc.iso8601 rescue nil
863
+ year = options[:acquired_to].rjust(4, "0")
864
+ if year.length == 4
865
+ acquisition_date[:to] = Time.zone.parse(Time.utc(year).to_s).end_of_year.utc.iso8601
866
+ else
867
+ acquisition_date[:to] = Time.zone.parse(options[:acquired_to]).end_of_day.utc.iso8601 rescue nil
868
+ end
775
869
  unless acquisition_date[:to]
776
- acquisition_date[:to] = Time.zone.parse(Time.mktime(options[:acquired_to]).to_s).end_of_year.utc.iso8601
870
+ pub_date[:to] = Time.zone.parse(Time.utc(options[:acquired_to]).to_s).end_of_year.utc.iso8601
777
871
  end
778
872
  end
873
+
779
874
  query = "#{query} acquired_at_d:[#{acquisition_date[:from]} TO #{acquisition_date[:to]}]"
780
875
  end
781
876
  query