enju_subject 0.1.1 → 0.2.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/app/controllers/classification_types_controller.rb +13 -2
  4. data/app/controllers/classifications_controller.rb +12 -3
  5. data/app/controllers/concerns/enju_subject/controller.rb +27 -0
  6. data/app/controllers/subject_heading_types_controller.rb +13 -2
  7. data/app/controllers/subject_types_controller.rb +13 -2
  8. data/app/controllers/subjects_controller.rb +12 -4
  9. data/app/models/classification.rb +1 -1
  10. data/app/models/classification_type.rb +0 -1
  11. data/app/models/concerns/enju_subject/enju_manifestation.rb +37 -0
  12. data/app/models/subject.rb +1 -1
  13. data/app/models/subject_heading_type.rb +0 -1
  14. data/app/models/subject_type.rb +0 -1
  15. data/app/policies/classification_policy.rb +21 -0
  16. data/app/policies/classification_type_policy.rb +23 -0
  17. data/app/policies/subject_heading_type_policy.rb +23 -0
  18. data/app/policies/subject_policy.rb +21 -0
  19. data/app/policies/subject_type_policy.rb +21 -0
  20. data/app/views/classification_types/index.html.erb +4 -4
  21. data/app/views/classification_types/show.html.erb +2 -2
  22. data/app/views/classifications/index.html.erb +2 -2
  23. data/app/views/classifications/show.html.erb +2 -2
  24. data/app/views/manifestations/_classification_fields.html.erb +5 -0
  25. data/app/views/manifestations/_subject_facet.html.erb +2 -2
  26. data/app/views/manifestations/_subject_fields.html.erb +6 -0
  27. data/app/views/manifestations/_subject_form.html.erb +8 -9
  28. data/app/views/subject_heading_types/index.html.erb +4 -4
  29. data/app/views/subject_heading_types/show.html.erb +2 -2
  30. data/app/views/subject_types/index.html.erb +4 -4
  31. data/app/views/subject_types/show.html.erb +2 -2
  32. data/app/views/subjects/index.html.erb +3 -3
  33. data/app/views/subjects/index.rss.builder +2 -2
  34. data/app/views/subjects/show.html.erb +3 -3
  35. data/db/fixtures/subject_types.yml +4 -4
  36. data/lib/enju_subject/master_model.rb +3 -3
  37. data/lib/enju_subject/version.rb +1 -1
  38. data/lib/enju_subject.rb +0 -29
  39. data/lib/generators/enju_subject/setup/setup_generator.rb +6 -1
  40. data/lib/generators/enju_subject/setup/templates/db/fixtures/classification_types.yml +6 -0
  41. data/lib/generators/enju_subject/setup/templates/db/fixtures/subject_heading_types.yml +6 -6
  42. data/lib/tasks/enju_subject_tasks.rake +1 -1
  43. data/spec/controllers/classification_types_controller_spec.rb +13 -13
  44. data/spec/controllers/classifications_controller_spec.rb +9 -9
  45. data/spec/controllers/subject_heading_types_controller_spec.rb +58 -58
  46. data/spec/controllers/subject_types_controller_spec.rb +13 -13
  47. data/spec/controllers/subjects_controller_spec.rb +9 -9
  48. data/spec/dummy/app/controllers/application_controller.rb +8 -4
  49. data/spec/dummy/app/models/user.rb +1 -1
  50. data/spec/dummy/config/application.rb +5 -24
  51. data/spec/dummy/config/environments/development.rb +25 -14
  52. data/spec/dummy/config/environments/production.rb +50 -31
  53. data/spec/dummy/config/environments/test.rb +23 -18
  54. data/spec/dummy/config/initializers/enju_leaf.rb +1 -0
  55. data/spec/dummy/db/schema.rb +2 -1
  56. data/spec/lib/generators/enju_subject/setup/setup_generator_spec.rb +34 -0
  57. data/spec/support/devise.rb +2 -1
  58. metadata +95 -20
  59. data/app/models/enju_subject/ability.rb +0 -58
  60. data/lib/enju_subject/manifestation.rb +0 -44
  61. data/spec/dummy/app/models/ability.rb +0 -59
  62. data/spec/dummy/config/application.yml +0 -38
  63. data/spec/dummy/config/initializers/assets.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09922ea1be19a25aec33ccc26685a09218512214
4
- data.tar.gz: 1da6d40e04ecb3e5fb4b484b29431f483d6d1fcf
3
+ metadata.gz: 4634ca355d0b6c820085bdc7ea5f3d6694cd40b9
4
+ data.tar.gz: 7b4ff7ab670cf1d95ae0b8bfdbca0a617ddb6be0
5
5
  SHA512:
6
- metadata.gz: cfdc1b0065f44cacdc6b8835fd55f1e9374a68bed2c4c75e76193b7cb69fc1fd0649d58abbf12b728a23a9973cf12d508b605f03b3d5753ac9648fa94bcd740e
7
- data.tar.gz: b23986e056231747d9d1c34ec451fe76ed4afa9e95eb04e7be34e09d756f0fbdab6c591dd972fe982b325024eaaccf160b42408efe3b9106cb21c23d9f77b03f
6
+ metadata.gz: b990544941c243f050fff730c0c168f3c5601b27fa42432f57a1d99eb341b2e9e141bda6ea5e06d6c40923f0f25dd878ad5e1dbd814b14e1311bfc110768b9f4
7
+ data.tar.gz: 6259f4790c078008714c6f325eade1f753510b188173780abf801374892916cc1ec5408d06b7874663fabe641d6fdcbdc99be14d1d0b38c6ed3104bd5b18a2c6
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = EnjuSubject
2
- {<img src="https://travis-ci.org/next-l/enju_subject.svg?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_subject]
3
- {<img src="https://coveralls.io/repos/next-l/enju_subject/badge.svg?branch=1.1&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_subject?branch=1.1]
4
- {<img src="https://hakiri.io/github/next-l/enju_subject/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_subject/1.1]
2
+ {<img src="https://travis-ci.org/next-l/enju_subject.svg?branch=1.2" alt="Build Status" />}[https://travis-ci.org/next-l/enju_subject]
3
+ {<img src="https://coveralls.io/repos/next-l/enju_subject/badge.svg?branch=1.2&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_subject?branch=1.2]
4
+ {<img src="https://hakiri.io/github/next-l/enju_subject/1.2.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_subject/1.2]
5
5
 
6
6
  This project rocks and uses MIT-LICENSE.
7
7
 
@@ -1,9 +1,11 @@
1
1
  class ClassificationTypesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_classification_type, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /classification_types
4
6
  # GET /classification_types.json
5
7
  def index
6
- @classification_types = ClassificationType.all
8
+ @classification_types = ClassificationType.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class ClassificationTypesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_classification_type
88
+ @classification_type = ClassificationType.find(params[:id])
89
+ authorize @classification_type
90
+ end
91
+
92
+ def check_policy
93
+ authorize ClassificationType
94
+ end
95
+
85
96
  def classification_type_params
86
97
  params.require(:classification_type).permit(:name, :display_name, :note)
87
98
  end
@@ -1,8 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class ClassificationsController < ApplicationController
3
- load_and_authorize_resource
4
- before_filter :get_subject, :get_classification_type
5
- after_filter :solr_commit, only: [:create, :update, :destroy]
3
+ before_action :set_classification, only: [:show, :edit, :update, :destroy]
4
+ before_action :check_policy, only: [:index, :new, :create]
5
+ before_action :get_subject, :get_classification_type
6
6
 
7
7
  # GET /classifications
8
8
  # GET /classifications.json
@@ -109,6 +109,15 @@ class ClassificationsController < ApplicationController
109
109
  end
110
110
 
111
111
  private
112
+ def set_classification
113
+ @classification = Classification.find(params[:id])
114
+ authorize @classification
115
+ end
116
+
117
+ def check_policy
118
+ authorize Classification
119
+ end
120
+
112
121
  def classification_params
113
122
  params.require(:classification).permit(
114
123
  :parent_id, :category, :note, :classification_type_id, :url, :label
@@ -0,0 +1,27 @@
1
+ module EnjuSubject
2
+ module Controller
3
+
4
+ private
5
+
6
+ def get_subject_heading_type
7
+ if params[:subject_heading_type_id]
8
+ @subject_heading_type = SubjectHeadingType.find(params[:subject_heading_type_id])
9
+ authorize @subject_heading_type, :show?
10
+ end
11
+ end
12
+
13
+ def get_subject
14
+ if params[:subject_id]
15
+ @subject = Subject.find(params[:subject_id])
16
+ authorize @subject, :show?
17
+ end
18
+ end
19
+
20
+ def get_classification
21
+ if params[:classification_id]
22
+ @classification = Classification.find(params[:classification_id])
23
+ authorize @classification, :show?
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,9 +1,11 @@
1
1
  class SubjectHeadingTypesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_subject_heading_type, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /subject_heading_types
4
6
  # GET /subject_heading_types.json
5
7
  def index
6
- @subject_heading_types = SubjectHeadingType.all
8
+ @subject_heading_types = SubjectHeadingType.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class SubjectHeadingTypesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_subject_heading_type
88
+ @subject_heading_type = SubjectHeadingType.find(params[:id])
89
+ authorize @subject_heading_type
90
+ end
91
+
92
+ def check_policy
93
+ authorize SubjectHeadingType
94
+ end
95
+
85
96
  def subject_heading_type_params
86
97
  params.require(:subject_heading_type).permit(:name, :display_name, :note)
87
98
  end
@@ -1,9 +1,11 @@
1
1
  class SubjectTypesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_subject_type, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /subject_types
4
6
  # GET /subject_types.json
5
7
  def index
6
- @subject_types = SubjectType.all
8
+ @subject_types = SubjectType.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class SubjectTypesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_subject_type
88
+ @subject_type = SubjectType.find(params[:id])
89
+ authorize @subject_type
90
+ end
91
+
92
+ def check_policy
93
+ authorize SubjectType
94
+ end
95
+
85
96
  def subject_type_params
86
97
  params.require(:subject_type).permit(:name, :display_name, :note)
87
98
  end
@@ -1,9 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class SubjectsController < ApplicationController
3
- load_and_authorize_resource except: :index
4
- authorize_resource only: :index
5
- before_filter :prepare_options, only: [:new, :edit]
6
- after_filter :solr_commit, only: [:create, :update, :destroy]
3
+ before_action :set_subject, only: [:show, :edit, :update, :destroy]
4
+ before_action :check_policy, only: [:index, :new, :create]
5
+ before_action :prepare_options, only: [:new, :edit]
7
6
 
8
7
  # GET /subjects
9
8
  # GET /subjects.json
@@ -131,6 +130,15 @@ class SubjectsController < ApplicationController
131
130
  end
132
131
 
133
132
  private
133
+ def set_subject
134
+ @subject = Subject.find(params[:id])
135
+ authorize @subject
136
+ end
137
+
138
+ def check_policy
139
+ authorize Subject
140
+ end
141
+
134
142
  def subject_params
135
143
  params.require(:subject).permit(
136
144
  :parent_id, :use_term_id, :term, :term_transcription,
@@ -8,7 +8,7 @@ class Classification < ActiveRecord::Base
8
8
  text :category, :note
9
9
  integer :classification_type_id
10
10
  end
11
- normalize_attributes :category, :url
11
+ strip_attributes only: [:category, :url]
12
12
 
13
13
  paginates_per 10
14
14
  end
@@ -1,6 +1,5 @@
1
1
  class ClassificationType < ActiveRecord::Base
2
2
  include MasterModel
3
- default_scope { order('classification_types.position') }
4
3
  has_many :classifications
5
4
  validates :name, format: { with: /\A[0-9a-z][0-9a-z_\-]*[0-9a-z]\Z/ }
6
5
  end
@@ -0,0 +1,37 @@
1
+ module EnjuSubject
2
+ module EnjuManifestation
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :subjects
7
+ has_many :classifications
8
+ accepts_nested_attributes_for :subjects, allow_destroy: true, reject_if: :all_blank
9
+ accepts_nested_attributes_for :classifications, allow_destroy: true, reject_if: :all_blank
10
+ after_save do
11
+ subject_index!
12
+ end
13
+ after_destroy do
14
+ subject_index!
15
+ end
16
+
17
+ searchable do
18
+ text :subject do
19
+ subjects.map{|s| [s.term, s.term_transcription]}.flatten.compact
20
+ end
21
+ string :subject, multiple: true do
22
+ subjects.map{|s| [s.term, s.term_transcription]}.flatten.compact
23
+ end
24
+ string :classification, multiple: true do
25
+ classifications.map{|c| "#{c.classification_type.name}_#{c.category}"}
26
+ end
27
+ integer :subject_ids, multiple: true
28
+ end
29
+ end
30
+
31
+ def subject_index!
32
+ subjects.map{|subject| subject.index}
33
+ classifications.map{|classification| classification.index}
34
+ Sunspot.commit
35
+ end
36
+ end
37
+ end
@@ -13,7 +13,7 @@ class Subject < ActiveRecord::Base
13
13
  integer :required_role_id
14
14
  end
15
15
 
16
- normalize_attributes :term
16
+ strip_attributes only: :term
17
17
 
18
18
  paginates_per 10
19
19
  end
@@ -1,6 +1,5 @@
1
1
  class SubjectHeadingType < ActiveRecord::Base
2
2
  include MasterModel
3
- default_scope { order("subject_heading_types.position") }
4
3
  has_many :subjects
5
4
  validates :name, format: {with: /\A[0-9a-z][0-9a-z_\-]*[0-9a-z]\Z/}
6
5
  end
@@ -1,6 +1,5 @@
1
1
  class SubjectType < ActiveRecord::Base
2
2
  include MasterModel
3
- default_scope { order("subject_types.position") }
4
3
  has_many :subjects
5
4
  validates :name, format: {with: /\A[0-9A-Za-z][0-9a-z_\-]*[0-9a-z]\Z/}
6
5
  end
@@ -0,0 +1,21 @@
1
+ class ClassificationPolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ class ClassificationTypePolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ if user.try(:has_role?, 'Administrator')
20
+ true if record.classifications.empty?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ class SubjectHeadingTypePolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ if user.try(:has_role?, 'Administrator')
20
+ true if record.subjects.empty?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ class SubjectPolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class SubjectTypePolicy < ApplicationPolicy
2
+ def index?
3
+ true if user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ true if user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -18,7 +18,7 @@
18
18
  <%- @classification_types.each do |classification_type| -%>
19
19
  <tr class="line<%= cycle("0", "1") -%>">
20
20
  <td>
21
- <%- if can? :update, classification_type -%>
21
+ <%- if policy(classification_type).update? -%>
22
22
  <%= move_position(classification_type) -%>
23
23
  <%- end -%>
24
24
  </td>
@@ -29,10 +29,10 @@
29
29
  <%= classification_type.note %>
30
30
  </td>
31
31
  <td>
32
- <%- if can? :update, classification_type -%>
32
+ <%- if policy(classification_type).update? -%>
33
33
  <%= link_to t('page.edit'), edit_classification_type_path(classification_type) -%>
34
34
  <% end %>
35
- <%- if can? :delete, classification_type -%>
35
+ <%- if policy(classification_type).destroy? -%>
36
36
  <%= link_to t('page.destroy'), classification_type_path(classification_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
37
37
  <%- end -%>
38
38
  </td>
@@ -45,7 +45,7 @@
45
45
 
46
46
  <div id="submenu" class="ui-corner-all ui-widget-content">
47
47
  <ul>
48
- <%- if can? :create, ClassificationType -%>
48
+ <%- if policy(ClassificationType).create? -%>
49
49
  <li><%= link_to t('page.new', model: t('activerecord.models.classification_type')), new_classification_type_path -%></li>
50
50
  <%- end -%>
51
51
  </ul>
@@ -23,9 +23,9 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <%- if can? :update, @classification_type -%>
26
+ <%- if policy(@classification_type).update? -%>
27
27
  <li><%= link_to t('page.edit'), edit_classification_type_path(@classification_type) -%></li>
28
28
  <%- end -%>
29
- <li><%= back_to_index(flash[:page_info]) -%></li>
29
+ <li><%= link_to t('page.back'), :back -%></li>
30
30
  </ul>
31
31
  </div>
@@ -26,7 +26,7 @@
26
26
  <td><%= classification.label -%></td>
27
27
  <td><%= link_to classification.classification_type.display_name.localize, classification.classification_type -%></td>
28
28
  <td>
29
- <%- if can? :delete, classification -%>
29
+ <%- if policy(classification).destroy? -%>
30
30
  <%= link_to t('page.edit'), edit_classification_path(classification) -%>
31
31
  <%= link_to t('page.destroy'), classification, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
32
32
  <%- end -%>
@@ -42,7 +42,7 @@
42
42
 
43
43
  <div id="submenu" class="ui-corner-all ui-widget-content">
44
44
  <ul>
45
- <%- if can? :create, Classification -%>
45
+ <%- if policy(Classification).create? -%>
46
46
  <%- if @classification_type -%>
47
47
  <li><%= link_to t('page.new', model: t('activerecord.models.classification')), new_classification_type_classification_path(@classification_type) -%></li>
48
48
  <%- else -%>
@@ -33,10 +33,10 @@
33
33
 
34
34
  <div id="submenu" class="ui-corner-all ui-widget-content">
35
35
  <ul>
36
- <%- if can? :update, @classification -%>
36
+ <%- if policy(@classification).update? -%>
37
37
 
38
38
  <li><%= link_to t('page.edit'), edit_classification_path(@classification) %></li>
39
39
  <%- end -%>
40
- <li><%= back_to_index(flash[:page_info]) -%></li>
40
+ <li><%= link_to t('page.back'), :back -%></li>
41
41
  </ul>
42
42
  </div>
@@ -0,0 +1,5 @@
1
+ <div class="nested-fields">
2
+ <%= f.select(:classification_type_id, @classification_types.collect{|c| [c.display_name.localize, c.id]}) %>
3
+ <%= f.text_field :category, class: 'resource_subject' %>
4
+ <%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %>
5
+ </div>
@@ -5,12 +5,12 @@
5
5
  <%- subject = Subject.where(id: facet.value).first -%>
6
6
  <%- if subject -%>
7
7
  <li>
8
- <%= link_to "#{subject.term} (#{facet.count})", url_for(params.merge(page: nil, subject: "\"#{subject.term}\"", view: nil, only_path: true)) -%>
8
+ <%= link_to "#{subject.term} (#{facet.count})", url_for(params.permit.merge(page: nil, subject: "\"#{subject.term}\"", view: nil, only_path: true)) -%>
9
9
  </li>
10
10
  <%- end -%>
11
11
  <%- end -%>
12
12
  <%- if @subject_by_term -%>
13
- <li><%= link_to t('page.remove_this_facet'), url_for(params.merge(subject: nil, page: nil, view: nil, only_path: true)) -%></li>
13
+ <li><%= link_to t('page.remove_this_facet'), url_for(params.permit.merge(subject: nil, page: nil, view: nil, only_path: true)) -%></li>
14
14
  <%- end -%>
15
15
  </ul>
16
16
  <%- else -%>
@@ -0,0 +1,6 @@
1
+ <div class="nested-fields">
2
+ <%= f.select(:subject_heading_type_id, @subject_heading_types.collect{|s| [s.display_name.localize, s.id]}) %>
3
+ <%= f.text_field :term, class: 'resource_subject' %>
4
+ <%= f.select(:subject_type_id, @subject_types.collect{|s| [s.display_name.localize, s.id]}) %>
5
+ <%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %>
6
+ </div>
@@ -1,21 +1,20 @@
1
1
  <div class="field">
2
2
  <%= f.label :subject -%><br />
3
3
  <%= f.fields_for :subjects do |subject_form| %>
4
- <%= subject_form.select(:subject_heading_type_id, @subject_heading_types.collect{|s| [s.display_name.localize, s.id]}) %>
5
- <%= subject_form.text_field :term %>
6
- <%= subject_form.select(:subject_type_id, @subject_types.collect{|s| [s.display_name.localize, s.id]}) %>
7
- <%= subject_form.link_to_remove t('page.remove'), confirm: t('page.are_you_sure') %>
4
+ <%= render 'subject_fields', f: subject_form %>
8
5
  <% end %>
9
- <p><%= f.link_to_add t('page.add'), :subjects %></p>
6
+ <div class="links">
7
+ <p><%= link_to_add_association t('page.add'), f, :subjects %></p>
8
+ </div>
10
9
  </div>
11
10
 
12
11
  <div class="field">
13
12
  <%= f.label :classification -%><br />
14
13
  <%= f.fields_for :classifications do |classification_form| %>
15
- <%= classification_form.select(:classification_type_id, @classification_types.collect{|c| [c.display_name.localize, c.id]}) %>
16
- <%= classification_form.text_field :category %>
17
- <%= classification_form.link_to_remove t('page.remove'), confirm: t('page.are_you_sure') %>
14
+ <%= render 'classification_fields', f: classification_form %>
18
15
  <% end %>
19
- <p><%= f.link_to_add t('page.add'), :classifications %></p>
16
+ <div class="links">
17
+ <p><%= link_to_add_association t('page.add'), f, :classifications %></p>
18
+ </div>
20
19
  </div>
21
20
 
@@ -18,7 +18,7 @@
18
18
  <%- @subject_heading_types.each do |subject_heading_type| -%>
19
19
  <tr class="line<%= cycle("0", "1") -%>">
20
20
  <td>
21
- <%- if can? :update, subject_heading_type -%>
21
+ <%- if policy(subject_heading_type).update? -%>
22
22
  <%= move_position(subject_heading_type) -%>
23
23
  <%- end -%>
24
24
  </td>
@@ -29,10 +29,10 @@
29
29
  <%= subject_heading_type.note %>
30
30
  </td>
31
31
  <td>
32
- <%- if can? :update, subject_heading_type -%>
32
+ <%- if policy(subject_heading_type).update? -%>
33
33
  <%= link_to t('page.edit'), edit_subject_heading_type_path(subject_heading_type) -%>
34
34
  <% end %>
35
- <%- if can? :delete, subject_heading_type -%>
35
+ <%- if policy(subject_heading_type).destroy? -%>
36
36
  <%= link_to t('page.destroy'), subject_heading_type_path(subject_heading_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
37
37
  <%- end -%>
38
38
  </td>
@@ -45,7 +45,7 @@
45
45
 
46
46
  <div id="submenu" class="ui-corner-all ui-widget-content">
47
47
  <ul>
48
- <%- if can? :create, SubjectHeadingType -%>
48
+ <%- if policy(SubjectHeadingType).create? -%>
49
49
  <li><%= link_to t('page.new', model: t('activerecord.models.subject_heading_type')), new_subject_heading_type_path -%></li>
50
50
  <%- end -%>
51
51
  </ul>
@@ -23,9 +23,9 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <%- if can? :update, @subject_heading_type -%>
26
+ <%- if policy(@subject_heading_type).update? -%>
27
27
  <li><%= link_to t('page.edit'), edit_subject_heading_type_path(@subject_heading_type) -%></li>
28
28
  <%- end -%>
29
- <li><%= back_to_index(flash[:page_info]) -%></li>
29
+ <li><%= link_to t('page.back'), :back -%></li>
30
30
  </ul>
31
31
  </div>
@@ -18,7 +18,7 @@
18
18
  <%- @subject_types.each do |subject_type| -%>
19
19
  <tr class="line<%= cycle("0", "1") -%>">
20
20
  <td>
21
- <%- if can? :update, subject_type -%>
21
+ <%- if policy(subject_type).update? -%>
22
22
  <%= move_position(subject_type) -%>
23
23
  <%- end -%>
24
24
  </td>
@@ -29,10 +29,10 @@
29
29
  <%= subject_type.note %>
30
30
  </td>
31
31
  <td>
32
- <%- if can? :update, subject_type -%>
32
+ <%- if policy(subject_type).update? -%>
33
33
  <%= link_to t('page.edit'), edit_subject_type_path(subject_type) -%>
34
34
  <% end %>
35
- <%- if can? :delete, subject_type -%>
35
+ <%- if policy(subject_type).destroy? -%>
36
36
  <%= link_to t('page.destroy'), subject_type_path(subject_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
37
37
  <%- end -%>
38
38
  </td>
@@ -45,7 +45,7 @@
45
45
 
46
46
  <div id="submenu" class="ui-corner-all ui-widget-content">
47
47
  <ul>
48
- <%- if can? :create, SubjectType -%>
48
+ <%- if policy(SubjectType).create? -%>
49
49
  <li><%= link_to t('page.new', model: t('activerecord.models.subject_type')), new_subject_type_path -%></li>
50
50
  <%- end -%>
51
51
  </ul>
@@ -23,9 +23,9 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <%- if can? :update, @subject_type -%>
26
+ <%- if policy().update?@subject_type -%>
27
27
  <li><%= link_to t('page.edit'), edit_subject_type_path(@subject_type) %></li>
28
28
  <%- end -%>
29
- <li><%= back_to_index(flash[:page_info]) %></li>
29
+ <li><%= link_to t('page.back'), :back %></li>
30
30
  </ul>
31
31
  </div>
@@ -21,10 +21,10 @@
21
21
  <tr class="line<%= cycle("0", "1") -%>">
22
22
  <td><%= link_to subject.term, subject -%></td>
23
23
  <td>
24
- <%- if can? :update, subject -%>
24
+ <%- if policy(subject).update? -%>
25
25
  <%= link_to t('page.edit'), edit_subject_path(subject) -%>
26
26
  <%- end -%>
27
- <%- if can? :delete, subject -%>
27
+ <%- if policy(subject).destroy? -%>
28
28
  <%= link_to t('page.destroy'), subject, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
29
29
  <%- end -%>
30
30
  </td>
@@ -38,7 +38,7 @@
38
38
 
39
39
  <div id="submenu" class="ui-corner-all ui-widget-content">
40
40
  <ul>
41
- <%- if can? :create, Subject -%>
41
+ <%- if policy(Subject).create? -%>
42
42
  <li><%= link_to t('page.new', model: t('activerecord.models.subject')), new_subject_path -%></li>
43
43
  <%- end -%>
44
44
  </ul>