socialforge/app/controllers/org_document_comments_contr...

62 lines
1.7 KiB
Ruby
Raw Normal View History

2015-11-12 09:32:00 +08:00
class OrgDocumentCommentsController < ApplicationController
before_filter :find_organization, :only => [:new, :create, :show, :index]
layout 'base_org'
def new
@org_document_comment = OrgDocumentComment.new
end
def create
@org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
@org_document_comment.title = params[:org_document_comment][:title]
@org_document_comment.content = params[:org_document_comment][:content]
if @org_document_comment.save
#flash[:notice] = 'success'
OrgActivity
redirect_to organization_org_document_comments_path(@organization)
else
redirect_to new_org_document_comment_path(:organization_id => @organization.id)
end
end
def show
end
def index
@documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc")
end
def update
2015-11-12 14:55:31 +08:00
@org_document = OrgDocumentComment.find(params[:id])
respond_to do |format|
# format.html {redirect_to :}
end
end
def edit
2015-11-12 09:32:00 +08:00
end
def add_reply
@document = OrgDocumentComment.find(params[:id]).root
@comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
@comment.content = params[:org_content]
@document.children << @comment
@document.save
end
def find_organization
@organization = Organization.find(params[:organization_id])
end
def destroy
@org_document_comment = OrgDocumentComment.find(params[:id])
org = @org_document_comment.organization
if @org_document_comment.destroy
if @org_document_comment.id == org.id
org.home_id == nil
end
end
end
end