Revision 0f7676c1
Added by Amos Benari almost 12 years ago
- ID 0f7676c17d491ecb8d2df267c0128549d7e3c94f
app/helpers/audits_helper.rb | ||
---|---|---|
end
|
||
|
||
def audit_parent audit
|
||
audit.associated
|
||
" / #{audit.associated}" if audit.associated
|
||
end
|
||
|
||
def details audit
|
||
... | ... | |
def associated_type audit
|
||
type_name = audit.auditable_type.split("::").last rescue ''
|
||
type_name ="Puppet Class" if type_name == "HostClass"
|
||
type_name ="#{audit.associated_type}-#{type_name}" if type_name == "Parameter"
|
||
type_name.underscore.titleize
|
||
end
|
||
|
app/models/domain_parameter.rb | ||
---|---|---|
class DomainParameter < Parameter
|
||
belongs_to :domain, :foreign_key => :reference_id
|
||
audited :except => [:priority], :parent => :domain
|
||
audited :except => [:priority], :associated_with => :domain
|
||
validates_uniqueness_of :name, :scope => :reference_id
|
||
|
||
private
|
app/models/group_parameter.rb | ||
---|---|---|
class GroupParameter < Parameter
|
||
belongs_to :hostgroup, :foreign_key => :reference_id
|
||
audited :except => [:priority], :parent => :hostgroup
|
||
audited :except => [:priority], :associated_with => :hostgroup
|
||
validates_uniqueness_of :name, :scope => :reference_id
|
||
|
||
private
|
app/views/audits/_row.erb | ||
---|---|---|
<% if audit_login? audit %>
|
||
<%= audit_user(audit)%> <%=link_to("Logged-in", audit_path(audit)) %>
|
||
<% else %>
|
||
<%= audit_user(audit)%> <%= audit_action_name audit%> <%= associated_type audit %> <%=link_to(" #{audit_title audit} ", audit_path(audit)) %>
|
||
<%= audit_user(audit)%> <%= audit_action_name audit%> <%= associated_type audit %>:
|
||
<%=link_to(audit_title(audit), audit_path(audit)) %> <%= audit_parent(audit) %>
|
||
<% end %>
|
||
<ul>
|
||
<% details(audit).each do |item| %>
|
app/views/audits/show.html.erb | ||
---|---|---|
<% title "#{@audit.action.camelize} #{@audit.auditable_type.split("::").last rescue ''} #{audit_title @audit}" %>
|
||
<% title "#{@audit.action.camelize} #{associated_type @audit}: #{audit_title @audit} #{audit_parent @audit}" %>
|
||
|
||
<%= title_actions link_to 'Back', :back, :class=>'btn' %>
|
||
<% tmplt = audit_template?(@audit) %>
|
db/migrate/20120620124659_fix_associated_type.rb | ||
---|---|---|
class FixAssociatedType < ActiveRecord::Migration
|
||
def self.up
|
||
execute "UPDATE audits SET associated_type='Host' WHERE associated_type='Puppet::Rails::Host'"
|
||
end
|
||
|
||
def self.down
|
||
execute "UPDATE audits SET associated_type='Puppet::Rails::Host' WHERE associated_type='Host'"
|
||
end
|
||
end
|
lib/audit_extensions.rb | ||
---|---|---|
|
||
def fix_auditable_type
|
||
self.auditable_type = "Host" if self.auditable_type == "Puppet::Rails::Host"
|
||
self.associated_type = "Host" if self.associated_type == "Puppet::Rails::Host"
|
||
self.auditable_type = auditable.type if self.auditable_type == "ComputeResource"
|
||
end
|
||
end
|
Also available in: Unified diff
audit with association.