65 lines
2.1 KiB
Ruby
65 lines
2.1 KiB
Ruby
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
|
|
@org_document = OrgDocumentComment.find(params[:id])
|
|
@org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
|
|
respond_to do |format|
|
|
format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)}
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@org_document = OrgDocumentComment.find(params[:id])
|
|
@organization = Organization.find(params[:organization_id])
|
|
end
|
|
|
|
def add_reply
|
|
@document = OrgDocumentComment.find(params[:id]).root
|
|
@act = OrgActivity.find(params[:id])
|
|
@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
|