fixes #925
This commit is contained in:
@@ -5,6 +5,11 @@ div.comments-for-post {
|
|||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
color: #AAA;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
div.list-of-comments {
|
div.list-of-comments {
|
||||||
article.comment {
|
article.comment {
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class Comment < ActiveRecord::Base
|
|||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
has_many :votes, :class_name => "CommentVote", :dependent => :destroy
|
has_many :votes, :class_name => "CommentVote", :dependent => :destroy
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
|
before_validation :initialize_updater
|
||||||
after_save :update_last_commented_at
|
after_save :update_last_commented_at
|
||||||
after_destroy :update_last_commented_at
|
after_destroy :update_last_commented_at
|
||||||
attr_accessible :body, :post_id, :do_not_bump_post
|
attr_accessible :body, :post_id, :do_not_bump_post
|
||||||
@@ -70,10 +71,19 @@ class Comment < ActiveRecord::Base
|
|||||||
self.ip_addr = CurrentUser.ip_addr
|
self.ip_addr = CurrentUser.ip_addr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize_updater
|
||||||
|
self.updater_id = CurrentUser.user.id
|
||||||
|
self.updater_ip_addr = CurrentUser.ip_addr
|
||||||
|
end
|
||||||
|
|
||||||
def creator_name
|
def creator_name
|
||||||
User.id_to_name(creator_id)
|
User.id_to_name(creator_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def updater_name
|
||||||
|
User.id_to_name(updater_id)
|
||||||
|
end
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
if creator.can_comment?
|
if creator.can_comment?
|
||||||
true
|
true
|
||||||
@@ -111,7 +121,7 @@ class Comment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def editable_by?(user)
|
def editable_by?(user)
|
||||||
creator_id == user.id || user.is_moderator?
|
creator_id == user.id || user.is_janitor?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="body prose">
|
<div class="body prose">
|
||||||
<%= format_text(comment.body) %>
|
<%= format_text(comment.body) %>
|
||||||
|
|
||||||
|
<% if comment.updater_id.present? && (comment.updater_id != comment.creator_id || comment.created_at != comment.updated_at) %>
|
||||||
|
<p class="info">Updated by <%= link_to comment.updater_name, user_path(comment.updater_id) %> <%= time_ago_in_words_tagged(comment.updated_at) %>.</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<menu>
|
<menu>
|
||||||
<% if @post || @posts %>
|
<% if @post || @posts %>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class AddUpdaterInfoToComments < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :comments, :updater_id, :integer
|
||||||
|
add_column :comments, :updater_ip_addr, "inet"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -684,7 +684,9 @@ CREATE TABLE comments (
|
|||||||
body_index tsvector NOT NULL,
|
body_index tsvector NOT NULL,
|
||||||
score integer DEFAULT 0 NOT NULL,
|
score integer DEFAULT 0 NOT NULL,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL
|
updated_at timestamp without time zone NOT NULL,
|
||||||
|
updater_id integer,
|
||||||
|
updater_ip_addr inet
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -6241,3 +6243,5 @@ INSERT INTO schema_migrations (version) VALUES ('20130305005138');
|
|||||||
INSERT INTO schema_migrations (version) VALUES ('20130307225324');
|
INSERT INTO schema_migrations (version) VALUES ('20130307225324');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20130308204213');
|
INSERT INTO schema_migrations (version) VALUES ('20130308204213');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20130318002652');
|
||||||
6
script/fixes/007.rb
Normal file
6
script/fixes/007.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||||
|
|
||||||
|
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||||
|
ActiveRecord::Base.connection.execute("update comments set updater_id = creator_id")
|
||||||
Reference in New Issue
Block a user