enju_biblio 0.1.0.pre37 → 0.1.0.pre38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/addresses.js +2 -0
  3. data/app/assets/javascripts/identifier_types.js +2 -0
  4. data/app/assets/javascripts/identifiers.js +2 -0
  5. data/app/assets/stylesheets/addresses.css +4 -0
  6. data/app/assets/stylesheets/identifier_types.css +4 -0
  7. data/app/assets/stylesheets/identifiers.css +4 -0
  8. data/app/controllers/addresses_controller.rb +2 -0
  9. data/app/controllers/carrier_types_controller.rb +85 -5
  10. data/app/controllers/identifier_types_controller.rb +84 -0
  11. data/app/controllers/identifiers_controller.rb +14 -0
  12. data/app/controllers/manifestations_controller.rb +14 -21
  13. data/app/helpers/addresses_helper.rb +2 -0
  14. data/app/helpers/identifier_types_helper.rb +2 -0
  15. data/app/helpers/identifiers_helper.rb +2 -0
  16. data/app/models/carrier_type.rb +2 -0
  17. data/app/models/enju_biblio/ability.rb +12 -0
  18. data/app/models/identifier.rb +65 -0
  19. data/app/models/identifier_type.rb +21 -0
  20. data/app/models/import_request.rb +1 -0
  21. data/app/models/manifestation.rb +28 -87
  22. data/app/models/page_sweeper.rb +0 -2
  23. data/app/models/resource_import_file.rb +34 -18
  24. data/app/views/addresses/_form.html.erb +57 -0
  25. data/app/views/addresses/edit.html.erb +6 -0
  26. data/app/views/addresses/index.html.erb +41 -0
  27. data/app/views/addresses/new.html.erb +5 -0
  28. data/app/views/addresses/show.html.erb +55 -0
  29. data/app/views/carrier_types/_form.html.erb +4 -1
  30. data/app/views/carrier_types/index.html.erb +1 -1
  31. data/app/views/identifier_types/_form.html.erb +22 -0
  32. data/app/views/identifier_types/edit.html.erb +13 -0
  33. data/app/views/identifier_types/index.html.erb +45 -0
  34. data/app/views/identifier_types/new.html.erb +12 -0
  35. data/app/views/identifier_types/show.html.erb +24 -0
  36. data/app/views/identifiers/_form.html.erb +30 -0
  37. data/app/views/identifiers/edit.html.erb +15 -0
  38. data/app/views/identifiers/index.html.erb +33 -0
  39. data/app/views/identifiers/new.html.erb +14 -0
  40. data/app/views/identifiers/show.html.erb +29 -0
  41. data/app/views/items/index.csv.erb +1 -1
  42. data/app/views/items/index.html.erb +2 -1
  43. data/app/views/manifestations/_form.html.erb +17 -36
  44. data/app/views/manifestations/_show.mods.builder +6 -2
  45. data/app/views/manifestations/_show.rdf.builder +7 -6
  46. data/app/views/manifestations/_show_detail_librarian.html.erb +5 -15
  47. data/app/views/manifestations/_show_detail_user.html.erb +5 -15
  48. data/app/views/manifestations/_show_index.html.erb +1 -1
  49. data/app/views/manifestations/index.csv.erb +1 -1
  50. data/app/views/manifestations/index.rss.builder +3 -1
  51. data/app/views/manifestations/show.mobile.erb +1 -1
  52. data/config/locales/translation_en.yml +14 -7
  53. data/config/locales/translation_ja.yml +15 -8
  54. data/config/routes.rb +6 -8
  55. data/db/migrate/005_create_manifestations.rb +0 -12
  56. data/db/migrate/20130506175303_create_identifier_types.rb +12 -0
  57. data/db/migrate/20130506175834_create_identifiers.rb +14 -0
  58. data/lib/enju_biblio/version.rb +1 -1
  59. data/lib/generators/enju_biblio/setup/templates/db/fixtures/identifier_types.yml +27 -0
  60. data/spec/controllers/identifier_types_controller_spec.rb +167 -0
  61. data/spec/controllers/identifiers_controller_spec.rb +446 -0
  62. data/spec/controllers/import_requests_controller_spec.rb +1 -1
  63. data/spec/controllers/manifestations_controller_spec.rb +12 -10
  64. data/spec/dummy/app/models/ability.rb +12 -0
  65. data/spec/dummy/db/development.sqlite3 +0 -0
  66. data/spec/dummy/db/migrate/20130504195916_add_subject_heading_type_id_to_subject.rb +5 -0
  67. data/spec/dummy/db/schema.rb +26 -16
  68. data/spec/dummy/db/test.sqlite3 +0 -0
  69. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  70. data/spec/dummy/solr/data/test/index/segments_myc +0 -0
  71. data/spec/dummy/tmp/cache/4AD/470/country_all +0 -0
  72. data/spec/factories/identifier.rb +6 -0
  73. data/spec/factories/identifier_type.rb +5 -0
  74. data/spec/fixtures/identifier_types.yml +29 -0
  75. data/spec/fixtures/identifiers.yml +113 -0
  76. data/spec/fixtures/manifestations.yml +0 -137
  77. data/spec/fixtures/subject_heading_types.yml +39 -0
  78. data/spec/fixtures/subject_types.yml +4 -4
  79. data/spec/models/identifier_spec.rb +22 -0
  80. data/spec/models/identifier_type_spec.rb +21 -0
  81. data/spec/models/manifestation_spec.rb +0 -11
  82. data/spec/models/resource_import_file_spec.rb +7 -7
  83. data/spec/routing/manifestations_routing_spec.rb +1 -1
  84. metadata +66 -16
  85. data/app/views/manifestations/_show_periodical_master.html.erb +0 -23
  86. data/app/views/manifestations/_show_series_statement.html.erb +0 -30
  87. data/spec/dummy/solr/data/test/index/segments_l8s +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41a6675a780e68eea3ee082220ebb165f09b927b
4
- data.tar.gz: af7fbb006e722aacad738bca1f303755629a317e
3
+ metadata.gz: cb9c6c9ab4fa481e1cb90e3b084369e41fb93df9
4
+ data.tar.gz: 5282c5b29fcdaa63b8d82c1d0b65835fa8f54252
5
5
  SHA512:
6
- metadata.gz: f73678cf486d992ce16bab6427e91982fe5be32e87986dc5c1caec236154b8d14c6609a6808eb5c3c13d0f80fc77bbf7a727922af6be211c0f406c4af2868ebb
7
- data.tar.gz: e296e9fa6733baffa7363734cfc2b63f2b8a15be0269edb60a94231e88ea5a0a163c684cff8e9cfeb72bf931bccaa196727213fca04064a1e7c12c78a00ed77a
6
+ metadata.gz: f17f0fe34499283c96fa960afc2b320d354bb8de2e1d4add975f7da2ee955a82ebeec5742e276a833cdc11b78252eb1afd51bbf87e5ba5e6a3df163a8c6b0c7f
7
+ data.tar.gz: 857cac540591576bcbffadf9ea8de65004566569f56955e0e4a1798f6fcd0eea4fbd9361f6213277341986c378200b509f2304cef2d5d1306c928e5b5eae44ea
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,2 @@
1
+ class AddressesController < InheritedResources::Base
2
+ end
@@ -1,14 +1,94 @@
1
- class CarrierTypesController < InheritedResources::Base
2
- respond_to :html, :json
3
- has_scope :page, :default => 1
1
+ class CarrierTypesController < ApplicationController
4
2
  load_and_authorize_resource
3
+ before_filter :prepare_options, :only => [:new, :edit]
5
4
 
5
+ # GET /carrier_types
6
+ # GET /carrier_types.json
7
+ def index
8
+ @carrier_types = CarrierType.order(:position).page(params[:page])
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @carrier_types }
13
+ end
14
+ end
15
+
16
+ # GET /carrier_types/1
17
+ # GET /carrier_types/1.json
18
+ def show
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.json { render :json => @carrier_type }
22
+ end
23
+ end
24
+
25
+ # GET /carrier_types/new
26
+ # GET /carrier_types/new.json
27
+ def new
28
+ @carrier_type = CarrierType.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render :json => @carrier_type }
33
+ end
34
+ end
35
+
36
+ # GET /carrier_types/1/edit
37
+ def edit
38
+ end
39
+
40
+ # POST /carrier_types
41
+ # POST /carrier_types.json
42
+ def create
43
+ @carrier_type = CarrierType.new(params[:carrier_type])
44
+
45
+ respond_to do |format|
46
+ if @carrier_type.save
47
+ format.html { redirect_to @carrier_type, :notice => t('controller.successfully_created', :model => t('activerecord.models.carrier_type')) }
48
+ format.json { render :json => @carrier_type, :status => :created, :location => @carrier_type }
49
+ else
50
+ prepare_options
51
+ format.html { render :action => "new" }
52
+ format.json { render :json => @carrier_type.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /carrier_types/1
58
+ # PUT /carrier_types/1.json
6
59
  def update
7
- @carrier_type = CarrierType.find(params[:id])
8
60
  if params[:move]
9
61
  move_position(@carrier_type, params[:move])
10
62
  return
11
63
  end
12
- update!
64
+
65
+ respond_to do |format|
66
+ if @carrier_type.update_attributes(params[:carrier_type])
67
+ format.html { redirect_to @carrier_type, :notice => t('controller.successfully_updated', :model => t('activerecord.models.carrier_type')) }
68
+ format.json { head :no_content }
69
+ else
70
+ prepare_options
71
+ format.html { render :action => "edit" }
72
+ format.json { render :json => @carrier_type.errors, :status => :unprocessable_entity }
73
+ end
74
+ end
75
+ end
76
+
77
+ # DELETE /carrier_types/1
78
+ # DELETE /carrier_types/1.json
79
+ def destroy
80
+ @carrier_type.destroy
81
+
82
+ respond_to do |format|
83
+ format.html { redirect_to carrier_types_url }
84
+ format.json { head :no_content }
85
+ end
86
+ end
87
+
88
+ private
89
+ def prepare_options
90
+ if defined?(EnjuCirculation)
91
+ @checkout_types = CheckoutType.select([:id, :display_name, :position])
92
+ end
13
93
  end
14
94
  end
@@ -0,0 +1,84 @@
1
+ class IdentifierTypesController < ApplicationController
2
+ load_and_authorize_resource
3
+
4
+ # GET /identifier_types
5
+ # GET /identifier_types.json
6
+ def index
7
+ @identifier_types = IdentifierType.order(:position).page(params[:page])
8
+
9
+ respond_to do |format|
10
+ format.html # index.html.erb
11
+ format.json { render :json => @identifier_types }
12
+ end
13
+ end
14
+
15
+ # GET /identifier_types/1
16
+ # GET /identifier_types/1.json
17
+ def show
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.json { render :json => @identifier_type }
21
+ end
22
+ end
23
+
24
+ # GET /identifier_types/new
25
+ # GET /identifier_types/new.json
26
+ def new
27
+ @identifier_type = IdentifierType.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.json { render :json => @identifier_type }
32
+ end
33
+ end
34
+
35
+ # GET /identifier_types/1/edit
36
+ def edit
37
+ end
38
+
39
+ # POST /identifier_types
40
+ # POST /identifier_types.json
41
+ def create
42
+ @identifier_type = IdentifierType.new(params[:identifier_type])
43
+
44
+ respond_to do |format|
45
+ if @identifier_type.save
46
+ format.html { redirect_to @identifier_type, :notice => t('controller.successfully_created', :model => t('activerecord.models.identifier_type')) }
47
+ format.json { render :json => @identifier_type, :status => :created, :location => @identifier_type }
48
+ else
49
+ format.html { render :action => "new" }
50
+ format.json { render :json => @identifier_type.errors, :status => :unprocessable_entity }
51
+ end
52
+ end
53
+ end
54
+
55
+ # PUT /identifier_types/1
56
+ # PUT /identifier_types/1.json
57
+ def update
58
+ if params[:move]
59
+ move_position(@identifier_type, params[:move])
60
+ return
61
+ end
62
+
63
+ respond_to do |format|
64
+ if @identifier_type.update_attributes(params[:identifier_type])
65
+ format.html { redirect_to @identifier_type, :notice => t('controller.successfully_updated', :model => t('activerecord.models.identifier_type')) }
66
+ format.json { head :no_content }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.json { render :json => @identifier_type.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /identifier_types/1
75
+ # DELETE /identifier_types/1.json
76
+ def destroy
77
+ @identifier_type.destroy
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to identifier_types_url }
81
+ format.json { head :no_content }
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,14 @@
1
+ class IdentifiersController < InheritedResources::Base
2
+ respond_to :html, :json
3
+ load_and_authorize_resource
4
+ has_scope :page, :default => 1
5
+
6
+ def update
7
+ @identifier = Identifier.find(params[:id])
8
+ if params[:move]
9
+ move_position(@identifier, params[:move])
10
+ return
11
+ end
12
+ update!
13
+ end
14
+ end
@@ -348,18 +348,8 @@ class ManifestationsController < ApplicationController
348
348
  # GET /manifestations/1
349
349
  # GET /manifestations/1.json
350
350
  def show
351
- if params[:isbn]
352
- @manifestation = Manifestation.find_by_isbn(params[:isbn])
353
- if @manifestation
354
- redirect_to manifestation_url(@manifestation, :format => params[:format])
355
- return
356
- else
357
- raise ActiveRecord::RecordNotFound
358
- end
359
- else
360
- if @version
361
- @manifestation = @manifestation.versions.find(@version).item if @version
362
- end
351
+ if @version
352
+ @manifestation = @manifestation.versions.find(@version).item if @version
363
353
  end
364
354
 
365
355
  case params[:mode]
@@ -557,39 +547,39 @@ class ManifestationsController < ApplicationController
557
547
  # query = "#{query} subject_sm:#{options[:subject]}"
558
548
  #end
559
549
 
560
- unless options[:tag].blank?
550
+ if options[:tag].present?
561
551
  query = "#{query} tag_sm:#{options[:tag]}"
562
552
  end
563
553
 
564
- unless options[:creator].blank?
554
+ if options[:creator].present?
565
555
  query = "#{query} creator_text:#{options[:creator]}"
566
556
  end
567
557
 
568
- unless options[:contributor].blank?
558
+ if options[:contributor].present?
569
559
  query = "#{query} contributor_text:#{options[:contributor]}"
570
560
  end
571
561
 
572
- unless options[:isbn].blank?
562
+ if options[:isbn].present?
573
563
  query = "#{query} isbn_sm:#{options[:isbn].gsub('-', '')}"
574
564
  end
575
565
 
576
- unless options[:issn].blank?
566
+ if options[:issn].present?
577
567
  query = "#{query} issn_sm:#{options[:issn].gsub('-', '')}"
578
568
  end
579
569
 
580
- unless options[:lccn].blank?
570
+ if options[:lccn].present?
581
571
  query = "#{query} lccn_s:#{options[:lccn]}"
582
572
  end
583
573
 
584
- unless options[:nbn].blank?
574
+ if options[:nbn].present?
585
575
  query = "#{query} nbn_s:#{options[:nbn]}"
586
576
  end
587
577
 
588
- unless options[:publisher].blank?
578
+ if options[:publisher].present?
589
579
  query = "#{query} publisher_text:#{options[:publisher]}"
590
580
  end
591
581
 
592
- unless options[:item_identifier].blank?
582
+ if options[:item_identifier].present?
593
583
  query = "#{query} item_identifier_sm:#{options[:item_identifier]}"
594
584
  end
595
585
 
@@ -679,9 +669,12 @@ class ManifestationsController < ApplicationController
679
669
  @roles = Role.select([:id, :display_name, :position])
680
670
  @languages = Language.select([:id, :display_name, :position])
681
671
  @frequencies = Frequency.select([:id, :display_name, :position])
672
+ @identifier_types = IdentifierType.select([:id, :display_name, :position])
673
+ @content_types = ContentType.select([:id, :display_name, :position])
682
674
  @nii_types = NiiType.select([:id, :display_name, :position]) if defined?(EnjuNii)
683
675
  if defined?(EnjuSubject)
684
676
  @subject_types = SubjectType.select([:id, :display_name, :position])
677
+ @subject_heading_types = SubjectHeadingType.select([:id, :display_name, :position])
685
678
  @classification_types = ClassificationType.select([:id, :display_name, :position])
686
679
  end
687
680
  end
@@ -0,0 +1,2 @@
1
+ module AddressesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module IdentifierTypesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module IdentifiersHelper
2
+ end
@@ -4,8 +4,10 @@ class CarrierType < ActiveRecord::Base
4
4
  default_scope :order => "carrier_types.position"
5
5
  has_many :manifestations
6
6
  if defined?(EnjuCirculation)
7
+ attr_accessible :carrier_type_has_checkout_types_attributes
7
8
  has_many :carrier_type_has_checkout_types, :dependent => :destroy
8
9
  has_many :checkout_types, :through => :carrier_type_has_checkout_types
10
+ accepts_nested_attributes_for :carrier_type_has_checkout_types, :allow_destroy => true, :reject_if => :all_blank
9
11
  end
10
12
 
11
13
  def mods_type
@@ -9,6 +9,10 @@ module EnjuBiblio
9
9
  can [:destroy, :delete], CarrierType do |carrier_type|
10
10
  true unless carrier_type.manifestations.exists?
11
11
  end if LibraryGroup.site_config.network_access_allowed?(ip_address)
12
+ can [:read, :create, :update], IdentifierType
13
+ can [:destroy, :delete], IdentifierType do |identifier_type|
14
+ true unless identifier_type.identifiers.exists?
15
+ end if LibraryGroup.site_config.network_access_allowed?(ip_address)
12
16
  can [:read, :create, :update], Item
13
17
  can [:destroy, :delete], Item do |item|
14
18
  item.removable?
@@ -22,6 +26,7 @@ module EnjuBiblio
22
26
  CreateType,
23
27
  Donate,
24
28
  Exemplify,
29
+ Identifier,
25
30
  ImportRequest,
26
31
  ManifestationRelationship,
27
32
  ManifestationRelationshipType,
@@ -58,6 +63,7 @@ module EnjuBiblio
58
63
  Extent,
59
64
  Frequency,
60
65
  FormOfWork,
66
+ IdentifierType,
61
67
  Language,
62
68
  License,
63
69
  MediumOfPerformance,
@@ -85,6 +91,7 @@ module EnjuBiblio
85
91
  Create,
86
92
  Donate,
87
93
  Exemplify,
94
+ Identifier,
88
95
  ImportRequest,
89
96
  ManifestationRelationship,
90
97
  Own,
@@ -103,6 +110,7 @@ module EnjuBiblio
103
110
  Extent,
104
111
  Frequency,
105
112
  FormOfWork,
113
+ IdentifierType,
106
114
  Language,
107
115
  License,
108
116
  ManifestationRelationshipType,
@@ -151,6 +159,8 @@ module EnjuBiblio
151
159
  Extent,
152
160
  Frequency,
153
161
  FormOfWork,
162
+ Identifier,
163
+ IdentifierType,
154
164
  Language,
155
165
  License,
156
166
  ManifestationRelationship,
@@ -181,6 +191,8 @@ module EnjuBiblio
181
191
  Extent,
182
192
  Frequency,
183
193
  FormOfWork,
194
+ Identifier,
195
+ IdentifierType,
184
196
  Item,
185
197
  Language,
186
198
  License,
@@ -0,0 +1,65 @@
1
+ class Identifier < ActiveRecord::Base
2
+ attr_accessible :body, :identifier_type_id, :manifestation_id, :primary, :position
3
+ belongs_to :identifier_type
4
+ belongs_to :manifestation
5
+
6
+ validates_presence_of :body
7
+ validates_uniqueness_of :body, :scope => [:identifier_type_id, :manifestation_id]
8
+ validate :check_identifier
9
+ before_save :convert_isbn
10
+
11
+ acts_as_list :scope => :manifestation_id
12
+ normalize_attributes :body
13
+
14
+ def check_identifier
15
+ case identifier_type.try(:name)
16
+ when 'isbn'
17
+ unless StdNum::ISBN.valid?(body)
18
+ errors.add(:body)
19
+ end
20
+
21
+ when 'issn'
22
+ unless StdNum::ISSN.valid?(body)
23
+ errors.add(:issn)
24
+ end
25
+
26
+ when 'lccn'
27
+ unless StdNum::LCCN.valid?(body)
28
+ errors.add(:body)
29
+ end
30
+ end
31
+ end
32
+
33
+ def convert_isbn
34
+ if identifier_type.name == 'isbn'
35
+ lisbn = Lisbn.new(body)
36
+ if lisbn.isbn
37
+ if lisbn.isbn.length == 10
38
+ self.body = lisbn.isbn13
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def hyphenated_isbn
45
+ if identifier_type.name == 'isbn'
46
+ lisbn = Lisbn.new(body)
47
+ lisbn.parts.join('-')
48
+ end
49
+ end
50
+ end
51
+
52
+ # == Schema Information
53
+ #
54
+ # Table name: identifiers
55
+ #
56
+ # id :integer not null, primary key
57
+ # body :string(255) not null
58
+ # identifier_type_id :integer not null
59
+ # manifestation_id :integer
60
+ # primary :boolean
61
+ # position :integer
62
+ # created_at :datetime not null
63
+ # updated_at :datetime not null
64
+ #
65
+