rails_audit 1.0.0 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -165
  3. data/README.md +17 -5
  4. data/app/controllers/auditor/admin/approvals_controller.rb +44 -0
  5. data/app/controllers/auditor/admin/audits_controller.rb +11 -0
  6. data/app/controllers/auditor/admin/base_controller.rb +4 -0
  7. data/app/controllers/auditor/admin/verifications_controller.rb +61 -0
  8. data/app/controllers/auditor/admin/verifiers_controller.rb +69 -0
  9. data/app/controllers/auditor/controller/application.rb +32 -0
  10. data/app/models/auditor/approval.rb +5 -0
  11. data/app/models/auditor/audit.rb +5 -0
  12. data/app/models/auditor/ext/audited.rb +58 -0
  13. data/app/models/auditor/ext/verifiable.rb +10 -0
  14. data/app/models/auditor/ext/verified.rb +25 -0
  15. data/app/models/auditor/model/approval.rb +59 -0
  16. data/app/models/auditor/model/approving.rb +65 -0
  17. data/app/models/auditor/model/audit.rb +25 -0
  18. data/app/models/auditor/model/verification.rb +32 -0
  19. data/app/models/auditor/model/verifier.rb +20 -0
  20. data/app/models/auditor/verification.rb +5 -0
  21. data/app/models/auditor/verifier.rb +5 -0
  22. data/app/models/auditor.rb +11 -0
  23. data/app/views/auditor/_approvals.html.erb +14 -0
  24. data/app/views/auditor/_checks.html.erb +16 -0
  25. data/app/views/auditor/admin/approvals/_filter.html.erb +7 -0
  26. data/app/views/auditor/admin/approvals/_form.html.erb +6 -0
  27. data/app/views/auditor/admin/approvals/_index.html.erb +10 -0
  28. data/app/views/auditor/admin/approvals/_show_table.html.erb +28 -0
  29. data/app/views/auditor/admin/approvals/_table.html.erb +28 -0
  30. data/app/views/auditor/admin/approvals/index.js.erb +3 -0
  31. data/app/views/auditor/admin/audits/_button.html.erb +0 -0
  32. data/app/views/auditor/admin/audits/_index_tbody.html.erb +38 -0
  33. data/app/views/auditor/admin/audits/_index_thead.html.erb +4 -0
  34. data/app/views/auditor/admin/audits/index.html.erb +7 -0
  35. data/app/views/auditor/admin/verifications/_edit_form.html.erb +7 -0
  36. data/app/views/auditor/admin/verifications/_filter_form.html.erb +5 -0
  37. data/app/views/auditor/admin/verifications/_index_tbody.html.erb +4 -0
  38. data/app/views/auditor/admin/verifications/_index_thead.html.erb +5 -0
  39. data/app/views/auditor/admin/verifications/_new_form.html.erb +7 -0
  40. data/app/views/auditor/admin/verifications/_show_table.html.erb +16 -0
  41. data/app/views/auditor/admin/verifiers/_edit_form.html.erb +3 -0
  42. data/app/views/auditor/admin/verifiers/_filter_form.html.erb +9 -0
  43. data/app/views/auditor/admin/verifiers/_form.html.erb +5 -0
  44. data/app/views/auditor/admin/verifiers/_index_tbody.html.erb +3 -0
  45. data/app/views/auditor/admin/verifiers/_index_thead.html.erb +4 -0
  46. data/app/views/auditor/admin/verifiers/_member_field.html.erb +1 -0
  47. data/app/views/auditor/admin/verifiers/_new_form.html.erb +3 -0
  48. data/app/views/auditor/admin/verifiers/_show_table.html.erb +24 -0
  49. data/app/views/auditor/admin/verifiers/members.turbo_stream.erb +3 -0
  50. data/config/locales/en.yml +12 -0
  51. data/config/locales/zh.controller.yml +13 -0
  52. data/config/locales/zh.enum.yml +7 -0
  53. data/config/locales/zh.yml +21 -0
  54. data/config/routes.rb +22 -2
  55. data/lib/rails_audit/config.rb +14 -0
  56. data/lib/rails_audit/engine.rb +15 -6
  57. data/lib/rails_audit.rb +3 -2
  58. data/test/controllers/audit/admin/approvals_controller_test.rb +36 -0
  59. data/test/dummy/Gemfile +54 -0
  60. data/test/dummy/Gemfile.lock +382 -0
  61. data/test/dummy/README.md +8 -1
  62. data/test/dummy/app/assets/images/default_avatar.jpg +0 -0
  63. data/test/dummy/app/assets/images/logo.png +0 -0
  64. data/test/dummy/app/assets/javascripts/admin/application.js +1 -0
  65. data/test/dummy/app/assets/javascripts/application.js +11 -2
  66. data/test/dummy/app/assets/javascripts/phone.js +5 -0
  67. data/test/dummy/app/assets/stylesheets/css.scss +4 -0
  68. data/test/dummy/app/controllers/active_storage/base_controller.rb +19 -0
  69. data/test/dummy/app/controllers/admin_controller.rb +3 -0
  70. data/test/dummy/app/controllers/application_controller.rb +10 -1
  71. data/test/dummy/app/controllers/home_controller.rb +0 -5
  72. data/test/dummy/app/controllers/me_controller.rb +4 -0
  73. data/test/dummy/app/controllers/my_controller.rb +4 -0
  74. data/test/dummy/app/models/auth/user.rb +7 -0
  75. data/test/dummy/app/views/home/index.css +3 -0
  76. data/test/dummy/app/views/home/index.html.erb +0 -0
  77. data/test/dummy/app/views/layouts/_right_menu.html.erb +0 -20
  78. data/test/dummy/bin/bundle +1 -1
  79. data/test/dummy/bin/setup +1 -1
  80. data/test/dummy/bin/vite +19 -0
  81. data/test/dummy/bin/yarn +11 -0
  82. data/test/dummy/config/application.rb +12 -5
  83. data/test/dummy/config/boot.rb +8 -4
  84. data/test/dummy/config/credentials/development.key +1 -0
  85. data/test/dummy/config/credentials/test.key +1 -0
  86. data/test/dummy/config/credentials.yml.enc +1 -0
  87. data/test/dummy/config/database.yml +16 -0
  88. data/test/dummy/config/environment.rb +0 -2
  89. data/test/dummy/config/environments/development.rb +19 -32
  90. data/test/dummy/config/environments/production.rb +1 -13
  91. data/test/dummy/config/environments/test.rb +5 -0
  92. data/test/dummy/config/initializers/mime_types.rb +0 -4
  93. data/test/dummy/config/initializers/new_framework_defaults.rb +0 -4
  94. data/test/dummy/config/locales/en.yml +1 -22
  95. data/test/dummy/config/master.key +1 -0
  96. data/test/dummy/config/puma.rb +28 -41
  97. data/test/dummy/config/routes.rb +9 -2
  98. data/test/dummy/config/storage.yml +11 -0
  99. data/test/dummy/config/vite/base.js +5 -0
  100. data/test/dummy/config/vite/development.js +12 -0
  101. data/test/dummy/config/vite/production.js +6 -0
  102. data/test/dummy/config.ru +2 -0
  103. data/test/dummy/lib/deploy.rb +115 -0
  104. data/test/dummy/package.json +23 -2
  105. data/test/dummy/postcss.config.js +11 -0
  106. data/test/dummy/yarn.lock +2140 -4
  107. data/test/factories/approvals.rb +7 -0
  108. data/test/factories/infos.rb +8 -0
  109. data/test/{the_audit_test.rb → rails_audit_test.rb} +3 -1
  110. data/test/test_helper.rb +9 -16
  111. metadata +151 -97
  112. data/app/controllers/admin/audits_controller.rb +0 -12
  113. data/app/models/rails_audit/audit.rb +0 -14
  114. data/app/models/rails_audit/concerns/auditable.rb +0 -59
  115. data/app/models/rails_audit/history.rb +0 -36
  116. data/app/models/rails_audit/major_record.rb +0 -14
  117. data/app/models/rails_audit/minor_record.rb +0 -15
  118. data/app/views/admin/audits/_index.html.erb +0 -9
  119. data/app/views/admin/audits/_table.html.erb +0 -61
  120. data/app/views/admin/audits/index.html.erb +0 -3
  121. data/app/views/admin/audits/index.js.erb +0 -8
  122. data/db/migrate/20170314035239_create_audits.rb +0 -20
  123. data/lib/rails_audit/controller_helper.rb +0 -39
  124. data/lib/rails_audit/version.rb +0 -3
  125. data/lib/tasks/the_history_tasks.rake +0 -4
  126. data/test/dummy/app/assets/config/manifest.js +0 -3
  127. data/test/dummy/app/assets/javascripts/cable.js +0 -13
  128. data/test/dummy/app/assets/stylesheets/application.css +0 -5
  129. data/test/dummy/app/controllers/admin/base_controller.rb +0 -7
  130. data/test/dummy/app/controllers/my/base_controller.rb +0 -7
  131. data/test/dummy/app/models/application_record.rb +0 -3
  132. data/test/dummy/app/models/user.rb +0 -3
  133. data/test/dummy/app/views/layouts/_navbar.html.erb +0 -18
  134. data/test/dummy/app/views/layouts/application.html.erb +0 -19
  135. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  136. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  137. data/test/dummy/bin/update +0 -29
  138. data/test/dummy/config/database.yml.mysql +0 -14
  139. data/test/dummy/config/database.yml.sqlite3 +0 -12
  140. data/test/dummy/config/initializers/assets.rb +0 -6
  141. data/test/dummy/config/secrets.yml +0 -22
  142. data/test/dummy/db/migrate/20180525090830_create_active_storage_tables.active_storage.rb +0 -26
  143. data/test/dummy/log/development.log +0 -2
@@ -0,0 +1,65 @@
1
+ module Auditor
2
+ module Model::Approving
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attribute :unapproved_approvals_count, :integer, default: 0
7
+
8
+ has_one :approval, ->{ where(approved: false).order(id: :desc) }, as: :approving
9
+ has_many :approvals, as: :approving, autosave: true, dependent: :delete_all # to test why autosave not works well
10
+ has_many :unapproved_approvals, ->{ where(approved: false) }, class_name: 'Approval', as: :approving
11
+ end
12
+
13
+ # user: {
14
+ # id: 1,
15
+ # changes: {
16
+ # name: ['a', 'b']
17
+ # }
18
+ # }
19
+ # params same as as_json
20
+ def save_with_approvals(only: [], except: [], include: [])
21
+ for_changes = {}
22
+
23
+ if only.present?
24
+ for_changes[:pending_changes] = self.changes.slice(*only)
25
+ self.assign_attributes self.changed_attributes.slice(*only)
26
+ else
27
+ for_changes[:pending_changes] = self.changes.except(*except)
28
+ self.assign_attributes self.changed_attributes.except(*except)
29
+ end
30
+
31
+ result = {}
32
+ include.each do |key|
33
+ targets = self.public_send(key)
34
+ attr_key = "#{key}_attributes"
35
+ result[attr_key] = []
36
+
37
+ Array(targets).each do |target|
38
+ if target.changes.present?
39
+ result[attr_key] << { id: target.id }.merge!(target.changes)
40
+ target.clear_changes_information
41
+ end
42
+ end
43
+ end
44
+ for_changes[:related_changes] = result
45
+
46
+ if for_changes[:pending_changes].present? || for_changes[:related_changes].present?
47
+ approval = self.approvals.build(for_changes)
48
+ self.class.transaction do
49
+ approval.save!
50
+ self.save!
51
+ end
52
+ else
53
+ self.save
54
+ end
55
+ end
56
+
57
+ def temp_apply_changes
58
+ if approval
59
+ assign_attributes approval.apply_attributes
60
+ end
61
+ self
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,25 @@
1
+ module Auditor
2
+ module Model::Audit
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attribute :action, :string, default: 'update'
7
+ attribute :audited_changes, :json, default: {}
8
+ attribute :related_changes, :json, default: {}
9
+ attribute :extra, :json, default: {}
10
+ attribute :note, :string, limit: 1024
11
+ attribute :remote_ip, :string
12
+ attribute :controller_path, :string
13
+ attribute :action_name, :string
14
+ attribute :created_at, :datetime, index: true, null: false
15
+
16
+ belongs_to :audited, polymorphic: true
17
+ belongs_to :operator, polymorphic: true
18
+ end
19
+
20
+ def audited_changes_i18n
21
+ audited_changes.transform_keys { |key| audited.class.human_attribute_name(key) }
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ module Auditor
2
+ module Model::Verification
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attribute :state, :string
7
+ attribute :note, :string
8
+ attribute :position, :integer
9
+ attribute :confirmed, :boolean, default: false
10
+
11
+ belongs_to :member, class_name: 'Org::Member'
12
+ belongs_to :job_title, class_name: 'Org::JobTitle'
13
+
14
+ belongs_to :verified, polymorphic: true
15
+ belongs_to :verifier
16
+
17
+ after_initialize if: :new_record? do
18
+ self.job_title ||= verifier.job_title
19
+ self.member ||= verifier.member
20
+ end
21
+ after_create_commit :checking_trigger
22
+ end
23
+
24
+ def checking_trigger
25
+ if self.confirmed
26
+ verified.do_trigger state: self.state
27
+ end
28
+ end
29
+
30
+
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ module Auditor
2
+ module Model::Verifier
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attribute :name, :string
7
+ attribute :position, :integer
8
+
9
+ belongs_to :member, class_name: 'Org::Member', optional: true
10
+ belongs_to :job_title, class_name: 'Org::JobTitle', optional: true
11
+
12
+ belongs_to :verifiable, polymorphic: true
13
+ has_many :verifications, dependent: :destroy_async, inverse_of: :verifier
14
+
15
+ acts_as_list
16
+ end
17
+
18
+
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Auditor
2
+ class Verification < ApplicationRecord
3
+ include Model::Verification
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Auditor
2
+ class Verifier < ApplicationRecord
3
+ include Model::Verifier
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Auditor
2
+
3
+ def self.use_relative_model_naming?
4
+ true
5
+ end
6
+
7
+ def self.table_name_prefix
8
+ 'auditor_'
9
+ end
10
+
11
+ end
@@ -0,0 +1,14 @@
1
+ <td class="ui labels">
2
+ <span class="ui label"><%= approval.state_i18n %></span>
3
+ <% if expense.can_operate?(current_member) %>
4
+ <div class="ui mini buttons">
5
+ <%= link_to t('.approve'), new_check_path('Expense', expense.id, state: expense.next_state_state), class: 'ui mini positive button' %>
6
+ <div class="or"></div>
7
+ <%= link_to Expense.enum_i18n(:state, 'rejected'), new_check_path('Expense', expense.id, state: 'rejected'), class: 'ui mini negative button' %>
8
+ <% if ['pending_om', 'pending_cfo'].include?(expense.state) %>
9
+ <div class="or"></div>
10
+ <%= link_to Expense.enum_i18n(:state, 'pending_md'), new_check_path('Expense', expense.id, state: 'pending_md'), class: 'ui mini positive button' %>
11
+ <% end %>
12
+ </div>
13
+ <% end %>
14
+ </td>
@@ -0,0 +1,16 @@
1
+ <table class="ui very basic table">
2
+ <% target.checks.each do |check| %>
3
+ <tr>
4
+ <td>
5
+ <span class="ui label"><%= target.class.enum_i18n(:state, check.state) %></span>
6
+ <% if check.confirmed? %>
7
+ <i class="green check icon"></i>
8
+ <% else %>
9
+ <i class="red question icon"></i>
10
+ <% end %>
11
+ </td>
12
+ <td><%= check.comment %></td>
13
+ <td><%= check.operator.name %></td>
14
+ </tr>
15
+ <% end %>
16
+ </table>
@@ -0,0 +1,7 @@
1
+ <%= form_with theme: 'search', model: Approval.new do |f| %>
2
+ <div class="fields">
3
+ <%= f.text_field :name %>
4
+ <%= f.submit %>
5
+ <%= link_to t('.clear'), filter_params(except: [:name]), class: 'ui button' %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= form_with model: @approval do |f| %>
2
+ <%= render 'error_messages', target: @approval %>
3
+ <%= f.text_field :comment %>
4
+ <%= f.text_field :state %>
5
+ <%= f.submit %>
6
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="ui modal" id="modal">
2
+ <i class="fas fa-times close"></i>
3
+ <div class="ui header">
4
+ <%= t('.title') %>
5
+ </div>
6
+
7
+ <div class="content">
8
+ <%= render 'table' %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,28 @@
1
+ <table class="table is-hoverable is-fullwidth">
2
+ <thead>
3
+ <tr>
4
+ <th class="six wide">
5
+ <%= link_to t('.edit'), edit_admin_approval_path(@approval), class: 'ui mini blue right floated button' %>
6
+ </th>
7
+ <th class="ten wide"></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <tr>
12
+ <td class="has-text-right"><%= Approval.human_attribute_name(:pending_changes) %></td>
13
+ <td><%= @approval.pending_changes %></td>
14
+ </tr>
15
+ <tr>
16
+ <td class="has-text-right"><%= Approval.human_attribute_name(:comment) %></td>
17
+ <td><%= @approval.note %></td>
18
+ </tr>
19
+ <tr>
20
+ <td class="has-text-right"><%= Approval.human_attribute_name(:state) %></td>
21
+ <td><%= @approval.state %></td>
22
+ </tr>
23
+ <tr>
24
+ <td class="has-text-right"><%= Approval.human_attribute_name(:approved_at) %></td>
25
+ <td><%= @approval.approved_at %></td>
26
+ </tr>
27
+ </tbody>
28
+ </table>
@@ -0,0 +1,28 @@
1
+ <table class="ui table">
2
+ <thead>
3
+ <tr>
4
+ <th><%= Approval.human_attribute_name(:pending_changes) %></th>
5
+ <th><%= Approval.human_attribute_name(:related_changes) %></th>
6
+ <th><%= Approval.human_attribute_name(:comment) %></th>
7
+ <th><%= Approval.human_attribute_name(:approved_at) %></th>
8
+ <th></th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @approvals.each do |approval| %>
13
+ <tr>
14
+ <td><%= simple_format approval.pending_changes_i18n %></td>
15
+ <td><%= simple_format approval.related_changes %></td>
16
+ <td><%= approval.comment %></td>
17
+ <td><%= approval.approved_at %></td>
18
+ <td>
19
+ <div class="ui toggle checkbox">
20
+ <%= check_box_tag '[approval]approved', nil, approval.approved, data: { method: :patch, url: admin_approval_path(approval), submit: true }, id: nil %>
21
+ </div>
22
+ </td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
27
+
28
+ <%= paginate @approvals %>
@@ -0,0 +1,3 @@
1
+ $('#modal').replaceWith('<%= j(render 'index') %>')
2
+ $('#modal').modal('show')
3
+ remote_js_load('<%= raw remote_js_load %>')
File without changes
@@ -0,0 +1,38 @@
1
+ <td>
2
+ <p><%= model.operator&.name %></p>
3
+ <p><time data-controller="time"><%= model.created_at.to_s(:rfc822) %></time></p>
4
+ <p><%= model.action %></p>
5
+ <p><%= model.controller_path %>/<%= model.action_name %></p>
6
+ <p><%= model.remote_ip %></p>
7
+ </td>
8
+ <td><%= model.note %></td>
9
+ <td class="ui list">
10
+ <% model.audited_changes_i18n.each do |key, value| %>
11
+ <div class="item">
12
+ <div class="ui label">
13
+ <%= key %>:
14
+ <div class="detail">
15
+ <span><%= value[0] %></span>
16
+ <i class="arrow circle right icon grey"></i>
17
+ <span><%= value[1] %></span>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <% end %>
22
+ </td>
23
+ <td>
24
+ <% model.related_changes.each do |key, value| %>
25
+ <% value.each do |relate| %>
26
+ <div class="ui segment">
27
+ <span class="ui blue label"><%= key %>: <%= relate[:id] %></span>
28
+ <div class="ui divider"></div>
29
+ <% relate[:changes].each do |k, v| %>
30
+ <div class="ui label"><%= k %>: </div>
31
+ <%= v[0] %>
32
+ <i class="arrow circle right icon grey"></i>
33
+ <%= v[1] %>
34
+ <% end %>
35
+ </div>
36
+ <% end %>
37
+ <% end %>
38
+ </td>
@@ -0,0 +1,4 @@
1
+ <th><%= Auditor::Audit.human_attribute_name(:operator) %></th>
2
+ <th><%= Auditor::Audit.human_attribute_name(:note) %></th>
3
+ <th><%= Auditor::Audit.human_attribute_name(:audited_changes) %></th>
4
+ <th><%= Auditor::Audit.human_attribute_name(:related_changes) %></th>
@@ -0,0 +1,7 @@
1
+ <turbo-frame id="modal">
2
+ <%= render layout: 'index_table', locals: { cache_key: Auditor::Audit.column_names.hash } do %>
3
+ <%= render partial: 'index_tbody', collection: @audits, as: :model %>
4
+ <% end %>
5
+
6
+ <%= paginate @audits %>
7
+ </turbo-frame>
@@ -0,0 +1,7 @@
1
+ <%= form_with model: @verification, url: { action: 'update' } do |f| %>
2
+ <%= render 'error_messages', target: f.object %>
3
+ <%= f.number_field :member_id %>
4
+ <%= f.text_area :note %>
5
+ <%= f.check_box :confirmed %>
6
+ <%= f.submit %>
7
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <%= form_with theme: 'search' do |f| %>
2
+ <div class="fields">
3
+ <%= f.submit %>
4
+ </div>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <td><%= model.member_id %></td>
2
+ <td><%= model.note %></td>
3
+ <td><%= model.verified %></td>
4
+ <td><%= model.position %></td>
@@ -0,0 +1,5 @@
1
+ <th><%= Auditor::Verification.human_attribute_name(:member_id) %></th>
2
+ <th><%= Auditor::Verification.human_attribute_name(:note) %></th>
3
+ <th><%= Auditor::Verification.human_attribute_name(:verified) %></th>
4
+ <th><%= Auditor::Verification.human_attribute_name(:position) %></th>
5
+ <th></th>
@@ -0,0 +1,7 @@
1
+ <%= form_with model: @verification, url: { action: 'create' } do |f| %>
2
+ <%= render 'error_messages', target: f.object %>
3
+ <%= f.hidden_field :state %>
4
+ <%= f.text_area :note %>
5
+ <%= f.check_box :confirmed %>
6
+ <%= f.submit %>
7
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <tr>
2
+ <td class="has-text-right"><%= Auditor::Verification.human_attribute_name(:member_id) %></td>
3
+ <td><%= @verification.member_id %></td>
4
+ </tr>
5
+ <tr>
6
+ <td class="has-text-right"><%= Auditor::Verification.human_attribute_name(:comment) %></td>
7
+ <td><%= @verification.comment %></td>
8
+ </tr>
9
+ <tr>
10
+ <td class="has-text-right"><%= Auditor::Verification.human_attribute_name(:approved) %></td>
11
+ <td><%= @verification.approved %></td>
12
+ </tr>
13
+ <tr>
14
+ <td class="has-text-right"><%= Auditor::Verification.human_attribute_name(:position) %></td>
15
+ <td><%= @verification.position %></td>
16
+ </tr>
@@ -0,0 +1,3 @@
1
+ <%= form_with model: @verifier, url: { action: 'update' } do |f| %>
2
+ <%= render partial: 'form', locals: { f: f } %>
3
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <%= form_with theme: 'search', model: Auditor::Verifier.new do |f| %>
2
+ <div class="field-body">
3
+ <%= f.text_field :name %>
4
+ <div class="field is-narrow">
5
+ <%= f.submit %>
6
+ <%= link_to t('.clear'), filter_params(except: [:name]), class: 'button is-light' %>
7
+ </div>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <%= render 'error_messages', target: f.object %>
2
+ <%= f.text_field :name %>
3
+ <%= f.collection_select :job_title_id, @job_titles, :id, :name, { include_blank: true }, { data: { action: 'input#filter', url: members_admin_verifiers_path(params[:verifiable_type], params[:verifiable_id]) } } %>
4
+ <%= f.select :member_id, options_for_select([]) %>
5
+ <%= f.submit %>
@@ -0,0 +1,3 @@
1
+ <td><%= model.name %></td>
2
+ <td><%= model.job_title_id %></td>
3
+ <td><%= model.member_id %></td>
@@ -0,0 +1,4 @@
1
+ <th><%= Auditor::Verifier.human_attribute_name(:name) %></th>
2
+ <th><%= Auditor::Verifier.human_attribute_name(:job_title_id) %></th>
3
+ <th><%= Auditor::Verifier.human_attribute_name(:member_id) %></th>
4
+ <th></th>
@@ -0,0 +1 @@
1
+ <%= f.collection_select :member_id, @members, :id, :name %>
@@ -0,0 +1,3 @@
1
+ <%= form_with model: @verifier, url: { action: 'create', verifiable_type: params[:verifiable_type], verifiable_id: params[:verifiable_id] }, data: { controller: 'input' } do |f| %>
2
+ <%= render partial: 'form', locals: { f: f } %>
3
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <table class="table is-fullwidth">
2
+ <thead>
3
+ <tr>
4
+ <th>
5
+ <%= link_to t('.edit'), edit_admin_verifier_path(@verifier), class: 'button is-small is-link' %>
6
+ </th>
7
+ <th></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <tr>
12
+ <td class="has-text-right"><%= Verifier.human_attribute_name(:name) %></td>
13
+ <td><%= @verifier.name %></td>
14
+ </tr>
15
+ <tr>
16
+ <td class="has-text-right"><%= Verifier.human_attribute_name(:job_title_id) %></td>
17
+ <td><%= @verifier.job_title_id %></td>
18
+ </tr>
19
+ <tr>
20
+ <td class="has-text-right"><%= Verifier.human_attribute_name(:member_id) %></td>
21
+ <td><%= @verifier.member_id %></td>
22
+ </tr>
23
+ </tbody>
24
+ </table>
@@ -0,0 +1,3 @@
1
+ <% form_object = form_object(@verifier, theme: nil) %>
2
+
3
+ document.getElementById('verifier_member_id').parentNode.innerHTML = '<%= j(render partial: 'member_field', locals: { f: form_object }) %>'
@@ -0,0 +1,12 @@
1
+ en:
2
+ audit/admin:
3
+ checks:
4
+ new:
5
+ check: 审核
6
+ activerecord:
7
+ models:
8
+ check: 审核
9
+ attributes:
10
+ check:
11
+ confirmed: 确认?
12
+ comment: 备注
@@ -0,0 +1,13 @@
1
+ zh:
2
+ auditor:
3
+ title: 操作审计
4
+ admin:
5
+ approvals:
6
+ index:
7
+ title: 待审核
8
+ audits:
9
+ index:
10
+ title: 操作日志
11
+ verifications:
12
+ new:
13
+ title: 审核
@@ -0,0 +1,7 @@
1
+ zh:
2
+ activerecord:
3
+ enum:
4
+ verification:
5
+ confirmed:
6
+ true: 已同意
7
+ false: 未同意
@@ -0,0 +1,21 @@
1
+ zh:
2
+ activerecord:
3
+ models:
4
+ verification: 审核
5
+ attributes:
6
+ verification:
7
+ confirmed: 同意
8
+ comment: 备注
9
+ approval:
10
+ pending_changes: 待审核修改
11
+ comment: 备注
12
+ approved_at: 审核时间
13
+ audit:
14
+ action: 操作
15
+ controller_path: API
16
+ operator: 操作人
17
+ audited_changes: 修改历史
18
+ related_changes: 关联修改历史
19
+ verifier:
20
+ job_title_id: 职务
21
+ member_id: 责任人
data/config/routes.rb CHANGED
@@ -1,7 +1,27 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- scope module: 'admin', path: ':auditable_type/:auditable_id' do
4
- resources :audits, only: ['index']
3
+ namespace :auditor, defaults: { business: 'auditor' } do
4
+ scope ':audited_type/:audited_id', module: 'admin', defaults: { namespace: 'admin' } do
5
+ resources :audits, only: [:index]
6
+ end
7
+
8
+ scope ':approving_type/:approving_id', module: 'admin', defaults: { namespace: 'admin' } do
9
+ resources :approvals, only: [:index]
10
+ end
11
+
12
+ namespace :admin, defaults: { namespace: 'admin' } do
13
+ resources :approvals, except: [:index, :new, :create]
14
+ scope path: ':verifiable_type/:verifiable_id' do
15
+ resources :verifiers do
16
+ collection do
17
+ get :members
18
+ end
19
+ end
20
+ end
21
+ scope path: ':verified_type/:verified_id' do
22
+ resources :verifications
23
+ end
24
+ end
5
25
  end
6
26
 
7
27
  end
@@ -0,0 +1,14 @@
1
+ require 'active_support/configurable'
2
+
3
+ module RailsAudit #:nodoc:
4
+ include ActiveSupport::Configurable
5
+
6
+ configure do |config|
7
+ config.default_except = [
8
+ 'updated_at'
9
+ ]
10
+ end
11
+
12
+ end
13
+
14
+
@@ -1,10 +1,19 @@
1
+ require 'rails_com'
1
2
  module RailsAudit
2
3
  class Engine < ::Rails::Engine
3
-
4
- config.eager_load_paths += Dir[
5
- "#{config.root}/app/models/rails_audit",
6
- "#{config.root}/app/models/rails_audit/concerns"
7
- ]
8
-
4
+
5
+ config.generators do |g|
6
+ g.rails = {
7
+ assets: false,
8
+ stylesheets: false,
9
+ helper: false
10
+ }
11
+ g.test_unit = {
12
+ fixture: true,
13
+ fixture_replacement: :factory_girl
14
+ }
15
+ g.templates.unshift File.expand_path('lib/templates', RailsCom::Engine.root)
16
+ end
17
+
9
18
  end
10
19
  end
data/lib/rails_audit.rb CHANGED
@@ -1,3 +1,4 @@
1
- require 'rails_audit/engine'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rails_audit/controller_helper'
3
+ require 'rails_audit/engine'
4
+ require 'rails_audit/config'