enju_biblio 0.1.0.pre2 → 0.1.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/app/controllers/carrier_types_controller.rb +1 -0
  2. data/app/controllers/content_types_controller.rb +1 -4
  3. data/app/controllers/countries_controller.rb +1 -4
  4. data/app/controllers/create_types_controller.rb +1 -0
  5. data/app/controllers/extents_controller.rb +1 -4
  6. data/app/controllers/form_of_works_controller.rb +1 -0
  7. data/app/controllers/frequencies_controller.rb +1 -0
  8. data/app/controllers/languages_controller.rb +1 -4
  9. data/app/controllers/licenses_controller.rb +1 -4
  10. data/app/controllers/manifestation_relationship_types_controller.rb +1 -0
  11. data/app/controllers/manifestation_relationships_controller.rb +7 -4
  12. data/app/controllers/manifestations_controller.rb +1 -1
  13. data/app/controllers/medium_of_performances_controller.rb +1 -4
  14. data/app/controllers/patron_relationship_types_controller.rb +1 -0
  15. data/app/controllers/patron_relationships_controller.rb +7 -4
  16. data/app/controllers/patron_types_controller.rb +1 -4
  17. data/app/controllers/produce_types_controller.rb +1 -0
  18. data/app/controllers/realize_types_controller.rb +1 -0
  19. data/app/controllers/series_has_manifestations_controller.rb +2 -0
  20. data/app/controllers/series_statement_relationships_controller.rb +20 -0
  21. data/app/controllers/series_statements_controller.rb +24 -1
  22. data/app/models/picture_file.rb +2 -0
  23. data/app/models/series_statement.rb +20 -4
  24. data/app/models/series_statement_relationship.rb +17 -0
  25. data/app/views/items/show.html.erb +1 -1
  26. data/app/views/manifestation_relationships/index.html.erb +1 -1
  27. data/app/views/manifestations/_submenu_series_statement.html.erb +1 -0
  28. data/app/views/patron_relationships/index.html.erb +1 -1
  29. data/app/views/patrons/_work_list.html.erb +1 -1
  30. data/app/views/patrons/show.html.erb +2 -2
  31. data/app/views/series_statement_relationships/_form.html.erb +27 -0
  32. data/app/views/series_statement_relationships/edit.html.erb +15 -0
  33. data/app/views/series_statement_relationships/index.html.erb +34 -0
  34. data/app/views/series_statement_relationships/new.html.erb +14 -0
  35. data/app/views/series_statement_relationships/show.html.erb +24 -0
  36. data/app/views/series_statements/_index_parent.html.erb +55 -0
  37. data/app/views/series_statements/index.html.erb +2 -0
  38. data/config/locales/translation_en.yml +6 -0
  39. data/config/locales/translation_ja.yml +6 -0
  40. data/config/routes.rb +3 -0
  41. data/db/migrate/20120728204337_create_series_statement_relationships.rb +11 -0
  42. data/lib/enju_biblio/version.rb +1 -1
  43. data/lib/generators/enju_biblio/views_generator.rb +1 -0
  44. data/spec/cassette_library/enju_ndl/manifestation.yml +10 -10
  45. data/spec/cassette_library/enju_ndl/ndl_search.yml +18 -18
  46. data/spec/controllers/series_statement_relationships_controller_spec.rb +179 -0
  47. data/spec/dummy/app/models/ability.rb +2 -0
  48. data/spec/dummy/db/schema.rb +9 -1
  49. data/spec/dummy/db/test.sqlite3 +0 -0
  50. data/spec/dummy/solr/conf/schema.xml +1 -7
  51. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  52. data/spec/dummy/solr/data/test/index/segments_5hq +0 -0
  53. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  54. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  55. data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
  56. data/spec/factories/series_statement_relationship.rb +8 -0
  57. data/spec/models/series_statement_relationship_spec.rb +4 -0
  58. data/spec/requests/series_statement_relationships_spec.rb +11 -0
  59. data/spec/routing/series_statement_relationships_routing_spec.rb +35 -0
  60. data/spec/views/series_statement_relationships/edit.html.erb_spec.rb +20 -0
  61. data/spec/views/series_statement_relationships/index.html.erb_spec.rb +23 -0
  62. data/spec/views/series_statement_relationships/new.html.erb_spec.rb +20 -0
  63. data/spec/views/series_statement_relationships/show.html.erb_spec.rb +17 -0
  64. metadata +31 -6
  65. data/spec/dummy/db/development.sqlite3 +0 -0
  66. data/spec/dummy/solr/data/test/index/segments_q1 +0 -0
@@ -1,5 +1,6 @@
1
1
  class CarrierTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,5 +1,6 @@
1
1
  class ContentTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class ContentTypesController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @content_types = @content_types.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class CountriesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class CountriesController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @countries = @countries.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class CreateTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,5 +1,6 @@
1
1
  class ExtentsController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class ExtentsController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @extents = @extents.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class FormOfWorksController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,5 +1,6 @@
1
1
  class FrequenciesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,5 +1,6 @@
1
1
  class LanguagesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class LanguagesController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @languages = @languages.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class LicensesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class LicensesController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @licenses = @licenses.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class ManifestationRelationshipTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,11 +1,9 @@
1
1
  class ManifestationRelationshipsController < InheritedResources::Base
2
+ respond_to :html, :json
3
+ has_scope :page, :default => 1
2
4
  load_and_authorize_resource
3
5
  before_filter :prepare_options, :except => [:index, :destroy]
4
6
 
5
- def prepare_options
6
- @manifestation_relationship_types = ManifestationRelationshipType.all
7
- end
8
-
9
7
  def new
10
8
  @manifestation_relationship = ManifestationRelationship.new(params[:manifestation_relationship])
11
9
  @manifestation_relationship.parent = Manifestation.find(params[:manifestation_id]) rescue nil
@@ -20,4 +18,9 @@ class ManifestationRelationshipsController < InheritedResources::Base
20
18
  end
21
19
  update!
22
20
  end
21
+
22
+ private
23
+ def prepare_options
24
+ @manifestation_relationship_types = ManifestationRelationshipType.all
25
+ end
23
26
  end
@@ -264,7 +264,7 @@ class ManifestationsController < ApplicationController
264
264
  end
265
265
 
266
266
  if defined?(EnjuSearchLog)
267
- save_search_history(query, @manifestations.limit_value, @count[:query_result], current_user)
267
+ save_search_history(query, @manifestations.offset_value + 1, @count[:query_result], current_user)
268
268
  end
269
269
 
270
270
  if defined?(EnjuOai)
@@ -1,5 +1,6 @@
1
1
  class MediumOfPerformancesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class MediumOfPerformancesController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @medium_of_performances = @medium_of_performances.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class PatronRelationshipTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,11 +1,9 @@
1
1
  class PatronRelationshipsController < InheritedResources::Base
2
+ respond_to :html, :json
3
+ has_scope :page, :default => 1
2
4
  load_and_authorize_resource
3
5
  before_filter :prepare_options, :except => [:index, :destroy]
4
6
 
5
- def prepare_options
6
- @patron_relationship_types = PatronRelationshipType.all
7
- end
8
-
9
7
  def new
10
8
  @patron_relationship = PatronRelationship.new(params[:patron_relationship])
11
9
  @patron_relationship.parent = Patron.find(params[:patron_id]) rescue nil
@@ -20,4 +18,9 @@ class PatronRelationshipsController < InheritedResources::Base
20
18
  end
21
19
  update!
22
20
  end
21
+
22
+ private
23
+ def prepare_options
24
+ @patron_relationship_types = PatronRelationshipType.all
25
+ end
23
26
  end
@@ -1,5 +1,6 @@
1
1
  class PatronTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -10,8 +11,4 @@ class PatronTypesController < InheritedResources::Base
10
11
  end
11
12
  update!
12
13
  end
13
-
14
- def index
15
- @patron_types = @patron_types.page(params[:page])
16
- end
17
14
  end
@@ -1,5 +1,6 @@
1
1
  class ProduceTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -1,5 +1,6 @@
1
1
  class RealizeTypesController < InheritedResources::Base
2
2
  respond_to :html, :json
3
+ has_scope :page, :default => 1
3
4
  load_and_authorize_resource
4
5
 
5
6
  def update
@@ -56,6 +56,7 @@ class SeriesHasManifestationsController < ApplicationController
56
56
  format.html { redirect_to @series_has_manifestation, :notice => t('controller.successfully_created', :model => t('activerecord.models.series_has_manifestation')) }
57
57
  format.json { render :json => @series_has_manifestation, :status => :created, :location => @series_has_manifestation }
58
58
  else
59
+ @series_statement = @series_has_manifestation.series_statement
59
60
  format.html { render :action => "new" }
60
61
  format.json { render :json => @series_has_manifestation.errors, :status => :unprocessable_entity }
61
62
  end
@@ -73,6 +74,7 @@ class SeriesHasManifestationsController < ApplicationController
73
74
  format.html { redirect_to @series_has_manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.series_has_manifestation')) }
74
75
  format.json { head :no_content }
75
76
  else
77
+ @series_statement = @series_has_manifestation.series_statement
76
78
  format.html { render :action => "edit" }
77
79
  format.json { render :json => @series_has_manifestation.errors, :status => :unprocessable_entity }
78
80
  end
@@ -0,0 +1,20 @@
1
+ class SeriesStatementRelationshipsController < InheritedResources::Base
2
+ respond_to :html, :json
3
+ has_scope :page, :default => 1
4
+ load_and_authorize_resource
5
+
6
+ def new
7
+ @series_statement_relationship = SeriesStatementRelationship.new(params[:series_statement_relationship])
8
+ @series_statement_relationship.parent = SeriesStatement.find(params[:parent_id]) rescue nil
9
+ @series_statement_relationship.child = SeriesStatement.find(params[:child_id]) rescue nil
10
+ end
11
+
12
+ def update
13
+ @series_statement_relationship = SeriesStatementRelationship.find(params[:id])
14
+ if params[:move]
15
+ move_position(@series_statement_relationship, params[:move])
16
+ return
17
+ end
18
+ update!
19
+ end
20
+ end
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class SeriesStatementsController < ApplicationController
3
3
  load_and_authorize_resource
4
- before_filter :get_work, :get_manifestation, :except => [:create, :update, :destroy]
4
+ before_filter :get_work, :get_manifestation, :get_parent_and_child, :except => [:create, :update, :destroy]
5
5
  cache_sweeper :page_sweeper, :only => [:create, :update, :destroy]
6
6
  after_filter :solr_commit, :only => [:create, :update, :destroy]
7
7
  if defined?(EnjuResourceMerge)
@@ -25,13 +25,21 @@ class SeriesStatementsController < ApplicationController
25
25
  end
26
26
  #work = @work
27
27
  manifestation = @manifestation
28
+ parent = @parent
29
+ child = @child
28
30
  series_statement_merge_list = @series_statement_merge_list
29
31
  unless params[:mode] == 'add'
30
32
  search.build do
31
33
  # with(:work_id).equal_to work.id if work
34
+ with(:parent_ids).equal_to parent.id if parent
35
+ with(:child_ids).equal_to child.id if child
32
36
  with(:manifestation_ids).equal_to manifestation.id if manifestation
33
37
  with(:series_statement_merge_list_ids).equal_to series_statement_merge_list.id if series_statement_merge_list
34
38
  end
39
+ else
40
+ search.build do
41
+ without(:parent_ids, parent.id) if parent
42
+ end
35
43
  end
36
44
  page = params[:page] || 1
37
45
  search.query.paginate(page.to_i, SeriesStatement.default_per_page)
@@ -46,6 +54,9 @@ class SeriesStatementsController < ApplicationController
46
54
  # GET /series_statements/1
47
55
  # GET /series_statements/1.json
48
56
  def show
57
+ #@manifestations = @series_statement.manifestations.order('date_of_publication DESC').page(params[:manifestation_page]).per(Manifestation.default_per_page)
58
+ #store_location
59
+
49
60
  respond_to do |format|
50
61
  format.html { # show.html.erb
51
62
  redirect_to series_statement_manifestations_url(@series_statement)
@@ -62,6 +73,8 @@ class SeriesStatementsController < ApplicationController
62
73
  # GET /series_statements/new.json
63
74
  def new
64
75
  @series_statement = SeriesStatement.new
76
+ @frequencies = Frequency.all
77
+ @series_statement.parent = @parent_series_statement if @parent_series_statement
65
78
 
66
79
  respond_to do |format|
67
80
  format.html # new.html.erb
@@ -72,6 +85,8 @@ class SeriesStatementsController < ApplicationController
72
85
  # GET /series_statements/1/edit
73
86
  def edit
74
87
  @series_statement.work = @work if @work
88
+ @frequencies = Frequency.all
89
+ @series_statement.parent = @parent_series_statement if @parent_series_statement
75
90
  end
76
91
 
77
92
  # POST /series_statements
@@ -86,6 +101,7 @@ class SeriesStatementsController < ApplicationController
86
101
  format.html { redirect_to @series_statement, :notice => t('controller.successfully_created', :model => t('activerecord.models.series_statement')) }
87
102
  format.json { render :json => @series_statement, :status => :created, :location => @series_statement }
88
103
  else
104
+ @frequencies = Frequency.all
89
105
  format.html { render :action => "new" }
90
106
  format.json { render :json => @series_statement.errors, :status => :unprocessable_entity }
91
107
  end
@@ -105,6 +121,7 @@ class SeriesStatementsController < ApplicationController
105
121
  format.html { redirect_to @series_statement, :notice => t('controller.successfully_updated', :model => t('activerecord.models.series_statement')) }
106
122
  format.json { head :no_content }
107
123
  else
124
+ @frequencies = Frequency.all
108
125
  format.html { render :action => "edit" }
109
126
  format.json { render :json => @series_statement.errors, :status => :unprocessable_entity }
110
127
  end
@@ -121,4 +138,10 @@ class SeriesStatementsController < ApplicationController
121
138
  format.json { head :no_content }
122
139
  end
123
140
  end
141
+
142
+ private
143
+ def get_parent_and_child
144
+ @parent = SeriesStatement.find(params[:parent_id]) if params[:parent_id]
145
+ @child = SeriesStatement.find(params[:child_id]) if params[:child_id]
146
+ end
124
147
  end
@@ -21,6 +21,8 @@ class PictureFile < ActiveRecord::Base
21
21
  # http://railsforum.com/viewtopic.php?id=11615
22
22
  acts_as_list :scope => 'picture_attachable_type=\'#{picture_attachable_type}\''
23
23
  normalize_attributes :picture_attachable_type
24
+
25
+ paginates_per 10
24
26
  end
25
27
 
26
28
  # == Schema Information
@@ -7,6 +7,11 @@ class SeriesStatement < ActiveRecord::Base
7
7
  has_many :series_has_manifestations, :dependent => :destroy
8
8
  has_many :manifestations, :through => :series_has_manifestations
9
9
  belongs_to :root_manifestation, :foreign_key => :root_manifestation_id, :class_name => 'Manifestation'
10
+ has_many :child_relationships, :foreign_key => 'parent_id', :class_name => 'SeriesStatementRelationship', :dependent => :destroy
11
+ has_many :parent_relationships, :foreign_key => 'child_id', :class_name => 'SeriesStatementRelationship', :dependent => :destroy
12
+ has_many :children, :through => :child_relationships, :source => :child
13
+ has_many :parents, :through => :parent_relationships, :source => :parent
14
+
10
15
  validates_presence_of :original_title
11
16
  validate :check_issn
12
17
  before_save :create_root_manifestation
@@ -18,17 +23,23 @@ class SeriesStatement < ActiveRecord::Base
18
23
  end
19
24
  text :numbering, :title_subseries, :numbering_subseries
20
25
  integer :manifestation_ids, :multiple => true do
21
- series_has_manifestations.pluck(:manifestation_id)
26
+ series_has_manifestations.collect(&:manifestation_id)
22
27
  end
23
28
  integer :position
24
29
  boolean :periodical
25
30
  integer :series_statement_merge_list_ids, :multiple => true if defined?(EnjuResourceMerge)
31
+ integer :parent_ids, :multiple => true do
32
+ parents.pluck('series_statements.id')
33
+ end
34
+ integer :child_ids, :multiple => true do
35
+ children.pluck('series_statements.id')
36
+ end
26
37
  end
27
38
 
39
+ attr_accessor :selected
28
40
  normalize_attributes :original_title, :issn
29
- paginates_per 10
30
41
 
31
- attr_accessor :selected
42
+ paginates_per 10
32
43
 
33
44
  def last_issue
34
45
  manifestations.where('date_of_publication IS NOT NULL').order('date_of_publication DESC').first || manifestations.order(:id).last
@@ -68,7 +79,12 @@ class SeriesStatement < ActiveRecord::Base
68
79
  end
69
80
 
70
81
  def titles
71
- [original_title, title_transcription]
82
+ [
83
+ original_title,
84
+ title_transcription,
85
+ parents.map{|parent| [parent.original_title, parent.title_transcription]},
86
+ children.map{|child| [child.original_title, child.title_transcription]}
87
+ ].flatten.compact
72
88
  end
73
89
 
74
90
  if defined?(EnjuResourceMerge)
@@ -0,0 +1,17 @@
1
+ class SeriesStatementRelationship < ActiveRecord::Base
2
+ attr_accessible :child_id, :parent_id
3
+ belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'SeriesStatement'
4
+ belongs_to :child, :foreign_key => 'child_id', :class_name => 'SeriesStatement'
5
+ after_save :reindex
6
+ after_destroy :reindex
7
+
8
+ validates_presence_of :parent_id, :child_id
9
+ validates_uniqueness_of :child_id, :scope => :parent_id
10
+ acts_as_list :scope => :parent_id
11
+
12
+ def reindex
13
+ parent.try(:index)
14
+ child.try(:index)
15
+ Sunspot.commit
16
+ end
17
+ end
@@ -101,7 +101,7 @@
101
101
 
102
102
  <p>
103
103
  <strong><%= t('activerecord.attributes.item.acquired_at') -%>:</strong>
104
- <%= l(@item.acquired_at, :formats => :only_date) if @item.acquired_at -%>
104
+ <%= l(@item.acquired_at, :format => :only_date) if @item.acquired_at -%>
105
105
  </p>
106
106
 
107
107
  <p>