features, bug fixes
This commit is contained in:
@@ -45,7 +45,7 @@ class BlogpostsController < ApplicationController
|
||||
|
||||
def update
|
||||
@post = Blogpost.find(params[:id])
|
||||
if mod?
|
||||
if mod? || @comment.author.is?(current_user)
|
||||
@post.user_editor = current_user
|
||||
if @post.update_attributes(params[:blogpost] ? params[:blogpost].slice(:title, :content, :user_editor) : {})
|
||||
redirect_to @post, notice: 'Post has been updated.'
|
||||
|
||||
@@ -14,7 +14,7 @@ class ForumsController < ApplicationController
|
||||
def show
|
||||
@forum = Forum.find(params[:id])
|
||||
if @forum.role_read.nil? || current_user && @forum.role_read <= current_user.role
|
||||
@threads = @forum.forumthreads.reverse
|
||||
@threads = @forum.forumthreads.order("sticky desc, updated_at desc")
|
||||
else
|
||||
redirect_to forums_path
|
||||
end
|
||||
|
||||
@@ -6,7 +6,26 @@ class ForumthreadsController < ApplicationController
|
||||
|
||||
def show
|
||||
@thread = Forumthread.find(params[:id])
|
||||
render text: @thread.content
|
||||
end
|
||||
|
||||
def update
|
||||
@thread = Forumthread.find(params[:id])
|
||||
if mod? || @thread.author.is?(current_user)
|
||||
@thread.user_editor = current_user
|
||||
if @thread.update_attributes(params[:forumthread] ? params[:forumthread].slice(:title, :content, :user_editor) : {})
|
||||
redirect_to [@thread.forum, @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.forum, @thread]
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@thread = Forumthread.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
Reference in New Issue
Block a user