app/controllers/commontator/comments_controller.rb in commontator-0.5.14 vs app/controllers/commontator/comments_controller.rb in commontator-1.0.0
- old
+ new
@@ -11,11 +11,11 @@
@comment.creator = @user
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
respond_to do |format|
- #format.html
+ format.html { redirect_to @thread }
format.js
end
end
@@ -27,13 +27,12 @@
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
if @comment.save
@thread.subscribe(@user) if @thread.config.auto_subscribe_on_comment
- @thread.mark_as_unread_except_for(@user)
+ @thread.add_unread_except_for(@user)
SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
- @thread.comment_created_callback(@user, @comment)
else
@errors = @comment.errors
end
respond_to do |format|
@@ -45,34 +44,33 @@
# GET /comments/1/edit
def edit
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
respond_to do |format|
- #format.html
+ format.html { redirect_to @thread }
format.js
end
end
# PUT /comments/1
def update
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
-
- @thread.comment_edited_callback(@user, @comment) \
- if @comment.update_attributes(params[:comment])
+ @comment.update_attributes(params[:comment])
+
respond_to do |format|
format.html { redirect_to @thread }
format.js
end
end
# PUT /comments/1/delete
def delete
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
- @comment.delete(@user)
- @thread.comment_deleted_callback(@user, @comment)
+ @comment.errors.add(:base, 'This comment has already been deleted.') \
+ unless @comment.delete(@user)
respond_to do |format|
format.html { redirect_to @thread }
format.js { render :delete }
end
@@ -80,10 +78,11 @@
# PUT /comments/1/undelete
def undelete
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
- @comment.undelete
+ @comment.errors.add(:base, 'This comment is not deleted.') \
+ unless @comment.undelete
respond_to do |format|
format.html { redirect_to @thread }
format.js { render :delete }
end