enju_subject 0.1.0.pre26 → 0.1.0.pre27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/classification_types_controller.rb +74 -4
  3. data/app/controllers/classifications_controller.rb +1 -1
  4. data/app/controllers/subject_heading_types_controller.rb +74 -4
  5. data/app/controllers/subject_types_controller.rb +74 -4
  6. data/app/controllers/subjects_controller.rb +1 -1
  7. data/app/models/classification.rb +1 -1
  8. data/app/models/enju_subject/ability.rb +4 -1
  9. data/app/models/subject.rb +1 -1
  10. data/app/views/classification_types/index.html.erb +13 -6
  11. data/app/views/classifications/index.html.erb +1 -0
  12. data/app/views/manifestations/_classification_detail.html.erb +1 -1
  13. data/app/views/subject_heading_types/index.html.erb +16 -7
  14. data/app/views/subject_heading_types/show.html.erb +5 -0
  15. data/app/views/subject_types/index.html.erb +15 -8
  16. data/app/views/subjects/_form.html.erb +4 -4
  17. data/app/views/subjects/index.html.erb +1 -0
  18. data/app/views/subjects/show.html.erb +5 -0
  19. data/lib/enju_subject/engine.rb +0 -1
  20. data/lib/enju_subject/manifestation.rb +15 -1
  21. data/lib/enju_subject/version.rb +1 -1
  22. data/lib/tasks/enju_subject_tasks.rake +12 -0
  23. data/lib/tasks/subject_heading_type.rb +6 -0
  24. data/lib/tasks/subject_type.rb +10 -0
  25. data/spec/controllers/classification_types_controller_spec.rb +51 -51
  26. data/spec/controllers/classifications_controller_spec.rb +26 -26
  27. data/spec/controllers/subject_heading_types_controller_spec.rb +24 -24
  28. data/spec/controllers/subject_types_controller_spec.rb +24 -24
  29. data/spec/controllers/subjects_controller_spec.rb +25 -25
  30. data/spec/dummy/db/test.sqlite3 +0 -0
  31. data/spec/dummy/solr/default/data/index/segments.gen +0 -0
  32. data/spec/dummy/solr/default/data/index/segments_14a +0 -0
  33. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001439 +0 -0
  34. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001440 +0 -0
  35. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001441 +0 -0
  36. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001442 +0 -0
  37. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001443 +0 -0
  38. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001444 +0 -0
  39. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001445 +0 -0
  40. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001446 +0 -0
  41. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001447 +0 -0
  42. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001448 +0 -0
  43. metadata +28 -40
  44. data/spec/dummy/solr/default/data/index/segments_ya +0 -0
  45. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001223 +0 -0
  46. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001224 +0 -0
  47. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001225 +0 -0
  48. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001226 +0 -0
  49. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001227 +0 -0
  50. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001228 +0 -0
  51. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001229 +0 -0
  52. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001230 +0 -0
  53. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001231 +0 -0
  54. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001232 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb377ab73e1f078b5899f949f29b6bca3805a0b2
4
- data.tar.gz: 219048b79e584acf30c2cf9112b804bb6f7368be
3
+ metadata.gz: f39a539208950c30df82cb40b7f4679ec04bd02d
4
+ data.tar.gz: 03750a9a61b0ad202afee9606d6efb8903a13d71
5
5
  SHA512:
6
- metadata.gz: 99de1b3f98bd62786fa6df67b0436aa55065de8211a05a3d393fa1b9bd4e34b7ee9b76b1018d6961d9d46c13613cea90779c0ed4fc29f6e43b8bd472b45d0e00
7
- data.tar.gz: ccd8eca7c18f65ad8783564d309ebfe464eaca5964f919c11125791aed8675502c7fa6c65dca62ec0ad6a977c4adc6e84ac51fe72f73f677053108bfce727305
6
+ metadata.gz: 9b4d3ae6aab37057222b13e7b45cdb65d465b43f2070bd3ad8c16a9e967d4f7d5c390abcd1018ce9f25c60b960f01dd9f3da6427f1d3ec13dae30f5ba70d8656
7
+ data.tar.gz: 156338c0e07072ddd799353638bad7cce20e8d1e59dd21d1272ae0299d06896c73ee18f35f132e23614b5b6970ba544d7ca36488c3e69c4f614770ec1bcda5bc
@@ -1,13 +1,83 @@
1
- class ClassificationTypesController < InheritedResources::Base
2
- respond_to :html, :json
1
+ class ClassificationTypesController < ApplicationController
3
2
  load_and_authorize_resource
3
+ # GET /classification_types
4
+ # GET /classification_types.json
5
+ def index
6
+ @classification_types = ClassificationType.all
4
7
 
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @classification_types }
11
+ end
12
+ end
13
+
14
+ # GET /classification_types/1
15
+ # GET /classification_types/1.json
16
+ def show
17
+ respond_to do |format|
18
+ format.html # show.html.erb
19
+ format.json { render json: @classification_type }
20
+ end
21
+ end
22
+
23
+ # GET /classification_types/new
24
+ # GET /classification_types/new.json
25
+ def new
26
+ @classification_type = ClassificationType.new
27
+
28
+ respond_to do |format|
29
+ format.html # new.html.erb
30
+ format.json { render json: @classification_type }
31
+ end
32
+ end
33
+
34
+ # GET /classification_types/1/edit
35
+ def edit
36
+ end
37
+
38
+ # POST /classification_types
39
+ # POST /classification_types.json
40
+ def create
41
+ @classification_type = ClassificationType.new(params[:classification_type])
42
+
43
+ respond_to do |format|
44
+ if @classification_type.save
45
+ format.html { redirect_to @classification_type, notice: t('controller.successfully_created', model: t('activerecord.models.classification_type')) }
46
+ format.json { render json: @classification_type, status: :created, location: @classification_type }
47
+ else
48
+ format.html { render action: "new" }
49
+ format.json { render json: @classification_type.errors, status: :unprocessable_entity }
50
+ end
51
+ end
52
+ end
53
+
54
+ # PUT /classification_types/1
55
+ # PUT /classification_types/1.json
5
56
  def update
6
- @classification_type = ClassificationType.find(params[:id])
7
57
  if params[:move]
8
58
  move_position(@classification_type, params[:move])
9
59
  return
10
60
  end
11
- update!
61
+
62
+ respond_to do |format|
63
+ if @classification_type.update_attributes(params[:classification_type])
64
+ format.html { redirect_to @classification_type, notice: t('controller.successfully_updated', model: t('activerecord.models.classification_type')) }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @classification_type.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /classification_types/1
74
+ # DELETE /classification_types/1.json
75
+ def destroy
76
+ @classification_type.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to classification_types_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.classification_type')) }
80
+ format.json { head :no_content }
81
+ end
12
82
  end
13
83
  end
@@ -103,7 +103,7 @@ class ClassificationsController < ApplicationController
103
103
  @classification.destroy
104
104
 
105
105
  respond_to do |format|
106
- format.html { redirect_to classifications_url }
106
+ format.html { redirect_to classifications_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.classification')) }
107
107
  format.json { head :no_content }
108
108
  end
109
109
  end
@@ -1,13 +1,83 @@
1
- class SubjectHeadingTypesController < InheritedResources::Base
2
- respond_to :html, :json
1
+ class SubjectHeadingTypesController < ApplicationController
3
2
  load_and_authorize_resource
3
+ # GET /subject_heading_types
4
+ # GET /subject_heading_types.json
5
+ def index
6
+ @subject_heading_types = SubjectHeadingType.all
4
7
 
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @subject_heading_types }
11
+ end
12
+ end
13
+
14
+ # GET /subject_heading_types/1
15
+ # GET /subject_heading_types/1.json
16
+ def show
17
+ respond_to do |format|
18
+ format.html # show.html.erb
19
+ format.json { render json: @subject_heading_type }
20
+ end
21
+ end
22
+
23
+ # GET /subject_heading_types/new
24
+ # GET /subject_heading_types/new.json
25
+ def new
26
+ @subject_heading_type = SubjectHeadingType.new
27
+
28
+ respond_to do |format|
29
+ format.html # new.html.erb
30
+ format.json { render json: @subject_heading_type }
31
+ end
32
+ end
33
+
34
+ # GET /subject_heading_types/1/edit
35
+ def edit
36
+ end
37
+
38
+ # POST /subject_heading_types
39
+ # POST /subject_heading_types.json
40
+ def create
41
+ @subject_heading_type = SubjectHeadingType.new(params[:subject_heading_type])
42
+
43
+ respond_to do |format|
44
+ if @subject_heading_type.save
45
+ format.html { redirect_to @subject_heading_type, notice: t('controller.successfully_created', model: t('activerecord.models.subject_heading_type')) }
46
+ format.json { render json: @subject_heading_type, status: :created, location: @subject_heading_type }
47
+ else
48
+ format.html { render action: "new" }
49
+ format.json { render json: @subject_heading_type.errors, status: :unprocessable_entity }
50
+ end
51
+ end
52
+ end
53
+
54
+ # PUT /subject_heading_types/1
55
+ # PUT /subject_heading_types/1.json
5
56
  def update
6
- @subject_heading_type = SubjectHeadingType.find(params[:id])
7
57
  if params[:move]
8
58
  move_position(@subject_heading_type, params[:move])
9
59
  return
10
60
  end
11
- update!
61
+
62
+ respond_to do |format|
63
+ if @subject_heading_type.update_attributes(params[:subject_heading_type])
64
+ format.html { redirect_to @subject_heading_type, notice: t('controller.successfully_updated', model: t('activerecord.models.subject_heading_type')) }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @subject_heading_type.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /subject_heading_types/1
74
+ # DELETE /subject_heading_types/1.json
75
+ def destroy
76
+ @subject_heading_type.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to subject_heading_types_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.subject_heading_type')) }
80
+ format.json { head :no_content }
81
+ end
12
82
  end
13
83
  end
@@ -1,13 +1,83 @@
1
- class SubjectTypesController < InheritedResources::Base
2
- respond_to :html, :json
1
+ class SubjectTypesController < ApplicationController
3
2
  load_and_authorize_resource
3
+ # GET /subject_types
4
+ # GET /subject_types.json
5
+ def index
6
+ @subject_types = SubjectType.all
4
7
 
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @subject_types }
11
+ end
12
+ end
13
+
14
+ # GET /subject_types/1
15
+ # GET /subject_types/1.json
16
+ def show
17
+ respond_to do |format|
18
+ format.html # show.html.erb
19
+ format.json { render json: @subject_type }
20
+ end
21
+ end
22
+
23
+ # GET /subject_types/new
24
+ # GET /subject_types/new.json
25
+ def new
26
+ @subject_type = SubjectType.new
27
+
28
+ respond_to do |format|
29
+ format.html # new.html.erb
30
+ format.json { render json: @subject_type }
31
+ end
32
+ end
33
+
34
+ # GET /subject_types/1/edit
35
+ def edit
36
+ end
37
+
38
+ # POST /subject_types
39
+ # POST /subject_types.json
40
+ def create
41
+ @subject_type = SubjectType.new(params[:subject_type])
42
+
43
+ respond_to do |format|
44
+ if @subject_type.save
45
+ format.html { redirect_to @subject_type, notice: t('controller.successfully_created', model: t('activerecord.models.subject_type')) }
46
+ format.json { render json: @subject_type, status: :created, location: @subject_type }
47
+ else
48
+ format.html { render action: "new" }
49
+ format.json { render json: @subject_type.errors, status: :unprocessable_entity }
50
+ end
51
+ end
52
+ end
53
+
54
+ # PUT /subject_types/1
55
+ # PUT /subject_types/1.json
5
56
  def update
6
- @subject_type = SubjectType.find(params[:id])
7
57
  if params[:move]
8
58
  move_position(@subject_type, params[:move])
9
59
  return
10
60
  end
11
- update!
61
+
62
+ respond_to do |format|
63
+ if @subject_type.update_attributes(params[:subject_type])
64
+ format.html { redirect_to @subject_type, notice: t('controller.successfully_updated', model: t('activerecord.models.subject_type')) }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @subject_type.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /subject_types/1
74
+ # DELETE /subject_types/1.json
75
+ def destroy
76
+ @subject_type.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to subject_types_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.subject_type')) }
80
+ format.json { head :no_content }
81
+ end
12
82
  end
13
83
  end
@@ -125,7 +125,7 @@ class SubjectsController < ApplicationController
125
125
  @subject.destroy
126
126
 
127
127
  respond_to do |format|
128
- format.html { redirect_to subjects_url }
128
+ format.html { redirect_to subjects_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.subjects')) }
129
129
  format.json { head :no_content }
130
130
  end
131
131
  end
@@ -1,7 +1,7 @@
1
1
  class Classification < ActiveRecord::Base
2
2
  attr_accessible :parent_id, :category, :note, :classification_type_id
3
3
  belongs_to :classification_type
4
- belongs_to :manifestation
4
+ belongs_to :manifestation, touch: true
5
5
 
6
6
  validates_associated :classification_type
7
7
  validates_presence_of :category, :classification_type
@@ -14,10 +14,13 @@ module EnjuSubject
14
14
  can [:destroy, :delete], ClassificationType do |classification_type|
15
15
  classification_type.classifications.empty?
16
16
  end
17
+ can [:read, :create, :update], SubjectHeadingType
18
+ can [:destroy, :delete], SubjectHeadingType do |subject_heading_type|
19
+ subject_heading_type.subjects.empty?
20
+ end
17
21
  can :manage, [
18
22
  Classification,
19
23
  Subject,
20
- SubjectHeadingType,
21
24
  SubjectType
22
25
  ]
23
26
  else
@@ -2,7 +2,7 @@ class Subject < ActiveRecord::Base
2
2
  attr_accessible :parent_id, :use_term_id, :term, :term_transcription,
3
3
  :subject_type_id, :note, :required_role_id, :subject_heading_type_id
4
4
 
5
- belongs_to :manifestation
5
+ belongs_to :manifestation, touch: true
6
6
  belongs_to :subject_type
7
7
  belongs_to :subject_heading_type
8
8
  belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
@@ -1,13 +1,17 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.listing', model: t('activerecord.models.classification_type')) -%></h1>
3
3
  <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
4
5
 
5
6
  <table class="table table-striped index">
6
7
  <tr>
7
8
  <th id="position"></th>
8
9
  <th><%= t('activerecord.attributes.classification_type.name') -%></th>
9
- <th><%= t('activerecord.attributes.classification_type.display_name') -%></th>
10
- <th><%= t('activerecord.attributes.classification_type.note') -%></th>
10
+ <th>
11
+ <%= t('activerecord.attributes.classification_type.display_name') -%>
12
+ /
13
+ <%= t('activerecord.attributes.classification_type.note') -%>
14
+ </th>
11
15
  <th></th>
12
16
  </tr>
13
17
 
@@ -18,15 +22,18 @@
18
22
  <%= move_position(classification_type) -%>
19
23
  <%- end -%>
20
24
  </td>
21
- <td><%= link_to classification_type.name, classification_type -%></td>
22
- <td><%= link_to classification_type.display_name.localize, classification_type -%></td>
23
- <td><%= classification_type.note -%></td>
25
+ <td><%= classification_type.name -%></td>
26
+ <td>
27
+ <%= link_to classification_type.display_name.localize, classification_type -%>
28
+ <br />
29
+ <%= classification_type.note %>
30
+ </td>
24
31
  <td>
25
32
  <%- if can? :update, classification_type -%>
26
33
  <%= link_to t('page.edit'), edit_classification_type_path(classification_type) -%>
27
34
  <% end %>
28
35
  <%- if can? :delete, classification_type -%>
29
- <%= link_to t('page.destroy'), classification_type, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
36
+ <%= link_to t('page.destroy'), classification_type_path(classification_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
30
37
  <%- end -%>
31
38
  </td>
32
39
  </tr>
@@ -1,6 +1,7 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.listing', model: t('activerecord.models.classification')) -%></h1>
3
3
  <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
4
5
 
5
6
  <div class="search_form">
6
7
  <%= form_for :classifications, url: classifications_path, html: {method: 'get'} do -%>
@@ -5,7 +5,7 @@
5
5
  <ul>
6
6
  <%- manifestation.classifications.each do |classification| -%>
7
7
  <li>
8
- <%= link_to "#{classification.classification_type.display_name.localize}: #{classification.category}", manifestations_path(query: "classification_sm:#{classification.category}") -%>
8
+ <%= link_to "#{classification.classification_type.display_name.localize}: #{classification.category}", manifestations_path(query: "classification_sm:#{classification.classification_type.name}_#{classification.category}") -%>
9
9
  </li>
10
10
  <%- end -%>
11
11
  </ul>
@@ -1,13 +1,17 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.listing', model: t('activerecord.models.subject_heading_type')) -%></h1>
3
3
  <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
4
5
 
5
6
  <table class="table table-striped index">
6
7
  <tr>
7
8
  <th id="position"></th>
8
9
  <th><%= t('activerecord.attributes.subject_heading_type.name') -%></th>
9
- <th><%= t('activerecord.attributes.subject_heading_type.display_name') -%></th>
10
- <th><%= t('activerecord.attributes.subject_heading_type.note') -%></th>
10
+ <th>
11
+ <%= t('activerecord.attributes.subject_heading_type.display_name') -%>
12
+ /
13
+ <%= t('activerecord.attributes.subject_heading_type.note') -%>
14
+ </th>
11
15
  <th></th>
12
16
  </tr>
13
17
 
@@ -18,15 +22,18 @@
18
22
  <%= move_position(subject_heading_type) -%>
19
23
  <%- end -%>
20
24
  </td>
21
- <td><%= link_to subject_heading_type.name, subject_heading_type -%></td>
22
- <td><%= link_to subject_heading_type.display_name.localize, subject_heading_type -%></td>
23
- <td><%= subject_heading_type.note -%></td>
25
+ <td><%= subject_heading_type.name -%></td>
26
+ <td>
27
+ <%= link_to subject_heading_type.display_name.localize, subject_heading_type -%>
28
+ <br />
29
+ <%= subject_heading_type.note %>
30
+ </td>
24
31
  <td>
25
32
  <%- if can? :update, subject_heading_type -%>
26
33
  <%= link_to t('page.edit'), edit_subject_heading_type_path(subject_heading_type) -%>
27
34
  <% end %>
28
35
  <%- if can? :delete, subject_heading_type -%>
29
- <%= link_to t('page.destroy'), subject_heading_type, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
36
+ <%= link_to t('page.destroy'), subject_heading_type_path(subject_heading_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
30
37
  <%- end -%>
31
38
  </td>
32
39
  </tr>
@@ -38,6 +45,8 @@
38
45
 
39
46
  <div id="submenu" class="ui-corner-all ui-widget-content">
40
47
  <ul>
41
- <li><%= link_to t('page.new', model: t('activerecord.models.subject_heading_type')), new_subject_heading_type_path -%></li>
48
+ <%- if can? :create, SubjectHeadingType -%>
49
+ <li><%= link_to t('page.new', model: t('activerecord.models.subject_heading_type')), new_subject_heading_type_path -%></li>
50
+ <%- end -%>
42
51
  </ul>
43
52
  </div>
@@ -3,6 +3,11 @@
3
3
  <div id="content_list">
4
4
  <p id="notice"><%= notice %></p>
5
5
 
6
+ <p>
7
+ <strong><%= t('activerecord.attributes.subject_heading_type.name') -%>:</strong>
8
+ <%= @subject_heading_type.name -%>
9
+ </p>
10
+
6
11
  <p>
7
12
  <strong><%= t('activerecord.attributes.subject_heading_type.display_name') -%>:</strong>
8
13
  <%= @subject_heading_type.display_name.localize -%>
@@ -1,13 +1,17 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.listing', model: t('activerecord.models.subject_type')) -%></h1>
3
3
  <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
4
5
 
5
6
  <table class="table table-striped index">
6
7
  <tr>
7
8
  <th id="position"></th>
8
9
  <th><%= t('activerecord.attributes.subject_type.name') -%></th>
9
- <th><%= t('activerecord.attributes.subject_type.display_name') -%></th>
10
- <th><%= t('activerecord.attributes.subject_type.note') -%></th>
10
+ <th>
11
+ <%= t('activerecord.attributes.subject_type.display_name') -%>
12
+ /
13
+ <%= t('activerecord.attributes.subject_type.note') -%>
14
+ </th>
11
15
  <th></th>
12
16
  </tr>
13
17
 
@@ -18,15 +22,18 @@
18
22
  <%= move_position(subject_type) -%>
19
23
  <%- end -%>
20
24
  </td>
21
- <td><%= link_to subject_type.name, subject_type -%></td>
22
- <td><%= link_to subject_type.display_name.localize, subject_type -%></td>
23
- <td><%= subject_type.note -%></td>
25
+ <td><%= subject_type.name -%></td>
26
+ <td>
27
+ <%= link_to subject_type.display_name.localize, subject_type -%>
28
+ <br />
29
+ <%= subject_type.note %>
30
+ </td>
24
31
  <td>
25
32
  <%- if can? :update, subject_type -%>
26
33
  <%= link_to t('page.edit'), edit_subject_type_path(subject_type) -%>
27
34
  <% end %>
28
35
  <%- if can? :delete, subject_type -%>
29
- <%= link_to t('page.destroy'), subject_type, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
36
+ <%= link_to t('page.destroy'), subject_type_path(subject_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
30
37
  <%- end -%>
31
38
  </td>
32
39
  </tr>
@@ -38,8 +45,8 @@
38
45
 
39
46
  <div id="submenu" class="ui-corner-all ui-widget-content">
40
47
  <ul>
41
- <% if can? :create, SubjectType %>
48
+ <%- if can? :create, SubjectType -%>
42
49
  <li><%= link_to t('page.new', model: t('activerecord.models.subject_type')), new_subject_type_path -%></li>
43
- <% end %>
50
+ <%- end -%>
44
51
  </ul>
45
52
  </div>
@@ -1,5 +1,9 @@
1
1
  <%= form_for(@subject) do |f| -%>
2
2
  <%= f.error_messages -%>
3
+ <div class="field">
4
+ <%= f.label t('activerecord.models.subject_heading_type') -%>
5
+ <%= f.select(:subject_heading_type_id, @subject_heading_types.collect{|s| [s.display_name.localize, s.id]}) -%>
6
+ </div>
3
7
  <div class="field">
4
8
  <%= f.label t('activerecord.models.subject_type') -%>
5
9
  <%= f.select(:subject_type_id, @subject_types.collect{|s| [s.display_name.localize, s.id]}) -%>
@@ -17,10 +21,6 @@
17
21
  <%= f.label :note -%><br />
18
22
  <%= f.text_area :note -%>
19
23
  </div>
20
- <div class="field">
21
- <%= f.label t('activerecord.models.subject_heading_type') -%>
22
- <%= f.select(:subject_heading_type_id, @subject_heading_types.collect{|s| [s.display_name.localize, s.id]}) -%>
23
- </div>
24
24
  <div class="actions">
25
25
  <%= f.submit %>
26
26
  </div>
@@ -1,6 +1,7 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.listing', model: t('activerecord.models.subject')) -%></h1>
3
3
  <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
4
5
 
5
6
  <div class="search_form">
6
7
  <%= form_for :subjects, url: subjects_path, html: {method: 'get'} do -%>
@@ -13,6 +13,11 @@
13
13
  <%= link_to @subject.subject_heading_type.display_name.localize, @subject.subject_heading_type -%>
14
14
  </p>
15
15
 
16
+ <p>
17
+ <strong><%= t('activerecord.models.subject_type') -%>:</strong>
18
+ <%= link_to @subject.subject_type.display_name.localize, @subject.subject_type -%>
19
+ </p>
20
+
16
21
  <p>
17
22
  <strong><%= t('activerecord.attributes.subject.term_transcription') -%>:</strong>
18
23
  <%= @subject.term_transcription -%>
@@ -1,5 +1,4 @@
1
1
  require 'enju_seed'
2
- require 'inherited_resources'
3
2
  require 'dynamic_form'
4
3
 
5
4
  module EnjuSubject
@@ -12,6 +12,12 @@ module EnjuSubject
12
12
  has_many :classifications
13
13
  accepts_nested_attributes_for :subjects, :allow_destroy => true, :reject_if => :all_blank
14
14
  accepts_nested_attributes_for :classifications, :allow_destroy => true, :reject_if => :all_blank
15
+ after_save do
16
+ subject_index!
17
+ end
18
+ after_destroy do
19
+ subject_index!
20
+ end
15
21
 
16
22
  searchable do
17
23
  text :subject do
@@ -21,11 +27,19 @@ module EnjuSubject
21
27
  subjects.map{|s| [s.term, s.term_transcription]}.flatten.compact
22
28
  end
23
29
  string :classification, :multiple => true do
24
- classifications.collect(&:category)
30
+ classifications.map{|c| "#{c.classification_type.name}_#{c.category}"}
25
31
  end
26
32
  integer :subject_ids, :multiple => true
27
33
  end
28
34
  end
35
+
36
+ module InstanceMethods
37
+ def subject_index!
38
+ subjects.map{|subject| subject.index}
39
+ classifications.map{|classification| classification.index}
40
+ Sunspot.commit
41
+ end
42
+ end
29
43
  end
30
44
  end
31
45
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuSubject
2
- VERSION = "0.1.0.pre26"
2
+ VERSION = "0.1.0.pre27"
3
3
  end
@@ -1,4 +1,7 @@
1
1
  require 'active_record/fixtures'
2
+ require 'tasks/subject_type'
3
+ require 'tasks/subject_heading_type'
4
+
2
5
  desc "create initial records for enju_subject"
3
6
  namespace :enju_subject do
4
7
  task :setup => :environment do
@@ -8,4 +11,13 @@ namespace :enju_subject do
8
11
 
9
12
  puts 'initial fixture files loaded.'
10
13
  end
14
+
15
+ desc "upgrade enju_subject"
16
+ task :upgrade => :environment do
17
+ SubjectType.transaction do
18
+ update_subject_type
19
+ update_subject_heading_type
20
+ end
21
+ puts 'enju_subject: The upgrade completed successfully.'
22
+ end
11
23
  end
@@ -0,0 +1,6 @@
1
+ def update_subject_heading_type
2
+ unknown = SubjectHeadingType.where(name: 'unknown').first
3
+ unless unknown
4
+ SubjectHeadingType.create!(name: 'unknown')
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ def update_subject_type
2
+ concept = SubjectType.where(name: 'Concept').first
3
+ concept.update_column(:name, 'concept') if concept
4
+ event = SubjectType.where(name: 'Event').first
5
+ event.update_column(:name, 'event') if event
6
+ object = SubjectType.where(name: 'Object').first
7
+ object.update_column(:name, 'object') if object
8
+ place = SubjectType.where(name: 'Place').first
9
+ place.update_column(:name, 'place') if place
10
+ end