Another partial fix for issue #2824, which also affected ip bans and feedback

Also fixed minor errors with IP bans
This commit is contained in:
Type-kun
2017-01-09 13:57:16 +05:00
parent c44c40c759
commit 9da5e67a65
6 changed files with 12 additions and 12 deletions

View File

@@ -8,7 +8,7 @@ class IpBansController < ApplicationController
def create
@ip_ban = IpBan.create(params[:ip_ban])
respond_with(@ip_ban)
respond_with(@ip_ban, :location => ip_bans_path)
end
def index

View File

@@ -12,11 +12,11 @@ class Comment < ActiveRecord::Base
before_validation :initialize_updater
after_create :update_last_commented_at_on_create
after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do
ModAction.log("comment ##{self.id} updated by #{CurrentUser.name}")
ModAction.log("comment ##{id} updated by #{CurrentUser.name}")
end
after_destroy :update_last_commented_at_on_destroy
after_destroy(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do
ModAction.log("comment ##{self.id} deleted by #{CurrentUser.name}")
ModAction.log("comment ##{id} deleted by #{CurrentUser.name}")
end
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin]
attr_accessible :is_sticky, :as => [:moderator, :admin]

View File

@@ -20,10 +20,10 @@ class ForumPost < ActiveRecord::Base
before_destroy :validate_topic_is_unlocked
after_save :delete_topic_if_original_post
after_update(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
ModAction.log("#{CurrentUser.name} updated forum post ##{self.id}")
ModAction.log("#{CurrentUser.name} updated forum post ##{id}")
end
after_destroy(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
ModAction.log("#{CurrentUser.name} deleted forum post ##{self.id}")
ModAction.log("#{CurrentUser.name} deleted forum post ##{id}")
end
mentionable(
:message_field => :body,

View File

@@ -7,10 +7,10 @@ class IpBan < ActiveRecord::Base
validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX}
attr_accessible :ip_addr, :reason
after_create do
ModAction.log("#{CurrentUser.name} created ip ban for #{rec.ip_addr}")
ModAction.log("#{CurrentUser.name} created ip ban for #{ip_addr}")
end
after_destroy do
ModAction.log("#{CurrentUser.name} deleted ip ban for ##{rec.ip_addr}")
ModAction.log("#{CurrentUser.name} deleted ip ban for #{ip_addr}")
end
def self.is_banned?(ip_addr)

View File

@@ -10,11 +10,11 @@ class UserFeedback < ActiveRecord::Base
validate :creator_is_gold
validate :user_is_not_creator
after_create :create_dmail
after_update(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
ModAction.log("#{CurrentUser.name} updated user feedback for #{rec.user_name}")
after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do
ModAction.log(%{#{CurrentUser.name} updated user feedback for "#{user_name}":/users/#{user_id}})
end
after_destroy(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
ModAction.log("#{CurrentUser.name} deleted user feedback for #{rec.user_name}")
after_destroy(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do
ModAction.log(%{#{CurrentUser.name} deleted user feedback for "#{user_name}":/users/#{user_id}})
end
module SearchMethods

View File

@@ -17,7 +17,7 @@
<td><%= ip_ban.ip_addr %></td>
<td><%= ip_ban.creator.name %></td>
<td><%= ip_ban.reason %></td>
<td><%= link_to "Unban", ip_ban_path(ip_ban), :remote => true, :method => :delete, :data => {:confirm => "Do your really want to unban #{ip_ban.creator.name}?"} %></td>
<td><%= link_to "Unban", ip_ban_path(ip_ban), :remote => true, :method => :delete, :data => {:confirm => "Do your really want to unban #{ip_ban.ip_addr}?"} %></td>
</tr>
<% end %>
</tbody>