log a moderation when hats are granted, since we're open and all that
This commit is contained in:
parent
31d4e97858
commit
ddb9215aa0
|
@ -6,6 +6,8 @@ class Hat < ActiveRecord::Base
|
||||||
validates :user, :presence => true
|
validates :user, :presence => true
|
||||||
validates :granted_by_user, :presence => true
|
validates :granted_by_user, :presence => true
|
||||||
|
|
||||||
|
after_create :log_moderation
|
||||||
|
|
||||||
def to_html_label
|
def to_html_label
|
||||||
h = "<span class=\"hat\" title=\"Granted by " <<
|
h = "<span class=\"hat\" title=\"Granted by " <<
|
||||||
"#{self.granted_by_user.username} on " <<
|
"#{self.granted_by_user.username} on " <<
|
||||||
|
@ -26,4 +28,14 @@ class Hat < ActiveRecord::Base
|
||||||
|
|
||||||
h.html_safe
|
h.html_safe
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th width="15%">Date/Time</th>
|
<th width="15%">Date/Time</th>
|
||||||
<th width="10%">Moderator</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>
|
</tr>
|
||||||
<% bit = 0 %>
|
<% bit = 0 %>
|
||||||
<% @moderations.each do |mod| %>
|
<% @moderations.each do |mod| %>
|
||||||
|
@ -21,8 +21,13 @@
|
||||||
<% elsif mod.comment %>
|
<% elsif mod.comment %>
|
||||||
<a href="<%= mod.comment.url %>">Comment on <%=
|
<a href="<%= mod.comment.url %>">Comment on <%=
|
||||||
mod.comment.story.title %></a>
|
mod.comment.story.title %></a>
|
||||||
<% elsif mod.user %>
|
<% elsif mod.user_id %>
|
||||||
User <%= mod.user.try(:username) %>
|
<% if mod.user %>
|
||||||
|
<a href="/u/<%= mod.user.username %>">User
|
||||||
|
<%= mod.user.username %></a>
|
||||||
|
<% else %>
|
||||||
|
User <%= mod.user_id %> (Deleted)
|
||||||
|
<% end %>
|
||||||
<% end %></td>
|
<% end %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="row<%= bit %> <%= mod.reason.present?? "nobottom" : "" %>">
|
<tr class="row<%= bit %> <%= mod.reason.present?? "nobottom" : "" %>">
|
||||||
|
|
Loading…
Reference in a new issue