Commit 266b9a4d by Rocky Duan

entry for whether thread is closed

parent 4fd9756b
...@@ -52,6 +52,7 @@ class Comment < Content ...@@ -52,6 +52,7 @@ class Comment < Content
.merge("user_id" => author.id) .merge("user_id" => author.id)
.merge("username" => author.username) .merge("username" => author.username)
.merge("depth" => depth) .merge("depth" => depth)
.merge("closed" => comment_thread.closed)
.merge("thread_id" => comment_thread.id) .merge("thread_id" => comment_thread.id)
.merge("votes" => votes.slice(*%w[count up_count down_count point])) .merge("votes" => votes.slice(*%w[count up_count down_count point]))
end end
......
...@@ -13,6 +13,7 @@ class CommentThread < Content ...@@ -13,6 +13,7 @@ class CommentThread < Content
field :course_id, type: String field :course_id, type: String
field :commentable_id, type: String field :commentable_id, type: String
field :anonymous, type: Boolean, default: false field :anonymous, type: Boolean, default: false
field :closed, type: Boolean, default: false
field :at_position_list, type: Array, default: [] field :at_position_list, type: Array, default: []
field :last_activity_at, type: Time field :last_activity_at, type: Time
...@@ -42,7 +43,7 @@ class CommentThread < Content ...@@ -42,7 +43,7 @@ class CommentThread < Content
belongs_to :author, class_name: "User", inverse_of: :comment_threads, index: true#, autosave: true belongs_to :author, class_name: "User", inverse_of: :comment_threads, index: true#, autosave: true
has_many :comments, dependent: :destroy#, autosave: true# Use destroy to envoke callback on the top-level comments TODO async has_many :comments, dependent: :destroy#, autosave: true# Use destroy to envoke callback on the top-level comments TODO async
attr_accessible :title, :body, :course_id, :commentable_id, :anonymous attr_accessible :title, :body, :course_id, :commentable_id, :anonymous, :closed
validates_presence_of :title validates_presence_of :title
validates_presence_of :body validates_presence_of :body
...@@ -86,7 +87,7 @@ class CommentThread < Content ...@@ -86,7 +87,7 @@ class CommentThread < Content
end end
def to_hash(params={}) def to_hash(params={})
doc = as_document.slice(*%w[title body course_id anonymous commentable_id created_at updated_at at_position_list]) doc = as_document.slice(*%w[title body course_id anonymous commentable_id created_at updated_at at_position_list closed])
.merge("id" => _id) .merge("id" => _id)
.merge("user_id" => author.id) .merge("user_id" => author.id)
.merge("username" => author.username) .merge("username" => author.username)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment