mentioning
This commit is contained in:
@@ -22,6 +22,7 @@ class BlogpostsController < ApplicationController
|
||||
@post = Blogpost.new(post_params)
|
||||
@post.user_author = current_user
|
||||
if @post.save
|
||||
@post.send_new_mention_mail
|
||||
redirect_to @post, notice: 'Post has been created.'
|
||||
else
|
||||
flash[:alert] = "Error creating blogpost"
|
||||
@@ -32,7 +33,9 @@ class BlogpostsController < ApplicationController
|
||||
def update
|
||||
@post.user_editor = current_user
|
||||
@post.attributes = post_params([:user_editor])
|
||||
old_content = @post.content_was
|
||||
if @post.save
|
||||
@post.send_new_mention_mail(old_content)
|
||||
redirect_to @post, notice: 'Post has been updated.'
|
||||
else
|
||||
flash[:alert] = "There was a problem while updating the post"
|
||||
|
||||
@@ -18,6 +18,7 @@ class CommentsController < ApplicationController
|
||||
@comment.blogpost = Blogpost.find(params[:blogpost_id])
|
||||
if @comment.save
|
||||
@comment.send_new_comment_mail
|
||||
@comment.send_new_mention_mail
|
||||
redirect_to blogpost_path(@comment.blogpost) + "#comment-#{@comment.id}", notice: 'Comment created!'
|
||||
else
|
||||
flash[:alert] = "Could not create comment."
|
||||
@@ -34,7 +35,9 @@ class CommentsController < ApplicationController
|
||||
if mod? || @comment.author.is?(current_user)
|
||||
@comment.user_editor = current_user
|
||||
@comment.attributes = comment_params
|
||||
old_content = @comment.content_was
|
||||
if @comment.save
|
||||
@comment.send_new_mention_mail(old_content)
|
||||
flash[:notice] = "Comment updated!"
|
||||
redirect_to blogpost_path(@comment.blogpost) + "#comment-#{@comment.id}"
|
||||
else
|
||||
|
||||
@@ -9,22 +9,6 @@ class ForumthreadsController < ApplicationController
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
if mod? || @thread.author.is?(current_user)
|
||||
@thread.user_editor = current_user
|
||||
@thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id]) : thread_params)
|
||||
if @thread.save
|
||||
redirect_to @thread, notice: 'Post has been updated.'
|
||||
else
|
||||
flash[:alert] = "There was a problem while updating the post"
|
||||
render action: "edit"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "You are not allowed to edit this thread!"
|
||||
redirect_to @thread
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
@@ -41,6 +25,7 @@ class ForumthreadsController < ApplicationController
|
||||
if @thread.can_write?(current_user)
|
||||
@thread.user_author = current_user
|
||||
if @thread.save
|
||||
@thread.send_new_mention_mail
|
||||
flash[:notice] = "Thread created!"
|
||||
redirect_to forumthread_path( @thread)
|
||||
return
|
||||
@@ -55,6 +40,23 @@ class ForumthreadsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if mod? || @thread.author.is?(current_user)
|
||||
@thread.user_editor = current_user
|
||||
@thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id]) : thread_params)
|
||||
old_content = @thread.content_was
|
||||
if @thread.save
|
||||
@thread.send_new_mention_mail(old_content)
|
||||
redirect_to @thread, notice: 'Post has been updated.'
|
||||
else
|
||||
flash[:alert] = "There was a problem while updating the post"
|
||||
render action: "edit"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "You are not allowed to edit this thread!"
|
||||
redirect_to @thread
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if mod? || @thread.author.is?(current_user)
|
||||
|
||||
@@ -17,6 +17,7 @@ class ThreadrepliesController < ApplicationController
|
||||
@reply.forumthread = thread
|
||||
if @reply.save
|
||||
@reply.send_new_reply_mail
|
||||
@reply.send_new_mention_mail
|
||||
redirect_to forumthread_path(@reply.thread) + "#reply-#{@reply.id}", notice: 'Reply created!'
|
||||
else
|
||||
flash[:alert] = "Could not create reply."
|
||||
@@ -31,7 +32,9 @@ class ThreadrepliesController < ApplicationController
|
||||
def update
|
||||
@reply = Threadreply.find(params[:id])
|
||||
if mod? || @reply.author.is?(current_user)
|
||||
old_content = @reply.content_was
|
||||
if @reply.update_attributes(reply_params)
|
||||
@reply.send_new_mention_mail(old_content)
|
||||
flash[:notice] = "Reply updated!"
|
||||
redirect_to forumthread_path(@reply.thread) + "#reply-#{@reply.id}"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user