log a moderation when hats are granted, since we're open and all that

This commit is contained in:
joshua stein 2014-11-15 09:52:29 -06:00
parent 31d4e97858
commit ddb9215aa0
2 changed files with 20 additions and 3 deletions

View file

@ -6,6 +6,8 @@ class Hat < ActiveRecord::Base
validates :user, :presence => true
validates :granted_by_user, :presence => true
after_create :log_moderation
def to_html_label
h = "<span class=\"hat\" title=\"Granted by " <<
"#{self.granted_by_user.username} on " <<
@ -26,4 +28,14 @@ class Hat < ActiveRecord::Base
h.html_safe
end
def log_moderation
m = Moderation.new
m.created_at = self.created_at
m.user_id = self.user_id
m.moderator_user_id = self.granted_by_user_id
m.action = "Granted hat \"#{self.hat}\"" + (self.link.present? ?
" (#{self.link})" : "")
m.save
end
end

View file

@ -7,7 +7,7 @@
<tr>
<th width="15%">Date/Time</th>
<th width="10%">Moderator</th>
<th width="75%">Story/Comment/User, Changes, Reason</th>
<th width="75%">Story/Comment/User, Action, Reason</th>
</tr>
<% bit = 0 %>
<% @moderations.each do |mod| %>
@ -21,8 +21,13 @@
<% elsif mod.comment %>
<a href="<%= mod.comment.url %>">Comment on <%=
mod.comment.story.title %></a>
<% elsif mod.user %>
User <%= mod.user.try(:username) %>
<% elsif mod.user_id %>
<% if mod.user %>
<a href="/u/<%= mod.user.username %>">User
<%= mod.user.username %></a>
<% else %>
User <%= mod.user_id %> (Deleted)
<% end %>
<% end %></td>
</tr>
<tr class="row<%= bit %> <%= mod.reason.present?? "nobottom" : "" %>">