Skip to content

Commit

Permalink
Refs #22049 - improve metadata usability
Browse files Browse the repository at this point in the history
  • Loading branch information
ares committed Mar 29, 2018
1 parent 682269f commit 8d3de91
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
20 changes: 20 additions & 0 deletions app/helpers/audits_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ def audit_time(audit)
date_time_absolute(audit.created_at)
end

def audit_affected_locations(audit)
base = audit.locations.authorized(:view_locations)
authorizer = Authorizer.new(User.current, base)
if base.empty?
_('none')
else
base.map { |location| link_to_if_authorized location.name, hash_for_edit_location_path(location).merge(:auth_object => location, :permission => 'edit_locations', :authorizer => authorizer) }.to_sentence.html_safe
end
end

def audit_affected_organizations(audit)
base = audit.organizations.authorized(:view_organizations)
authorizer = Authorizer.new(User.current, base)
if base.empty?
_('none')
else
base.map { |organization| link_to_if_authorized organization.name, hash_for_edit_organization_path(organization).merge(:auth_object => organization, :permission => 'edit_organizations', :authorizer => authorizer) }.to_sentence.html_safe
end
end

def audited_icon(audit)
style = 'label-info'
style = case audit.action
Expand Down
8 changes: 4 additions & 4 deletions app/views/audits/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
</div>
<div class="row">
<strong class="col-md-2"><%= _("Audit Time:")%></strong>
<div class="col-md-10"><%= date_time_absolute(@audit.created_at) %></div>
<div class="col-md-10"><%= audit_time(@audit) %></div>
</div>
<div class="row">
<strong class="col-md-2"><%= _("User Name:")%></strong>
<div class="col-md-10"><%= @audit.username %></div>
<div class="col-md-10"><%= audit_user(@audit) %></div>
</div>
<% if Taxonomy.organizations_enabled %>
<div class="row">
<strong class="col-md-2"><%= _("Affected Organizations:")%></strong>
<div class="col-md-10"><%= @audit.organizations.authorized(:view_organizations).to_sentence %></div>
<div class="col-md-10"><%= audit_affected_organizations(@audit) %></div>
</div>
<% end %>
<% if Taxonomy.locations_enabled %>
<div class="row">
<strong class="col-md-2"><%= _("Affected Locations:")%></strong>
<div class="col-md-10"><%= @audit.locations.authorized(:view_locations).to_sentence %></div>
<div class="col-md-10"><%= audit_affected_locations(@audit) %></div>
</div>
<% end %>
<hr/>
Expand Down

0 comments on commit 8d3de91

Please sign in to comment.